ric: making the e2 pack/send function generic

master
yagoda 2 years ago committed by Justin Tallon
parent d34bd957bc
commit d4fbdfd54b

@ -21,6 +21,7 @@
#include "srsran/srsran.h" #include "srsran/srsran.h"
static const int e2ap_ppid = 70; static const int e2ap_ppid = 70;
static const int e2ap_port = 36422; static const int e2ap_port = 36422;
enum e2_msg_type_t { E2_SETUP_REQUEST, E2_SUB_RESPONSE, E2_INDICATION };
namespace srsenb { namespace srsenb {
class ric_client : public srsran::thread class ric_client : public srsran::thread
{ {
@ -30,7 +31,7 @@ public:
void stop(); void stop();
void run_thread(); void run_thread();
bool send_sctp(srsran::unique_byte_buffer_t& buf); 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 bool
handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, const sockaddr_in& from, const sctp_sndrcvinfo& sri, int flags); 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_init_msg(asn1::e2ap::init_msg_s& init_msg);

@ -67,7 +67,7 @@ void ric_client::run_thread()
{ {
while (running) { while (running) {
if (!e2ap_.has_setup_response()) { if (!e2ap_.has_setup_response()) {
send_e2_setup_request(); send_e2_msg(E2_SETUP_REQUEST);
printf("e2 setup request sent\n"); printf("e2 setup request sent\n");
} }
sleep(1); sleep(1);
@ -95,18 +95,30 @@ bool ric_client::send_sctp(srsran::unique_byte_buffer_t& buf)
return true; 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(); srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer();
if (buf == nullptr) { if (buf == nullptr) {
// logger.error("Fatal Error: Couldn't allocate buffer for %s.", procedure_name); // logger.error("Fatal Error: Couldn't allocate buffer for %s.", procedure_name);
return false; return false;
} }
e2_ap_pdu_c send_pdu;
e2_ap_pdu_c setup_req_pdu = e2ap_.generate_setup_request(); 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()); 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"); logger.error("Failed to pack TX E2 PDU");
return false; return false;
} }

Loading…
Cancel
Save