Merge pull request #157 from softwareradiosystems/issue_154fix

Issue 154fix
master
Paul Sutton 7 years ago committed by GitHub
commit 57505725e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,6 +30,7 @@
#include "srslte/common/timers.h" #include "srslte/common/timers.h"
#include "srslte/common/security.h" #include "srslte/common/security.h"
#include "srslte/asn1/liblte_rrc.h" #include "srslte/asn1/liblte_rrc.h"
#include <string>
namespace srslte { namespace srslte {
@ -37,11 +38,13 @@ namespace srslte {
class srslte_nas_config_t class srslte_nas_config_t
{ {
public: public:
srslte_nas_config_t(uint32_t lcid_ = 0) srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "")
:lcid(lcid_) :lcid(lcid_),
apn(apn_)
{} {}
uint32_t lcid; uint32_t lcid;
std::string apn;
}; };

@ -11,6 +11,7 @@
# mcc: Mobile Country Code # mcc: Mobile Country Code
# mnc: Mobile Network Code # mnc: Mobile Network Code
# mme_bindx_addr: IP subnet to listen for eNB S1 connnections # mme_bindx_addr: IP subnet to listen for eNB S1 connnections
# apn: Set Access Point Name (APN)
# #
##################################################################### #####################################################################
[mme] [mme]
@ -20,6 +21,7 @@ tac = 0x0007
mcc = 001 mcc = 001
mnc = 01 mnc = 01
mme_bind_addr = 127.0.1.100 mme_bind_addr = 127.0.1.100
apn = test123
##################################################################### #####################################################################
# HSS configuration # HSS configuration

@ -49,6 +49,7 @@ typedef struct{
uint16_t mnc; // BCD-coded with 0xF filler uint16_t mnc; // BCD-coded with 0xF filler
std::string mme_bind_addr; std::string mme_bind_addr;
std::string mme_name; std::string mme_name;
std::string mme_apn;
} s1ap_args_t; } s1ap_args_t;
typedef struct{ typedef struct{
@ -96,6 +97,7 @@ typedef struct{
LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT ms_network_cap; LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT ms_network_cap;
bool eit; bool eit;
uint8_t procedure_transaction_id; uint8_t procedure_transaction_id;
uint8_t attach_type;
} ue_ctx_t; } ue_ctx_t;
}//namespace }//namespace
#endif #endif

@ -84,6 +84,7 @@ public:
bool pack_identity_request(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id); bool pack_identity_request(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id);
bool pack_emm_information(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id); bool pack_emm_information(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id);
bool pack_service_reject(srslte::byte_buffer_t *reply_msg, uint8_t emm_cause, uint32_t enb_ue_s1ap_id);
void log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req); void log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req);
void log_unhandled_pdn_con_request_ies(const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT *pdn_con_req); void log_unhandled_pdn_con_request_ies(const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT *pdn_con_req);

