Starting to use EMM state to know whether attach request or service request are initiating the NAS.

master
Pedro Alvarez 7 years ago
parent 9b28527423
commit d5478ff7a2

@ -52,8 +52,8 @@ public:
bool init(srslte::log_filter *mme_gtpc_log); bool init(srslte::log_filter *mme_gtpc_log);
uint32_t get_new_ctrl_teid(); uint32_t get_new_ctrl_teid();
void send_create_session_request(uint64_t imsi, bool pack_attach); void send_create_session_request(uint64_t imsi);
void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu, bool pack_attach); void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu);
void send_modify_bearer_request(uint64_t imsi, erab_ctx_t *bearer_ctx); void send_modify_bearer_request(uint64_t imsi, erab_ctx_t *bearer_ctx);
void handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu); void handle_modify_bearer_response(srslte::gtpc_pdu *mb_resp_pdu);
void send_release_access_bearers_request(uint64_t imsi); void send_release_access_bearers_request(uint64_t imsi);

@ -136,9 +136,12 @@ typedef struct{
LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT guti; LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT guti;
eps_security_ctx_t security_ctxt; eps_security_ctx_t security_ctxt;
uint8_t procedure_transaction_id; uint8_t procedure_transaction_id;
emm_state_t emm_state; emm_state_t state;
uint32_t mme_ue_s1ap_id; uint32_t mme_ue_s1ap_id;
uint8_t attach_type; uint8_t attach_type;
//enum nas_init_msg init_msg;
//enum emm_connection_management conn_mngmnt_state;
//enum emm_common_proc common_proc_state;
} ue_emm_ctx_t; } ue_emm_ctx_t;
typedef struct{ typedef struct{

@ -48,7 +48,7 @@ public:
void init(void); void init(void);
//bool send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp, struct srslte::gtpc_f_teid_ie sgw_ctrl_fteid); //bool send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp, struct srslte::gtpc_f_teid_ie sgw_ctrl_fteid);
bool send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, ue_ecm_ctx_t *ecm_ctx, erab_ctx_t *erab_ctx, bool pack_attach); bool send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, ue_ecm_ctx_t *ecm_ctx, erab_ctx_t *erab_ctx);
bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp); bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp);
bool handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQUEST_STRUCT *ue_rel, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQUEST_STRUCT *ue_rel, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool send_ue_context_release_command(ue_ecm_ctx_t *ecm_ctx, srslte::byte_buffer_t *reply_buffer); bool send_ue_context_release_command(ue_ecm_ctx_t *ecm_ctx, srslte::byte_buffer_t *reply_buffer);

@ -73,7 +73,7 @@ public:
void stop(); void stop();
void run_thread(); void run_thread();
void handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu,bool pack_attach); void handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu);
void handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct srslte::gtpc_pdu *mb_resp_pdu); void handle_modify_bearer_request(struct srslte::gtpc_pdu *mb_req_pdu, struct srslte::gtpc_pdu *mb_resp_pdu);
void handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct srslte::gtpc_pdu *del_resp_pdu); void handle_delete_session_request(struct srslte::gtpc_pdu *del_req_pdu, struct srslte::gtpc_pdu *del_resp_pdu);
void handle_release_access_bearers_request(struct srslte::gtpc_pdu *rel_req_pdu, struct srslte::gtpc_pdu *rel_resp_pdu); void handle_release_access_bearers_request(struct srslte::gtpc_pdu *rel_req_pdu, struct srslte::gtpc_pdu *rel_resp_pdu);

