From d4fbdfd54bd2c93946b38438d3de2a43ba0f5bbf Mon Sep 17 00:00:00 2001 From: yagoda Date: Tue, 22 Nov 2022 22:28:50 +0100 Subject: [PATCH] ric: making the e2 pack/send function generic --- srsgnb/hdr/stack/ric/ric_client.h | 3 ++- srsgnb/src/stack/ric/ric_client.cc | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/srsgnb/hdr/stack/ric/ric_client.h b/srsgnb/hdr/stack/ric/ric_client.h index 6bf836b76..8d5f23267 100644 --- a/srsgnb/hdr/stack/ric/ric_client.h +++ b/srsgnb/hdr/stack/ric/ric_client.h @@ -21,6 +21,7 @@ #include "srsran/srsran.h" static const int e2ap_ppid = 70; static const int e2ap_port = 36422; +enum e2_msg_type_t { E2_SETUP_REQUEST, E2_SUB_RESPONSE, E2_INDICATION }; namespace srsenb { class ric_client : public srsran::thread { @@ -30,7 +31,7 @@ public: void stop(); void run_thread(); bool send_sctp(srsran::unique_byte_buffer_t& buf); - bool send_e2_setup_request(); + bool send_e2_msg(e2_msg_type_t msg_type); bool handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); bool handle_e2_init_msg(asn1::e2ap::init_msg_s& init_msg); diff --git a/srsgnb/src/stack/ric/ric_client.cc b/srsgnb/src/stack/ric/ric_client.cc index b896d7794..79eb60f9d 100644 --- a/srsgnb/src/stack/ric/ric_client.cc +++ b/srsgnb/src/stack/ric/ric_client.cc @@ -67,7 +67,7 @@ void ric_client::run_thread() { while (running) { if (!e2ap_.has_setup_response()) { - send_e2_setup_request(); + send_e2_msg(E2_SETUP_REQUEST); printf("e2 setup request sent\n"); } sleep(1); @@ -95,18 +95,30 @@ bool ric_client::send_sctp(srsran::unique_byte_buffer_t& buf) return true; } -bool ric_client::send_e2_setup_request() +bool ric_client::send_e2_msg(e2_msg_type_t msg_type) { srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer(); if (buf == nullptr) { // logger.error("Fatal Error: Couldn't allocate buffer for %s.", procedure_name); return false; } - - e2_ap_pdu_c setup_req_pdu = e2ap_.generate_setup_request(); - + e2_ap_pdu_c send_pdu; + switch (msg_type) { + case e2_msg_type_t::E2_SETUP_REQUEST: + send_pdu = e2ap_.generate_setup_request(); + break; + case e2_msg_type_t::E2_SUB_RESPONSE: + send_pdu = e2ap_.generate_subscription_response(); + break; + case e2_msg_type_t::E2_INDICATION: + // TODO create E2 INDICATION generation + break; + default: + printf("Unknown E2AP message type\n"); + return false; + } asn1::bit_ref bref(buf->msg, buf->get_tailroom()); - if (setup_req_pdu.pack(bref) != asn1::SRSASN_SUCCESS) { + if (send_pdu.pack(bref) != asn1::SRSASN_SUCCESS) { logger.error("Failed to pack TX E2 PDU"); return false; }