Changed detach request and tracking area update request to nas.cc

master
Pedro Alvarez 6 years ago
parent d2cb01ce87
commit 9350e03810

@ -221,8 +221,28 @@ public:
gtpc_interface_nas *gtpc, gtpc_interface_nas *gtpc,
hss_interface_nas *hss, hss_interface_nas *hss,
srslte::log *nas_log); srslte::log *nas_log);
//Dettach request messages //Dettach request messages
static bool handle_detach_request( uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_rx,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
//Tracking area update request messages //Tracking area update request messages
static bool handle_tracking_area_update_request( uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_rx,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
/* Uplink NAS messages handling */ /* Uplink NAS messages handling */
bool handle_authentication_response (srslte::byte_buffer_t *nas_rx); bool handle_authentication_response (srslte::byte_buffer_t *nas_rx);
@ -232,7 +252,7 @@ public:
bool handle_identity_response (srslte::byte_buffer_t *nas_rx); bool handle_identity_response (srslte::byte_buffer_t *nas_rx);
bool handle_tracking_area_update_request (srslte::byte_buffer_t *nas_rx); bool handle_tracking_area_update_request (srslte::byte_buffer_t *nas_rx);
bool handle_authentication_failure (srslte::byte_buffer_t *nas_rx); bool handle_authentication_failure (srslte::byte_buffer_t *nas_rx);
bool handle_nas_detach_request (srslte::byte_buffer_t *nas_rx); bool handle_detach_request (srslte::byte_buffer_t *nas_rx);
/* Downlink NAS messages packing */ /* Downlink NAS messages packing */
bool pack_authentication_request (srslte::byte_buffer_t *nas_buffer); bool pack_authentication_request (srslte::byte_buffer_t *nas_buffer);

@ -505,15 +505,16 @@ nas::handle_guti_attach_request_known_ue( nas *nas_ctx,
} }
//Service Requests //Service Requests
bool nas::handle_service_request( uint32_t m_tmsi, bool
uint32_t enb_ue_s1ap_id, nas::handle_service_request( uint32_t m_tmsi,
struct sctp_sndrcvinfo *enb_sri, uint32_t enb_ue_s1ap_id,
srslte::byte_buffer_t *nas_rx, struct sctp_sndrcvinfo *enb_sri,
nas_init_t args, srslte::byte_buffer_t *nas_rx,
s1ap_interface_nas *s1ap, nas_init_t args,
gtpc_interface_nas *gtpc, s1ap_interface_nas *s1ap,
hss_interface_nas *hss, gtpc_interface_nas *gtpc,
srslte::log *nas_log) hss_interface_nas *hss,
srslte::log *nas_log)
{ {
nas_log->info("Service request -- S-TMSI 0x%x\n", m_tmsi); nas_log->info("Service request -- S-TMSI 0x%x\n", m_tmsi);
nas_log->console("Service request -- S-TMSI 0x%x\n", m_tmsi); nas_log->console("Service request -- S-TMSI 0x%x\n", m_tmsi);
@ -615,6 +616,96 @@ nas::handle_guti_attach_request_known_ue( nas *nas_ctx,
return true; return true;
} }
bool nas::handle_detach_request( uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_rx,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log)
{
nas_log->info("Detach Request -- S-TMSI 0x%x\n", m_tmsi);
nas_log->console("Detach Request -- S-TMSI 0x%x\n", m_tmsi);
nas_log->info("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
nas_log->console("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
bool mac_valid = false;
LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req;
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_detach_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_rx, &detach_req);
if (err !=LIBLTE_SUCCESS) {
nas_log->error("Could not unpack detach request\n");
return false;
}
uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi);
if (imsi == 0) {
nas_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
nas_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
return true;
}
nas *nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi);
if (nas_ctx == NULL) {
nas_log->console("Could not find UE context from IMSI\n");
nas_log->error("Could not find UE context from IMSI\n");
return true;
}
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
sec_ctx_t *sec_ctx = &nas_ctx->m_sec_ctx;
gtpc->send_delete_session_request(emm_ctx->imsi);
emm_ctx->state = EMM_STATE_DEREGISTERED;
sec_ctx->ul_nas_count++;
nas_log->console("Received. M-TMSI 0x%x\n", m_tmsi);
//Received detach request as an initial UE message
//eNB created new ECM context to send the detach request; this needs to be cleared.
ecm_ctx->mme_ue_s1ap_id = s1ap->get_next_mme_ue_s1ap_id();
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
s1ap->send_ue_context_release_command(ecm_ctx->mme_ue_s1ap_id);
return true;
}
bool
nas::handle_tracking_area_update_request( uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_rx,
nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log)
{
nas_log->info("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi);
nas_log->console("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi);
nas_log->info("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
nas_log->console("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
nas_log->console("Warning: Tracking area update requests are not handled yet.\n");
nas_log->warning("Tracking area update requests are not handled yet.\n");
uint64_t imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi);
if (imsi == 0) {
nas_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
nas_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
return true;
}
nas *nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi);
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
sec_ctx_t *sec_ctx = &nas_ctx->m_sec_ctx;
sec_ctx->ul_nas_count++; //Increment the NAS count, not to break the security ctx
return true;
}
/*************************************** /***************************************
* *
* Handle Uplink NAS Transport messages * Handle Uplink NAS Transport messages
@ -916,7 +1007,7 @@ nas::handle_authentication_failure(srslte::byte_buffer_t *nas_rx)
} }
bool bool
nas::handle_nas_detach_request(srslte::byte_buffer_t *nas_msg) nas::handle_detach_request(srslte::byte_buffer_t *nas_msg)
{ {
m_nas_log->console("Detach request -- IMSI %015lu\n", m_emm_ctx.imsi); m_nas_log->console("Detach request -- IMSI %015lu\n", m_emm_ctx.imsi);

@ -115,23 +115,25 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
m_s1ap_log->console("Received Initial UE message -- Attach Request\n"); m_s1ap_log->console("Received Initial UE message -- Attach Request\n");
m_s1ap_log->info("Received Initial UE message -- Attach Request\n"); m_s1ap_log->info("Received Initial UE message -- Attach Request\n");
err = nas::handle_attach_request(enb_ue_s1ap_id, enb_sri, nas_msg, nas_init, err = nas::handle_attach_request(enb_ue_s1ap_id, enb_sri, nas_msg, nas_init,
m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log); m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
break; break;
case LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST: case LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST:
m_s1ap_log->console("Received Initial UE message -- Service Request\n"); m_s1ap_log->console("Received Initial UE message -- Service Request\n");
m_s1ap_log->info("Received Initial UE message -- Service Request\n"); m_s1ap_log->info("Received Initial UE message -- Service Request\n");
err = nas::handle_service_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, nas_init, err = nas::handle_service_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, nas_init,
m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log); m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
break; break;
case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST:
m_s1ap_log->console("Received Initial UE message -- Detach Request\n"); m_s1ap_log->console("Received Initial UE message -- Detach Request\n");
m_s1ap_log->info("Received Initial UE message -- Detach Request\n"); m_s1ap_log->info("Received Initial UE message -- Detach Request\n");
err = handle_nas_detach_request(m_tmsi, enb_ue_s1ap_id, nas_msg, reply_buffer,reply_flag, enb_sri); err = nas::handle_detach_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, nas_init,
m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
break; break;
case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST: case LIBLTE_MME_MSG_TYPE_TRACKING_AREA_UPDATE_REQUEST:
m_s1ap_log->console("Received Initial UE message -- Tracking Area Update Request\n"); m_s1ap_log->console("Received Initial UE message -- Tracking Area Update Request\n");
m_s1ap_log->info("Received Initial UE message -- Tracking Area Update Request\n"); m_s1ap_log->info("Received Initial UE message -- Tracking Area Update Request\n");
err = handle_nas_tracking_area_update_request(m_tmsi, enb_ue_s1ap_id, nas_msg, reply_buffer,reply_flag, enb_sri); err = nas::handle_tracking_area_update_request(m_tmsi, enb_ue_s1ap_id, enb_sri, nas_msg, nas_init,
m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
break; break;
default: default:
m_s1ap_log->info("Unhandled Initial UE Message 0x%x \n", msg_type); m_s1ap_log->info("Unhandled Initial UE Message 0x%x \n", msg_type);
@ -215,11 +217,11 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST:
m_s1ap_log->info("Plain Protected UL NAS: Detach Request\n"); m_s1ap_log->info("Plain Protected UL NAS: Detach Request\n");
m_s1ap_log->console("Plain Protected UL NAS: Detach Request\n"); m_s1ap_log->console("Plain Protected UL NAS: Detach Request\n");
nas_ctx->handle_nas_detach_request(nas_msg); nas_ctx->handle_detach_request(nas_msg);
break; break;
default: default:
m_s1ap_log->warning("Unhandled Plain NAS message 0x%x\n", msg_type ); m_s1ap_log->warning("Unhandled Plain NAS message 0x%x\n", msg_type);
m_s1ap_log->console("Unhandled Plain NAS message 0x%x\n", msg_type ); m_s1ap_log->console("Unhandled Plain NAS message 0x%x\n", msg_type);
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
return false; return false;
} }
@ -282,7 +284,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST:
m_s1ap_log->info("Integrity Protected UL NAS: Detach Request\n"); m_s1ap_log->info("Integrity Protected UL NAS: Detach Request\n");
m_s1ap_log->console("Integrity Protected UL NAS: Detach Request\n"); m_s1ap_log->console("Integrity Protected UL NAS: Detach Request\n");
nas_ctx->handle_nas_detach_request(nas_msg); nas_ctx->handle_detach_request(nas_msg);
break; break;
default: default:
m_s1ap_log->warning("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type)); m_s1ap_log->warning("Unhandled NAS integrity protected message %s\n", liblte_nas_msg_type_to_string(msg_type));
@ -299,86 +301,6 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
return true; return true;
} }
bool
s1ap_nas_transport::handle_nas_detach_request(uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer,
bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri)
{
m_s1ap_log->info("Detach Request -- S-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->console("Detach Request -- S-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->info("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
m_s1ap_log->console("Detach Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
bool mac_valid = false;
LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req;
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_detach_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &detach_req);
if (err !=LIBLTE_SUCCESS) {
m_s1ap_log->error("Could not unpack detach request\n");
return false;
}
std::map<uint32_t,uint64_t>::iterator it = m_s1ap->m_tmsi_to_imsi.find(m_tmsi);
if (it == m_s1ap->m_tmsi_to_imsi.end()) {
m_s1ap_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
return true;
}
nas *nas_ctx = m_s1ap->find_nas_ctx_from_imsi(it->second);
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
sec_ctx_t *sec_ctx = &nas_ctx->m_sec_ctx;
m_mme_gtpc->send_delete_session_request(emm_ctx->imsi);
emm_ctx->state = EMM_STATE_DEREGISTERED;
sec_ctx->ul_nas_count++;
m_s1ap_log->console("Received. M-TMSI 0x%x\n", m_tmsi);
//Received detach request as an initial UE message
//eNB created new ECM context to send the detach request; this needs to be cleared.
ecm_ctx->mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
ecm_ctx->enb_ue_s1ap_id = enb_ue_s1ap_id;
m_s1ap->m_s1ap_ctx_mngmt_proc->send_ue_context_release_command(nas_ctx);
return true;
}
bool
s1ap_nas_transport::handle_nas_tracking_area_update_request(uint32_t m_tmsi,
uint32_t enb_ue_s1ap_id,
srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer,
bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri)
{
m_s1ap_log->info("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->console("Tracking Area Update Request -- S-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->info("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
m_s1ap_log->console("Tracking Area Update Request -- eNB UE S1AP Id %d\n", enb_ue_s1ap_id);
m_s1ap_log->console("Warning: Tracking area update requests are not handled yet.\n");
m_s1ap_log->warning("Tracking area update requests are not handled yet.\n");
std::map<uint32_t,uint64_t>::iterator it = m_s1ap->m_tmsi_to_imsi.find(m_tmsi);
if (it == m_s1ap->m_tmsi_to_imsi.end()) {
m_s1ap_log->console("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->error("Could not find IMSI from M-TMSI. M-TMSI 0x%x\n", m_tmsi);
return true;
}
nas *nas_ctx = m_s1ap->find_nas_ctx_from_imsi(it->second);
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
sec_ctx_t *sec_ctx = &nas_ctx->m_sec_ctx;
sec_ctx->ul_nas_count++; //Increment the NAS count, not to break the security ctx
return true;
}
bool bool
s1ap_nas_transport::send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, srslte::byte_buffer_t *nas_msg, struct sctp_sndrcvinfo enb_sri) s1ap_nas_transport::send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id, srslte::byte_buffer_t *nas_msg, struct sctp_sndrcvinfo enb_sri)
{ {

Loading…
Cancel
Save