e2ap, asn1: adding initial support for e2ap ORAN interfacec

master
yagoda 2 years ago committed by Justin Tallon
parent cdd084adee
commit 554c6c62f5

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -66,5 +66,9 @@ add_library(nas_5g_msg STATIC nas_5g_msg.cc nas_5g_ies.cc nas_5g_utils.cc)
target_compile_options(nas_5g_msg PRIVATE "-Os")
target_link_libraries(nas_5g_msg asn1_utils srsran_common)
install(TARGETS nas_5g_msg DESTINATION ${LIBRARY_DIR} OPTIONAL)
## ORAN E2 RIC
add_library(ric_e2 STATIC e2ap.cpp e2sm.cpp)
target_compile_options(ric_e2 PRIVATE "-Os")
target_link_libraries(ric_e2 asn1_utils srsran_common)
install(TARGETS ric_e2 DESTINATION ${LIBRARY_DIR} OPTIONAL)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -33,6 +33,7 @@
#include "srsenb/hdr/stack/mac/sched_interface.h"
#include "srsgnb/hdr/stack/gnb_stack_nr.h"
#include "srsgnb/hdr/stack/ric/ric_client.h"
#include "srsran/common/bcd_helpers.h"
#include "srsran/common/buffer_pool.h"
#include "srsran/common/interfaces_common.h"
@ -169,6 +170,7 @@ private:
std::unique_ptr<enb_stack_base> nr_stack = nullptr;
std::unique_ptr<srsran::radio_base> radio = nullptr;
std::unique_ptr<enb_phy_base> phy = nullptr;
std::unique_ptr<ric_client> ric = nullptr;
// System metrics processor.
srsran::sys_metrics_processor sys_proc;

@ -29,8 +29,8 @@ add_executable(srsenb main.cc enb.cc metrics_stdout.cc metrics_csv.cc metrics_js
set(SRSENB_SOURCES srsenb_phy srsenb_stack srsenb_common srsenb_s1ap srsenb_upper srsenb_mac srsenb_rrc srslog system)
set(SRSRAN_SOURCES srsran_common srsran_mac srsran_phy srsran_gtpu srsran_rlc srsran_pdcp srsran_radio rrc_asn1 s1ap_asn1 enb_cfg_parser srslog support system)
set(SRSENB_SOURCES ${SRSENB_SOURCES} srsgnb_stack srsgnb_ngap srsgnb_mac srsgnb_rrc)
set(SRSRAN_SOURCES ${SRSRAN_SOURCES} rrc_nr_asn1 ngap_nr_asn1)
set(SRSENB_SOURCES ${SRSENB_SOURCES} srsgnb_stack srsgnb_ric srsgnb_ngap srsgnb_mac srsgnb_rrc)
set(SRSRAN_SOURCES ${SRSRAN_SOURCES} rrc_nr_asn1 ngap_nr_asn1 ric_e2)
target_link_libraries(srsenb ${SRSENB_SOURCES}
${SRSRAN_SOURCES}

@ -118,6 +118,15 @@ int enb::init(const all_args_t& args_)
ret = SRSRAN_ERROR;
}
}
std::unique_ptr<srsenb::ric_client> tmp_ric_client = std::unique_ptr<srsenb::ric_client>(new srsenb::ric_client());
if (tmp_ric_client == nullptr) {
srsran::console("Error creating RIC client instance.\n");
return SRSRAN_ERROR;
}
if (tmp_ric_client->init()) {
srsran::console("Error initializing RIC client.\n");
return SRSRAN_ERROR;
}
if (tmp_eutra_stack) {
eutra_stack = std::move(tmp_eutra_stack);
@ -127,7 +136,7 @@ int enb::init(const all_args_t& args_)
}
phy = std::move(tmp_phy);
radio = std::move(tmp_radio);
ric = std::move(tmp_ric_client);
started = true; // set to true in any case to allow stopping the eNB if an error happened
// Now that everything is setup, log sector start events.

@ -0,0 +1,36 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2022 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*
*/
#include "srsran/asn1/e2ap.h"
#include "srsran/srsran.h"
#ifndef RIC_E2AP_H
#define RIC_E2AP_H
using namespace asn1::e2ap;
class e2ap
{
public:
e2_ap_pdu_c generate_setup_request();
int process_setup_response();
int process_setup_failure();
int process_subscription_request();
int generate_subscription_response();
int generate_subscription_failure();
int generate_indication();
private:
};
#endif /* RIC_E2AP_H */