@ -81,6 +81,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
string mcc; string mcc;
string mnc; string mnc;
string mme_bind_addr; string mme_bind_addr;
string mme_apn;
string spgw_bind_addr; string spgw_bind_addr;
string sgi_if_addr; string sgi_if_addr;
string hss_db_file; string hss_db_file;
@ -105,6 +106,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
("mme.mcc", bpo::value<string>(&mcc)->default_value("001"), "Mobile Country Code") ("mme.mcc", bpo::value<string>(&mcc)->default_value("001"), "Mobile Country Code")
("mme.mnc", bpo::value<string>(&mnc)->default_value("01"), "Mobile Network Code") ("mme.mnc", bpo::value<string>(&mnc)->default_value("01"), "Mobile Network Code")
("mme.mme_bind_addr", bpo::value<string>(&mme_bind_addr)->default_value("127.0.0.1"),"IP address of MME for S1 connnection") ("mme.mme_bind_addr", bpo::value<string>(&mme_bind_addr)->default_value("127.0.0.1"),"IP address of MME for S1 connnection")
("mme.apn", bpo::value<string>(&mme_apn)->default_value(""), "Set Access Point Name (APN) for data services")
("hss.db_file", bpo::value<string>(&hss_db_file)->default_value("ue_db.csv"),".csv file that stores UE's keys") ("hss.db_file", bpo::value<string>(&hss_db_file)->default_value("ue_db.csv"),".csv file that stores UE's keys")
("hss.auth_algo", bpo::value<string>(&hss_auth_algo)->default_value("milenage"),"HSS uthentication algorithm.") ("hss.auth_algo", bpo::value<string>(&hss_auth_algo)->default_value("milenage"),"HSS uthentication algorithm.")
("spgw.gtpu_bind_addr", bpo::value<string>(&spgw_bind_addr)->default_value("127.0.0.1"),"IP address of SP-GW for the S1-U connection") ("spgw.gtpu_bind_addr", bpo::value<string>(&spgw_bind_addr)->default_value("127.0.0.1"),"IP address of SP-GW for the S1-U connection")
@ -204,6 +206,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
} }
args->mme_args.s1ap_args.mme_bind_addr = mme_bind_addr; args->mme_args.s1ap_args.mme_bind_addr = mme_bind_addr;
args->mme_args.s1ap_args.mme_apn = mme_apn;
args->spgw_args.gtpu_bind_addr = spgw_bind_addr; args->spgw_args.gtpu_bind_addr = spgw_bind_addr;
args->spgw_args.sgi_if_addr = sgi_if_addr; args->spgw_args.sgi_if_addr = sgi_if_addr;
args->hss_args.db_file = hss_db_file; args->hss_args.db_file = hss_db_file;

@ -118,7 +118,8 @@ mme_gtpc::send_create_session_request(uint64_t imsi, uint32_t mme_ue_s1ap_id)
m_mme_gtpc_log->console("Creating Session Response -- IMSI: %015lu \n", imsi); m_mme_gtpc_log->console("Creating Session Response -- IMSI: %015lu \n", imsi);
m_mme_gtpc_log->console("Creating Session Response -- MME control TEID: %lu \n", cs_req->sender_f_teid.teid); m_mme_gtpc_log->console("Creating Session Response -- MME control TEID: %lu \n", cs_req->sender_f_teid.teid);
// APN // APN
memcpy(cs_req->apn, "internet", sizeof("internet")); strncpy(cs_req->apn, m_s1ap->m_s1ap_args.mme_apn.c_str(), sizeof(cs_req->apn)-1);
cs_req->apn[sizeof(cs_req->apn)-1] = 0;
// RAT Type // RAT Type
//cs_req->rat_type = srslte::GTPC_RAT_TYPE::EUTRAN; //cs_req->rat_type = srslte::GTPC_RAT_TYPE::EUTRAN;

@ -38,7 +38,9 @@ boost::mutex s1ap_instance_mutex;
s1ap::s1ap(): s1ap::s1ap():
m_s1mme(-1), m_s1mme(-1),
m_next_mme_ue_s1ap_id(1) m_next_mme_ue_s1ap_id(1),
m_mme_gtpc(NULL),
m_pool(NULL)
{ {
} }

