Starting to handle NAS initial UE messages as static methods of the nas class.

master
Pedro Alvarez 6 years ago
parent e3286897ce
commit 9e808ff968

@ -131,55 +131,76 @@ typedef struct{
LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT guti; LIBLTE_MME_EPS_MOBILE_ID_GUTI_STRUCT guti;
} sec_ctx_t; } sec_ctx_t;
/*
* NAS Initialization Arguments
*/
typedef struct {
uint16_t mcc;
uint16_t mnc;
uint8_t mme_code;
uint16_t mme_group;
uint16_t tac;
std::string apn;
std::string dns;
} nas_init_t;
class nas class nas
{ {
public: public:
nas(); nas();
void init(uint16_t mcc, void init(nas_init_t args,
uint16_t mnc,
uint8_t mme_code,
uint16_t mme_group,
uint16_t tac,
std::string apn,
std::string dns,
s1ap_interface_nas *s1ap, s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc, gtpc_interface_nas *gtpc,
hss_interface_nas *hss, hss_interface_nas *hss,
srslte::log *nas_log); srslte::log *nas_log);
/*Initial UE messages*/ /***********************
bool handle_attach_request( uint32_t enb_ue_s1ap_id, * Initial UE messages *
***********************/
//Attach request messages
static bool handle_attach_request( uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer, nas_init_t args,
bool* reply_flag, s1ap_interface_nas *s1ap,
struct sctp_sndrcvinfo *enb_sri); gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
bool handle_imsi_attach_request(uint32_t enb_ue_s1ap_id, static bool handle_imsi_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
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,
struct sctp_sndrcvinfo *enb_sri); nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
bool handle_guti_attach_request( uint32_t enb_ue_s1ap_id, bool handle_imsi_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
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);
srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer,
bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri);
bool handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
static bool handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
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,
srslte::byte_buffer_t *nas_rx, nas_init_t args,
struct sctp_sndrcvinfo *enb_sri); s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log);
bool handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id, bool handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
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);
srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer, //Service request Messages
bool* reply_flag, //Dettach request Messages
struct sctp_sndrcvinfo *enb_sri); //
/* 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);
bool handle_security_mode_complete( srslte::byte_buffer_t *nas_rx); bool handle_security_mode_complete( srslte::byte_buffer_t *nas_rx);

@ -40,25 +40,19 @@ nas::nas() {
} }
void void
nas::init(uint16_t mcc, nas::init(nas_init_t args,
uint16_t mnc,
uint8_t mme_code,
uint16_t mme_group,
uint16_t tac,
std::string apn,
std::string dns,
s1ap_interface_nas *s1ap, s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc, gtpc_interface_nas *gtpc,
hss_interface_nas *hss, hss_interface_nas *hss,
srslte::log *nas_log) srslte::log *nas_log)
{ {
m_mcc = mcc; m_mcc = args.mcc;
m_mnc = mnc; m_mnc = args.mnc;
m_mme_code = mme_code; m_mme_code = args.mme_code;
m_mme_group = mme_group; m_mme_group = args.mme_group;
m_tac = tac; m_tac = args.tac;
m_apn = apn; m_apn = args.apn;
m_dns = dns; m_dns = args.dns;
m_s1ap = s1ap; m_s1ap = s1ap;
m_gtpc = gtpc; m_gtpc = gtpc;
@ -71,80 +65,136 @@ nas::init(uint16_t mcc,
* Handle UE Initiating Messages * Handle UE Initiating Messages
* *
********************************/ ********************************/
//FIXME Move UE Initiating mesages from s1ap_nas_transport static bool
bool
nas::handle_attach_request( uint32_t enb_ue_s1ap_id, nas::handle_attach_request( uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer, nas_init_t args,
bool* reply_flag, s1ap_interface_nas *s1ap,
struct sctp_sndrcvinfo *enb_sri) gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log)
{ {
bool save = true; uint32_t m_tmsi = 0;
uint64_t imsi = 0;
LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req; LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT attach_req;
LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req; LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req;
//Get NAS Attach Request and PDN connectivity request messages //Get NAS Attach Request and PDN connectivity request messages
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_request_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_req); LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_request_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_req);
if(err != LIBLTE_SUCCESS){ if(err != LIBLTE_SUCCESS){
m_nas_log->error("Error unpacking NAS attach request. Error: %s\n", liblte_error_text[err]); nas_log->error("Error unpacking NAS attach request. Error: %s\n", liblte_error_text[err]);
return save; return false;
} }
/*Get PDN Connectivity Request*/ //Get PDN Connectivity Request*/
err = liblte_mme_unpack_pdn_connectivity_request_msg(&attach_req.esm_msg, &pdn_con_req); err = liblte_mme_unpack_pdn_connectivity_request_msg(&attach_req.esm_msg, &pdn_con_req);
if(err != LIBLTE_SUCCESS){ if(err != LIBLTE_SUCCESS){
m_nas_log->error("Error unpacking NAS PDN Connectivity Request. Error: %s\n", liblte_error_text[err]); nas_log->error("Error unpacking NAS PDN Connectivity Request. Error: %s\n", liblte_error_text[err]);
return save; return false;
} }
//Get attach type from attach request //Get UE IMSI
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) {
m_nas_log->console("Attach Request -- IMSI-style attach request\n"); for(int i=0;i<=14;i++){
m_nas_log->info("Attach Request -- IMSI-style attach request\n"); imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i);
save = handle_imsi_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, enb_sri); }
nas_log->console("Attach request -- IMSI Style Attach request\n");
nas_log->info("Attach request -- IMSI Style Attach request\n");
nas_log->console("Attach request -- IMSI: %015lu\n", imsi);
nas_log->info("Attach request -- IMSI: %015lu\n", imsi);
} 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) {
m_nas_log->console("Attach Request -- GUTI-style attach request\n"); m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi;
m_nas_log->info("Attach Request -- GUTI-style attach request\n"); imsi = s1ap->find_imsi_from_m_tmsi(m_tmsi);
save = handle_guti_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, nas_msg, reply_buffer, reply_flag, enb_sri); nas_log->console("Attach request -- GUTI Style Attach request\n");
nas_log->info("Attach request -- GUTI Style Attach request\n");
nas_log->console("Attach request -- M-TMSI: 0x%x\n", m_tmsi);
nas_log->info("Attach request -- M-TMSI: 0x%x\n", m_tmsi);
} else { } else {
m_nas_log->error("Unhandled Mobile Id type in attach request\n"); nas_log->error("Unhandled Mobile Id type in attach request\n");
return save; return false;
} }
//Log Attach Request information //Log Attach Request Information
m_nas_log->console("Attach request -- IMSI: %015lu\n", m_emm_ctx.imsi); nas_log->console("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id);
m_nas_log->info("Attach request -- IMSI: %015lu\n", m_emm_ctx.imsi); nas_log->info("Attach request -- eNB-UE S1AP Id: %d\n", enb_ue_s1ap_id);
m_nas_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id); nas_log->console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
m_nas_log->info("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id); nas_log->info("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
m_nas_log->console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type); nas_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n",
m_nas_log->info("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
m_nas_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3], attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3],
attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]); attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]);
m_nas_log->info("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", nas_log->info("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3], attach_req.ue_network_cap.eea[0], attach_req.ue_network_cap.eea[1], attach_req.ue_network_cap.eea[2], attach_req.ue_network_cap.eea[3],
attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]); attach_req.ue_network_cap.eea[4], attach_req.ue_network_cap.eea[5], attach_req.ue_network_cap.eea[6], attach_req.ue_network_cap.eea[7]);
m_nas_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", nas_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3], attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3],
attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]); attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]);
m_nas_log->info("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n", nas_log->info("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3], attach_req.ue_network_cap.eia[0], attach_req.ue_network_cap.eia[1], attach_req.ue_network_cap.eia[2], attach_req.ue_network_cap.eia[3],
attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]); attach_req.ue_network_cap.eia[4], attach_req.ue_network_cap.eia[5], attach_req.ue_network_cap.eia[6], attach_req.ue_network_cap.eia[7]);
m_nas_log->console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false"); nas_log->console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false");
m_nas_log->info("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false"); nas_log->info("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false");
m_nas_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); nas_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id);
m_nas_log->info("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id); nas_log->info("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id);
m_nas_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); nas_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id);
m_nas_log->info("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); nas_log->info("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id);
m_nas_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); nas_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false");
m_nas_log->info("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); nas_log->info("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false");
return save;
//Get NAS Context if UE is known
nas * nas_ctx = s1ap->find_nas_ctx_from_imsi(imsi);
if (nas_ctx == NULL)
{
//Get attach type from attach request
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->info("Attach Request -- IMSI-style attach request\n");
nas::handle_imsi_attach_request_unknown_ue(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) {
nas_log->console("Attach Request -- GUTI-style attach request\n");
nas_log->info("Attach Request -- GUTI-style attach request\n");
nas::handle_guti_attach_request_unknown_ue(enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req, args, s1ap, gtpc, hss, nas_log);
} else {
nas_log->error("Unhandled Mobile Id type in attach request\n");
return false;
}
} else {
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->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);
} 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->info("Attach Request -- GUTI-style attach request\n");
nas_ctx->handle_guti_attach_request_known_ue(enb_ue_s1ap_id, enb_sri, attach_req, pdn_con_req);
} else {
nas_log->error("Unhandled Mobile Id type in attach request\n");
return false;
}
} }
bool //Log Attach Request information
nas::handle_imsi_attach_request( uint32_t enb_ue_s1ap_id, return true;
}
static bool
nas::handle_imsi_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
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,
struct sctp_sndrcvinfo *enb_sri) nas_init_t args,
s1ap_interface_nas *s1ap,
gtpc_interface_nas *gtpc,
hss_interface_nas *hss,
srslte::log *nas_log)
{
return true;
}
bool
nas::handle_imsi_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri,
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req )
{ {
srslte::byte_buffer_t *nas_tx; srslte::byte_buffer_t *nas_tx;
@ -218,86 +268,11 @@ nas::handle_imsi_attach_request( uint32_t enb_ue_s1ap_id,
return true; return true;
} }
bool
nas::handle_guti_attach_request( uint32_t enb_ue_s1ap_id,
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req,
srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer,
bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri)
{
//Parse the message security header
uint8 pd = 0;
uint8 sec_hdr_type = 0;
liblte_mme_parse_msg_sec_header((LIBLTE_BYTE_MSG_STRUCT*)nas_msg, &pd, &sec_hdr_type);
bool integrity_valid = false;
if(sec_hdr_type != LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY) {
m_nas_log->info("Attach request -- GUTI-stlye attach request is not integrity protected\n");
m_nas_log->console("Attach request -- GUTI-stlye attach request is not integrity protected\n");
} else {
m_nas_log->info("Attach request -- GUTI-stlye attach request is integrity protected\n");
m_nas_log->console("Attach request -- GUTI-stlye attach request is integrity protected\n");
}
//GUTI style attach
uint32_t m_tmsi = attach_req.eps_mobile_id.guti.m_tmsi;
/*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()) {
//Could not find IMSI from M-TMSI, send Id request
m_s1ap_log->console("Attach Request -- Could not find M-TMSI 0x%x\n", m_tmsi);
m_s1ap_log->info("Attach Request -- Could not find M-TMSI 0x%x\n", m_tmsi);
//nas *nas_ctx = new nas;
//nas_ctx->init(m_s1ap->m_s1ap_args.mcc,
// m_s1ap->m_s1ap_args.mnc,
// m_s1ap->m_s1ap_args.mme_code,
// m_s1ap->m_s1ap_args.mme_group,
// m_s1ap->m_s1ap_args.tac,
// m_s1ap->m_s1ap_args.mme_apn,
// m_s1ap->m_s1ap_args.dns_addr,
// m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
bool err = nas_ctx->handle_guti_attach_request_unknown_ue( enb_ue_s1ap_id,
attach_req,
pdn_con_req,
nas_msg,
reply_buffer,
reply_flag,
enb_sri);
//if (err == false) {
// delete nas_ctx;
//}
return err;
} else {
//Found UE context from M-TMSI
m_nas_log->console("Attach Request -- Found M-TMSI: %d\n",m_tmsi);
m_nas_log->console("Attach Request -- IMSI: %015lu\n",it->second);
//Get UE EMM context
nas *nas_ctx = m_s1ap->find_nas_ctx_from_imsi(it->second);
if (nas_ctx!=NULL) {
nas_ctx->handle_guti_attach_request_known_ue( enb_ue_s1ap_id,
attach_req,
pdn_con_req,
nas_msg,
reply_buffer,
reply_flag,
enb_sri);
} else {
m_s1ap_log->error("Found M-TMSI but could not find UE context\n");
m_s1ap_log->console("Error: Found M-TMSI but could not find UE context\n");
return false;
}
}*/
return true;
}
bool bool
nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id, nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
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)
srslte::byte_buffer_t *nas_rx,
struct sctp_sndrcvinfo *enb_sri)
{ {
m_nas_log->console("Found UE context. IMSI: %015lu, old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n",m_emm_ctx.imsi, m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id); m_nas_log->console("Found UE context. IMSI: %015lu, old eNB UE S1ap Id %d, old MME UE S1AP Id %d\n",m_emm_ctx.imsi, m_ecm_ctx.enb_ue_s1ap_id, m_ecm_ctx.mme_ue_s1ap_id);
@ -432,14 +407,17 @@ nas::handle_guti_attach_request_known_ue( uint32_t enb_ue_s1ap_id,
} }
} }
bool static bool
nas::handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id, nas::handle_guti_attach_request_unknown_ue( uint32_t enb_ue_s1ap_id,
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,
srslte::byte_buffer_t *nas_msg, nas_init_t args,
srslte::byte_buffer_t *reply_buffer, s1ap_interface_nas *s1ap,
bool* reply_flag, gtpc_interface_nas *gtpc,
struct sctp_sndrcvinfo *enb_sri) hss_interface_nas *hss,
srslte::log *nas_log)
{ {
srslte::byte_buffer_t *nas_tx; srslte::byte_buffer_t *nas_tx;

@ -96,47 +96,22 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
m_s1ap_log->console("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); m_s1ap_log->console("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type));
m_s1ap_log->info ("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type)); m_s1ap_log->info ("Initial UE message: %s\n", liblte_nas_msg_type_to_string(msg_type));
//Make sure M-TMSI is present, if mandatory nas_init_t nas_init;
if (msg_type != LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST && !init_ue->S_TMSI_present){ nas_init.mcc = m_s1ap->m_s1ap_args.mcc;
m_s1ap_log->error("Initial UE Message 0x%x -- S-TMSI not present\n", msg_type); nas_init.mnc = m_s1ap->m_s1ap_args.mnc;
m_s1ap_log->console("Initial UE message 0x%x -- S-TMSI not present\n", msg_type); nas_init.mme_code = m_s1ap->m_s1ap_args.mme_code;
m_pool->deallocate(nas_msg); nas_init.mme_group = m_s1ap->m_s1ap_args.mme_group;
return false; nas_init.tac = m_s1ap->m_s1ap_args.tac;
} nas_init.mme_apn = m_s1ap->m_s1ap_args.mme_apn;
nas_init.dns_addr = m_s1ap->m_s1ap_args.dns_addr;
//Get NAS context if TMSI is present
nas *nas_ctx = NULL;
if (init_ue->S_TMSI_present) {
m_tmsi = ntohl(*((uint32_t*)&init_ue->S_TMSI.m_TMSI.buffer));
imsi = m_s1ap->find_imsi_from_m_tmsi(m_tmsi);
if(imsi !=0){
nas_ctx = m_s1ap->find_nas_ctx_from_imsi(imsi);
}
}
//Create new NAS context if Attach request without known NAS context
//This will be release if the attach request returns an error
if (msg_type == LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST && nas_ctx == NULL) {
nas_ctx = new nas;
nas_ctx->init(m_s1ap->m_s1ap_args.mcc,
m_s1ap->m_s1ap_args.mnc,
m_s1ap->m_s1ap_args.mme_code,
m_s1ap->m_s1ap_args.mme_group,
m_s1ap->m_s1ap_args.tac,
m_s1ap->m_s1ap_args.mme_apn,
m_s1ap->m_s1ap_args.dns_addr,
m_s1ap, m_mme_gtpc, m_hss, m_s1ap->m_nas_log);
}
switch (msg_type) switch (msg_type)
{ {
case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST: case LIBLTE_MME_MSG_TYPE_ATTACH_REQUEST:
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 = handle_nas_attach_request(enb_ue_s1ap_id, nas_msg, reply_buffer,reply_flag, enb_sri); err = nas::handle_nas_attach_request(enb_ue_s1ap_id, nas_init, enb_sri, nas_msg,
if (err == false) { m_s1ap, m_gtpc, m_hss, m_s1ap->m_nas_log);
delete nas_ctx;
}
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");

Loading…
Cancel
Save