From 724bc6cbb540d5052a0e2142b586d017fad35df1 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 23 Jan 2018 15:26:54 +0000 Subject: [PATCH 1/9] rm boost::mutex from S1AP. --- srsepc/src/mme/s1ap.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 07563e7ca..ef6a116f4 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -34,7 +34,7 @@ namespace srsepc{ s1ap* s1ap::m_instance = NULL; -boost::mutex s1ap_instance_mutex; +pthread_mutex_t s1ap_instance_mutex = PTHREAD_MUTEX_INITIALIZER; s1ap::s1ap(): m_s1mme(-1), @@ -49,21 +49,24 @@ s1ap::~s1ap() s1ap* s1ap::get_instance(void) { - boost::mutex::scoped_lock lock(s1ap_instance_mutex); - if(NULL == m_instance) { + + pthread_mutex_lock(&s1ap_instance_mutex); + if(m_instance == NULL) { m_instance = new s1ap(); } + pthread_mutex_unlock(&s1ap_instance_mutex); return(m_instance); } void s1ap::cleanup(void) { - boost::mutex::scoped_lock lock(s1ap_instance_mutex); + pthread_mutex_lock(&s1ap_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&s1ap_instance_mutex); } int From 99e1a9f0382353658aa4e775f69b6510b28731cc Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jan 2018 10:31:47 +0000 Subject: [PATCH 2/9] rm boost::mutex from MME --- srsepc/src/mme/mme.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index ab4778c20..56766fa6b 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -29,13 +29,12 @@ #include #include #include -#include #include "mme/mme.h" namespace srsepc{ mme* mme::m_instance = NULL; -boost::mutex mme_instance_mutex; +pthread_mutex_t mme_instance_mutex = PTHREAD_MUTEX_INITIALIZER; mme::mme(): m_running(false) @@ -52,21 +51,23 @@ mme::~mme() mme* mme::get_instance(void) { - boost::mutex::scoped_lock lock(mme_instance_mutex); + pthread_mutex_lock(&mme_instance_mutex); if(NULL == m_instance) { m_instance = new mme(); } + pthread_mutex_unlock(&mme_instance_mutex); return(m_instance); } void mme::cleanup(void) { - boost::mutex::scoped_lock lock(mme_instance_mutex); + pthread_mutex_lock(&mme_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&mme_instance_mutex); } int From d87023bb37bd785b96c67bdf20dc76d622f834fb Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jan 2018 11:17:34 +0000 Subject: [PATCH 3/9] rm boost::mutex from s1ap_nas_transport --- srsepc/src/mme/s1ap_nas_transport.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index e5bf2890a..0054041fe 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -31,7 +31,7 @@ namespace srsepc{ s1ap_nas_transport* s1ap_nas_transport::m_instance = NULL; -boost::mutex s1ap_nas_transport_instance_mutex; +pthread_mutex_t s1ap_nas_transport_instance_mutex = PTHREAD_MUTEX_INITIALIZER; s1ap_nas_transport::s1ap_nas_transport() { @@ -46,21 +46,23 @@ s1ap_nas_transport::~s1ap_nas_transport() s1ap_nas_transport* s1ap_nas_transport::get_instance(void) { - boost::mutex::scoped_lock lock(s1ap_nas_transport_instance_mutex); + pthread_mutex_lock(&s1ap_nas_transport_instance_mutex); if(NULL == m_instance) { m_instance = new s1ap_nas_transport(); } + pthread_mutex_unlock(&s1ap_nas_transport_instance_mutex); return(m_instance); } void s1ap_nas_transport::cleanup(void) { - boost::mutex::scoped_lock lock(s1ap_nas_transport_instance_mutex); + pthread_mutex_lock(&s1ap_nas_transport_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&s1ap_nas_transport_instance_mutex); } void From 360bb5e2d60552bdfe08f0239eb40e9a617b30ca Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jan 2018 13:50:03 +0000 Subject: [PATCH 4/9] rm boost::mutex from s1ap_mngmnt_proc --- srsepc/src/mme/s1ap_mngmt_proc.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srsepc/src/mme/s1ap_mngmt_proc.cc b/srsepc/src/mme/s1ap_mngmt_proc.cc index 8fa469ec3..477ce203f 100644 --- a/srsepc/src/mme/s1ap_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_mngmt_proc.cc @@ -32,7 +32,7 @@ namespace srsepc{ s1ap_mngmt_proc* s1ap_mngmt_proc::m_instance = NULL; -boost::mutex s1ap_mngmt_proc_instance_mutex; +pthread_mutex_t s1ap_mngmt_proc_instance_mutex = PTHREAD_MUTEX_INITIALIZER; s1ap_mngmt_proc::s1ap_mngmt_proc() @@ -46,21 +46,23 @@ s1ap_mngmt_proc::~s1ap_mngmt_proc() s1ap_mngmt_proc* s1ap_mngmt_proc::get_instance(void) { - boost::mutex::scoped_lock lock(s1ap_mngmt_proc_instance_mutex); + pthread_mutex_lock(&s1ap_mngmt_proc_instance_mutex); if(NULL == m_instance) { m_instance = new s1ap_mngmt_proc(); } return(m_instance); + pthread_mutex_unlock(&s1ap_mngmt_proc_instance_mutex); } void s1ap_mngmt_proc::cleanup(void) { - boost::mutex::scoped_lock lock(s1ap_mngmt_proc_instance_mutex); + pthread_mutex_lock(&s1ap_mngmt_proc_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&s1ap_mngmt_proc_instance_mutex); } void From aa437806d8218b03d4032487e61304afac327bad Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jan 2018 15:47:06 +0000 Subject: [PATCH 5/9] rm boost::mutex from s1ap_ctx_mngmt --- srsepc/src/mme/s1ap_ctx_mngmt_proc.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 7dffe3c35..2be599c87 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -34,7 +34,7 @@ namespace srsepc{ s1ap_ctx_mngmt_proc* s1ap_ctx_mngmt_proc::m_instance = NULL; -boost::mutex s1ap_ctx_mngmt_proc_instance_mutex; +pthread_mutex_t s1ap_ctx_mngmt_proc_instance_mutex = PTHREAD_MUTEX_INITIALIZER; s1ap_ctx_mngmt_proc::s1ap_ctx_mngmt_proc() @@ -48,21 +48,23 @@ s1ap_ctx_mngmt_proc::~s1ap_ctx_mngmt_proc() s1ap_ctx_mngmt_proc* s1ap_ctx_mngmt_proc::get_instance(void) { - boost::mutex::scoped_lock lock(s1ap_ctx_mngmt_proc_instance_mutex); + pthread_mutex_lock(&s1ap_ctx_mngmt_proc_instance_mutex); if(NULL == m_instance) { m_instance = new s1ap_ctx_mngmt_proc(); } + pthread_mutex_unlock(&s1ap_ctx_mngmt_proc_instance_mutex); return(m_instance); } void s1ap_ctx_mngmt_proc::cleanup(void) { - boost::mutex::scoped_lock lock(s1ap_ctx_mngmt_proc_instance_mutex); + pthread_mutex_lock(&s1ap_ctx_mngmt_proc_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&s1ap_ctx_mngmt_proc_instance_mutex); } void From 628ccec07f3a2eeb2473c6b24509136f0288e9b9 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jan 2018 16:41:59 +0000 Subject: [PATCH 6/9] Removed boost::mutex from EPC --- srsepc/src/hss/hss.cc | 10 ++++++---- srsepc/src/mme/s1ap_mngmt_proc.cc | 2 +- srsepc/src/spgw/spgw.cc | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index 5fc383078..36b47d0e3 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -36,7 +36,7 @@ using namespace srslte; namespace srsepc{ hss* hss::m_instance = NULL; -boost::mutex hss_instance_mutex; +pthread_mutex_t hss_instance_mutex = PTHREAD_MUTEX_INITIALIZER; hss::hss() // :m_sqn(0x112233445566) @@ -53,22 +53,24 @@ hss::~hss() hss* hss::get_instance(void) -{ - boost::mutex::scoped_lock lock(hss_instance_mutex); +{ + pthread_mutex_lock(&hss_instance_mutex); if(NULL == m_instance) { m_instance = new hss(); } + pthread_mutex_unlock(&hss_instance_mutex); return(m_instance); } void hss::cleanup(void) { - boost::mutex::scoped_lock lock(hss_instance_mutex); + pthread_mutex_lock(&hss_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&hss_instance_mutex); } int diff --git a/srsepc/src/mme/s1ap_mngmt_proc.cc b/srsepc/src/mme/s1ap_mngmt_proc.cc index 477ce203f..3aa3688e0 100644 --- a/srsepc/src/mme/s1ap_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_mngmt_proc.cc @@ -50,8 +50,8 @@ s1ap_mngmt_proc::get_instance(void) if(NULL == m_instance) { m_instance = new s1ap_mngmt_proc(); } - return(m_instance); pthread_mutex_unlock(&s1ap_mngmt_proc_instance_mutex); + return(m_instance); } void diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 2458a065b..2f0e0e468 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -41,7 +41,7 @@ namespace srsepc{ spgw* spgw::m_instance = NULL; -boost::mutex spgw_instance_mutex; +pthread_mutex_t spgw_instance_mutex = PTHREAD_MUTEX_INITIALIZER; const uint16_t SPGW_BUFFER_SIZE = 2500; @@ -63,21 +63,23 @@ spgw::~spgw() spgw* spgw::get_instance(void) { - boost::mutex::scoped_lock lock(spgw_instance_mutex); + pthread_mutex_lock(&spgw_instance_mutex); if(NULL == m_instance) { m_instance = new spgw(); } + pthread_mutex_unlock(&spgw_instance_mutex); return(m_instance); } void spgw::cleanup(void) { - boost::mutex::scoped_lock lock(spgw_instance_mutex); + pthread_mutex_lock(&spgw_instance_mutex); if(NULL != m_instance) { delete m_instance; m_instance = NULL; } + pthread_mutex_unlock(&spgw_instance_mutex); } int From af2816f83fa52052f3eb93d0a7c37d384974519b Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 26 Jan 2018 17:43:21 +0000 Subject: [PATCH 7/9] Staring to make APN configurable. --- srsepc/epc.conf.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srsepc/epc.conf.example b/srsepc/epc.conf.example index 739b2c137..2576d127a 100644 --- a/srsepc/epc.conf.example +++ b/srsepc/epc.conf.example @@ -10,7 +10,7 @@ # tac: 16-bit Tracking Area Code. # mcc: Mobile Country Code # mnc: Mobile Network Code -# mme_bindx_addr: IP subnet to listen for eNB S1 connnections +# mme_bind_addr: IP bind addr to listen for eNB S1 connnections # ##################################################################### [mme] @@ -20,6 +20,7 @@ tac = 0x0007 mcc = 001 mnc = 01 mme_bind_addr = 127.0.1.100 +apn = srsapn ##################################################################### # HSS configuration From 7013865c0d5695b4586f802d8061a1403b26c7d2 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 30 Jan 2018 14:41:23 +0000 Subject: [PATCH 8/9] fixed un-initialized values in attach accept. --- srsepc/src/mme/s1ap_nas_transport.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 0054041fe..52e8e6775 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -117,13 +117,15 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA } 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) { m_s1ap_log->info("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); + handle_nas_service_request(enb_ue_s1ap_id, attach_req,pdn_con_req,reply_buffer,reply_flag, enb_sri); return false; - } + }*/ m_pool->deallocate(nas_msg); return true; @@ -422,6 +424,18 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id, return true; } + /* +bool +s1ap_nas_transport::handle_nas_service_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 *reply_buffer, + bool* reply_flag, + struct sctp_sndrcvinfo *enb_sri) +{ + +}*/ + bool s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *nas_msg, ue_ctx_t *ue_ctx, srslte::byte_buffer_t *reply_buffer, bool* reply_flag) { @@ -1093,6 +1107,14 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[2] = 8; act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[3] = 8; + //Make sure all unused options are set to false + act_def_eps_bearer_context_req.negotiated_qos_present = false; + act_def_eps_bearer_context_req.llc_sapi_present = false; + act_def_eps_bearer_context_req.radio_prio_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.esm_cause_present = false; + uint8_t sec_hdr_type =2; ue_ctx->security_ctxt.dl_nas_count++; liblte_mme_pack_activate_default_eps_bearer_context_request_msg(&act_def_eps_bearer_context_req, &attach_accept.esm_msg); From c4b2dd5e65ca48f132b4761cf421eea5e8f18033 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 2 Feb 2018 19:08:51 +0000 Subject: [PATCH 9/9] Starting to add the response to the service request. --- srsepc/hdr/mme/s1ap_nas_transport.h | 8 +++ srsepc/src/mme/s1ap.cc | 6 ++- srsepc/src/mme/s1ap_nas_transport.cc | 75 ++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 7 deletions(-) diff --git a/srsepc/hdr/mme/s1ap_nas_transport.h b/srsepc/hdr/mme/s1ap_nas_transport.h index e37ce4d61..bb8f7967f 100644 --- a/srsepc/hdr/mme/s1ap_nas_transport.h +++ b/srsepc/hdr/mme/s1ap_nas_transport.h @@ -47,6 +47,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_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); + //Initial UE messages bool handle_nas_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, @@ -65,6 +66,13 @@ public: srslte::byte_buffer_t *reply_buffer, bool* reply_flag, struct sctp_sndrcvinfo *enb_sri); + bool handle_nas_service_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 *reply_buffer, + bool* reply_flag, + struct sctp_sndrcvinfo *enb_sri); + bool handle_nas_authentication_response(srslte::byte_buffer_t *nas_msg, ue_ctx_t *ue_ctx, srslte::byte_buffer_t *reply_buffer, bool* reply_flag); bool handle_nas_security_mode_complete(srslte::byte_buffer_t *nas_msg, ue_ctx_t *ue_ctx, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, ue_ctx_t *ue_ctx, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 85a07596c..e0604b113 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -259,7 +259,7 @@ s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb } -bool +bool s1ap::handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri) { bool reply_flag = false; @@ -291,7 +291,9 @@ s1ap::handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, stru ssize_t n_sent = sctp_send(m_s1mme,reply_buffer->msg, reply_buffer->N_bytes, enb_sri, 0); if(n_sent == -1) { - m_s1ap_log->console("Failed to send S1 Setup Setup Reply\n"); + m_s1ap_log->console("Failed to send S1AP Initiating Reply.\n"); + m_s1ap_log->error("Failed to send S1AP Initiating Reply. \n"); + m_pool->deallocate(reply_buffer); m_pool->deallocate(reply_buffer); return false; } diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index c6f86db56..3f2a1eb49 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -117,7 +117,6 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA } 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) { m_s1ap_log->info("Received Service Request \n"); @@ -125,7 +124,7 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA liblte_mme_unpack_service_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &service_req); handle_nas_service_request(enb_ue_s1ap_id, attach_req,pdn_con_req,reply_buffer,reply_flag, enb_sri); return false; - }*/ + } m_pool->deallocate(nas_msg); return true; @@ -424,7 +423,6 @@ s1ap_nas_transport::handle_nas_guti_attach_request(uint32_t enb_ue_s1ap_id, return true; } - /* bool s1ap_nas_transport::handle_nas_service_request(uint32_t enb_ue_s1ap_id, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, @@ -433,8 +431,70 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t enb_ue_s1ap_id, bool* reply_flag, struct sctp_sndrcvinfo *enb_sri) { + m_s1ap_log->warning("Service Request not handled yet\n"); + m_s1ap_log->console("Service Request not handled yet\n"); + + 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 = 16; + 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 serv_rej; + serv_rej.t3442_present = false; + serv_rej.t3446_present = false; + serv_rej.emm_cause = 9; //UE Identity cannot be derived by the network + + uint8_t sec_hdr_type = 2; + uint32_t count = 0 ; + LIBLTE_ERROR_ENUM err; + err = liblte_mme_pack_service_reject_msg(&serv_rej, sec_hdr_type, count, (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"); + 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_buffer); + if(err != LIBLTE_SUCCESS) + { + m_s1ap_log->error("Error packing Athentication Request\n"); + m_s1ap_log->console("Error packing Athentication Request\n"); + return false; + } + + + + bool send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp, struct srslte::gtpc_f_teid_ie sgw_ctrl_fteid); + m_pool->deallocate(nas_buffer); + + //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"); + return true; +} bool s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *nas_msg, ue_ctx_t *ue_ctx, srslte::byte_buffer_t *reply_buffer, bool* reply_flag) @@ -1063,11 +1123,16 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE attach_accept.guti.guti.mme_code, attach_accept.guti.guti.m_tmsi); + + attach_accept.t3402_present=true; + attach_accept.t3402.unit = LIBLTE_MME_GPRS_TIMER_UNIT_1_MINUTE; // GPRS 1 minute unit + attach_accept.t3402.value = 30; // 30 minute periodic timer + //Make sure all unused options are set to false attach_accept.lai_present=false; attach_accept.ms_id_present=false; attach_accept.emm_cause_present=false; - attach_accept.t3402_present=false; + //attach_accept.t3402_present=false; attach_accept.t3423_present=false; attach_accept.equivalent_plmns_present=false; attach_accept.emerg_num_list_present=false;