@ -88,7 +88,7 @@ mme_gtpc::get_new_ctrl_teid()
return m_next_ctrl_teid++; //FIXME Use a Id pool? return m_next_ctrl_teid++; //FIXME Use a Id pool?
} }
void void
mme_gtpc::send_create_session_request(uint64_t imsi, bool pack_attach) mme_gtpc::send_create_session_request(uint64_t imsi)
{ {
m_mme_gtpc_log->info("Sending Create Session Request.\n"); m_mme_gtpc_log->info("Sending Create Session Request.\n");
m_mme_gtpc_log->console("Sending Create Session Request.\n"); m_mme_gtpc_log->console("Sending Create Session Request.\n");
@ -151,12 +151,12 @@ mme_gtpc::send_create_session_request(uint64_t imsi, bool pack_attach)
bzero(&gtpc_ctx,sizeof(gtpc_ctx_t)); bzero(&gtpc_ctx,sizeof(gtpc_ctx_t));
gtpc_ctx.mme_ctr_fteid = cs_req->sender_f_teid; gtpc_ctx.mme_ctr_fteid = cs_req->sender_f_teid;
m_imsi_to_gtpc_ctx.insert(std::pair<uint64_t,gtpc_ctx_t>(imsi,gtpc_ctx)); m_imsi_to_gtpc_ctx.insert(std::pair<uint64_t,gtpc_ctx_t>(imsi,gtpc_ctx));
m_spgw->handle_create_session_request(cs_req, &cs_resp_pdu, pack_attach); m_spgw->handle_create_session_request(cs_req, &cs_resp_pdu);
} }
void void
mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu, bool pack_attach) mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
{ {
struct srslte::gtpc_create_session_response *cs_resp = & cs_resp_pdu->choice.create_session_response; struct srslte::gtpc_create_session_response *cs_resp = & cs_resp_pdu->choice.create_session_response;
m_mme_gtpc_log->info("Received Create Session Response\n"); m_mme_gtpc_log->info("Received Create Session Response\n");
@ -243,7 +243,8 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu, bool pac
erab_ctx->pdn_addr_alloc= cs_resp->paa; erab_ctx->pdn_addr_alloc= cs_resp->paa;
erab_ctx->sgw_s1u_fteid = cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid; erab_ctx->sgw_s1u_fteid = cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid;
m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx, erab_ctx, pack_attach); m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx, erab_ctx);
return;
} }

@ -350,9 +350,16 @@ s1ap::delete_enb_ctx(int32_t assoc_id)
void void
s1ap::add_new_ue_emm_ctx(const ue_emm_ctx_t &ue_emm_ctx) s1ap::add_new_ue_emm_ctx(const ue_emm_ctx_t &ue_emm_ctx)
{ {
std::map<uint64_t, ue_emm_ctx_t*>::iterator emm_ctx_it = m_imsi_to_ue_emm_ctx.find(ue_emm_ctx.imsi);
if(emm_ctx_it != m_imsi_to_ue_emm_ctx.end())
{
m_s1ap_log->warning("EMM Context already exists. Replacing EMM Context\n");
delete emm_ctx_it->second;
m_imsi_to_ue_emm_ctx.erase(emm_ctx_it);
}
ue_emm_ctx_t *ue_ptr = new ue_emm_ctx_t; ue_emm_ctx_t *ue_ptr = new ue_emm_ctx_t;
memcpy(ue_ptr,&ue_emm_ctx,sizeof(ue_emm_ctx)); memcpy(ue_ptr,&ue_emm_ctx,sizeof(ue_emm_ctx));
//This map will store UEs EMM context //This map will store UEs EMM context
m_imsi_to_ue_emm_ctx.insert(std::pair<uint64_t,ue_emm_ctx_t*>(ue_ptr->imsi,ue_ptr)); m_imsi_to_ue_emm_ctx.insert(std::pair<uint64_t,ue_emm_ctx_t*>(ue_ptr->imsi,ue_ptr));
} }

