diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 51821f641..c1e3b1b9a 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -140,6 +140,8 @@ public: virtual void write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu) = 0; virtual uint32_t get_ul_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/upper/nas.h b/srsue/hdr/upper/nas.h index 203d3802b..2c633ef38 100644 --- a/srsue/hdr/upper/nas.h +++ b/srsue/hdr/upper/nas.h @@ -88,6 +88,8 @@ public: uint32_t get_ul_count(); 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); // UE interface bool attach_request(); diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index 658a8a920..686a55cd5 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -54,6 +54,7 @@ nas::nas() ctxt.integ_algo = INTEGRITY_ALGORITHM_ID_EIA0; plmn_is_selected = false; chap_id = 0; + memset(ipv6_if_id, 0, sizeof(ipv6_if_id)); } void nas::init(usim_interface_nas *usim_, @@ -411,6 +412,21 @@ bool nas::get_k_asme(uint8_t *k_asme_, uint32_t n) { return true; } +uint32_t nas::get_ipv4_addr() +{ + return ip_addr; +} + +bool nas::get_ipv6_addr(uint8_t *ipv6_addr) +{ + uint8_t null_addr[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + if (memcmp(ipv6_addr, null_addr, 8) != 0) { + memcpy(ipv6_addr, ipv6_if_id, 8); + return true; + } + return false; +} + /******************************************************************************* PCAP *******************************************************************************/