Changing security mode complete to use downlink nas transport

master
Pedro Alvarez 6 years ago
parent 93222f582c
commit 21c34b9ce5

@ -185,9 +185,9 @@ public:
bool* reply_flag, bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri); struct sctp_sndrcvinfo *enb_sri);
/* Uplink NAS messages handling */ /* Uplink NAS messages handling */
bool handle_nas_authentication_response( srslte::byte_buffer_t *nas_rx); bool handle_authentication_response( srslte::byte_buffer_t *nas_rx);
bool handle_nas_security_mode_complete( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_security_mode_complete( srslte::byte_buffer_t *nas_rx);
bool handle_nas_attach_complete( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_attach_complete( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool handle_esm_information_response( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_esm_information_response( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool handle_identity_response( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_identity_response( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool handle_tracking_area_update_request( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_tracking_area_update_request( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);

@ -483,7 +483,7 @@ nas::handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
* *
*/ */
bool bool
nas::handle_nas_authentication_response(srslte::byte_buffer_t *nas_rx) nas::handle_authentication_response(srslte::byte_buffer_t *nas_rx)
{ {
srslte::byte_buffer_t *nas_tx; srslte::byte_buffer_t *nas_tx;
LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_resp; LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_resp;
@ -536,41 +536,48 @@ nas::handle_nas_authentication_response(srslte::byte_buffer_t *nas_rx)
} }
bool bool
nas::handle_nas_security_mode_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag) nas::handle_security_mode_complete(srslte::byte_buffer_t *nas_rx)
{ {
srslte::byte_buffer_t *nas_tx;
LIBLTE_MME_SECURITY_MODE_COMPLETE_MSG_STRUCT sm_comp; LIBLTE_MME_SECURITY_MODE_COMPLETE_MSG_STRUCT sm_comp;
//Get NAS authentication response //Get NAS security mode complete
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_security_mode_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &sm_comp); LIBLTE_ERROR_ENUM err = liblte_mme_unpack_security_mode_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_rx, &sm_comp);
if(err != LIBLTE_SUCCESS){ if(err != LIBLTE_SUCCESS){
m_nas_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]); m_nas_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]);
return false; return false;
} }
//Log security mode complete
m_nas_log->info("Security Mode Command Complete -- IMSI: %lu\n", m_emm_ctx.imsi); m_nas_log->info("Security Mode Command Complete -- IMSI: %lu\n", m_emm_ctx.imsi);
m_nas_log->console("Security Mode Command Complete -- IMSI: %lu\n", m_emm_ctx.imsi); m_nas_log->console("Security Mode Command Complete -- IMSI: %lu\n", m_emm_ctx.imsi);
//Check wether secure ESM information transfer is required
nas_tx = m_pool->allocate();
if (m_ecm_ctx.eit == true) { if (m_ecm_ctx.eit == true) {
pack_esm_information_request(reply_buffer); //Secure ESM information transfer is required
m_nas_log->console("Sending ESM information request\n"); m_nas_log->console("Sending ESM information request\n");
m_nas_log->info_hex(reply_buffer->msg, reply_buffer->N_bytes, "Sending ESM information request\n"); m_nas_log->info("Sending ESM information request\n");
*reply_flag = true;
//Packing ESM information request
pack_esm_information_request(nas_tx);
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);
} else { } else {
//Get subscriber info from HSS //Secure ESM information transfer not necessary
//Sending create session request to SP-GW.
uint8_t default_bearer=5; uint8_t default_bearer=5;
m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci); m_hss->gen_update_loc_answer(m_emm_ctx.imsi, &m_esm_ctx[default_bearer].qci);
m_nas_log->debug("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_nas_log->debug("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci);
m_nas_log->console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci); m_nas_log->console("Getting subscription information -- QCI %d\n", m_esm_ctx[default_bearer].qci);
//FIXME The packging of GTP-C messages is not ready.
//This means that GTP-U tunnels are created with function calls, as opposed to GTP-C.
m_gtpc->send_create_session_request(m_emm_ctx.imsi); m_gtpc->send_create_session_request(m_emm_ctx.imsi);
*reply_flag = false; //No reply needed
} }
m_pool->deallocate(nas_tx);
return true; return true;
} }
bool bool
nas::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, bool *reply_flag) nas::handle_attach_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, bool *reply_flag)
{ {
LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp; LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp;

@ -223,7 +223,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE: case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE:
m_s1ap_log->info("Uplink NAS: Received Authentication Response\n"); m_s1ap_log->info("Uplink NAS: Received Authentication Response\n");
m_s1ap_log->console("Uplink NAS: Received Authentication Response\n"); m_s1ap_log->console("Uplink NAS: Received Authentication Response\n");
nas_ctx->handle_nas_authentication_response(nas_msg); nas_ctx->handle_authentication_response(nas_msg);
break; break;
// Authentication failure with the option sync failure can be sent not integrity protected // Authentication failure with the option sync failure can be sent not integrity protected
case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_FAILURE: case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_FAILURE:
@ -257,7 +257,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
sec_ctx->dl_nas_count = 0; sec_ctx->dl_nas_count = 0;
mac_valid = nas_ctx->integrity_check(nas_msg); mac_valid = nas_ctx->integrity_check(nas_msg);
if(mac_valid){ if(mac_valid){
nas_ctx->handle_nas_security_mode_complete(nas_msg, reply_buffer, reply_flag); nas_ctx->handle_security_mode_complete(nas_msg);
} else { } else {
m_s1ap_log->warning("Invalid MAC in Security Mode Command Complete message.\n" ); m_s1ap_log->warning("Invalid MAC in Security Mode Command Complete message.\n" );
} }
@ -282,7 +282,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE: case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE:
m_s1ap_log->info("Integrity Protected UL NAS: Received Attach Complete\n"); m_s1ap_log->info("Integrity Protected UL NAS: Received Attach Complete\n");
m_s1ap_log->console("Integrity Protected UL NAS: Received Attach Complete\n"); m_s1ap_log->console("Integrity Protected UL NAS: Received Attach Complete\n");
nas_ctx->handle_nas_attach_complete(nas_msg, reply_buffer, reply_flag); nas_ctx->handle_attach_complete(nas_msg, reply_buffer, reply_flag);
break; break;
case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE: case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE:
m_s1ap_log->info("Integrity Protected UL NAS: Received ESM Information Response\n"); m_s1ap_log->info("Integrity Protected UL NAS: Received ESM Information Response\n");

Loading…
Cancel
Save