|
|
|
@ -733,60 +733,40 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi,
|
|
|
|
|
m_s1ap->m_s1ap_ctx_mngmt_proc->send_ue_context_release_command(ecm_ctx,reply_buffer);
|
|
|
|
|
m_s1ap->release_ue_ecm_ctx(ecm_ctx->mme_ue_s1ap_id);
|
|
|
|
|
}
|
|
|
|
|
//Handle service request from Connected UE.
|
|
|
|
|
//Set eNB UE S1ap identity
|
|
|
|
|
// ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
// m_s1ap_log->console("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);
|
|
|
|
|
|
|
|
|
|
//Delete eNB context and connect.
|
|
|
|
|
//m_s1ap_log->console("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);
|
|
|
|
|
//int default_bearer_id = 5;
|
|
|
|
|
//m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx, &ecm_ctx->erabs_ctx[5]);
|
|
|
|
|
//}
|
|
|
|
|
//else if(ecm_ctx->state == ECM_STATE_IDLE)
|
|
|
|
|
//{
|
|
|
|
|
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
|
|
|
|
|
//UE not connect. Connect normally.
|
|
|
|
|
m_s1ap_log->console("Service Request -- User is ECM DISCONNECTED\n");
|
|
|
|
|
m_s1ap_log->info("Service Request -- User is ECM DISCONNECTED\n");
|
|
|
|
|
//Create ECM context
|
|
|
|
|
ecm_ctx->imsi = emm_ctx->imsi;
|
|
|
|
|
ecm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
|
|
|
|
|
emm_ctx->mme_ue_s1ap_id = ecm_ctx->mme_ue_s1ap_id;
|
|
|
|
|
//Set eNB information
|
|
|
|
|
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
memcpy(&ecm_ctx->enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo));
|
|
|
|
|
|
|
|
|
|
//Save whether secure ESM information transfer is necessary
|
|
|
|
|
ecm_ctx->eit = false;
|
|
|
|
|
|
|
|
|
|
//Get UE IP, and uplink F-TEID
|
|
|
|
|
if(emm_ctx->ue_ip.s_addr == 0 )
|
|
|
|
|
{
|
|
|
|
|
m_s1ap_log->error("UE has no valid IP assigned upon reception of service request");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_s1ap_log->console("UE previously assigned IP: %s",inet_ntoa(emm_ctx->ue_ip));
|
|
|
|
|
//Mark E-RABs as setup, but not active yet
|
|
|
|
|
|
|
|
|
|
//Re-generate 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",emm_ctx->security_ctxt.ul_nas_count);
|
|
|
|
|
m_s1ap_log->console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid);
|
|
|
|
|
|
|
|
|
|
//Save UE ctx to MME UE S1AP id
|
|
|
|
|
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx);
|
|
|
|
|
m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx,&ecm_ctx->erabs_ctx[5]);
|
|
|
|
|
/*}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
|
|
|
|
|
//UE not connect. Connect normally.
|
|
|
|
|
m_s1ap_log->console("Service Request -- User is ECM DISCONNECTED\n");
|
|
|
|
|
m_s1ap_log->info("Service Request -- User is ECM DISCONNECTED\n");
|
|
|
|
|
//Create ECM context
|
|
|
|
|
ecm_ctx->imsi = emm_ctx->imsi;
|
|
|
|
|
ecm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
|
|
|
|
|
emm_ctx->mme_ue_s1ap_id = ecm_ctx->mme_ue_s1ap_id;
|
|
|
|
|
//Set eNB information
|
|
|
|
|
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
memcpy(&ecm_ctx->enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo));
|
|
|
|
|
|
|
|
|
|
//Save whether secure ESM information transfer is necessary
|
|
|
|
|
ecm_ctx->eit = false;
|
|
|
|
|
|
|
|
|
|
//Get UE IP, and uplink F-TEID
|
|
|
|
|
if(emm_ctx->ue_ip.s_addr == 0 )
|
|
|
|
|
{
|
|
|
|
|
m_s1ap_log->console("ECM context is un-initialized.\n");
|
|
|
|
|
m_s1ap_log->error("ECM context is un-initialized.\n");
|
|
|
|
|
}*/
|
|
|
|
|
m_s1ap_log->error("UE has no valid IP assigned upon reception of service request");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_s1ap_log->console("UE previously assigned IP: %s",inet_ntoa(emm_ctx->ue_ip));
|
|
|
|
|
//Mark E-RABs as setup, but not active yet
|
|
|
|
|
|
|
|
|
|
//Re-generate 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",emm_ctx->security_ctxt.ul_nas_count);
|
|
|
|
|
m_s1ap_log->console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid);
|
|
|
|
|
|
|
|
|
|
//Save UE ctx to MME UE S1AP id
|
|
|
|
|
m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx);
|
|
|
|
|
m_s1ap->m_s1ap_ctx_mngmt_proc->send_initial_context_setup_request(emm_ctx, ecm_ctx,&ecm_ctx->erabs_ctx[5]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|