From eda5600ab0290c92fc5334d4a40d76265a148d89 Mon Sep 17 00:00:00 2001 From: yagoda Date: Wed, 16 Nov 2022 12:38:54 +0100 Subject: [PATCH] ric: adding receiver socket with taskqueue for E2 --- srsgnb/hdr/stack/ric/ric_client.h | 20 +++++++++++++++----- srsgnb/src/stack/ric/ric_client.cc | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/srsgnb/hdr/stack/ric/ric_client.h b/srsgnb/hdr/stack/ric/ric_client.h index c5ea078c7..baacc8410 100644 --- a/srsgnb/hdr/stack/ric/ric_client.h +++ b/srsgnb/hdr/stack/ric/ric_client.h @@ -16,6 +16,7 @@ #include "srsgnb/hdr/stack/ric/e2ap.h" #include "srsran/common/network_utils.h" +#include "srsran/common/task_scheduler.h" #include "srsran/common/threads.h" #include "srsran/srsran.h" static const int e2ap_ppid = 70; @@ -30,13 +31,22 @@ public: void run_thread(); bool send_sctp(srsran::unique_byte_buffer_t& buf); bool send_e2_setup_request(); + 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); + bool handle_e2_successful_outcome(asn1::e2ap::successful_outcome_s& successful_outcome); + bool handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome_s& unsuccessful_outcome); + bool handle_e2_setup_response(e2setup_resp_s setup_response); private: - e2ap e2ap_; - srsran::unique_socket ric_socket; - struct sockaddr_in ric_addr = {}; // RIC address - bool running = false; - srslog::basic_logger& logger; + e2ap e2ap_; + srsran::unique_socket ric_socket; + srsran::task_queue_handle ric_rece_task_queue; + srsran::task_scheduler task_sched; + srsran::socket_manager rx_sockets; + srslog::basic_logger& logger; + struct sockaddr_in ric_addr = {}; // RIC address + bool running = false; }; } // namespace srsenb diff --git a/srsgnb/src/stack/ric/ric_client.cc b/srsgnb/src/stack/ric/ric_client.cc index 754a69a5e..dce625f41 100644 --- a/srsgnb/src/stack/ric/ric_client.cc +++ b/srsgnb/src/stack/ric/ric_client.cc @@ -15,7 +15,10 @@ #include "stdint.h" using namespace srsenb; -ric_client::ric_client(srslog::basic_logger& logger) : logger(logger), thread("RIC_CLIENT_THREAD") {} +ric_client::ric_client(srslog::basic_logger& logger) : + task_sched(), logger(logger), rx_sockets(), thread("RIC_CLIENT_THREAD") +{ +} bool ric_client::init() { printf("RIC_CLIENT: Init\n"); @@ -41,10 +44,18 @@ bool ric_client::init() if (not ric_socket.connect_to("10.104.149.217", e2ap_port, &ric_addr)) { return false; } + // Assign a handler to rx RIC packets + ric_rece_task_queue = task_sched.make_task_queue(); + auto rx_callback = + [this](srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags) { + handle_e2_rx_msg(std::move(pdu), from, sri, flags); + }; + rx_sockets.add_socket_handler(ric_socket.fd(), + srsran::make_sctp_sdu_handler(logger, ric_rece_task_queue, rx_callback)); + printf("SCTP socket connected with RIC. fd=%d", ric_socket.fd()); running = true; start(0); - return SRSRAN_SUCCESS; } void ric_client::stop()