e2ap: adding e2sm_kpm class to manage creation of e2sm_kpm messages, adding proper creation of RAN function definition in E2 setup request message

master
yagoda 2 years ago committed by Justin Tallon
parent 5ef7ee0e49
commit cd442e57ca

@ -11,13 +11,16 @@
* *
*/ */
#include "e2sm_kpm.h"
#include "srsran/asn1/e2ap.h" #include "srsran/asn1/e2ap.h"
#include "srsran/asn1/e2sm_kpm.h"
#include "srsran/srsran.h" #include "srsran/srsran.h"
#ifndef RIC_E2AP_H #ifndef RIC_E2AP_H
#define RIC_E2AP_H #define RIC_E2AP_H
using namespace asn1::e2ap; using namespace asn1::e2ap;
using namespace asn1::e2sm_kpm;
class e2ap class e2ap
{ {
@ -34,8 +37,12 @@ public:
private: private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
bool setup_response_received = false; e2sm_kpm e2sm_;
bool pending_subscription_request = false; bool setup_response_received = false;
bool pending_subscription_request = false;
int setup_procedure_transaction_id = 0;
uint64_t plmn_id = 3617847;
uint64_t gnb_id = 381210353;
}; };
#endif /* RIC_E2AP_H */ #endif /* RIC_E2AP_H */

@ -0,0 +1,33 @@
/**
*
* \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/e2sm.h"
#include "srsran/asn1/e2sm_kpm.h"
#include "srsran/srsran.h"
#ifndef RIC_E2SM_KPM_H
#define RIC_E2SM_KPM_H
class e2sm_kpm
{
public:
e2sm_kpm(srslog::basic_logger& logger_);
bool generate_ran_function_description(srsran::unique_byte_buffer_t& buf);
bool process_ric_action_definition();
bool generate_indication_header();
bool generate_indication_message();
private:
srslog::basic_logger& logger;
};
#endif /*E2SM_KPM*/

