Changed authentication response to use downlink_nas_transport().

master
Pedro Alvarez 6 years ago
parent 3073ab6822
commit 93222f582c

@ -21,6 +21,7 @@
#ifndef SRSLTE_EPC_INTERFACES_H #ifndef SRSLTE_EPC_INTERFACES_H
#define SRSLTE_EPC_INTERFACES_H #define SRSLTE_EPC_INTERFACES_H
#include "srslte/asn1/gtpc_ies.h" #include "srslte/asn1/gtpc_ies.h"
#include <netinet/sctp.h>
namespace srsepc { namespace srsepc {
@ -54,6 +55,7 @@ public:
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 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;
virtual bool send_ue_context_release_command(uint32_t mme_ue_s1ap_id) = 0; virtual bool send_ue_context_release_command(uint32_t mme_ue_s1ap_id) = 0;
virtual bool 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) = 0;
}; };
//NAS -> HSS //NAS -> HSS

@ -185,7 +185,7 @@ 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_msg, srslte::byte_buffer_t *reply_buffer, bool* reply_flag); bool handle_nas_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_nas_security_mode_complete( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool handle_nas_attach_complete( srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_nas_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);

@ -112,7 +112,7 @@ public:
//Interfaces //Interfaces
virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup); virtual bool send_initial_context_setup_request(uint64_t imsi, uint16_t erab_to_setup);
virtual bool send_ue_context_release_command(uint32_t mme_ue_s1ap_id); virtual bool send_ue_context_release_command(uint32_t mme_ue_s1ap_id);
virtual bool 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);
private: private:
s1ap(); s1ap();
virtual ~s1ap(); virtual ~s1ap();

@ -46,7 +46,7 @@ public:
bool handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool 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); bool 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);
bool handle_nas_attach_request(uint32_t enb_ue_s1ap_id, bool handle_nas_attach_request(uint32_t enb_ue_s1ap_id,
srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *nas_msg,

@ -482,54 +482,56 @@ nas::handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
* Handle Uplink NAS Transport message * Handle Uplink NAS Transport message
* *
*/ */
bool bool
nas::handle_nas_authentication_response(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, bool* reply_flag) nas::handle_nas_authentication_response(srslte::byte_buffer_t *nas_rx)
{ {
srslte::byte_buffer_t *nas_tx;
LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_resp; LIBLTE_MME_AUTHENTICATION_RESPONSE_MSG_STRUCT auth_resp;
m_nas_log->console("Authentication Response -- IMSI %015lu\n", m_emm_ctx.imsi); bool ue_valid=true;
//Get NAS authentication response //Get NAS authentication response
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_authentication_response_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &auth_resp); LIBLTE_ERROR_ENUM err = liblte_mme_unpack_authentication_response_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_rx, &auth_resp);
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;
} }
m_nas_log->console("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n",
auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3],
auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]);
m_nas_log->info("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n",
auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3],
auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]);
bool ue_valid=true; //Log received authentication response
m_nas_log->console("Authentication Response -- IMSI %015lu\n", m_emm_ctx.imsi);
m_nas_log->info("Authentication Response -- IMSI %015lu\n", m_emm_ctx.imsi);
m_nas_log->info_hex(auth_resp.res,8, "Authentication response -- RES");
m_nas_log->info_hex(m_sec_ctx.xres,8, "Authentication response -- XRES");
//Check UE authentication
for(int i=0; i<8;i++){ for(int i=0; i<8;i++){
if( auth_resp.res[i] != m_sec_ctx.xres[i] ) { if( auth_resp.res[i] != m_sec_ctx.xres[i] ) {
ue_valid = false; ue_valid = false;
} }
} }
nas_tx = m_pool->allocate();
if(!ue_valid) { if(!ue_valid) {
m_nas_log->info_hex(m_sec_ctx.xres,8, "XRES"); //Authentication rejected
m_nas_log->console("UE Authentication Rejected.\n"); m_nas_log->console("UE Authentication Rejected.\n");
m_nas_log->warning("UE Authentication Rejected.\n"); m_nas_log->warning("UE Authentication Rejected.\n");
//Send back Athentication Reject //Send back Athentication Reject
pack_authentication_reject(reply_buffer); pack_authentication_reject(nas_tx);
*reply_flag = true; m_nas_log->info("Downlink NAS: Sending Authentication Reject.\n");
m_nas_log->console("Downlink NAS: Sending Authentication Reject.\n");
return false;
} else { } else {
//Authentication accepted
m_nas_log->console("UE Authentication Accepted.\n"); m_nas_log->console("UE Authentication Accepted.\n");
m_nas_log->info("UE Authentication Accepted.\n"); m_nas_log->info("UE Authentication Accepted.\n");
//Send Security Mode Command //Send Security Mode Command
m_sec_ctx.ul_nas_count = 0; // Reset the NAS uplink counter for the right key k_enb derivation m_sec_ctx.ul_nas_count = 0; // Reset the NAS uplink counter for the right key k_enb derivation
pack_security_mode_command(reply_buffer); pack_security_mode_command(nas_tx);
*reply_flag = true;
m_nas_log->console("Downlink NAS: Sending NAS Security Mode Command.\n"); m_nas_log->console("Downlink NAS: Sending NAS Security Mode Command.\n");
} }
//Send reply
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);
return true; return true;
} }

@ -650,4 +650,9 @@ s1ap::send_ue_context_release_command(uint32_t mme_ue_s1ap_id)
return true; return true;
} }
bool
s1ap::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)
{
return m_s1ap_nas_transport->send_downlink_nas_transport(enb_ue_s1ap_id, mme_ue_s1ap_id, nas_msg, enb_sri);
}
} //namespace srsepc } //namespace srsepc

@ -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, reply_buffer, reply_flag); nas_ctx->handle_nas_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:
@ -673,7 +673,7 @@ s1ap_nas_transport::handle_nas_tracking_area_update_request(uint32_t m_tmsi,
} }
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)
{ {
//Allocate Reply buffer //Allocate Reply buffer
srslte::byte_buffer_t *reply_msg = m_pool->allocate(); srslte::byte_buffer_t *reply_msg = m_pool->allocate();
@ -709,7 +709,7 @@ s1ap_nas_transport::send_downlink_nas_transport(uint32_t enb_ue_s1ap_id, uint32_
m_pool->deallocate(reply_msg); m_pool->deallocate(reply_msg);
return false; return false;
} }
m_s1ap->s1ap_tx_pdu(nas_msg,enb_sri); m_s1ap->s1ap_tx_pdu(nas_msg, &enb_sri);
m_pool->deallocate(reply_msg); m_pool->deallocate(reply_msg);
return true; return true;
} }

Loading…
Cancel
Save