starting to add EMM states to keep EMM state, security context, etc., even when UE context release request is received.

master
Pedro Alvarez 7 years ago
parent a279ab47f0
commit 955be59a59

@ -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_BPLMN=6; //Maximum broadcasted PLMNs per TAC
static const uint8_t MAX_ERABS_PER_UE = 16; 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 enum erab_state
{ {
ERAB_DEACTIVATED, ERAB_DEACTIVATED,
@ -74,6 +115,9 @@ typedef struct{
srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo; srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo;
uint8_t k_nas_enc[32]; uint8_t k_nas_enc[32];
uint8_t k_nas_int[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; } eps_security_ctx_t;
typedef struct{ typedef struct{
@ -89,11 +133,9 @@ typedef struct{
uint32_t mme_ue_s1ap_id; uint32_t mme_ue_s1ap_id;
uint16_t enb_id; uint16_t enb_id;
struct sctp_sndrcvinfo enb_sri; struct sctp_sndrcvinfo enb_sri;
emm_state_t emm_state;
eps_security_ctx_t security_ctxt; eps_security_ctx_t security_ctxt;
erab_ctx_t erabs_ctx[MAX_ERABS_PER_UE]; 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; bool eit;
uint8_t procedure_transaction_id; uint8_t procedure_transaction_id;
} ue_ctx_t; } ue_ctx_t;

@ -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); bzero(in_ctxt_req->UESecurityCapabilities.integrityProtectionAlgorithms.buffer,sizeof(uint8_t)*16);
for(int i = 0; i<3; i++) 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 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 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 in_ctxt_req->UESecurityCapabilities.integrityProtectionAlgorithms.buffer[i] = 1; //EEA supported
} }

@ -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(); ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
//Save UE network capabilities //Save UE network capabilities
memcpy(&ue_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); memcpy(&ue_ctx.security_ctxt.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; ue_ctx.security_ctxt.ms_network_cap_present = attach_req.ms_network_cap_present;
if(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 uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused
ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; 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(); ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
//Save UE network capabilities //Save UE network capabilities
memcpy(&ue_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); memcpy(&ue_ctx.security_ctxt.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; ue_ctx.security_ctxt.ms_network_cap_present = attach_req.ms_network_cap_present;
if(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 uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused
ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; 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; sm_cmd.nas_ksi.nas_ksi=0;
//Replay UE security cap //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.eea,ue_ctx->security_ctxt.ue_network_cap.eea,8*sizeof(bool));
memcpy(sm_cmd.ue_security_cap.eia,ue_ctx->ue_network_cap.eia,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->ue_network_cap.uea_present; 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->ue_network_cap.uea,8*sizeof(bool)); 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->ue_network_cap.uia_present; 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->ue_network_cap.uia,8*sizeof(bool)); 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->ms_network_cap_present; sm_cmd.ue_security_cap.gea_present = ue_ctx->security_ctxt.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.gea,ue_ctx->security_ctxt.ms_network_cap.gea,8*sizeof(bool));
sm_cmd.imeisv_req_present=false; sm_cmd.imeisv_req_present=false;
sm_cmd.nonce_ue_present=false; sm_cmd.nonce_ue_present=false;

Loading…
Cancel
Save