From f1d30c7f237e862a745ae551fab0fd740dc3f4d0 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 22 Aug 2018 15:00:01 +0100 Subject: [PATCH] Changed handle guti_attach_from_known_ue and unknown_ue to use send_downstream_nas_message. --- srsepc/hdr/mme/nas.h | 4 +--- srsepc/src/mme/nas.cc | 25 +++++++++++++++---------- srsepc/src/mme/s1ap_nas_transport.cc | 2 -- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/srsepc/hdr/mme/nas.h b/srsepc/hdr/mme/nas.h index 0b9d9ded7..54f80c0ef 100644 --- a/srsepc/hdr/mme/nas.h +++ b/srsepc/hdr/mme/nas.h @@ -170,9 +170,7 @@ public: bool handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req, - srslte::byte_buffer_t *nas_msg, - srslte::byte_buffer_t *reply_buffer, - bool* reply_flag, + srslte::byte_buffer_t *nas_rx, struct sctp_sndrcvinfo *enb_sri); bool handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id, diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index f20ae43e1..c3364ec05 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -296,16 +296,17 @@ bool nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req, - srslte::byte_buffer_t *nas_msg, - srslte::byte_buffer_t *reply_buffer, - bool* reply_flag, + srslte::byte_buffer_t *nas_rx, struct sctp_sndrcvinfo *enb_sri) { m_nas_log->console("Found UE context. IMSI: %015lu, old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n",m_emm_ctx.imsi, m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id); - //Check NAS integrity + bool msg_valid = false; + srslte::byte_buffer_t *nas_tx; + + //Check NAS integrity m_sec_ctx.ul_nas_count++; - msg_valid = integrity_check(nas_msg); + msg_valid = integrity_check(nas_rx); if (msg_valid == true && m_emm_ctx.state == EMM_STATE_DEREGISTERED) { m_nas_log->console("GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d\n",m_sec_ctx.ul_nas_count, m_sec_ctx.dl_nas_count); m_nas_log->info ("GUTI Attach -- NAS Integrity OK. UL count %d, DL count %d\n",m_sec_ctx.ul_nas_count, m_sec_ctx.dl_nas_count); @@ -342,11 +343,13 @@ nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, m_nas_log->console("Generating KeNB with UL NAS COUNT: %d\n", m_sec_ctx.ul_nas_count); m_nas_log->info_hex(m_sec_ctx.k_enb, 32, "Key eNodeB (k_enb)\n"); + //Send reply + nas_tx = m_pool->allocate(); if (m_ecm_ctx.eit) { m_nas_log->console("Secure ESM information transfer requested.\n"); m_nas_log->info("Secure ESM information transfer requested.\n"); - pack_esm_information_request(reply_buffer); - *reply_flag = true; + pack_esm_information_request(nas_tx); + m_s1ap->send_downlink_nas_transport(m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id,nas_tx, *enb_sri); } else { //Get subscriber info from HSS uint8_t default_bearer=5; @@ -354,8 +357,8 @@ nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, m_nas_log->debug("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_nas_log->console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_gtpc->send_create_session_request(m_emm_ctx.imsi); - *reply_flag = false; //No reply needed } + m_pool->deallocate(nas_tx); return true; } else { if (m_emm_ctx.state != EMM_STATE_DEREGISTERED) { @@ -417,10 +420,12 @@ nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, //Restarting security context. Reseting eKSI to 0. m_sec_ctx.eksi=0; - pack_authentication_request(reply_buffer); + nas_tx = m_pool->allocate(); + pack_authentication_request(nas_tx); //Send reply to eNB - *reply_flag = true; + m_s1ap->send_downlink_nas_transport(m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id,nas_tx, *enb_sri); + m_pool->deallocate(nas_tx); m_nas_log->info("Downlink NAS: Sent Authentication Request\n"); m_nas_log->console("Downlink NAS: Sent Authentication Request\n"); return true; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 1e99eb20b..1a40df2b3 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -479,8 +479,6 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, attach_req, pdn_con_req, nas_msg, - reply_buffer, - reply_flag, enb_sri); } else { m_s1ap_log->error("Found M-TMSI but could not find UE context\n");