@ -2,7 +2,7 @@
#include "srsgnb/hdr/stack/ric/e2ap.h" #include "srsgnb/hdr/stack/ric/e2ap.h"
#include "stdint.h" #include "stdint.h"
e2ap::e2ap(srslog::basic_logger& logger) : logger(logger) {} e2ap::e2ap(srslog::basic_logger& logger) : logger(logger), e2sm_(logger) {}
e2_ap_pdu_c e2ap::generate_setup_request() e2_ap_pdu_c e2ap::generate_setup_request()
{ {
@ -13,13 +13,12 @@ e2_ap_pdu_c e2ap::generate_setup_request()
e2setup_request_s& setup = initmsg.value.e2setup_request(); e2setup_request_s& setup = initmsg.value.e2setup_request();
setup->transaction_id.crit = asn1::crit_opts::reject; setup->transaction_id.crit = asn1::crit_opts::reject;
setup->transaction_id.value.value = 1; setup->transaction_id.value.value = setup_procedure_transaction_id;
setup->global_e2node_id.crit = asn1::crit_opts::reject;
auto& gnb_ = setup->global_e2node_id.value.set_gnb();
setup->global_e2node_id.crit = asn1::crit_opts::reject; gnb_.global_g_nb_id.plmn_id.from_number(plmn_id);
auto& gnb_id = setup->global_e2node_id.value.set_gnb(); gnb_.global_g_nb_id.gnb_id.gnb_id().from_number(gnb_id);
// 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; setup->ra_nfunctions_added.crit = asn1::crit_opts::reject;
auto& list = setup->ra_nfunctions_added.value; auto& list = setup->ra_nfunctions_added.value;
@ -28,17 +27,14 @@ e2_ap_pdu_c e2ap::generate_setup_request()
asn1::protocol_ie_single_container_s<ra_nfunction_item_ies_o> item; asn1::protocol_ie_single_container_s<ra_nfunction_item_ies_o> item;
item.load_info_obj(ASN1_E2AP_ID_RA_NFUNCTION_ITEM); item.load_info_obj(ASN1_E2AP_ID_RA_NFUNCTION_ITEM);
item.value().ra_nfunction_item().ran_function_id = 0; 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( // pack E2SM-KPM-PDU into ran function definition
"20C04F52414E2D4532534D2D4B504D0000054F494431323305004B504D206D6F6E69746F720860283861AAE33F0060000101070050657269" auto& ran_func_def = item.value().ra_nfunction_item().ran_function_definition;
"6F646963207265706F727401051401011D004F2D4455204D6561737572656D656E7420436F6E7461696E657220666F722074686520354743" srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer();
"20636F6E6E6563746564206465706C6F796D656E74010101010001021D004F2D4455204D6561737572656D656E7420436F6E7461696E6572" e2sm_.generate_ran_function_description(buf);
"20666F72207468652045504320636F6E6E6563746564206465706C6F796D656E74010101010001031E804F2D43552D4350204D6561737572" ran_func_def.resize(buf->N_bytes);
"656D656E7420436F6E7461696E657220666F72207468652035474320636F6E6E6563746564206465706C6F796D656E74010101010001041E" std::copy(buf->msg, buf->msg + buf->N_bytes, ran_func_def.data());
"804F2D43552D4350204D6561737572656D656E7420436F6E7461696E657220666F72207468652045504320636F6E6E656374656420646570"
"6C6F796D656E74010101010001051E804F2D43552D5550204D6561737572656D656E7420436F6E7461696E657220666F7220746865203547"
"4320636F6E6E6563746564206465706C6F796D656E74010101010001061E804F2D43552D5550204D6561737572656D656E7420436F6E7461"
"696E657220666F72207468652045504320636F6E6E6563746564206465706C6F796D656E7401010101");
item.value().ra_nfunction_item().ran_function_oid.resize(1); item.value().ra_nfunction_item().ran_function_oid.resize(1);
setup->ra_nfunctions_added.value.push_back(item); setup->ra_nfunctions_added.value.push_back(item);

@ -0,0 +1,66 @@
#include "srsgnb/hdr/stack/ric/e2sm_kpm.h"
e2sm_kpm::e2sm_kpm(srslog::basic_logger& logger_) : logger(logger_) {}
bool e2sm_kpm::generate_ran_function_description(srsran::unique_byte_buffer_t& buf)
{
using namespace asn1::e2sm_kpm;
e2_sm_kpm_ra_nfunction_description_s e2sm_kpm_ra_nfunction_description;
e2sm_kpm_ra_nfunction_description.ran_function_name.ran_function_instance_present = true;
e2sm_kpm_ra_nfunction_description.ran_function_name.ran_function_instance = 0;
e2sm_kpm_ra_nfunction_description.ran_function_name.ran_function_short_name.from_string("ORAN-E2SM-KPM");
e2sm_kpm_ra_nfunction_description.ran_function_name.ran_function_e2_sm_oid.from_string("OID123");
e2sm_kpm_ra_nfunction_description.ran_function_name.ran_function_description.from_string("KPM monitor");
e2sm_kpm_ra_nfunction_description.e2_sm_kpm_ra_nfunction_item.ric_event_trigger_style_list.resize(1);
auto& ric_event_trigger_style_list_item =
e2sm_kpm_ra_nfunction_description.e2_sm_kpm_ra_nfunction_item.ric_event_trigger_style_list[0];
ric_event_trigger_style_list_item.ric_event_trigger_format_type = 5;
ric_event_trigger_style_list_item.ric_event_trigger_style_type = 1;
ric_event_trigger_style_list_item.ric_event_trigger_style_name.from_string("Periodic report");
auto& list = e2sm_kpm_ra_nfunction_description.e2_sm_kpm_ra_nfunction_item.ric_report_style_list;
list.resize(6);
for (int i = 0; i < (int)list.size(); i++) {
auto& ric_report_style_list_item =
e2sm_kpm_ra_nfunction_description.e2_sm_kpm_ra_nfunction_item.ric_report_style_list[i];
ric_report_style_list_item.ric_ind_hdr_format_type = 1;
ric_report_style_list_item.ric_ind_msg_format_type = 1;
ric_report_style_list_item.ric_report_style_type = i + 1;
switch (i) {
case 0:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-DU Measurement Container for the 5GC connected deployment");
break;
case 1:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-DU Measurement Container for the EPC connected deployment");
break;
case 2:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-CU-CP Measurement Container for the 5GC connected deployment");
break;
case 3:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-CU-CP Measurement Container for the EPC connected deployment");
break;
case 4:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-CU-UP Measurement Container for the 5GC connected deployment");
break;
case 5:
ric_report_style_list_item.ric_report_style_name.from_string(
"O-CU-UP Measurement Container for the EPC connected deployment");
break;
};
ric_report_style_list_item.ric_report_style_name.from_string("Periodic report");
}
logger.info("Generating RAN function description");
asn1::bit_ref bref(buf->msg, buf->get_tailroom());
if (e2sm_kpm_ra_nfunction_description.pack(bref) != asn1::SRSASN_SUCCESS) {
printf("Failed to pack TX E2 PDU\n");
return false;
}
buf->N_bytes = bref.distance_bytes();
return true;
}

@ -72,10 +72,23 @@ void test_reference_e2ap_setup_request()
0x72, 0x65, 0x73, 0x70, 0x61, 0x72, 0x74}; 0x72, 0x65, 0x73, 0x70, 0x61, 0x72, 0x74};
asn1::cbit_ref bref(&e2ap_msg_foreign[0], sizeof(e2ap_msg_foreign)); asn1::cbit_ref bref(&e2ap_msg_foreign[0], sizeof(e2ap_msg_foreign));
e2_ap_pdu_c pdu, pdu2; e2_ap_pdu_c pdu;
asn1::SRSASN_CODE unpack_ret = pdu2.unpack(bref); asn1::SRSASN_CODE unpack_ret = pdu.unpack(bref);
TESTASSERT_EQ(asn1::SRSASN_SUCCESS, unpack_ret); TESTASSERT_EQ(asn1::SRSASN_SUCCESS, unpack_ret);
printf("Unpacked E2AP PDU %d\n", (int)unpack_ret); printf("Unpacked E2AP PDU %d\n", (int)unpack_ret);
auto& ran_func_data = pdu.init_msg()
.value.e2setup_request()
->ra_nfunctions_added.value[0]
.value()
.ra_nfunction_item()
.ran_function_definition;
srsran::byte_buffer_t ran_function_def;
asn1::cbit_ref ran_func_bref(ran_function_def.msg, ran_function_def.get_tailroom());
std::copy(ran_func_data.data(), ran_func_data.data() + ran_func_data.size(), ran_function_def.begin());
e2_sm_kpm_ra_nfunction_description_s e2sm_kpm_ra_nfunction_description;
asn1::SRSASN_CODE nfunc_unpack = e2sm_kpm_ra_nfunction_description.unpack(ran_func_bref);
TESTASSERT_EQ(asn1::SRSASN_SUCCESS, nfunc_unpack);
printf("Unpacked E2SM PDU (KPM RAN function description) %d\n", (int)nfunc_unpack);
} }
void test_native_e2ap_setup_request() void test_native_e2ap_setup_request()

Loading…
Cancel
Save