From 8f5ad55c4af6d7a4f55577ecc25f5f83a4bc30a6 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 20 Jun 2019 18:31:25 +0100 Subject: [PATCH] Added attach request as a UL info trasnfer in the UE. Added interface to remove eps bearer map when going idle. Fixed bug in GW in assignment of IPv4 addresses. UE seems to rebound from the service reject now. --- lib/include/srslte/interfaces/ue_interfaces.h | 17 ++++++++------- srsue/hdr/stack/upper/nas.h | 9 ++++---- srsue/src/stack/rrc/rrc.cc | 1 + srsue/src/stack/upper/gw.cc | 4 ++-- srsue/src/stack/upper/nas.cc | 21 ++++++++++++++++--- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index de4806c7b..dc514b78c 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -129,14 +129,15 @@ public: BARRING_MT, BARRING_ALL } barring_t; - virtual void set_barring(barring_t barring) = 0; - virtual void paging(asn1::rrc::s_tmsi_s* ue_identiy) = 0; - virtual bool is_attached() = 0; - virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; - virtual uint32_t get_k_enb_count() = 0; - virtual bool get_k_asme(uint8_t *k_asme_, uint32_t n) = 0; - virtual uint32_t get_ipv4_addr() = 0; - virtual bool get_ipv6_addr(uint8_t *ipv6_addr) = 0; + virtual void leave_connected() = 0; + virtual void set_barring(barring_t barring) = 0; + virtual void paging(asn1::rrc::s_tmsi_s* ue_identiy) = 0; + virtual bool is_attached() = 0; + virtual void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu) = 0; + virtual uint32_t get_k_enb_count() = 0; + virtual bool get_k_asme(uint8_t* k_asme_, uint32_t n) = 0; + virtual uint32_t get_ipv4_addr() = 0; + virtual bool get_ipv6_addr(uint8_t* ipv6_addr) = 0; }; // NAS interface for UE diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index f81d6b09b..3f038135c 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -54,14 +54,15 @@ public: emm_state_t get_state(); // RRC interface + void leave_connected(); void paging(asn1::rrc::s_tmsi_s* ue_identiy); - void set_barring(barring_t barring); + void set_barring(barring_t barring); void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu); uint32_t get_k_enb_count(); - bool is_attached(); - bool get_k_asme(uint8_t *k_asme_, uint32_t n); + bool is_attached(); + bool get_k_asme(uint8_t* k_asme_, uint32_t n); uint32_t get_ipv4_addr(); - bool get_ipv6_addr(uint8_t *ipv6_addr); + bool get_ipv6_addr(uint8_t* ipv6_addr); // UE interface bool attach_request(); diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 9b739647f..78b1aade7 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1730,6 +1730,7 @@ void rrc::leave_connected() drb_up = false; security_is_activated = false; measurements.reset(); + nas->leave_connected(); pdcp->reset(); rlc->reset(); phy->reset(); diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index a65961149..83664d761 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -390,8 +390,8 @@ int gw::init_if(char* err_str) // Delete link-local IPv6 address. struct in6_addr in6p; - char addr_str[INET6_ADDRSTRLEN]; - if(find_ipv6_addr(&in6p)){ + char addr_str[INET6_ADDRSTRLEN]; + if (find_ipv6_addr(&in6p)) { log.debug("Found link-local IPv6 address: %s\n", inet_ntop(AF_INET6, &in6p, addr_str, INET6_ADDRSTRLEN)); del_ipv6_addr(&in6p); } else { diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 0ea5309f9..a2c3e0f3a 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -232,6 +232,10 @@ bool nas::detach_request() { return false; } +void nas::leave_connected() { + eps_bearer.clear(); + return; +} bool nas::is_attached() { return state == EMM_STATE_REGISTERED; @@ -702,6 +706,7 @@ void nas::parse_attach_accept(uint32_t lcid, unique_byte_buffer_t pdu) nas_log->warning("EMM Cause: %d\n", attach_accept.emm_cause ); } if (LIBLTE_MME_PDN_TYPE_IPV4 == act_def_eps_bearer_context_req.pdn_addr.pdn_type) { + ip_addr = 0; ip_addr |= act_def_eps_bearer_context_req.pdn_addr.addr[0] << 24; ip_addr |= act_def_eps_bearer_context_req.pdn_addr.addr[1] << 16; ip_addr |= act_def_eps_bearer_context_req.pdn_addr.addr[2] << 8; @@ -1077,7 +1082,7 @@ void nas::parse_service_reject(uint32_t lcid, unique_byte_buffer_t pdu) LIBLTE_MME_SERVICE_REJECT_MSG_STRUCT service_reject; if (liblte_mme_unpack_service_reject_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &service_reject)) { nas_log->error("Error unpacking service reject.\n"); - goto exit; + return; } nas_log->console("Received service reject with EMM cause=0x%x.\n", service_reject.emm_cause); @@ -1088,8 +1093,18 @@ void nas::parse_service_reject(uint32_t lcid, unique_byte_buffer_t pdu) // FIXME: handle NAS backoff-timers correctly -exit: - ctxt.rx_count++; + // Mark state as EMM-DEREGISTERED + state = EMM_STATE_DEREGISTERED; + + // Reset security context + ctxt = {}; + have_ctxt = false; + have_guti = false; + + // Send attach request after receiving service reject + pdu->clear(); + gen_attach_request(pdu.get()); + rrc->write_sdu(std::move(pdu)); } void nas::parse_esm_information_request(uint32_t lcid, unique_byte_buffer_t pdu)