@ -114,14 +114,19 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
return false; return false;
} }
handle_nas_attach_request(enb_ue_s1ap_id, attach_req,pdn_con_req,reply_buffer,reply_flag, enb_sri); handle_nas_attach_request(enb_ue_s1ap_id, attach_req, pdn_con_req, reply_buffer, reply_flag, enb_sri);
} }
else if(msg_type == LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST) else if(msg_type == LIBLTE_MME_SECURITY_HDR_TYPE_SERVICE_REQUEST)
{ {
m_s1ap_log->info("Received Service Request \n"); m_s1ap_log->info("Received Service Request \n");
m_s1ap_log->console("Received Service Request \n"); m_s1ap_log->console("Received Service Request \n");
liblte_mme_unpack_service_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &service_req); liblte_mme_unpack_service_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &service_req);
return false;
m_s1ap_log->info("Service Request not implemented. Sending Service Reject.");
m_s1ap_log->console("Service Request not implemented. Sending Service Reject.");
/* Force UE to re-attach */
pack_service_reject(reply_buffer, LIBLTE_MME_EMM_CAUSE_IMPLICITLY_DETACHED, enb_ue_s1ap_id);
*reply_flag = true;
} }
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
@ -201,7 +206,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
if(*reply_flag == true) if(*reply_flag == true)
{ {
m_s1ap_log->info("DL NAS: Sent Downlink NAS message\n"); m_s1ap_log->info("DL NAS: Sent Downlink NAS message\n");
m_s1ap_log->console("DL NAS: Sent Downlink NAs Message\n"); m_s1ap_log->console("DL NAS: Sent Downlink NAS Message\n");
} }
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
@ -288,6 +293,10 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
m_s1ap_log->console("Attach request -- IMSI: %015lu\n", ue_ctx.imsi); m_s1ap_log->console("Attach request -- IMSI: %015lu\n", ue_ctx.imsi);
m_s1ap_log->info("Attach request -- IMSI: %015lu\n", ue_ctx.imsi); m_s1ap_log->info("Attach request -- IMSI: %015lu\n", ue_ctx.imsi);
m_s1ap_log->console("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
m_s1ap_log->info("Attach request -- Attach type: %d\n", attach_req.eps_attach_type);
m_s1ap_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id); m_s1ap_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id);
m_s1ap_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n", m_s1ap_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[0],
@ -312,6 +321,9 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
m_s1ap_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id); m_s1ap_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id);
m_s1ap_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false"); m_s1ap_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false");
//Save attach request type
ue_ctx.attach_type = attach_req.eps_attach_type;
//Get Authentication Vectors from HSS //Get Authentication Vectors from HSS
if(!m_hss->gen_auth_info_answer(ue_ctx.imsi, ue_ctx.security_ctxt.k_asme, autn, rand, ue_ctx.security_ctxt.xres)) if(!m_hss->gen_auth_info_answer(ue_ctx.imsi, ue_ctx.security_ctxt.k_asme, autn, rand, ue_ctx.security_ctxt.xres))
{ {
@ -326,8 +338,8 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
//Send reply to eNB //Send reply to eNB
*reply_flag = true; *reply_flag = true;
m_s1ap_log->info("Downlink NAS: Sending Athentication Request\n"); m_s1ap_log->info("Downlink NAS: Sending Authentication Request\n");
m_s1ap_log->console("Downlink NAS: Sending Athentication Request\n"); m_s1ap_log->console("Downlink NAS: Sending Authentication Request\n");
return true; return true;
} }
@ -360,6 +372,9 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id,
uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused
ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id;
//Save attach request type
ue_ctx.attach_type = attach_req.eps_attach_type;
//Save whether ESM information transfer is necessary //Save whether ESM information transfer is necessary
ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present; ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present;
//m_s1ap_log->console("EPS Bearer id: %d\n", eps_bearer_id); //m_s1ap_log->console("EPS Bearer id: %d\n", eps_bearer_id);
@ -412,6 +427,8 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id,
ue_ctx_t *ue_ctx_ptr = m_s1ap->find_ue_ctx(it->second); ue_ctx_t *ue_ctx_ptr = m_s1ap->find_ue_ctx(it->second);
if(ue_ctx_ptr!=NULL) if(ue_ctx_ptr!=NULL)
{ {
//Save attach request type
ue_ctx_ptr->attach_type = attach_req.eps_attach_type;
m_s1ap_log->console("Found UE context. IMSI: %015lu\n",ue_ctx_ptr->imsi); m_s1ap_log->console("Found UE context. IMSI: %015lu\n",ue_ctx_ptr->imsi);
m_mme_gtpc->send_create_session_request(ue_ctx_ptr->imsi, ue_ctx_ptr->mme_ue_s1ap_id); m_mme_gtpc->send_create_session_request(ue_ctx_ptr->imsi, ue_ctx_ptr->mme_ue_s1ap_id);
*reply_flag = false; //No reply needed *reply_flag = false; //No reply needed
@ -467,7 +484,7 @@ s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *na
m_s1ap_log->console("UE Authentication Rejected.\n"); m_s1ap_log->console("UE Authentication Rejected.\n");
m_s1ap_log->warning("UE Authentication Rejected.\n"); m_s1ap_log->warning("UE Authentication Rejected.\n");
//Send back Athentication Reject //Send back Authentication Reject
pack_authentication_reject(reply_buffer, ue_ctx->enb_ue_s1ap_id, ue_ctx->mme_ue_s1ap_id); pack_authentication_reject(reply_buffer, ue_ctx->enb_ue_s1ap_id, ue_ctx->mme_ue_s1ap_id);
*reply_flag = true; *reply_flag = true;
m_s1ap_log->console("Downlink NAS: Sending Authentication Reject.\n"); m_s1ap_log->console("Downlink NAS: Sending Authentication Reject.\n");
@ -511,6 +528,7 @@ s1ap_nas_transport::handle_nas_security_mode_complete(srslte::byte_buffer_t *nas
{ {
pack_esm_information_request(reply_buffer, ue_ctx); pack_esm_information_request(reply_buffer, ue_ctx);
m_s1ap_log->console("Sending ESM information request\n"); m_s1ap_log->console("Sending ESM information request\n");
m_s1ap_log->info("Sending ESM information request\n");
*reply_flag = true; *reply_flag = true;
} }
else else
@ -532,7 +550,7 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u
srslte::byte_buffer_t *esm_msg = m_pool->allocate(); srslte::byte_buffer_t *esm_msg = m_pool->allocate();
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_bearer; LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_bearer;
m_s1ap_log->info_hex(nas_msg->msg, nas_msg->N_bytes, "NAS Attach complte"); m_s1ap_log->info_hex(nas_msg->msg, nas_msg->N_bytes, "NAS Attach complete");
//Get NAS authentication response //Get NAS authentication response
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_comp); LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_comp);
@ -548,7 +566,7 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u
} }
m_s1ap_log->console("Unpacked Attached Complete Message\n"); m_s1ap_log->console("Unpacked Attached Complete Message\n");
m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id); m_s1ap_log->console("Unpacked Activate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id);
//ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid; //ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid;
if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15)
{ {
@ -576,6 +594,11 @@ s1ap_nas_transport::handle_esm_information_response(srslte::byte_buffer_t *nas_m
m_s1ap_log->info("ESM Info: APN %s\n",esm_info_resp.eps_bearer_id); m_s1ap_log->info("ESM Info: APN %s\n",esm_info_resp.eps_bearer_id);
m_s1ap_log->console("ESM Info: APN %s\n",esm_info_resp.eps_bearer_id); m_s1ap_log->console("ESM Info: APN %s\n",esm_info_resp.eps_bearer_id);
} }
if(esm_info_resp.protocol_cnfg_opts_present)
{
m_s1ap_log->info("ESM Info: %d Protocol Configuration Options %s\n",esm_info_resp.protocol_cnfg_opts.N_opts);
m_s1ap_log->console("ESM Info: %d Protocol Configuration Options %s\n",esm_info_resp.protocol_cnfg_opts.N_opts);
}
//FIXME The packging of GTP-C messages is not ready. //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. //This means that GTP-U tunnels are created with function calls, as opposed to GTP-C.
@ -794,8 +817,8 @@ s1ap_nas_transport::pack_authentication_request(srslte::byte_buffer_t *reply_msg
LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Athentication Request\n"); m_s1ap_log->error("Error packing Authentication Request\n");
m_s1ap_log->console("Error packing Athentication Request\n"); m_s1ap_log->console("Error packing Authentication Request\n");
return false; return false;
} }
@ -807,8 +830,8 @@ s1ap_nas_transport::pack_authentication_request(srslte::byte_buffer_t *reply_msg
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Athentication Request\n"); m_s1ap_log->error("Error packing Authentication Request\n");
m_s1ap_log->console("Error packing Athentication Request\n"); m_s1ap_log->console("Error packing Authentication Request\n");
return false; return false;
} }
@ -845,8 +868,8 @@ s1ap_nas_transport::pack_authentication_reject(srslte::byte_buffer_t *reply_msg,
LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_reject_msg(&auth_rej, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_reject_msg(&auth_rej, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Athentication Reject\n"); m_s1ap_log->error("Error packing Authentication Reject\n");
m_s1ap_log->console("Error packing Athentication Reject\n"); m_s1ap_log->console("Error packing Authentication Reject\n");
return false; return false;
} }
@ -858,8 +881,8 @@ s1ap_nas_transport::pack_authentication_reject(srslte::byte_buffer_t *reply_msg,
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); m_s1ap_log->error("Error packing Dw NAS Transport: Authentication Reject\n");
m_s1ap_log->console("Error packing Downlink NAS Transport: Athentication Reject\n"); m_s1ap_log->console("Error packing Downlink NAS Transport: Authentication Reject\n");
return false; return false;
} }
@ -948,7 +971,7 @@ s1ap_nas_transport::pack_security_mode_command(srslte::byte_buffer_t *reply_msg,
LIBLTE_ERROR_ENUM err = liblte_mme_pack_security_mode_command_msg(&sm_cmd,sec_hdr_type, ue_ctx->security_ctxt.dl_nas_count,(LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = liblte_mme_pack_security_mode_command_msg(&sm_cmd,sec_hdr_type, ue_ctx->security_ctxt.dl_nas_count,(LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->console("Error packing Athentication Request\n"); m_s1ap_log->console("Error packing Authentication Request\n");
return false; return false;
} }
@ -982,7 +1005,7 @@ s1ap_nas_transport::pack_security_mode_command(srslte::byte_buffer_t *reply_msg,
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->console("Error packing Athentication Request\n"); m_s1ap_log->console("Error packing Authentication Request\n");
return false; return false;
} }
m_s1ap_log->debug_hex(reply_msg->msg, reply_msg->N_bytes, "Security Mode Command: "); m_s1ap_log->debug_hex(reply_msg->msg, reply_msg->N_bytes, "Security Mode Command: ");
@ -1015,7 +1038,7 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms
dw_nas->SubscriberProfileIDforRFP_present=false; dw_nas->SubscriberProfileIDforRFP_present=false;
LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT esm_info_req; LIBLTE_MME_ESM_INFORMATION_REQUEST_MSG_STRUCT esm_info_req;
esm_info_req.eps_bearer_id=0; esm_info_req.eps_bearer_id = 0;
esm_info_req.proc_transaction_id = ue_ctx->procedure_transaction_id; esm_info_req.proc_transaction_id = ue_ctx->procedure_transaction_id;
uint8_t sec_hdr_type=2; uint8_t sec_hdr_type=2;
@ -1048,8 +1071,8 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); m_s1ap_log->error("Error packing Dw NAS Transport: Authentication Reject\n");
m_s1ap_log->console("Error packing Downlink NAS Transport: Athentication Reject\n"); m_s1ap_log->console("Error packing Downlink NAS Transport: Authentication Reject\n");
return false; return false;
} }
@ -1087,7 +1110,7 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE
} }
//Attach accept //Attach accept
attach_accept.eps_attach_result = LIBLTE_MME_EPS_ATTACH_RESULT_EPS_ONLY; attach_accept.eps_attach_result = ue_ctx->attach_type;
//Mandatory //Mandatory
//FIXME: Set t3412 from config //FIXME: Set t3412 from config
attach_accept.t3412.unit = LIBLTE_MME_GPRS_TIMER_UNIT_1_MINUTE; // GPRS 1 minute unit attach_accept.t3412.unit = LIBLTE_MME_GPRS_TIMER_UNIT_1_MINUTE; // GPRS 1 minute unit
@ -1140,8 +1163,7 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE
act_def_eps_bearer_context_req.eps_qos.mbr_dl_ext = 250; //FIXME check act_def_eps_bearer_context_req.eps_qos.mbr_dl_ext = 250; //FIXME check
//set apn //set apn
//act_def_eps_bearer_context_req.apn //act_def_eps_bearer_context_req.apn
std::string apn("test123"); act_def_eps_bearer_context_req.apn.apn = m_s1ap->m_s1ap_args.mme_apn;
act_def_eps_bearer_context_req.apn.apn = apn; //FIXME
act_def_eps_bearer_context_req.proc_transaction_id = ue_ctx->procedure_transaction_id; //FIXME act_def_eps_bearer_context_req.proc_transaction_id = ue_ctx->procedure_transaction_id; //FIXME
//Set DNS server //Set DNS server
@ -1161,6 +1183,7 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE
act_def_eps_bearer_context_req.packet_flow_id_present = false; act_def_eps_bearer_context_req.packet_flow_id_present = false;
act_def_eps_bearer_context_req.apn_ambr_present = false; act_def_eps_bearer_context_req.apn_ambr_present = false;
act_def_eps_bearer_context_req.esm_cause_present = false; act_def_eps_bearer_context_req.esm_cause_present = false;
act_def_eps_bearer_context_req.connectivity_type_present = false;
uint8_t sec_hdr_type =2; uint8_t sec_hdr_type =2;
ue_ctx->security_ctxt.dl_nas_count++; ue_ctx->security_ctxt.dl_nas_count++;
@ -1230,8 +1253,8 @@ s1ap_nas_transport::pack_identity_request(srslte::byte_buffer_t *reply_msg, uint
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg); err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS) if(err != LIBLTE_SUCCESS)
{ {
m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); m_s1ap_log->error("Error packing Dw NAS Transport: Authentication Reject\n");
m_s1ap_log->console("Error packing Downlink NAS Transport: Athentication Reject\n"); m_s1ap_log->console("Error packing Downlink NAS Transport: Authentication Reject\n");
return false; return false;
} }
@ -1308,6 +1331,59 @@ s1ap_nas_transport::pack_emm_information(srslte::byte_buffer_t *reply_msg, uint3
return true; return true;
} }
bool
s1ap_nas_transport::pack_service_reject(srslte::byte_buffer_t *reply_msg, uint8_t emm_cause, uint32_t enb_ue_s1ap_id)
{
srslte::byte_buffer_t *nas_buffer = m_pool->allocate();
//Setup initiating message
LIBLTE_S1AP_S1AP_PDU_STRUCT tx_pdu;
bzero(&tx_pdu, sizeof(LIBLTE_S1AP_S1AP_PDU_STRUCT));
tx_pdu.ext = false;
tx_pdu.choice_type = LIBLTE_S1AP_S1AP_PDU_CHOICE_INITIATINGMESSAGE;
LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *init = &tx_pdu.choice.initiatingMessage;
init->procedureCode = LIBLTE_S1AP_PROC_ID_DOWNLINKNASTRANSPORT;
init->choice_type = LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_DOWNLINKNASTRANSPORT;
//Setup Dw NAS structure
LIBLTE_S1AP_MESSAGE_DOWNLINKNASTRANSPORT_STRUCT *dw_nas = &init->choice.DownlinkNASTransport;
dw_nas->ext=false;
dw_nas->MME_UE_S1AP_ID.MME_UE_S1AP_ID = m_s1ap->get_next_mme_ue_s1ap_id();
dw_nas->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = enb_ue_s1ap_id;
dw_nas->HandoverRestrictionList_present=false;
dw_nas->SubscriberProfileIDforRFP_present=false;
LIBLTE_MME_SERVICE_REJECT_MSG_STRUCT service_rej;
service_rej.t3442_present = true;
service_rej.t3442.unit = LIBLTE_MME_GPRS_TIMER_DEACTIVATED;
service_rej.t3442.value = 0;
service_rej.t3446_present = true;
service_rej.t3446 = 0;
service_rej.emm_cause = emm_cause;
LIBLTE_ERROR_ENUM err = liblte_mme_pack_service_reject_msg(&service_rej, LIBLTE_MME_SECURITY_HDR_TYPE_PLAIN_NAS, 0, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS)
{
m_s1ap_log->error("Error packing Service Reject\n");
m_s1ap_log->console("Error packing Service Reject\n");
return false;
}
//Copy NAS PDU to Downlink NAS Trasport message buffer
memcpy(dw_nas->NAS_PDU.buffer, nas_buffer->msg, nas_buffer->N_bytes);
dw_nas->NAS_PDU.n_octets = nas_buffer->N_bytes;
//Pack Downlink NAS Transport Message
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
if(err != LIBLTE_SUCCESS)
{
m_s1ap_log->error("Error packing Dw NAS Transport: Service Reject\n");
m_s1ap_log->console("Error packing Downlink NAS Transport: Service Reject\n");
return false;
}
return true;
}
/*Helper functions*/ /*Helper functions*/
void void
s1ap_nas_transport::log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req) s1ap_nas_transport::log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req)

