From 85672d4a3f058c4cd9a0b1ec8b49a2e3a252b3ec Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 18 Jul 2018 17:25:37 +0100 Subject: [PATCH] Fixing up s1ap.cc --- .../srslte/interfaces/epc_interfaces.h | 4 ++-- srsepc/hdr/mme/s1ap.h | 6 +++++- srsepc/src/mme/nas.cc | 20 +++++++------------ srsepc/src/mme/s1ap.cc | 16 +++++++++++++++ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/lib/include/srslte/interfaces/epc_interfaces.h b/lib/include/srslte/interfaces/epc_interfaces.h index e4fc189c8..692921988 100644 --- a/lib/include/srslte/interfaces/epc_interfaces.h +++ b/lib/include/srslte/interfaces/epc_interfaces.h @@ -13,14 +13,14 @@ namespace srsepc { class s1ap_interface_gtpc { public: - virtual bool send_initial_context_setup_request(uint64_t imsi) = 0; + virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup) = 0; }; //NAS -> S1AP class s1ap_interface_nas { public: - virtual bool send_initial_context_setup_request(uint64_t imsi) = 0; + virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup) = 0; }; //S1AP -> HSS diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index c47c804e1..295e0f1f9 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -54,7 +54,8 @@ namespace srsepc{ const uint16_t S1MME_PORT = 36412; class s1ap: - public s1ap_interface_nas + public s1ap_interface_nas, + public s1ap_interface_gtpc { public: @@ -106,6 +107,9 @@ public: std::map m_tmsi_to_imsi; + //Interfaces + virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup); + private: s1ap(); virtual ~s1ap(); diff --git a/srsepc/src/mme/nas.cc b/srsepc/src/mme/nas.cc index fa7b1d010..bb025039a 100644 --- a/srsepc/src/mme/nas.cc +++ b/srsepc/src/mme/nas.cc @@ -63,18 +63,16 @@ nas::handle_nas_detach_request(srslte::byte_buffer_t *nas_msg, ue_ctx_t* ue_ctx, LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; LIBLTE_ERROR_ENUM err = liblte_mme_unpack_detach_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &detach_req); - if(err !=LIBLTE_SUCCESS) - { + if(err !=LIBLTE_SUCCESS) { m_s1ap_log->error("Could not unpack detach request\n"); return false; - } + } m_mme_gtpc->send_delete_session_request(ue_ctx->emm_ctx.imsi); ue_ctx->emm_ctx.state = EMM_STATE_DEREGISTERED; - if(ue_ctx->ecm_ctx.mme_ue_s1ap_id!=0) - { + if(ue_ctx->ecm_ctx.mme_ue_s1ap_id!=0) { m_s1ap->m_s1ap_ctx_mngmt_proc->send_ue_context_release_command(&ue_ctx->ecm_ctx, reply_msg); - } + } return true; } @@ -737,8 +735,7 @@ nas::pack_esm_information_request(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t //Pack Downlink NAS Transport Message err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); - if(err != LIBLTE_SUCCESS) - { + if(err != LIBLTE_SUCCESS) { m_s1ap_log->error("Error packing Dw NAS Transport: Authentication Reject\n"); m_s1ap_log->console("Error packing Downlink NAS Transport: Authentication Reject\n"); return false; @@ -762,14 +759,11 @@ nas::pack_attach_accept(LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctx mcc += 100*( (0x0F00 & m_s1ap->m_s1ap_args.mcc) >> 8); uint32_t mnc = 0; - if( 0xFF00 == (m_s1ap->m_s1ap_args.mnc & 0xFF00 )) - { + if( 0xFF00 == (m_s1ap->m_s1ap_args.mnc & 0xFF00 )) { //Two digit MNC mnc += 0x000F & m_s1ap->m_s1ap_args.mnc; mnc += 10*((0x00F0 & m_s1ap->m_s1ap_args.mnc) >> 4); - } - else - { + } else { //Three digit MNC mnc += 0x000F & m_s1ap->m_s1ap_args.mnc; mnc += 10*((0x00F0 & m_s1ap->m_s1ap_args.mnc) >> 4); diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 77047ef44..2e9dd9fd8 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -608,5 +608,21 @@ s1ap::print_enb_ctx_info(const std::string &prefix, const enb_ctx_t &enb_ctx) return; } +/* + * Interfaces + */ +// NAS -> S1AP interfaces +bool +s1ap::send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup) +{ + nas* nas_ctx = find_nas_ctx_from_imsi(imsi); + if (nas_ctx==NULL) { + m_s1ap_log->error("Error finding NAS context when sending initial context Setup Request\n"); + return false; + } + m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(nas_ctx, erab_to_setup); + return true; +} + } //namespace srsepc