diff --git a/srsepc/hdr/mme/s1ap_common.h b/srsepc/hdr/mme/s1ap_common.h index f5462ad65..2d693eba9 100644 --- a/srsepc/hdr/mme/s1ap_common.h +++ b/srsepc/hdr/mme/s1ap_common.h @@ -33,6 +33,47 @@ 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; +// MME EMM states (3GPP 24.301 v10.0.0, section 5.1.3.4) +typedef enum { + EMM_STATE_DEREGISTERED = 0, + EMM_STATE_COMMON_PROCEDURE_INITIATED, + EMM_STATE_REGISTERED, + EMM_STATE_DEREGISTERED_INITIATED, + EMM_STATE_N_ITEMS, +} emm_state_t; +static const char emm_state_text[EMM_STATE_N_ITEMS][100] = {"DEREGISTERED", + "COMMON PROCEDURE INITIATED", + "REGISTERED", + "DEREGISTERED INITIATED"}; + +// MME ECM states (3GPP 23.401 v10.0.0, section 4.6.3) +typedef enum { + ECM_STATE_IDLE = 0, + ECM_STATE_CONNECTED, + ECM_STATE_N_ITEMS, +} ecm_state_t; +static const char ecm_state_text[ECM_STATE_N_ITEMS][100] = {"IDLE", + "CONNECTED"}; + +// MME ESM states (3GPP 23.401 v10.0.0, section 4.6.3) +typedef enum { + ESM_BEARER_CONTEXT_INACTIVE = 0, + ESM_BEARER_CONTEXT_ACTIVE_PENDING, + ESM_BEARER_CONTEXT_ACTIVE, + ESM_BEARER_CONTEXT_INACTIVE_PENDING, + ESM_BEARER_CONTEXT_MODIFY_PENDING, + ESM_BEARER_PROCEDURE_TRANSACTION_INACTIVE, + ESM_BEARER_PROCEDURE_TRANSACTION_PENDING, + ESM_STATE_N_ITEMS, +} esm_state_t; +static const char esm_state_text[ESM_STATE_N_ITEMS][100] = {"CONTEXT INACTIVE", + "CONTEXT ACTIVE PENDING", + "CONTEXT ACTIVE", + "CONTEXT_INACTIVE_PENDING", + "CONTEXT_MODIFY_PENDING", + "PROCEDURE_TRANSACTION_INACTIVE" + "PROCEDURE_TRANSACTION_PENDING"}; + enum erab_state { ERAB_DEACTIVATED, @@ -74,6 +115,9 @@ typedef struct{ srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; uint8_t k_nas_enc[32]; uint8_t k_nas_int[32]; + LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT ue_network_cap; + bool ms_network_cap_present; + LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT ms_network_cap; } eps_security_ctx_t; typedef struct{ @@ -89,11 +133,9 @@ typedef struct{ uint32_t mme_ue_s1ap_id; uint16_t enb_id; struct sctp_sndrcvinfo enb_sri; + emm_state_t emm_state; eps_security_ctx_t security_ctxt; erab_ctx_t erabs_ctx[MAX_ERABS_PER_UE]; - LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT ue_network_cap; - bool ms_network_cap_present; - LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT ms_network_cap; bool eit; uint8_t procedure_transaction_id; } ue_ctx_t; diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 7dffe3c35..1d6df8cf3 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -143,7 +143,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, bzero(in_ctxt_req->UESecurityCapabilities.integrityProtectionAlgorithms.buffer,sizeof(uint8_t)*16); for(int i = 0; i<3; i++) { - if(ue_ctx->ue_network_cap.eea[i+1] == true) + if(ue_ctx->security_ctxt.ue_network_cap.eea[i+1] == true) { in_ctxt_req->UESecurityCapabilities.encryptionAlgorithms.buffer[i] = 1; //EEA supported } @@ -151,7 +151,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, { in_ctxt_req->UESecurityCapabilities.encryptionAlgorithms.buffer[i] = 0; //EEA not supported } - if(ue_ctx->ue_network_cap.eia[i+1] == true) + if(ue_ctx->security_ctxt.ue_network_cap.eia[i+1] == true) { in_ctxt_req->UESecurityCapabilities.integrityProtectionAlgorithms.buffer[i] = 1; //EEA supported } diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 7ba6fbe25..a200369a7 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -250,11 +250,11 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); //Save UE network capabilities - memcpy(&ue_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); - ue_ctx.ms_network_cap_present = attach_req.ms_network_cap_present; + memcpy(&ue_ctx.security_ctxt.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); + ue_ctx.security_ctxt.ms_network_cap_present = attach_req.ms_network_cap_present; if(attach_req.ms_network_cap_present) { - memcpy(&ue_ctx.ms_network_cap, &attach_req.ms_network_cap, sizeof(LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT)); + memcpy(&ue_ctx.security_ctxt.ms_network_cap, &attach_req.ms_network_cap, sizeof(LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT)); } uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; @@ -345,11 +345,11 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); //Save UE network capabilities - memcpy(&ue_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); - ue_ctx.ms_network_cap_present = attach_req.ms_network_cap_present; + memcpy(&ue_ctx.security_ctxt.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); + ue_ctx.security_ctxt.ms_network_cap_present = attach_req.ms_network_cap_present; if(attach_req.ms_network_cap_present) { - memcpy(&ue_ctx.ms_network_cap, &attach_req.ms_network_cap, sizeof(LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT)); + memcpy(&ue_ctx.security_ctxt.ms_network_cap, &attach_req.ms_network_cap, sizeof(LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT)); } uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; @@ -863,14 +863,14 @@ s1ap_nas_transport::pack_security_mode_command(srslte::byte_buffer_t *reply_msg, sm_cmd.nas_ksi.nas_ksi=0; //Replay UE security cap - memcpy(sm_cmd.ue_security_cap.eea,ue_ctx->ue_network_cap.eea,8*sizeof(bool)); - memcpy(sm_cmd.ue_security_cap.eia,ue_ctx->ue_network_cap.eia,8*sizeof(bool)); - sm_cmd.ue_security_cap.uea_present = ue_ctx->ue_network_cap.uea_present; - memcpy(sm_cmd.ue_security_cap.uea,ue_ctx->ue_network_cap.uea,8*sizeof(bool)); - sm_cmd.ue_security_cap.uia_present = ue_ctx->ue_network_cap.uia_present; - memcpy(sm_cmd.ue_security_cap.uia,ue_ctx->ue_network_cap.uia,8*sizeof(bool)); - sm_cmd.ue_security_cap.gea_present = ue_ctx->ms_network_cap_present; - memcpy(sm_cmd.ue_security_cap.gea,ue_ctx->ms_network_cap.gea,8*sizeof(bool)); + memcpy(sm_cmd.ue_security_cap.eea,ue_ctx->security_ctxt.ue_network_cap.eea,8*sizeof(bool)); + memcpy(sm_cmd.ue_security_cap.eia,ue_ctx->security_ctxt.ue_network_cap.eia,8*sizeof(bool)); + sm_cmd.ue_security_cap.uea_present = ue_ctx->security_ctxt.ue_network_cap.uea_present; + memcpy(sm_cmd.ue_security_cap.uea,ue_ctx->security_ctxt.ue_network_cap.uea,8*sizeof(bool)); + sm_cmd.ue_security_cap.uia_present = ue_ctx->security_ctxt.ue_network_cap.uia_present; + memcpy(sm_cmd.ue_security_cap.uia,ue_ctx->security_ctxt.ue_network_cap.uia,8*sizeof(bool)); + sm_cmd.ue_security_cap.gea_present = ue_ctx->security_ctxt.ms_network_cap_present; + memcpy(sm_cmd.ue_security_cap.gea,ue_ctx->security_ctxt.ms_network_cap.gea,8*sizeof(bool)); sm_cmd.imeisv_req_present=false; sm_cmd.nonce_ue_present=false;