From fcedeb027821b2fed8b8e9ac0668870d2bc61da5 Mon Sep 17 00:00:00 2001 From: Merlin Chlosta Date: Mon, 22 Jan 2018 19:12:02 +0100 Subject: [PATCH 1/2] Add APN to config and PDN connectivity request --- lib/include/srslte/common/interfaces_common.h | 9 ++++++--- srsue/hdr/ue_base.h | 1 + srsue/src/main.cc | 1 + srsue/src/ue.cc | 3 ++- srsue/src/upper/nas.cc | 9 ++++++++- srsue/ue.conf.example | 9 +++++++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index 1ddcb5150..e7de90ea1 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -30,6 +30,7 @@ #include "srslte/common/timers.h" #include "srslte/common/security.h" #include "srslte/asn1/liblte_rrc.h" +#include namespace srslte { @@ -37,11 +38,13 @@ namespace srslte { class srslte_nas_config_t { public: - srslte_nas_config_t(uint32_t lcid_ = 0) - :lcid(lcid_) + srslte_nas_config_t(uint32_t lcid_ = 0, std::string apn_ = "") + :lcid(lcid_), + apn(apn_) {} - uint32_t lcid; + uint32_t lcid; + std::string apn; }; diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index 9674a1486..acedb51b0 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -126,6 +126,7 @@ typedef struct { usim_args_t usim; rrc_args_t rrc; std::string ue_category_str; + std::string apn; expert_args_t expert; }all_args_t; diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 0f668b927..cdd31e13d 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -82,6 +82,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { "UECapabilityInformation message. Default 0xe6041c00") ("rrc.ue_category", bpo::value(&args->ue_category_str)->default_value("4"), "UE Category (1 to 5)") + ("nas.apn", bpo::value(&args->apn)->default_value(""), "Set Access Point Name (APN) for data services") ("pcap.enable", bpo::value(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark") ("pcap.filename", bpo::value(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename") diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 78988ef9e..66a40ce22 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -195,7 +195,8 @@ bool ue::init(all_args_t *args_) pdcp.init(&rlc, &rrc, &gw, &pdcp_log, 0 /* RB_ID_SRB0 */, SECURITY_DIRECTION_UPLINK); 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.set_netmask(args->expert.ip_netmask); diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index 9a9015af7..b574de8d7 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -884,7 +884,14 @@ void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg) { // Set the optional flags 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.device_properties_present = false; diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 347822072..1b87853fa 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -118,6 +118,15 @@ imei = 353490069873319 #ue_category = 4 #feature_group = 0xe6041c00 +##################################################################### +# NAS configuration +# +# apn: Set Access Point Name (APN) +##################################################################### +[nas] +# apn = internetinternet + + [gui] enable = false From 148c0a97bdcad3b208146d862a40552ab9ea8c9a Mon Sep 17 00:00:00 2001 From: FabianEckermann Date: Thu, 15 Feb 2018 16:42:26 +0100 Subject: [PATCH 2/2] Read MME APN from epc config --- srsepc/epc.conf.example | 2 + srsepc/hdr/mme/s1ap_common.h | 1 + srsepc/src/main.cc | 3 ++ srsepc/src/mme/mme_gtpc.cc | 2 +- srsepc/src/mme/s1ap_nas_transport.cc | 55 +++++++++++++++------------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/srsepc/epc.conf.example b/srsepc/epc.conf.example index d90e3a6ef..b32a6984a 100644 --- a/srsepc/epc.conf.example +++ b/srsepc/epc.conf.example @@ -11,6 +11,7 @@ # mcc: Mobile Country Code # mnc: Mobile Network Code # mme_bindx_addr: IP subnet to listen for eNB S1 connnections +# apn: Set Access Point Name (APN) # ##################################################################### [mme] @@ -20,6 +21,7 @@ tac = 0x0007 mcc = 001 mnc = 01 mme_bind_addr = 127.0.1.100 +apn = test123 ##################################################################### # HSS configuration diff --git a/srsepc/hdr/mme/s1ap_common.h b/srsepc/hdr/mme/s1ap_common.h index f5462ad65..9a7d72ce5 100644 --- a/srsepc/hdr/mme/s1ap_common.h +++ b/srsepc/hdr/mme/s1ap_common.h @@ -49,6 +49,7 @@ typedef struct{ uint16_t mnc; // BCD-coded with 0xF filler std::string mme_bind_addr; std::string mme_name; + std::string mme_apn; } s1ap_args_t; typedef struct{ diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index 89ae4c83e..1736279c4 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -81,6 +81,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) { string mcc; string mnc; string mme_bind_addr; + string mme_apn; string spgw_bind_addr; string sgi_if_addr; string hss_db_file; @@ -105,6 +106,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) { ("mme.mcc", bpo::value(&mcc)->default_value("001"), "Mobile Country Code") ("mme.mnc", bpo::value(&mnc)->default_value("01"), "Mobile Network Code") ("mme.mme_bind_addr", bpo::value(&mme_bind_addr)->default_value("127.0.0.1"),"IP address of MME for S1 connnection") + ("mme.apn", bpo::value(&mme_apn)->default_value(""), "Set Access Point Name (APN) for data services") ("hss.db_file", bpo::value(&hss_db_file)->default_value("ue_db.csv"),".csv file that stores UE's keys") ("hss.auth_algo", bpo::value(&hss_auth_algo)->default_value("milenage"),"HSS uthentication algorithm.") ("spgw.gtpu_bind_addr", bpo::value(&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_apn = mme_apn; args->spgw_args.gtpu_bind_addr = spgw_bind_addr; args->spgw_args.sgi_if_addr = sgi_if_addr; args->hss_args.db_file = hss_db_file; diff --git a/srsepc/src/mme/mme_gtpc.cc b/srsepc/src/mme/mme_gtpc.cc index 4b396f7a8..0c36541c0 100644 --- a/srsepc/src/mme/mme_gtpc.cc +++ b/srsepc/src/mme/mme_gtpc.cc @@ -118,7 +118,7 @@ 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 -- MME control TEID: %lu \n", cs_req->sender_f_teid.teid); // APN - memcpy(cs_req->apn, "internet", sizeof("internet")); + strcpy(cs_req->apn, m_s1ap->m_s1ap_args.mme_apn.c_str()); // RAT Type //cs_req->rat_type = srslte::GTPC_RAT_TYPE::EUTRAN; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index d4f0702de..0cd646136 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -114,7 +114,7 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA m_pool->deallocate(nas_msg); 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) { @@ -201,7 +201,7 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA if(*reply_flag == true) { 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); @@ -326,8 +326,8 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id, //Send reply to eNB *reply_flag = true; - m_s1ap_log->info("Downlink NAS: Sending Athentication Request\n"); - m_s1ap_log->console("Downlink NAS: Sending Athentication Request\n"); + m_s1ap_log->info("Downlink NAS: Sending Authentication Request\n"); + m_s1ap_log->console("Downlink NAS: Sending Authentication Request\n"); return true; } @@ -358,7 +358,7 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id, memcpy(&ue_ctx.ms_network_cap, &attach_req.ms_network_cap, sizeof(LIBLTE_MME_MS_NETWORK_CAPABILITY_STRUCT)); } 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 whether ESM information transfer is necessary ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present; @@ -467,7 +467,7 @@ s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *na m_s1ap_log->console("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); *reply_flag = true; m_s1ap_log->console("Downlink NAS: Sending Authentication Reject.\n"); @@ -511,6 +511,7 @@ s1ap_nas_transport::handle_nas_security_mode_complete(srslte::byte_buffer_t *nas { pack_esm_information_request(reply_buffer, ue_ctx); m_s1ap_log->console("Sending ESM information request\n"); + m_s1ap_log->info("Sending ESM information request\n"); *reply_flag = true; } else @@ -532,7 +533,7 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u srslte::byte_buffer_t *esm_msg = m_pool->allocate(); 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 LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_comp); @@ -548,7 +549,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 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; if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) { @@ -576,6 +577,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->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. //This means that GTP-U tunnels are created with function calls, as opposed to GTP-C. @@ -794,8 +800,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Athentication Request\n"); - m_s1ap_log->console("Error packing Athentication Request\n"); + m_s1ap_log->error("Error packing Authentication Request\n"); + m_s1ap_log->console("Error packing Authentication Request\n"); return false; } @@ -807,8 +813,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Athentication Request\n"); - m_s1ap_log->console("Error packing Athentication Request\n"); + m_s1ap_log->error("Error packing Authentication Request\n"); + m_s1ap_log->console("Error packing Authentication Request\n"); return false; } @@ -845,8 +851,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Athentication Reject\n"); - m_s1ap_log->console("Error packing Athentication Reject\n"); + m_s1ap_log->error("Error packing Authentication Reject\n"); + m_s1ap_log->console("Error packing Authentication Reject\n"); return false; } @@ -858,8 +864,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); - m_s1ap_log->console("Error packing Downlink 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: Authentication Reject\n"); return false; } @@ -948,7 +954,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->console("Error packing Athentication Request\n"); + m_s1ap_log->console("Error packing Authentication Request\n"); return false; } @@ -982,7 +988,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->console("Error packing Athentication Request\n"); + m_s1ap_log->console("Error packing Authentication Request\n"); return false; } m_s1ap_log->debug_hex(reply_msg->msg, reply_msg->N_bytes, "Security Mode Command: "); @@ -1015,7 +1021,7 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms dw_nas->SubscriberProfileIDforRFP_present=false; 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; uint8_t sec_hdr_type=2; @@ -1048,8 +1054,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); - m_s1ap_log->console("Error packing Downlink 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: Authentication Reject\n"); return false; } @@ -1140,8 +1146,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 //set apn //act_def_eps_bearer_context_req.apn - std::string apn("test123"); - act_def_eps_bearer_context_req.apn.apn = apn; //FIXME + act_def_eps_bearer_context_req.apn.apn = m_s1ap->m_s1ap_args.mme_apn; act_def_eps_bearer_context_req.proc_transaction_id = ue_ctx->procedure_transaction_id; //FIXME //Set DNS server @@ -1230,8 +1235,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); if(err != LIBLTE_SUCCESS) { - m_s1ap_log->error("Error packing Dw NAS Transport: Athentication Reject\n"); - m_s1ap_log->console("Error packing Downlink 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: Authentication Reject\n"); return false; }