@ -126,6 +126,7 @@ typedef struct {
usim_args_t usim; usim_args_t usim;
rrc_args_t rrc; rrc_args_t rrc;
std::string ue_category_str; std::string ue_category_str;
std::string apn;
expert_args_t expert; expert_args_t expert;
}all_args_t; }all_args_t;

@ -82,6 +82,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
"UECapabilityInformation message. Default 0xe6041c00") "UECapabilityInformation message. Default 0xe6041c00")
("rrc.ue_category", bpo::value<string>(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)") ("rrc.ue_category", bpo::value<string>(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)")
("nas.apn", bpo::value<string>(&args->apn)->default_value(""), "Set Access Point Name (APN) for data services")
("pcap.enable", bpo::value<bool>(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark") ("pcap.enable", bpo::value<bool>(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark")
("pcap.filename", bpo::value<string>(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename") ("pcap.filename", bpo::value<string>(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename")

@ -190,7 +190,8 @@ bool ue::init(all_args_t *args_)
pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK); pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK);
usim.init(&args->usim, &usim_log); usim.init(&args->usim, &usim_log);
nas.init(&usim, &rrc, &gw, &nas_log, 1 /* RB_ID_SRB1 */); srslte_nas_config_t nas_cfg(1, args->apn); /* RB_ID_SRB1 */
nas.init(&usim, &rrc, &gw, &nas_log, nas_cfg);
gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */); gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */);
gw.set_netmask(args->expert.ip_netmask); gw.set_netmask(args->expert.ip_netmask);

@ -897,7 +897,14 @@ void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg) {
// Set the optional flags // Set the optional flags
pdn_con_req.esm_info_transfer_flag_present = false; //FIXME: Check if this is needed pdn_con_req.esm_info_transfer_flag_present = false; //FIXME: Check if this is needed
pdn_con_req.apn_present = false; if (cfg.apn == "") {
pdn_con_req.apn_present = false;
} else {
pdn_con_req.apn_present = true;
LIBLTE_MME_ACCESS_POINT_NAME_STRUCT apn;
apn.apn = cfg.apn;
pdn_con_req.apn = apn;
}
pdn_con_req.protocol_cnfg_opts_present = false; pdn_con_req.protocol_cnfg_opts_present = false;
pdn_con_req.device_properties_present = false; pdn_con_req.device_properties_present = false;

@ -109,6 +109,15 @@ imei = 353490069873319
#ue_category = 4 #ue_category = 4
#feature_group = 0xe6041c00 #feature_group = 0xe6041c00
#####################################################################
# NAS configuration
#
# apn: Set Access Point Name (APN)
#####################################################################
[nas]
# apn = internetinternet
[gui] [gui]
enable = false enable = false

Loading…
Cancel
Save