diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 5df4dce71..c688523e8 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -101,11 +101,11 @@ private: hss *m_hss; int m_s1mme; - std::map m_active_enbs; - std::map m_sctp_to_enb_id; - std::map m_active_ues; - std::map > m_enb_id_to_ue_ids; - uint32_t m_next_mme_ue_s1ap_id; + std::map m_active_enbs; + std::map m_sctp_to_enb_id; + std::map m_active_ues; + std::map > m_enb_id_to_ue_ids; + uint32_t m_next_mme_ue_s1ap_id; s1ap_mngmt_proc m_s1ap_mngmt_proc; s1ap_nas_transport m_s1ap_nas_transport; diff --git a/srsepc/hdr/mme/s1ap_common.h b/srsepc/hdr/mme/s1ap_common.h index ad004190d..3c13e669e 100644 --- a/srsepc/hdr/mme/s1ap_common.h +++ b/srsepc/hdr/mme/s1ap_common.h @@ -22,11 +22,13 @@ #define S1AP_COMMON_H #include "srslte/common/security.h" +#include "srslte/asn1/gtpc_ies.h" namespace srsepc{ static const uint8_t MAX_TA=255; //Maximum TA supported static const uint8_t MAX_BPLMN=6; //Maximum broadcasted PLMNs per TAC +static const uint8_t MAX_ERABS_PER_UE = 16; typedef struct{ uint8_t mme_code; @@ -52,22 +54,32 @@ typedef struct{ struct sctp_sndrcvinfo sri; } enb_ctx_t; +typedef struct{ + uint8_t k_asme[32]; + uint8_t xres[8]; + uint32_t dl_nas_count; + uint32_t ul_nas_count; + srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; + uint8_t k_nas_enc[32]; + uint8_t k_nas_int[32]; +} eps_security_ctx_t; + +typedef struct{ + bool active; + uint8_t erab_id; + srslte::gtpc_f_teid_ie enb_fteid; + //gtpc_f_teid_ie sgw_fteid; //? +} erab_ctx_t; + typedef struct{ uint64_t imsi; uint32_t enb_ue_s1ap_id; uint32_t mme_ue_s1ap_id; uint16_t enb_id; struct sctp_sndrcvinfo enb_sri; - struct eps_security_ctxt{ - uint8_t k_asme[32]; - uint8_t xres[8]; - uint32_t dl_nas_count; - uint32_t ul_nas_count; - srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo; - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; - uint8_t k_nas_enc[32]; - uint8_t k_nas_int[32]; - } security_ctxt; + eps_security_ctx_t security_ctxt; + erab_ctx_t erabs[MAX_ERABS_PER_UE]; } ue_ctx_t; }//namespace #endif diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 5d9cd1868..c64977a2a 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -707,18 +707,32 @@ s1ap::handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSE bool iE_Extensions_present; }LIBLTE_S1AP_E_RABSETUPITEMCTXTSURES_STRUCT; */ - erabs_it = m_active_erabs.find(in_ctxt_resp->MME_UE_S1AP_ID.MME_UE_S1AP_ID); - if (erabs_it == m_active_erabs.end()) + uint32_t mme_ue_s1ap_id = in_ctxt_resp->MME_UE_S1AP_ID.MME_UE_S1AP_ID; + std::map ue_ctx_it = m_acive_ues.find(mme_ue_s1ap_id); + if (ue_ctx_it == m_active_ues.end()) { - m_s1ap_log->error("Could not find UE's in UE active bearers map\n"); + m_s1ap_log->error("Could not find UE's context in active UE's map\n"); return false; } - else{ - for(int i; iE_RABSetupListCtxtSURes.len;i++) + { + uint8_t erab_id = in_ctxt_resp->E_RABSetupListCtxtSURes.buffer[i].e_RAB_ID.E_RAB_ID; + if (erab_ctx->active == false) + { + m_s1ap_log->error("E-RAB requested was not active %d\n",); + return false; + } + erab_ctx_t *erab_ctx = &ue_ctx_it->second->erab_ctx[i]; + for(uint32_t i; iE_RABSetupListCtxtSURes.len;i++) { - erabs_it->second.insert(std::pair<>()); + uint8_t erab_id = in_ctxt_resp->E_RABSetupListCtxtSURes.buffer[i].e_RAB_ID.E_RAB_ID; + std::set ue_erab_it = erabs_it->second.find(erab_id); + if(ue_erab_it == erabs_it->second.end() ) + { + m_s1ap_log->error("Could not find UE's in UE active bearers map\n"); + return false; + } } - } return true; }