@ -0,0 +1,42 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2022 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*
*/
#ifndef RIC_CLIENT_H
#define RIC_CLIENT_H
#include "srsgnb/hdr/stack/ric/e2ap.h"
#include "srsran/common/network_utils.h"
#include "srsran/common/threads.h"
#include "srsran/srsran.h"
static const int e2ap_ppid = 70;
static const int e2ap_port = 36422;
namespace srsenb {
class ric_client : public srsran::thread
{
public:
ric_client();
bool init();
void stop();
void run_thread();
bool send_sctp(srsran::unique_byte_buffer_t& buf);
bool send_e2_setup_request();
private:
e2ap e2ap_;
srsran::unique_socket ric_socket;
struct sockaddr_in ric_addr = {}; // RIC address
bool running = false;
};
} // namespace srsenb
#endif /* RIC_CLIENT_H */

@ -10,6 +10,7 @@ include_directories(${PROJECT_SOURCE_DIR})
add_subdirectory(mac)
add_subdirectory(ngap)
add_subdirectory(ric)
add_subdirectory(rrc)
add_subdirectory(sdap)

@ -0,0 +1,5 @@
set(SOURCES ric_client.cc e2ap.cc)
add_library(srsgnb_ric STATIC ${SOURCES})
#target_link_libraries(srsgnb_ric srsran_asn1)
add_subdirectory(test)

@ -0,0 +1,53 @@
#include "srsgnb/hdr/stack/ric/e2ap.h"
#include "stdint.h"
e2_ap_pdu_c e2ap::generate_setup_request()
{
e2_ap_pdu_c pdu;
init_msg_s& initmsg = pdu.set_init_msg();
initmsg.load_info_obj(ASN1_E2AP_ID_E2SETUP);
e2setup_request_s& setup = initmsg.value.e2setup_request();
setup->transaction_id.crit = asn1::crit_opts::reject;
setup->transaction_id.value.value = 1;
setup->global_e2node_id.crit = asn1::crit_opts::reject;
auto& gnb_id = setup->global_e2node_id.value.set_gnb();
// gnb_id.ext = true;
gnb_id.global_g_nb_id.plmn_id.from_number(3617847);
gnb_id.global_g_nb_id.gnb_id.gnb_id().from_number(381210353);
setup->ra_nfunctions_added.crit = asn1::crit_opts::reject;
auto& list = setup->ra_nfunctions_added.value;
setup->ra_nfunctions_added.id = ASN1_E2AP_ID_RA_NFUNCTIONS_ADDED;
asn1::protocol_ie_single_container_s<ra_nfunction_item_ies_o> item;
item.load_info_obj(ASN1_E2AP_ID_RA_NFUNCTION_ITEM);
item.value().ra_nfunction_item().ran_function_id = 0;
// TODO use E2SM to correctly generate this message
item.value().ra_nfunction_item().ran_function_definition.from_string(
"20C04F52414E2D4532534D2D4B504D0000054F494431323305004B504D206D6F6E69746F720860283861AAE33F0060000101070050657269"
"6F646963207265706F727401051401011D004F2D4455204D6561737572656D656E7420436F6E7461696E657220666F722074686520354743"
"20636F6E6E6563746564206465706C6F796D656E74010101010001021D004F2D4455204D6561737572656D656E7420436F6E7461696E6572"
"20666F72207468652045504320636F6E6E6563746564206465706C6F796D656E74010101010001031E804F2D43552D4350204D6561737572"
"656D656E7420436F6E7461696E657220666F72207468652035474320636F6E6E6563746564206465706C6F796D656E74010101010001041E"
"804F2D43552D4350204D6561737572656D656E7420436F6E7461696E657220666F72207468652045504320636F6E6E656374656420646570"
"6C6F796D656E74010101010001051E804F2D43552D5550204D6561737572656D656E7420436F6E7461696E657220666F7220746865203547"
"4320636F6E6E6563746564206465706C6F796D656E74010101010001061E804F2D43552D5550204D6561737572656D656E7420436F6E7461"
"696E657220666F72207468652045504320636F6E6E6563746564206465706C6F796D656E7401010101");
item.value().ra_nfunction_item().ran_function_oid.resize(1);
setup->ra_nfunctions_added.value.push_back(item);
setup->e2node_component_cfg_addition.crit = asn1::crit_opts::reject;
auto& list1 = setup->e2node_component_cfg_addition.value;
list1.resize(1);
list1[0].load_info_obj(ASN1_E2AP_ID_E2NODE_COMPONENT_CFG_ADDITION_ITEM);
e2node_component_cfg_addition_item_s& item1 = list1[0].value().e2node_component_cfg_addition_item();
item1.e2node_component_interface_type = e2node_component_interface_type_opts::ng;
item1.e2node_component_id.set_e2node_component_interface_type_ng().amf_name.from_string("nginterf");
item1.e2node_component_cfg.e2node_component_request_part.from_string("72657170617274");
item1.e2node_component_cfg.e2node_component_resp_part.from_string("72657370617274");
return pdu;
}

