|
|
@ -73,6 +73,101 @@ nas::init(uint16_t mcc,
|
|
|
|
********************************/
|
|
|
|
********************************/
|
|
|
|
|
|
|
|
|
|
|
|
//FIXME Move UE Initiating mesages from s1ap_nas_transport
|
|
|
|
//FIXME Move UE Initiating mesages from s1ap_nas_transport
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
|
|
nas::handle_imsi_attach_request(uint32_t enb_ue_s1ap_id,
|
|
|
|
|
|
|
|
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
|
|
|
|
|
|
|
|
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req,
|
|
|
|
|
|
|
|
srslte::byte_buffer_t *reply_buffer,
|
|
|
|
|
|
|
|
bool* reply_flag,
|
|
|
|
|
|
|
|
struct sctp_sndrcvinfo *enb_sri)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get IMSI
|
|
|
|
|
|
|
|
uint64_t imsi = 0;
|
|
|
|
|
|
|
|
for(int i=0;i<=14;i++){
|
|
|
|
|
|
|
|
imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save IMSI, MME UE S1AP Id and make sure UE is EMM_DEREGISTERED
|
|
|
|
|
|
|
|
m_emm_ctx.imsi = imsi;
|
|
|
|
|
|
|
|
m_emm_ctx.state = EMM_STATE_DEREGISTERED;
|
|
|
|
|
|
|
|
m_ecm_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save UE network capabilities
|
|
|
|
|
|
|
|
memcpy(&m_sec_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT));
|
|
|
|
|
|
|
|
m_sec_ctx.ms_network_cap_present = attach_req.ms_network_cap_present;
|
|
|
|
|
|
|
|
if (attach_req.ms_network_cap_present) {
|
|
|
|
|
|
|
|
memcpy(&m_sec_ctx.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
|
|
|
|
|
|
|
|
m_emm_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Initialize NAS count
|
|
|
|
|
|
|
|
m_sec_ctx.ul_nas_count = 0;
|
|
|
|
|
|
|
|
m_sec_ctx.dl_nas_count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Set eNB information
|
|
|
|
|
|
|
|
m_ecm_ctx.enb_ue_s1ap_id = enb_ue_s1ap_id;
|
|
|
|
|
|
|
|
memcpy(&m_ecm_ctx.enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save whether secure ESM information transfer is necessary
|
|
|
|
|
|
|
|
m_ecm_ctx.eit = pdn_con_req.esm_info_transfer_flag_present;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Initialize E-RABs
|
|
|
|
|
|
|
|
for (uint i = 0 ; i< MAX_ERABS_PER_UE; i++) {
|
|
|
|
|
|
|
|
m_esm_ctx[i].state = ERAB_DEACTIVATED;
|
|
|
|
|
|
|
|
m_esm_ctx[i].erab_id = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Log Attach Request information
|
|
|
|
|
|
|
|
m_nas_log->console("Attach request -- IMSI: %015lu\n", m_emm_ctx.imsi);
|
|
|
|
|
|
|
|
m_nas_log->info("Attach request -- IMSI: %015lu\n", m_emm_ctx.imsi);
|
|
|
|
|
|
|
|
m_nas_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id);
|
|
|
|
|
|
|
|
m_nas_log->info("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id);
|
|
|
|
|
|
|
|
m_nas_log->console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
|
|
|
|
|
|
|
|
m_nas_log->info("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_nas_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n",
|
|
|
|
|
|
|
|
attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3],
|
|
|
|
|
|
|
|
attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]);
|
|
|
|
|
|
|
|
m_nas_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n",
|
|
|
|
|
|
|
|
attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3],
|
|
|
|
|
|
|
|
attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_nas_log->console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false");
|
|
|
|
|
|
|
|
m_nas_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id);
|
|
|
|
|
|
|
|
m_nas_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id);
|
|
|
|
|
|
|
|
m_nas_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save attach request type
|
|
|
|
|
|
|
|
m_emm_ctx.attach_type = attach_req.eps_attach_type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get Authentication Vectors from HSS
|
|
|
|
|
|
|
|
if (!m_hss->gen_auth_info_answer(m_emm_ctx.imsi, m_sec_ctx.k_asme, m_sec_ctx.autn, m_sec_ctx.rand, m_sec_ctx.xres)) {
|
|
|
|
|
|
|
|
m_nas_log->console("User not found. IMSI %015lu\n",m_emm_ctx.imsi);
|
|
|
|
|
|
|
|
m_nas_log->info("User not found. IMSI %015lu\n",m_emm_ctx.imsi);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Allocate eKSI for this authentication vector
|
|
|
|
|
|
|
|
//Here we assume a new security context thus a new eKSI
|
|
|
|
|
|
|
|
m_sec_ctx.eksi=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save the UE context
|
|
|
|
|
|
|
|
m_s1ap->add_nas_ctx_to_imsi_map(this);
|
|
|
|
|
|
|
|
m_s1ap->add_nas_ctx_to_mme_ue_s1ap_id_map(this);
|
|
|
|
|
|
|
|
m_s1ap->add_ue_to_enb_set(enb_sri->sinfo_assoc_id,m_ecm_ctx.mme_ue_s1ap_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Pack NAS Authentication Request in Downlink NAS Transport msg
|
|
|
|
|
|
|
|
pack_authentication_request(reply_buffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Send reply to eNB
|
|
|
|
|
|
|
|
*reply_flag = true;
|
|
|
|
|
|
|
|
m_nas_log->info("Downlink NAS: Sending Authentication Request\n");
|
|
|
|
|
|
|
|
m_nas_log->console("Downlink NAS: Sending Authentication Request\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
|
|
|
|
nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
|
|
|
|
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
|
|
|
|
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
|
|
|
|