Fixed GUTI attach procedure when authentication is successful. Ping works again.

master
Pedro Alvarez 7 years ago
parent 51e7b3fec6
commit 62dc65556a

@ -195,8 +195,10 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx,
addr.s_addr = htonl(sgw_s1u_ip); addr.s_addr = htonl(sgw_s1u_ip);
m_s1ap_log->info("Sent Intial Context Setup Request. E-RAB id %d \n",erab_ctx_req->e_RAB_ID.E_RAB_ID); m_s1ap_log->info("Sent Intial Context Setup Request. E-RAB id %d \n",erab_ctx_req->e_RAB_ID.E_RAB_ID);
m_s1ap_log->info("Initial Context -- S1-U TEID 0x%x. IP %s \n", sgw_s1u_teid,inet_ntoa(addr)); m_s1ap_log->info("Initial Context -- S1-U TEID 0x%x. IP %s \n", sgw_s1u_teid,inet_ntoa(addr));
m_s1ap_log->console("Sent Intial Context Setup Request, E-RAB id %d\n",erab_ctx_req->e_RAB_ID.E_RAB_ID); m_s1ap_log->console("Initial Context Setup Request -- eNB UE S1AP Id %d, MME UE S1AP Id %d\n",in_ctxt_req->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID, in_ctxt_req->MME_UE_S1AP_ID.MME_UE_S1AP_ID);
m_s1ap_log->console("Initial Context -- S1-U TEID 0x%x. IP %s \n", sgw_s1u_teid,inet_ntoa(addr)); m_s1ap_log->console("Initial Context Setup Request -- E-RAB id %d\n",erab_ctx_req->e_RAB_ID.E_RAB_ID);
m_s1ap_log->console("Initial Context Setup Request -- S1-U TEID 0x%x. IP %s \n", sgw_s1u_teid,inet_ntoa(addr));
m_s1ap_log->console("Initial Context Setup Request -- S1-U TEID 0x%x. IP %s \n", sgw_s1u_teid,inet_ntoa(addr));
m_pool->deallocate(reply_buffer); m_pool->deallocate(reply_buffer);
m_pool->deallocate(nas_buffer); m_pool->deallocate(nas_buffer);

@ -274,8 +274,10 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
if(*reply_flag == true) if(*reply_flag == true)
{ {
m_s1ap_log->console("DL NAS: Sent Downlink NAs Message. DL NAS Count=%d, UL NAS count=%d\n",emm_ctx->security_ctxt.dl_nas_count,emm_ctx->security_ctxt.ul_nas_count ); m_s1ap_log->console("DL NAS: Sent Downlink NAS Message. DL NAS Count=%d, UL NAS count=%d\n",emm_ctx->security_ctxt.dl_nas_count,emm_ctx->security_ctxt.ul_nas_count );
m_s1ap_log->info("DL NAS: Sent Downlink NAS message. DL NAS Count=%d, UL NAS count=%d\n",emm_ctx->security_ctxt.dl_nas_count, emm_ctx->security_ctxt.ul_nas_count); m_s1ap_log->info("DL NAS: Sent Downlink NAS message. DL NAS Count=%d, UL NAS count=%d\n",emm_ctx->security_ctxt.dl_nas_count, emm_ctx->security_ctxt.ul_nas_count);
m_s1ap_log->info("DL NAS: MME UE S1AP id %d\n",ecm_ctx->mme_ue_s1ap_id);
m_s1ap_log->console("DL NAS: MME UE S1AP id %d\n",ecm_ctx->mme_ue_s1ap_id);
} }
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
return true; return true;
@ -473,8 +475,8 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
if(it == m_s1ap->m_tmsi_to_imsi.end()) if(it == m_s1ap->m_tmsi_to_imsi.end())
{ {
m_s1ap_log->console("Attach Request -- Could not find M-TMSI 0x%x", m_tmsi); m_s1ap_log->console("Attach Request -- Could not find M-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->info("Attach Request -- Could not find M-TMSI 0x%x", m_tmsi); m_s1ap_log->info("Attach Request -- Could not find M-TMSI 0x%x\n", m_tmsi);
//Could not find IMSI from M-TMSI, send Id request //Could not find IMSI from M-TMSI, send Id request
ue_ctx_t ue_ctx; ue_ctx_t ue_ctx;
@ -558,8 +560,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
{ {
ue_emm_ctx_t *emm_ctx = &ue_ctx->emm_ctx; ue_emm_ctx_t *emm_ctx = &ue_ctx->emm_ctx;
ue_ecm_ctx_t *ecm_ctx = &ue_ctx->ecm_ctx; ue_ecm_ctx_t *ecm_ctx = &ue_ctx->ecm_ctx;
m_s1ap_log->console("Found UE context. IMSI: %015lu\n",emm_ctx->imsi); m_s1ap_log->console("Found UE context. IMSI: %015lu, old MME UE S1AP Id %d\n",emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id);
//Check NAS integrity //Check NAS integrity
bool msg_valid = false; bool msg_valid = false;
emm_ctx->security_ctxt.ul_nas_count++; emm_ctx->security_ctxt.ul_nas_count++;
@ -567,8 +568,15 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
if(msg_valid == true) if(msg_valid == true)
{ {
//Create new MME UE S1AP Identity //Create new MME UE S1AP Identity
emm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); uint32_t new_mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
//Make sure context from previous MME
if(ecm_ctx->mme_ue_s1ap_id!=0)
{
m_s1ap->release_ue_ecm_ctx(ecm_ctx->mme_ue_s1ap_id);
}
emm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
ecm_ctx->mme_ue_s1ap_id = emm_ctx->mme_ue_s1ap_id;
//Set EMM as de-registered //Set EMM as de-registered
emm_ctx->state = EMM_STATE_DEREGISTERED; emm_ctx->state = EMM_STATE_DEREGISTERED;
//Save Attach type //Save Attach type
@ -591,7 +599,8 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
ecm_ctx->erabs_ctx[i].erab_id = i; ecm_ctx->erabs_ctx[i].erab_id = i;
} }
//m_s1ap->add_new_ue_ecm_ctx(ue_ecm_ctx); //Store context based on MME UE S1AP id
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_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(emm_ctx->imsi); m_mme_gtpc->send_create_session_request(emm_ctx->imsi);
@ -1158,8 +1167,8 @@ s1ap_nas_transport::integrity_check(ue_emm_ctx_t *emm_ctx, srslte::byte_buffer_t
// Check if expected mac equals the sent mac // Check if expected mac equals the sent mac
for(i=0; i<4; i++){ for(i=0; i<4; i++){
if(exp_mac[i] != mac[i]){ if(exp_mac[i] != mac[i]){
m_s1ap_log->warning("Integrity check failure. Local: count=%d, [%02x %02x %02x %02x], " m_s1ap_log->warning("Integrity check failure. UL Local: count=%d, [%02x %02x %02x %02x], "
"Received: count=%d, [%02x %02x %02x %02x]\n", "Received: UL count=%d, [%02x %02x %02x %02x]\n",
emm_ctx->security_ctxt.ul_nas_count, exp_mac[0], exp_mac[1], exp_mac[2], exp_mac[3], emm_ctx->security_ctxt.ul_nas_count, exp_mac[0], exp_mac[1], exp_mac[2], exp_mac[3],
pdu->msg[5], mac[0], mac[1], mac[2], mac[3]); pdu->msg[5], mac[0], mac[1], mac[2], mac[3]);
return false; return false;

Loading…
Cancel
Save