@ -0,0 +1,105 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2022 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srsgnb/hdr/stack/ric/ric_client.h"
#include "srsran/asn1/e2ap.h"
#include "stdint.h"
using namespace srsenb;
ric_client::ric_client() : thread("RIC_CLIENT_THREAD") {}
bool ric_client::init()
{
printf("RIC_CLIENT: Init\n");
using namespace srsran::net_utils;
// Open SCTP socket
if (not ric_socket.open_socket(addr_family::ipv4, socket_type::seqpacket, protocol_type::SCTP)) {
return false;
}
printf("RIC SCTP socket opened. fd=%d\n", ric_socket.fd());
if (not ric_socket.sctp_subscribe_to_events()) {
ric_socket.close();
return false;
}
// Bind socket
if (not ric_socket.bind_addr("172.17.0.3", 36422)) {
ric_socket.close();
return false;
}
// Connect to the AMF address
if (not ric_socket.connect_to("10.104.149.217", e2ap_port, &ric_addr)) {
return false;
}
printf("SCTP socket connected with RIC. fd=%d", ric_socket.fd());
running = true;
start(0);
return SRSRAN_SUCCESS;
}
void ric_client::stop()
{
running = false;
wait_thread_finish();
}
void ric_client::run_thread()
{
while (running) {
send_e2_setup_request();
printf("e2 setup request sent\n");
sleep(5);
}
}
bool ric_client::send_sctp(srsran::unique_byte_buffer_t& buf)
{
ssize_t ret;
ret = sctp_sendmsg(ric_socket.fd(),
buf->msg,
buf->N_bytes,
(struct sockaddr*)&ric_addr,
sizeof(ric_addr),
htonl(e2ap_ppid),
0,
0,
0,
0);
if (ret == -1) {
printf("failed to send %d bytes\n", buf->N_bytes);
return false;
}
return true;
}
bool ric_client::send_e2_setup_request()
{
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();
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
if (setup_req_pdu.pack(bref) != asn1::SRSASN_SUCCESS) {
printf("Failed to pack TX E2 PDU\n");
return false;
}
buf->N_bytes = bref.distance_bytes();
printf("try to send %d bytes to addr %s \n", buf->N_bytes, inet_ntoa(ric_addr.sin_addr));
if (!send_sctp(buf)) {
printf("failed to send e2 setup request\n");
return false;
}
return true;
}

@ -0,0 +1,12 @@
#
# Copyright 2013-2021 Software Radio Systems Limited
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the distribution.
#
add_executable(e2ap_test e2ap_test.cc)
target_link_libraries(e2ap_test srsran_common ric_e2 srsgnb_ric srsenb_upper srsgnb_stack ${SCTP_LIBRARIES})
add_test(e2ap_test e2ap_test)

