|
|
@ -303,113 +303,6 @@ s1ap::handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
|
|
s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue, struct sctp_sndrcvinfo *enb_sri)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req;
|
|
|
|
|
|
|
|
LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t imsi;
|
|
|
|
|
|
|
|
uint8_t k_asme[32];
|
|
|
|
|
|
|
|
uint8_t autn[16];
|
|
|
|
|
|
|
|
uint8_t rand[6];
|
|
|
|
|
|
|
|
uint8_t xres[8];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ue_ctx_t ue_ctx;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Get info from initial UE message*/
|
|
|
|
|
|
|
|
ue_ctx.enb_ue_s1ap_id = init_ue->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID;
|
|
|
|
|
|
|
|
m_s1ap_log->console("Received Initial UE Message. eNB-UE S1AP Id: %d\n", ue_ctx.enb_ue_s1ap_id);
|
|
|
|
|
|
|
|
m_s1ap_log->info("Received Initial UE Message. eNB-UE S1AP Id: %d\n", ue_ctx.enb_ue_s1ap_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Log unhandled Initial UE message IEs*/
|
|
|
|
|
|
|
|
m_s1ap_nas_transport->log_unhandled_initial_ue_message_ies(init_ue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Get NAS Attach Request and PDN connectivity request messages*/
|
|
|
|
|
|
|
|
if(!m_s1ap_nas_transport->unpack_initial_ue_message(init_ue, &attach_req,&pdn_con_req))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Could not decode the attach request and the PDN connectivity request.
|
|
|
|
|
|
|
|
m_s1ap_log->error("Could not unpack NAS Attach Request and PDN connectivity request.\n");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get IMSI
|
|
|
|
|
|
|
|
imsi = 0;
|
|
|
|
|
|
|
|
for(int i=0;i<=14;i++){
|
|
|
|
|
|
|
|
imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_s1ap_log->console("Attach request from IMSI: %015lu\n", imsi);
|
|
|
|
|
|
|
|
m_s1ap_log->info("Attach request from IMSI: %015lu\n", imsi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get UE network capabilities
|
|
|
|
|
|
|
|
memcpy(&ue_ctx.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;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//FIXME use this info
|
|
|
|
|
|
|
|
uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused
|
|
|
|
|
|
|
|
ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save whether ESM information transfer is necessary
|
|
|
|
|
|
|
|
ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present;
|
|
|
|
|
|
|
|
m_s1ap_log->console("EPS Bearer id: %d\n", eps_bearer_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Initialize NAS count
|
|
|
|
|
|
|
|
ue_ctx.security_ctxt.ul_nas_count = 0;
|
|
|
|
|
|
|
|
ue_ctx.security_ctxt.dl_nas_count = 0;
|
|
|
|
|
|
|
|
//Add eNB info to UE ctxt
|
|
|
|
|
|
|
|
memcpy(&ue_ctx.enb_sri, enb_sri, sizeof(struct sctp_sndrcvinfo));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get Authentication Vectors from HSS
|
|
|
|
|
|
|
|
if(!m_hss->gen_auth_info_answer(imsi, ue_ctx.security_ctxt.k_asme, autn, rand, ue_ctx.security_ctxt.xres))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_s1ap_log->console("User not found. IMSI %015lu\n",imsi);
|
|
|
|
|
|
|
|
m_s1ap_log->info("User not found. IMSI %015lu\n",imsi);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Save UE context
|
|
|
|
|
|
|
|
ue_ctx.imsi = imsi;
|
|
|
|
|
|
|
|
ue_ctx.mme_ue_s1ap_id = m_next_mme_ue_s1ap_id++;
|
|
|
|
|
|
|
|
for(uint i = 0 ; i< MAX_ERABS_PER_UE; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ue_ctx.erabs_ctx[i].state = ERAB_DEACTIVATED;
|
|
|
|
|
|
|
|
ue_ctx.erabs_ctx[i].erab_id = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ue_ctx_t *ue_ptr = new ue_ctx_t;
|
|
|
|
|
|
|
|
memcpy(ue_ptr,&ue_ctx,sizeof(ue_ctx));
|
|
|
|
|
|
|
|
m_active_ues.insert(std::pair<uint32_t,ue_ctx_t*>(ue_ptr->mme_ue_s1ap_id,ue_ptr));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::map<int32_t,uint16_t>::iterator it_enb = m_sctp_to_enb_id.find(enb_sri->sinfo_assoc_id);
|
|
|
|
|
|
|
|
uint16_t enb_id = it_enb->second;
|
|
|
|
|
|
|
|
std::map<uint16_t,std::set<uint32_t> >::iterator it_ue_id = m_enb_id_to_ue_ids.find(enb_id);
|
|
|
|
|
|
|
|
if(it_ue_id==m_enb_id_to_ue_ids.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_s1ap_log->error("Could not find eNB's UEs\n");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
it_ue_id->second.insert(ue_ptr->mme_ue_s1ap_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Pack NAS Authentication Request in Downlink NAS Transport msg
|
|
|
|
|
|
|
|
srslte::byte_buffer_t *reply_msg = m_pool->allocate();
|
|
|
|
|
|
|
|
m_s1ap_nas_transport->pack_authentication_request(reply_msg, ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id, autn, rand);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Send Reply to eNB
|
|
|
|
|
|
|
|
ssize_t n_sent = sctp_send(m_s1mme,reply_msg->msg, reply_msg->N_bytes, enb_sri, 0);
|
|
|
|
|
|
|
|
if(n_sent == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_s1ap_log->error("Failed to send NAS Attach Request");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_s1ap_log->info("DL NAS: Sent Athentication Request\n");
|
|
|
|
|
|
|
|
m_pool->deallocate(reply_msg);
|
|
|
|
|
|
|
|
//TODO Start T3460 Timer!
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
s1ap::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri)
|
|
|
|
s1ap::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri)
|
|
|
|
{
|
|
|
|
{
|
|
|
|