@ -79,8 +79,7 @@ s1ap_ctx_mngmt_proc::init(void)
bool bool
s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx,
ue_ecm_ctx_t *ecm_ctx, ue_ecm_ctx_t *ecm_ctx,
erab_ctx_t *erab_ctx, erab_ctx_t *erab_ctx)
bool pack_attach)
{ {
int s1mme = m_s1ap->get_s1_mme(); int s1mme = m_s1ap->get_s1_mme();
@ -161,13 +160,13 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx,
m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Initial Context Setup Request -- Key eNB\n"); m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Initial Context Setup Request -- Key eNB\n");
srslte::byte_buffer_t *nas_buffer = m_pool->allocate(); srslte::byte_buffer_t *nas_buffer = m_pool->allocate();
if(pack_attach) if(emm_ctx->state == EMM_STATE_DEREGISTERED)
{ {
pack_attach = false; //Attach procedure initiated from an attach request
m_s1ap_nas_transport->pack_attach_accept(emm_ctx, ecm_ctx, erab_ctx_req, &erab_ctx->pdn_addr_alloc, nas_buffer); m_s1ap_nas_transport->pack_attach_accept(emm_ctx, ecm_ctx, erab_ctx_req, &erab_ctx->pdn_addr_alloc, nas_buffer);
} }
LIBLTE_ERROR_ENUM err = liblte_s1ap_pack_s1ap_pdu(&pdu, (LIBLTE_BYTE_MSG_STRUCT*)reply_buffer); LIBLTE_ERROR_ENUM err = liblte_s1ap_pack_s1ap_pdu(&pdu, (LIBLTE_BYTE_MSG_STRUCT*)reply_buffer);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {

@ -107,14 +107,15 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
m_s1ap_log->console("Received Service Request \n"); m_s1ap_log->console("Received Service Request \n");
if(!init_ue->S_TMSI_present) if(!init_ue->S_TMSI_present)
{ {
m_s1ap_log->error("Service request -- S-TMSI not present\n "); m_s1ap_log->error("Service request -- S-TMSI not present\n");
m_s1ap_log->console("Service request -- S-TMSI not present\n" ); m_s1ap_log->console("Service request -- S-TMSI not present\n" );
return false;
} }
uint32_t *m_tmsi = (uint32_t*) &init_ue->S_TMSI.m_TMSI.buffer; uint32_t *m_tmsi = (uint32_t*) &init_ue->S_TMSI.m_TMSI.buffer;
uint32_t enb_ue_s1ap_id = init_ue->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID; uint32_t enb_ue_s1ap_id = init_ue->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID;
m_s1ap_log->info("Service request -- S-TMSI 0x%x\n ", ntohl(*m_tmsi)); m_s1ap_log->info("Service request -- S-TMSI 0x%x\n", ntohl(*m_tmsi));
m_s1ap_log->console("Service request -- S-TMSI 0x%x\n", ntohl(*m_tmsi) ); m_s1ap_log->console("Service request -- S-TMSI 0x%x\n", ntohl(*m_tmsi) );
m_s1ap_log->info("Service request -- eNB UE S1AP Id %d\n ", enb_ue_s1ap_id); m_s1ap_log->info("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
m_s1ap_log->console("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id); m_s1ap_log->console("Service request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
handle_nas_service_request(ntohl(*m_tmsi), enb_ue_s1ap_id, nas_msg, reply_buffer,reply_flag, enb_sri); handle_nas_service_request(ntohl(*m_tmsi), enb_ue_s1ap_id, nas_msg, reply_buffer,reply_flag, enb_sri);
return false; return false;
@ -320,7 +321,7 @@ s1ap_nas_transport::handle_nas_attach_request(uint32_t enb_ue_s1ap_id,
//Get attach type from attach request //Get attach type from attach request
if(attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI) if(attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI)
{ {
m_s1ap_log->console("Attach Request -- IMSI-style attach request\n"); m_s1ap_log->console("Attach Request -- IMSI-style attach request\n");
m_s1ap_log->info("Attach Request -- IMSI-style attach request\n"); m_s1ap_log->info("Attach Request -- IMSI-style attach request\n");
handle_nas_imsi_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, reply_buffer, reply_flag, enb_sri); handle_nas_imsi_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, reply_buffer, reply_flag, enb_sri);
@ -592,7 +593,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx); m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx);
//Create session request //Create session request
m_s1ap_log->console("GUTI Attach -- NAS Integrity OK."); m_s1ap_log->console("GUTI Attach -- NAS Integrity OK.");
m_mme_gtpc->send_create_session_request(ue_emm_ctx->imsi,true); m_mme_gtpc->send_create_session_request(ue_emm_ctx->imsi);
*reply_flag = false; //No reply needed *reply_flag = false; //No reply needed
return true; return true;
} }
@ -643,22 +644,22 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi,
return true; return true;
} }
ue_emm_ctx_t *ue_emm_ctx = m_s1ap->find_ue_emm_ctx_from_imsi(it->second); ue_emm_ctx_t *emm_ctx = m_s1ap->find_ue_emm_ctx_from_imsi(it->second);
if(ue_emm_ctx == NULL) if(emm_ctx == NULL || emm_ctx->state != EMM_STATE_REGISTERED)
{ {
m_s1ap_log->console("Could not find UE security context\n"); m_s1ap_log->console("UE is not EMM-Registered.\n");
m_s1ap_log->error("Could not find UE security context\n"); m_s1ap_log->error("UE is not EMM-Registered.\n");
pack_service_reject(reply_buffer, LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED, enb_ue_s1ap_id); pack_service_reject(reply_buffer, LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED, enb_ue_s1ap_id);
*reply_flag = true; *reply_flag = true;
return true; return true;
} }
ue_emm_ctx->security_ctxt.ul_nas_count++; emm_ctx->security_ctxt.ul_nas_count++;
mac_valid = short_integrity_check(ue_emm_ctx,nas_msg); mac_valid = short_integrity_check(emm_ctx,nas_msg);
if(mac_valid) if(mac_valid)
{ {
m_s1ap_log->console("Service Request -- Short MAC valid\n"); m_s1ap_log->console("Service Request -- Short MAC valid\n");
m_s1ap_log->info("Service Request -- Short MAC valid\n"); m_s1ap_log->info("Service Request -- Short MAC valid\n");
ue_ecm_ctx_t *ecm_ctx = m_s1ap->find_ue_ecm_ctx_from_mme_ue_s1ap_id(ue_emm_ctx->mme_ue_s1ap_id); ue_ecm_ctx_t *ecm_ctx = m_s1ap->find_ue_ecm_ctx_from_mme_ue_s1ap_id(emm_ctx->mme_ue_s1ap_id);
if(ecm_ctx !=NULL) if(ecm_ctx !=NULL)
{ {
//Service request to Connected UE. //Service request to Connected UE.
@ -672,7 +673,7 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi,
m_s1ap_log->info("Service Request -- User has ECM context already\n"); m_s1ap_log->info("Service Request -- User has ECM context already\n");
//m_s1ap->m_s1ap_ctx_mngmt_proc->send_ue_context_release_command(ecm_ctx,reply_buffer); //m_s1ap->m_s1ap_ctx_mngmt_proc->send_ue_context_release_command(ecm_ctx,reply_buffer);
int default_bearer_id = 5; int default_bearer_id = 5;
m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(ue_emm_ctx, ecm_ctx, &ecm_ctx->erabs_ctx[default_bearer_id],false); m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx, &ecm_ctx->erabs_ctx[default_bearer_id]);
} }
else else
{ {
@ -683,9 +684,9 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi,
m_s1ap_log->console("Service Request -- User without ECM context\n"); m_s1ap_log->console("Service Request -- User without ECM context\n");
m_s1ap_log->info("Service Request -- User without ECM context\n"); m_s1ap_log->info("Service Request -- User without ECM context\n");
//Create ECM context //Create ECM context
ue_ecm_ctx.imsi = ue_emm_ctx->imsi; ue_ecm_ctx.imsi = emm_ctx->imsi;
ue_ecm_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); ue_ecm_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
ue_emm_ctx->mme_ue_s1ap_id = ue_ecm_ctx.mme_ue_s1ap_id; emm_ctx->mme_ue_s1ap_id = ue_ecm_ctx.mme_ue_s1ap_id;
//Set eNB information //Set eNB information
ue_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id; ue_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id;
memcpy(&ue_ecm_ctx.enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo)); memcpy(&ue_ecm_ctx.enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo));
@ -703,12 +704,11 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi,
m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx); m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx);
//Re-generate K_eNB //Re-generate K_eNB
liblte_security_generate_k_enb(ue_emm_ctx->security_ctxt.k_asme, ue_emm_ctx->security_ctxt.ul_nas_count, ue_emm_ctx->security_ctxt.k_enb); liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb);
m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",ue_emm_ctx->security_ctxt.ul_nas_count); m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count);
//FIXME Send Modify context request OR send ctx release command and wait for the reply. //FIXME Send Modify context request OR send ctx release command and wait for the reply.
m_mme_gtpc->send_create_session_request(ue_ecm_ctx.imsi,false); m_mme_gtpc->send_create_session_request(ue_ecm_ctx.imsi);
m_s1ap_log->console("UE ESM Ctr TEID %d\n", ue_ecm_ctx.sgw_ctrl_fteid.teid); m_s1ap_log->console("UE ESM Ctr TEID %d\n", ue_ecm_ctx.sgw_ctrl_fteid.teid);
// m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(ue_);
} }
} }
else else
@ -823,14 +823,14 @@ s1ap_nas_transport::handle_nas_security_mode_complete(srslte::byte_buffer_t *nas
{ {
//FIXME The packging of GTP-C messages is not ready. //FIXME The packging of GTP-C messages is not ready.
//This means that GTP-U tunnels are created with function calls, as opposed to GTP-C. //This means that GTP-U tunnels are created with function calls, as opposed to GTP-C.
m_mme_gtpc->send_create_session_request(ue_ecm_ctx->imsi,true); m_mme_gtpc->send_create_session_request(ue_ecm_ctx->imsi);
*reply_flag = false; //No reply needed *reply_flag = false; //No reply needed
} }
return true; return true;
} }
bool bool
s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, ue_ecm_ctx_t *ue_ecm_ctx, srslte::byte_buffer_t *reply_msg, bool *reply_flag) s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, ue_ecm_ctx_t *ecm_ctx, srslte::byte_buffer_t *reply_msg, bool *reply_flag)
{ {
LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp; LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp;
@ -853,7 +853,13 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u
return false; return false;
} }
m_s1ap_log->console("Unpacked Attached Complete Message\n"); ue_emm_ctx_t *emm_ctx = m_s1ap->find_ue_emm_ctx_from_imsi(ecm_ctx->imsi);
if(emm_ctx == NULL)
{
m_s1ap_log->error("Received Attach complete, but could not find UE's EMM Context.\n");
}
m_s1ap_log->console("Unpacked Attached Complete Message. IMSI %d\n", emm_ctx->imsi);
m_s1ap_log->console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id); m_s1ap_log->console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id);
//ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid; //ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid;
if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15)
@ -861,14 +867,17 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u
m_s1ap_log->error("EPS Bearer ID out of range\n"); m_s1ap_log->error("EPS Bearer ID out of range\n");
return false; return false;
} }
m_mme_gtpc->send_modify_bearer_request(ue_ecm_ctx->imsi, &ue_ecm_ctx->erabs_ctx[act_bearer.eps_bearer_id]); if(emm_ctx->state == EMM_STATE_DEREGISTERED)
{
//Send reply to eNB //Attach requested from attach request
m_s1ap_log->console("Packing EMM infromationi\n"); m_mme_gtpc->send_modify_bearer_request(ecm_ctx->imsi, &ecm_ctx->erabs_ctx[act_bearer.eps_bearer_id]);
*reply_flag = pack_emm_information(ue_ecm_ctx, reply_msg); //Send reply to eNB
m_s1ap_log->console("Sending EMM infromation, bytes %d\n",reply_msg->N_bytes); m_s1ap_log->console("Packing EMM infromationi\n");
m_s1ap_log->info("Sending EMM infromation\n"); *reply_flag = pack_emm_information(ecm_ctx, reply_msg);
m_s1ap_log->console("Sending EMM infromation, bytes %d\n",reply_msg->N_bytes);
m_s1ap_log->info("Sending EMM infromation\n");
}
emm_ctx->state = EMM_STATE_REGISTERED;
return true; return true;
} }
@ -897,7 +906,7 @@ s1ap_nas_transport::handle_esm_information_response(srslte::byte_buffer_t *nas_m
//FIXME The packging of GTP-C messages is not ready. //FIXME The packging of GTP-C messages is not ready.
//This means that GTP-U tunnels are created with function calls, as opposed to GTP-C. //This means that GTP-U tunnels are created with function calls, as opposed to GTP-C.
m_mme_gtpc->send_create_session_request(ue_ecm_ctx->imsi,true); m_mme_gtpc->send_create_session_request(ue_ecm_ctx->imsi);
return true; return true;
} }
@ -1756,7 +1765,7 @@ s1ap_nas_transport::pack_emm_information( ue_ecm_ctx_t *ue_ecm_ctx, srslte::byte
LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT emm_info; LIBLTE_MME_EMM_INFORMATION_MSG_STRUCT emm_info;
emm_info.full_net_name_present = true; emm_info.full_net_name_present = true;
emm_info.full_net_name.name = std::string("srsLTE"); emm_info.full_net_name.name = std::string("Software Radio Systems LTE");
emm_info.full_net_name.add_ci = LIBLTE_MME_ADD_CI_DONT_ADD; emm_info.full_net_name.add_ci = LIBLTE_MME_ADD_CI_DONT_ADD;
emm_info.short_net_name_present = true; emm_info.short_net_name_present = true;
emm_info.short_net_name.name = std::string("srsLTE"); emm_info.short_net_name.name = std::string("srsLTE");
@ -1771,7 +1780,7 @@ s1ap_nas_transport::pack_emm_information( ue_ecm_ctx_t *ue_ecm_ctx, srslte::byte
return false; return false;
uint8_t sec_hdr_type =2; uint8_t sec_hdr_type =2;
//ue_emm_ctx->security_ctxt.dl_nas_count++; // ue_emm_ctx->security_ctxt.dl_nas_count++;
LIBLTE_ERROR_ENUM err = liblte_mme_pack_emm_information_msg(&emm_info, sec_hdr_type, ue_emm_ctx->security_ctxt.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = liblte_mme_pack_emm_information_msg(&emm_info, sec_hdr_type, ue_emm_ctx->security_ctxt.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {

@ -144,8 +144,8 @@ spgw::stop()
std::map<uint32_t,spgw_tunnel_ctx*>::iterator it = m_teid_to_tunnel_ctx.begin(); //Map control TEID to tunnel ctx. Usefull to get reply ctrl TEID, UE IP, etc. std::map<uint32_t,spgw_tunnel_ctx*>::iterator it = m_teid_to_tunnel_ctx.begin(); //Map control TEID to tunnel ctx. Usefull to get reply ctrl TEID, UE IP, etc.
while(it!=m_teid_to_tunnel_ctx.end()) while(it!=m_teid_to_tunnel_ctx.end())
{ {
m_spgw_log->info("Deleting SP-GW Tunnel. IMSI: %lu\n", it->second->imsi); m_spgw_log->info("Deleting SP-GW GTP-C Tunnel. IMSI: %lu\n", it->second->imsi);
m_spgw_log->console("Deleting SP-GW Tunnel. IMSI: %lu\n", it->second->imsi); m_spgw_log->console("Deleting SP-GW GTP-C Tunnel. IMSI: %lu\n", it->second->imsi);
delete it->second; delete it->second;
m_teid_to_tunnel_ctx.erase(it++); m_teid_to_tunnel_ctx.erase(it++);
} }
@ -437,7 +437,7 @@ spgw::get_new_ue_ipv4()
} }
void void
spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu, bool pack_attach) spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *cs_req, struct srslte::gtpc_pdu *cs_resp_pdu)
{ {
srslte::gtpc_header *header = &cs_resp_pdu->header; srslte::gtpc_header *header = &cs_resp_pdu->header;
srslte::gtpc_create_session_response *cs_resp = &cs_resp_pdu->choice.create_session_response; srslte::gtpc_create_session_response *cs_resp = &cs_resp_pdu->choice.create_session_response;
@ -492,7 +492,7 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
cs_resp->paa.ipv4_present = true; cs_resp->paa.ipv4_present = true;
cs_resp->paa.ipv4 = ue_ip; cs_resp->paa.ipv4 = ue_ip;
m_spgw_log->info("Sending Create Session Response\n"); m_spgw_log->info("Sending Create Session Response\n");
m_mme_gtpc->handle_create_session_response(cs_resp_pdu, pack_attach ); m_mme_gtpc->handle_create_session_response(cs_resp_pdu);
return; return;
} }

Loading…
Cancel
Save