Added IMSI attach from unknown UE as a static function.

master
Pedro Alvarez 6 years ago
parent 0ddb3d39dc
commit 0d80ae795b

@ -53,6 +53,7 @@ public:
virtual bool add_nas_ctx_to_mme_ue_s1ap_id_map(nas *nas_ctx) = 0; virtual bool add_nas_ctx_to_mme_ue_s1ap_id_map(nas *nas_ctx) = 0;
virtual bool add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id) = 0; virtual bool add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id) = 0;
virtual bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id) = 0; virtual bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id) = 0;
virtual bool delete_ue_ctx(uint64_t imsi) = 0;
virtual uint64_t find_imsi_from_m_tmsi(uint32_t m_tmsi) = 0; virtual uint64_t find_imsi_from_m_tmsi(uint32_t m_tmsi) = 0;
virtual nas* find_nas_ctx_from_imsi(uint64_t imsi) = 0; virtual nas* find_nas_ctx_from_imsi(uint64_t imsi) = 0;
virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup) = 0; virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup) = 0;

@ -177,10 +177,16 @@ public:
hss_interface_nas *hss, hss_interface_nas *hss,
srslte::log *nas_log); srslte::log *nas_log);
bool handle_imsi_attach_request_known_ue( uint32_t enb_ue_s1ap_id, static bool handle_imsi_attach_request_known_ue( nas *nas_ctx,
struct sctp_sndrcvinfo *enb_sri, uint32_t enb_ue_s1ap_id,
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, struct sctp_sndrcvinfo *enb_sri,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req); const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
static bool handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id, static bool handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,

@ -94,7 +94,7 @@ public:
bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id); bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id);
void release_ues_ecm_ctx_in_enb(int32_t enb_assoc); void release_ues_ecm_ctx_in_enb(int32_t enb_assoc);
bool delete_ue_ctx(uint64_t imsi); virtual bool delete_ue_ctx(uint64_t imsi);
uint32_t allocate_m_tmsi(uint64_t imsi); uint32_t allocate_m_tmsi(uint64_t imsi);
virtual uint64_t find_imsi_from_m_tmsi(uint32_t m_tmsi); virtual uint64_t find_imsi_from_m_tmsi(uint32_t m_tmsi);

@ -157,10 +157,12 @@ nas::handle_attach_request( uint32_t enb_ue_s1ap_id,
return false; return false;
} }
} else { } else {
nas_log->info("Attach Request -- Found previously attached UE.\n");
nas_log->console("Attach Request -- Found previously attach UE.\n");
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) {
nas_log->console("Attach Request -- IMSI-style attach request\n"); nas_log->console("Attach Request -- IMSI-style attach request\n");
nas_log->info("Attach Request -- IMSI-style attach request\n"); nas_log->info("Attach Request -- IMSI-style attach request\n");
nas_ctx->handle_imsi_attach_request_known_ue(enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req); nas::handle_imsi_attach_request_known_ue(nas_ctx, enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req, args, s1ap, gtpc, hss, nas_log);
} else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) { } else if (attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_GUTI) {
nas_log->console("Attach Request -- GUTI-style attach request\n"); nas_log->console("Attach Request -- GUTI-style attach request\n");
nas_log->info("Attach Request -- GUTI-style attach request\n"); nas_log->info("Attach Request -- GUTI-style attach request\n");
@ -267,81 +269,31 @@ nas::handle_imsi_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
} }
bool bool
nas::handle_imsi_attach_request_known_ue( uint32_t enb_ue_s1ap_id, nas::handle_imsi_attach_request_known_ue( nas *nas_ctx,
uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri, struct sctp_sndrcvinfo *enb_sri,
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req ) const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log)
{ {
srslte::byte_buffer_t *nas_tx; bool err;
//Delete previous GTP-U session
//Get IMSI gtpc->send_delete_session_request(nas_ctx->m_emm_ctx.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 //Release previous context in the eNB, if present
memcpy(&m_sec_ctx.ue_network_cap, &attach_req.ue_network_cap, sizeof(LIBLTE_MME_UE_NETWORK_CAPABILITY_STRUCT)); if(nas_ctx->m_ecm_ctx.mme_ue_s1ap_id != 0){
m_sec_ctx.ms_network_cap_present = attach_req.ms_network_cap_present; s1ap->send_ue_context_release_command(nas_ctx->m_ecm_ctx.mme_ue_s1ap_id);
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));
} }
//Delete previous NAS context
s1ap->delete_ue_ctx(nas_ctx->m_emm_ctx.imsi);
uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused //Handle new attach
m_emm_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; err = nas::handle_imsi_attach_request_unknown_ue(enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req, args, s1ap, gtpc, hss, nas_log);
return err;
//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;
}
//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
nas_tx = m_pool->allocate();
pack_authentication_request(nas_tx);
//Send reply to eNB
m_s1ap->send_downlink_nas_transport(m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id, nas_tx, m_ecm_ctx.enb_sri);
m_pool->deallocate(nas_tx);
m_nas_log->info("Downlink NAS: Sending Authentication Request\n");
m_nas_log->console("Downlink NAS: Sending Authentication Request\n");
return true;
} }
bool bool

Loading…
Cancel
Save