From 6c60c493e72416ff85e1de1d2d4a46fd4ff8c89e Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 31 Oct 2017 18:05:26 +0000 Subject: [PATCH] Hard-coded k, amf and op (for now). --- srsepc/src/hss/hss.cc | 17 ++++++++++---- srsepc/src/mme/s1ap.cc | 53 +++++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index 0cc05d726..e64a3accb 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -81,19 +81,28 @@ bool hss::get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op ) { + uint8_t k_tmp[16]; + for(int i=0;i<8;i++) + { + k_tmp[2*i]=i; + k_tmp[2*i+1]=i; + } + uint8_t amf_tmp[2]={0x80,0x00}; + uint8_t op_tmp[16]={0x63,0xbf,0xA5,0x0E,0xE6,0x52,0x33,0x65,0xFF,0x14,0xC1,0xF4,0x5F,0x88,0x73,0x7D}; if(imsi != 1010123456789) { return false; } - else - { + m_hss_log.console("Found User %015lu\n",imsi); + memcpy(k,k_tmp,16); + memcpy(amf,amf_tmp,2); + memcpy(op,op_tmp,16); - } //uint8_t k[16]; //uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H //uint8_t op[16]; - return false; + return true; } } //namespace srsepc diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 9483da9e4..c65c55d58 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -263,13 +263,13 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_request_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_req); if(err != LIBLTE_SUCCESS){ - m_s1ap_log->console("Error unpacking NAS attach request. Error: %s\n", liblte_error_text[err]); + m_s1ap_log->error("Error unpacking NAS attach request. Error: %s\n", liblte_error_text[err]); return false; } m_s1ap_log->info("Received Attach Request\n"); if(attach_req.eps_mobile_id.type_of_id!=LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI){ - m_s1ap_log->warning("NAS Attach Request: Unhandle UE Id Type"); + m_s1ap_log->error("NAS Attach Request: Unhandle UE Id Type"); return false; } @@ -277,7 +277,6 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg for(int i=0;i<=14;i++) { imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i); - //std::cout << (uint16_t) attach_req.eps_mobile_id.imsi[i] << " "; } m_s1ap_log->console("IMSI: %015lu\n", imsi); @@ -298,21 +297,31 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg /*Handle PDN Connctivity Request*/ - liblte_mme_unpack_pdn_connectivity_request_msg(&attach_req.esm_msg, &pdn_con_req); - - //pdn_con_req.eps_bearer_id - //pdn_con_req.proc_transaction_id = 0x01; // First transaction ID - //pdn_con_req.pdn_type = LIBLTE_MME_PDN_TYPE_IPV4; - //pdn_con_req.request_type = LIBLTE_MME_REQUEST_TYPE_INITIAL_REQUEST; + err = liblte_mme_unpack_pdn_connectivity_request_msg(&attach_req.esm_msg, &pdn_con_req); + if(err != LIBLTE_SUCCESS){ + m_s1ap_log->error("Error unpacking NAS PDN Connectivity Request. Error: %s\n", liblte_error_text[err]); + return false; + } - // Set the optional flags + uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused + uint8_t proc_transaction_id = pdn_con_req.proc_transaction_id; //TODO: Transaction ID unused + if(pdn_con_req.pdn_type != LIBLTE_MME_PDN_TYPE_IPV4) + { + m_s1ap_log->error("PDN Connectivity Request: Only IPv4 connectivity supported.\n"); + return false; + } + if(pdn_con_req.request_type != LIBLTE_MME_REQUEST_TYPE_INITIAL_REQUEST) + { + m_s1ap_log->error("PDN Connectivity Request: Only Initial Request supported.\n"); + return false; + } + + //Handle the optional flags if(pdn_con_req.esm_info_transfer_flag_present){} if(pdn_con_req.apn_present){} if(pdn_con_req.protocol_cnfg_opts_present){} if(pdn_con_req.device_properties_present){} - - /*Log unhandled IEs*/ if(msg->S_TMSI_present){ m_s1ap_log->warning("S-TMSI present, but not handled."); @@ -350,7 +359,9 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg if(!m_hss->get_k_amf_op(imsi, k, amf, op)) { - m_s1ap_log->info("User %d not found",imsi); + m_s1ap_log->console("User not found. IMSI %015lu\n",imsi); + m_s1ap_log->info("User not found. IMSI %015lu\n",imsi); + return false; } @@ -393,6 +404,22 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *msg }LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT; */ /* + typedef struct{ + LIBLTE_MME_ACCESS_POINT_NAME_STRUCT apn; + LIBLTE_MME_PROTOCOL_CONFIG_OPTIONS_STRUCT protocol_cnfg_opts; + LIBLTE_MME_ESM_INFO_TRANSFER_FLAG_ENUM esm_info_transfer_flag; + LIBLTE_MME_DEVICE_PROPERTIES_ENUM device_properties; + uint8 eps_bearer_id; + uint8 proc_transaction_id; + uint8 pdn_type; + uint8 request_type; + bool esm_info_transfer_flag_present; + bool apn_present; + bool protocol_cnfg_opts_present; + bool device_properties_present; + }LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT; + */ + /* typedef struct{ bool ext; LIBLTE_S1AP_ENB_UE_S1AP_ID_STRUCT eNB_UE_S1AP_ID;