From a14cc451d085408c3cae50320375333d2ebb2f0d Mon Sep 17 00:00:00 2001 From: Bedran Karakoc Date: Wed, 27 Oct 2021 15:34:02 +0200 Subject: [PATCH] Addition NGAP cleanup --- .../srsran/interfaces/gnb_ngap_interfaces.h | 1 - srsenb/hdr/stack/ngap/ngap.h | 1 - srsenb/hdr/stack/ngap/ngap_ue.h | 1 - srsenb/src/stack/ngap/ngap.cc | 30 ++++--------------- srsenb/src/stack/ngap/ngap_ue.cc | 14 ++++----- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/lib/include/srsran/interfaces/gnb_ngap_interfaces.h b/lib/include/srsran/interfaces/gnb_ngap_interfaces.h index 6780d0a02..0dc899e67 100644 --- a/lib/include/srsran/interfaces/gnb_ngap_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_ngap_interfaces.h @@ -49,7 +49,6 @@ public: virtual void user_mod(uint16_t old_rnti, uint16_t new_rnti) = 0; virtual bool user_release(uint16_t rnti, asn1::ngap_nr::cause_radio_network_e cause_radio) = 0; virtual bool is_amf_connected() = 0; - virtual void ue_ctxt_setup_complete(uint16_t rnti) = 0; virtual void ue_notify_rrc_reconf_complete(uint16_t rnti, bool outcome) = 0; }; diff --git a/srsenb/hdr/stack/ngap/ngap.h b/srsenb/hdr/stack/ngap/ngap.h index 87f7415e1..7fb014e28 100644 --- a/srsenb/hdr/stack/ngap/ngap.h +++ b/srsenb/hdr/stack/ngap/ngap.h @@ -65,7 +65,6 @@ public: bool send_error_indication(const asn1::ngap_nr::cause_c& cause, srsran::optional ran_ue_ngap_id = {}, srsran::optional amf_ue_ngap_id = {}); - void ue_ctxt_setup_complete(uint16_t rnti); void ue_notify_rrc_reconf_complete(uint16_t rnti, bool outcome); bool send_pdu_session_resource_setup_response(); diff --git a/srsenb/hdr/stack/ngap/ngap_ue.h b/srsenb/hdr/stack/ngap/ngap_ue.h index 4515b1fef..03ba97dec 100644 --- a/srsenb/hdr/stack/ngap/ngap_ue.h +++ b/srsenb/hdr/stack/ngap/ngap_ue.h @@ -54,7 +54,6 @@ public: bool handle_pdu_session_res_setup_request(const asn1::ngap_nr::pdu_session_res_setup_request_s& msg); bool was_uectxtrelease_requested() const { return release_requested; } - void ue_ctxt_setup_complete(); void notify_rrc_reconf_complete(const bool reconf_complete_outcome); ngap_ue_ctxt_t ctxt = {}; diff --git a/srsenb/src/stack/ngap/ngap.cc b/srsenb/src/stack/ngap/ngap.cc index ace4a027f..a92781efe 100644 --- a/srsenb/src/stack/ngap/ngap.cc +++ b/srsenb/src/stack/ngap/ngap.cc @@ -244,15 +244,6 @@ void ngap::initial_ue(uint16_t rnti, u->send_initial_ue_message(cause, std::move(pdu), true, s_tmsi); } -void ngap::ue_ctxt_setup_complete(uint16_t rnti) -{ - ue* u = users.find_ue_rnti(rnti); - if (u == nullptr) { - return; - } - u->ue_ctxt_setup_complete(); -} - void ngap::ue_notify_rrc_reconf_complete(uint16_t rnti, bool outcome) { ue* u = users.find_ue_rnti(rnti); @@ -396,8 +387,6 @@ bool ngap::handle_ngap_rx_pdu(srsran::byte_buffer_t* pdu) send_error_indication(cause); return false; } - // TODO: - // log_ngap_msg(rx_pdu, srsran::make_span(*pdu), true); switch (rx_pdu.type().value) { case ngap_pdu_c::types_opts::init_msg: @@ -459,6 +448,7 @@ bool ngap::handle_ng_setup_response(const asn1::ngap_nr::ng_setup_resp_s& msg) amf_connected = true; ng_setup_proc_t::ngsetupresult res; res.success = true; + logger.info("AMF name: %s", ngsetupresponse.protocol_ies.amf_name.value.to_string()); ngsetup_proc.trigger(res); return true; @@ -663,13 +653,11 @@ bool ngap::setup_ng() bref.pack(args.gnb_id, 8); memcpy(gnb_str.data(), &buffer[0], bref.distance_bytes()); - // .from_number(args.gnb_id); - container.ran_node_name_present = true; if (args.gnb_name.length() >= 150) { args.gnb_name.resize(150); } - // container.ran_node_name.value.from_string(args.enb_name); + container.ran_node_name.value.resize(args.gnb_name.size()); memcpy(&container.ran_node_name.value[0], &args.gnb_name[0], args.gnb_name.size()); @@ -708,12 +696,6 @@ bool ngap::sctp_send_ngap_pdu(const asn1::ngap_nr::ngap_pdu_c& tx_pdu, uint32_t } buf->N_bytes = bref.distance_bytes(); - // TODO: when we got pcap support - // Save message to PCAP - // if (pcap != nullptr) { - // pcap->write_s1ap(buf->msg, buf->N_bytes); - // } - if (rnti != SRSRAN_INVALID_RNTI) { logger.info(buf->msg, buf->N_bytes, "Tx NGAP SDU, %s, rnti=0x%x", procedure_name, rnti); } else { @@ -781,12 +763,12 @@ ngap::ue* ngap::handle_ngapmsg_ue_id(uint32_t gnb_id, uint32_t amf_id) send_error_indication(cause, gnb_id, amf_id); - if (user_ptr != nullptr) { - // rrc->release_ue(user_ptr->ctxt.rnti); + /* if (user_ptr != nullptr) { + rrc->release_ue(user_ptr->ctxt.rnti); } if (user_amf_ptr != nullptr and user_amf_ptr != user_ptr) { - // rrc->release_ue(user_mme_ptr->ctxt.rnti); - } + rrc->release_ue(user_mme_ptr->ctxt.rnti); + } */ return nullptr; } diff --git a/srsenb/src/stack/ngap/ngap_ue.cc b/srsenb/src/stack/ngap/ngap_ue.cc index 875b784d6..9c24f2dc9 100644 --- a/srsenb/src/stack/ngap/ngap_ue.cc +++ b/srsenb/src/stack/ngap/ngap_ue.cc @@ -105,7 +105,11 @@ bool ngap::ue::send_ul_nas_transport(srsran::unique_byte_buffer_t pdu) asn1::ngap_nr::ul_nas_transport_ies_container& container = tx_pdu.init_msg().value.ul_nas_transport().protocol_ies; // AMF UE NGAP ID - container.amf_ue_ngap_id.value = ctxt.amf_ue_ngap_id.value(); + if (ctxt.amf_ue_ngap_id.has_value()) { + container.amf_ue_ngap_id.value = ctxt.amf_ue_ngap_id.value(); + } else { + logger.error("Attempting to send UL NAS Transport without AMF context"); + } // RAN UE NGAP ID container.ran_ue_ngap_id.value = ctxt.ran_ue_ngap_id; @@ -125,14 +129,6 @@ bool ngap::ue::send_ul_nas_transport(srsran::unique_byte_buffer_t pdu) return ngap_ptr->sctp_send_ngap_pdu(tx_pdu, ctxt.rnti, "UplinkNASTransport"); } -void ngap::ue::ue_ctxt_setup_complete() -{ - ngap_pdu_c tx_pdu; - // Handle PDU Session List once RRC interface is ready - tx_pdu.set_successful_outcome().load_info_obj(ASN1_NGAP_NR_ID_INIT_CONTEXT_SETUP); - auto& container = tx_pdu.successful_outcome().value.init_context_setup_resp().protocol_ies; -} - void ngap::ue::notify_rrc_reconf_complete(const bool outcome) { initial_context_setup_proc.trigger(outcome);