@ -0,0 +1,106 @@
#include "srsgnb/hdr/stack/ric/e2ap.h"
#include "srsran/asn1/e2ap.h"
#include "srsran/common/test_common.h"
#include "srsran/srsran.h"
// function to test the encoding of the E2AP message
void test_reference_e2ap_setup_request()
{
uint8_t e2ap_msg_foreign[] = {
0x00, 0x01, 0x00, 0x82, 0x40, 0x00, 0x00, 0x04, 0x00, 0x31, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x09, 0x00,
0x37, 0x34, 0x37, 0x38, 0xb5, 0xc6, 0x77, 0x88, 0x00, 0x0a, 0x00, 0x81, 0xff, 0x00, 0x00, 0x08, 0x00, 0x81, 0xf9,
0x00, 0x00, 0x00, 0x81, 0xe9, 0x20, 0xc0, 0x4f, 0x52, 0x41, 0x4e, 0x2d, 0x45, 0x32, 0x53, 0x4d, 0x2d, 0x4b, 0x50,
0x4d, 0x00, 0x00, 0x05, 0x4f, 0x49, 0x44, 0x31, 0x32, 0x33, 0x05, 0x00, 0x4b, 0x50, 0x4d, 0x20, 0x6d, 0x6f, 0x6e,
0x69, 0x74, 0x6f, 0x72, 0x08, 0xdc, 0x2b, 0xda, 0xe3, 0xae, 0xd1, 0x4d, 0x00, 0x60, 0x00, 0x01, 0x01, 0x07, 0x00,
0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x69, 0x63, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x01, 0x05, 0x14, 0x01,
0x01, 0x1d, 0x00, 0x4f, 0x2d, 0x44, 0x55, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74,
0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
0x35, 0x47, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f,
0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x1d, 0x00, 0x4f, 0x2d, 0x44, 0x55, 0x20,
0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01,
0x01, 0x00, 0x01, 0x03, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x43, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75,
0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f,
0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x35, 0x47, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64,
0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x04, 0x1e,
0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x43, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65,
0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c,
0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x05, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55,
0x2d, 0x55, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e,
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x35, 0x47, 0x43, 0x20,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e,
0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x06, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x55, 0x50, 0x20, 0x4d,
0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65,
0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01,
0x00, 0x02, 0x00, 0x00, 0x05, 0x4f, 0x49, 0x44, 0x31, 0x32, 0x33, 0x00, 0x32, 0x00, 0x22, 0x00, 0x00, 0x00, 0x33,
0x00, 0x1c, 0x00, 0x00, 0xe0, 0x6e, 0x67, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x00, 0x07, 0x72, 0x65, 0x71, 0x70,
0x61, 0x72, 0x74, 0x07, 0x72, 0x65, 0x73, 0x70, 0x61, 0x72, 0x74};
uint8_t e2ap_msg_self[] = {
0x00, 0x01, 0x00, 0x82, 0x3c, 0x00, 0x00, 0x04, 0x00, 0x31, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x09, 0x00,
0x37, 0x34, 0x37, 0x38, 0xb5, 0xc6, 0x77, 0x88, 0x00, 0x0a, 0x00, 0x81, 0xfa, 0x00, 0x00, 0x08, 0x00, 0x81, 0xf4,
0x00, 0x00, 0x00, 0x81, 0xe9, 0x20, 0xc0, 0x4f, 0x52, 0x41, 0x4e, 0x2d, 0x45, 0x32, 0x53, 0x4d, 0x2d, 0x4b, 0x50,
0x4d, 0x00, 0x00, 0x05, 0x4f, 0x49, 0x44, 0x31, 0x32, 0x33, 0x05, 0x00, 0x4b, 0x50, 0x4d, 0x20, 0x6d, 0x6f, 0x6e,
0x69, 0x74, 0x6f, 0x72, 0x08, 0x60, 0x28, 0x38, 0x61, 0xaa, 0xe3, 0x3f, 0x00, 0x60, 0x00, 0x01, 0x01, 0x07, 0x00,
0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x69, 0x63, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x01, 0x05, 0x14, 0x01,
0x01, 0x1d, 0x00, 0x4f, 0x2d, 0x44, 0x55, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74,
0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
0x35, 0x47, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f,
0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x1d, 0x00, 0x4f, 0x2d, 0x44, 0x55, 0x20,
0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01,
0x01, 0x00, 0x01, 0x03, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x43, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75,
0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f,
0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x35, 0x47, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64,
0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x04, 0x1e,
0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x43, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65,
0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c,
0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x05, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55,
0x2d, 0x55, 0x50, 0x20, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e,
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x35, 0x47, 0x43, 0x20,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e,
0x74, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x06, 0x1e, 0x80, 0x4f, 0x2d, 0x43, 0x55, 0x2d, 0x55, 0x50, 0x20, 0x4d,
0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65,
0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x45, 0x50, 0x43, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x65, 0x64, 0x20, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x23, 0x00, 0x00, 0x00, 0x33, 0x00, 0x1d, 0x00, 0x00, 0x03,
0x80, 0x6e, 0x67, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x00, 0x07, 0x72, 0x65, 0x71, 0x70, 0x61, 0x72, 0x74, 0x07,
0x72, 0x65, 0x73, 0x70, 0x61, 0x72, 0x74};
asn1::cbit_ref bref(&e2ap_msg_foreign[0], sizeof(e2ap_msg_foreign));
e2_ap_pdu_c pdu, pdu2;
asn1::SRSASN_CODE unpack_ret = pdu2.unpack(bref);
TESTASSERT_EQ(asn1::SRSASN_SUCCESS, unpack_ret);
printf("Unpacked E2AP PDU %d\n", (int)unpack_ret);
}
void test_native_e2ap_setup_request()
{
srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer();
e2_ap_pdu_c pdu, pdu2;
e2ap e2ap_;
pdu = e2ap_.generate_setup_request();
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
if (pdu.pack(bref) != asn1::SRSASN_SUCCESS) {
printf("Failed to pack TX E2 PDU\n");
return;
}
asn1::cbit_ref bref2(buf->msg, buf->get_tailroom());
asn1::SRSASN_CODE unpack_ret = pdu2.unpack(bref2);
TESTASSERT_EQ(asn1::SRSASN_SUCCESS, unpack_ret);
printf("Unpacked native E2AP PDU %d\n", (int)unpack_ret);
}
int main()
{
test_reference_e2ap_setup_request();
test_native_e2ap_setup_request();
return 0;
}
Loading…
Cancel
Save