X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2sim%2Fe2sm_examples%2Fkpm_e2sm%2Fsrc%2Fkpm%2Fkpm_callbacks.cpp;h=fea3a4bd03a0ee2069d197f4a033227973a374ad;hb=40c9800d92beecb080aefbed0d609afea260e5ed;hp=18081f38223a7283a2ef0fb82faea883bfecdeaf;hpb=e99b594eb6a250b50f9d7ef5ae59291b09bc7fb7;p=sim%2Fe2-interface.git diff --git a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp old mode 100644 new mode 100755 index 18081f3..fea3a4b --- a/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp +++ b/e2sim/e2sm_examples/kpm_e2sm/src/kpm/kpm_callbacks.cpp @@ -50,6 +50,8 @@ extern "C" { #include #include +#include "viavi_connector.hpp" + using json = nlohmann::json; using namespace std; @@ -79,7 +81,7 @@ int main(int argc, char* argv[]) { (E2SM_KPM_RANfunction_Description_t*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description_t)); encode_kpm_function_description(ranfunc_desc); - uint8_t e2smbuffer[8192]; + uint8_t e2smbuffer[8192] = {0, }; size_t e2smbuffer_size = 8192; asn_enc_rval_t er = @@ -146,12 +148,19 @@ void get_cell_id(uint8_t *nrcellid_buf, char *cid_return_buf) { } -void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long actionId) { +void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long actionId) +{ + std::filebuf reports_json; + std::streambuf *input_filebuf = &reports_json; - std::ifstream input("/playpen/src/reports.json"); - bool x = input.good(); + std::unique_ptr viavi_connector; + if (!reports_json.open("/playpen/src/reports.json", std::ios::in)) { + std::cerr << "Can't open reports.json, enabling VIAVI connector instead..." << endl; + viavi_connector.reset(new viavi::RICTesterReceiver {3001, nullptr}); + input_filebuf = viavi_connector->get_data_filebuf(); + } - fprintf(stderr, "%s\n", x ? "true" : "false"); + std::istream input {input_filebuf}; long seqNum = 1; @@ -236,7 +245,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long json::json_pointer p5(std::string("/ueMeasReport/ueMeasReportList/") + std::to_string(i) +"/neighbourCellList"); - uint8_t *crnti_buf = (uint8_t*)calloc(1,2); + uint8_t crnti_buf[3] = {0, }; if (ueId.find("Pedestrian") != string::npos) { std::string ind = ueId.substr(11); @@ -297,14 +306,14 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long } - uint8_t *neighbor_cellid_buf = (uint8_t*)calloc(1,5); + uint8_t neighbor_cellid_buf[6] = {0, }; neighbor_cellid_buf[0] = 0x22; neighbor_cellid_buf[1] = 0x5B; neighbor_cellid_buf[2] = 0xD6; neighbor_cellid_buf[3] = nextNbCell; neighbor_cellid_buf[4] = 0x70; - char *cid_buf = (char*)calloc(1,24); + char cid_buf[25] = {0, }; get_cell_id(neighbor_cellid_buf,cid_buf); @@ -324,22 +333,22 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long const uint8_t *neighbor_buf = reinterpret_cast(neighbor_str.c_str()); - uint8_t *nrcellid_buf = (uint8_t*)calloc(1,5); + uint8_t nrcellid_buf[6] = {0, }; nrcellid_buf[0] = 0x22; nrcellid_buf[1] = 0x5B; nrcellid_buf[2] = 0xD6; nrcellid_buf[3] = nextCellId; nrcellid_buf[4] = 0x70; - uint8_t *gnbid_buf = (uint8_t*)calloc(1,3); + uint8_t gnbid_buf[4] = {0, }; gnbid_buf[0] = 0x22; gnbid_buf[1] = 0x5B; gnbid_buf[2] = 0xD6; - uint8_t cuupid_buf[1]; + uint8_t cuupid_buf[2] = {0, }; cuupid_buf[0] = 20000; - uint8_t duid_buf[1]; + uint8_t duid_buf[2] = {0, }; duid_buf[0] = 20000; uint8_t *cuupname_buf = (uint8_t*)"GNBCUUP5"; @@ -350,7 +359,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long encode_kpm_report_rancontainer_cucp_parameterized(ind_msg_cucp_ue, plmnid_buf, nrcellid_buf, crnti_buf, serving_buf, neighbor_buf); - uint8_t e2sm_message_buf_cucp_ue[8192]; + uint8_t e2sm_message_buf_cucp_ue[8192] = {0, }; size_t e2sm_message_buf_size_cucp_ue = 8192; asn_codec_ctx_t *opt_cod; @@ -360,6 +369,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cucp_ue, e2sm_message_buf_cucp_ue, e2sm_message_buf_size_cucp_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cucp_ue); fprintf(stderr, "er encded is %d\n", er_message_cucp_ue.encoded); fprintf(stderr, "after encoding message\n"); @@ -370,13 +380,14 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long fprintf(stderr, "Now printing xer outside of function call\n"); xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cucp_ue); - uint8_t e2sm_header_buf_cucp_ue[8192]; + uint8_t e2sm_header_buf_cucp_ue[8192] = {0, }; size_t e2sm_header_buf_size_cucp_ue = 8192; asn_enc_rval_t er_header_cucp_ue = asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cucp_ue, e2sm_header_buf_cucp_ue, e2sm_header_buf_size_cucp_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cucp_ue); fprintf(stderr, "er encded is %d\n", er_header_cucp_ue.encoded); fprintf(stderr, "error buf is %s\n", (char*)e2sm_header_buf_cucp_ue); @@ -408,7 +419,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long encode_kpm_report_rancontainer_cuup_parameterized(ind_msg_cuup_ue, plmnid_buf, nrcellid_buf, crnti_buf, bytes, 0); - uint8_t e2sm_message_buf_cuup_ue[8192]; + uint8_t e2sm_message_buf_cuup_ue[8192] = {0, }; size_t e2sm_message_buf_size_cuup_ue = 8192; asn_codec_ctx_t *opt_cod2; @@ -418,6 +429,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cuup_ue, e2sm_message_buf_cuup_ue, e2sm_message_buf_size_cuup_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_cuup_ue); fprintf(stderr, "er encded is %d\n", er_message_cuup_ue.encoded); fprintf(stderr, "after encoding message\n"); @@ -426,13 +438,14 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t)); encode_e2sm_kpm_indication_header(ind_header_cuup_ue, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf); - uint8_t e2sm_header_buf_cuup_ue[8192]; + uint8_t e2sm_header_buf_cuup_ue[8192] = {0, }; size_t e2sm_header_buf_size_cuup_ue = 8192; asn_enc_rval_t er_header_cuup_ue = asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cuup_ue, e2sm_header_buf_cuup_ue, e2sm_header_buf_size_cuup_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_cuup_ue); E2AP_PDU *pdu_cuup_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU)); @@ -459,7 +472,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long encode_kpm_report_rancontainer_du_parameterized(ind_message_du_ue, plmnid_buf, nrcellid_buf, crnti_buf, prb_usage, 0); - uint8_t e2sm_message_buf_du_ue[8192]; + uint8_t e2sm_message_buf_du_ue[8192] = {0, }; size_t e2sm_message_buf_size_du_ue = 8192; asn_codec_ctx_t *opt_cod3; @@ -471,6 +484,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long ind_message_du_ue, e2sm_message_buf_du_ue, e2sm_message_buf_size_du_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_message_du_ue); fprintf(stderr, "er encded is %d\n", er_message_du_ue.encoded); fprintf(stderr, "after encoding message\n"); @@ -479,7 +493,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t)); encode_e2sm_kpm_indication_header(ind_header_du_ue, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf); - uint8_t e2sm_header_buf_du_ue[8192]; + uint8_t e2sm_header_buf_du_ue[8192] = {0, }; size_t e2sm_header_buf_size_du_ue = 8192; asn_enc_rval_t er_header_du_ue = asn_encode_to_buffer(opt_cod, @@ -487,6 +501,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_du_ue, e2sm_header_buf_du_ue, e2sm_header_buf_size_du_ue); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_du_ue); E2AP_PDU *pdu_du_ue = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU)); @@ -548,22 +563,22 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long uint8_t *sd_buf = (uint8_t*)"100"; uint8_t *plmnid_buf = (uint8_t*)"747"; - uint8_t *nrcellid_buf = (uint8_t*)calloc(1,5); + uint8_t nrcellid_buf[6] = {0, }; nrcellid_buf[0] = 0x22; nrcellid_buf[1] = 0x5B; nrcellid_buf[2] = 0xD6; nrcellid_buf[3] = cellid; nrcellid_buf[4] = 0x70; - uint8_t *gnbid_buf = (uint8_t*)calloc(1,3); + uint8_t gnbid_buf[4] = {0, }; gnbid_buf[0] = 0x22; gnbid_buf[1] = 0x5B; gnbid_buf[2] = 0xD6; - uint8_t cuupid_buf[1]; + uint8_t cuupid_buf[2] = {0, }; cuupid_buf[0] = 20000; - uint8_t duid_buf[1]; + uint8_t duid_buf[2] = {0, }; duid_buf[0] = 20000; uint8_t *cuupname_buf = (uint8_t*)"GNBCUUP5"; @@ -581,13 +596,14 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long encode_kpm_report_style5_parameterized(ind_msg_style5 , cuupname_buf, bytes_dl, bytes_ul, sst_buf, sd_buf, plmnid_buf); - uint8_t e2sm_message_buf_style5[8192]; + uint8_t e2sm_message_buf_style5[8192] = {0, }; size_t e2sm_message_buf_size_style5 = 8192; asn_enc_rval_t er_message_style5 = asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_style5, e2sm_message_buf_style5, e2sm_message_buf_size_style5); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_msg_style5); fprintf(stderr, "er encded is %d\n", er_message_style5.encoded); fprintf(stderr, "after encoding message\n"); @@ -599,7 +615,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t)); encode_e2sm_kpm_indication_header(ind_header_style5, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf); - uint8_t e2sm_header_buf_style5[8192]; + uint8_t e2sm_header_buf_style5[8192] = {0, }; size_t e2sm_header_buf_size_style5 = 8192; asn_enc_rval_t er_header_style5 = asn_encode_to_buffer(opt_cod, @@ -607,6 +623,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_style5, e2sm_header_buf_style5, e2sm_header_buf_size_style5); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_style5); encoding::generate_e2apv1_indication_request_parameterized(pdu_style5, requestorId, @@ -636,14 +653,16 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long - long l_dl_prbs = prb_dl; - long l_ul_prbs = prb_ul; + long *l_dl_prbs = (long*)calloc(1, sizeof(long)); + long *l_ul_prbs = (long*)calloc(1, sizeof(long)); + *l_dl_prbs = (long)prb_dl; + *l_ul_prbs = (long)prb_ul; encode_kpm_report_style1_parameterized(ind_message_style1, fiveqi, prb_dl, prb_ul, sst_buf, sd_buf, - plmnid_buf, nrcellid_buf, &l_dl_prbs, &l_ul_prbs); + plmnid_buf, nrcellid_buf, l_dl_prbs, l_ul_prbs); - uint8_t e2sm_message_buf_style1[8192]; + uint8_t e2sm_message_buf_style1[8192] = {0, }; size_t e2sm_message_buf_size_style1 = 8192; asn_enc_rval_t er_message_style1 = asn_encode_to_buffer(opt_cod2, @@ -651,6 +670,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long &asn_DEF_E2SM_KPM_IndicationMessage, ind_message_style1, e2sm_message_buf_style1, e2sm_message_buf_size_style1); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationMessage, ind_message_style1); fprintf(stderr, "er encded is %d\n", er_message_style1.encoded); fprintf(stderr, "after encoding message\n"); @@ -664,7 +684,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long (E2SM_KPM_IndicationHeader_t*)calloc(1,sizeof(E2SM_KPM_IndicationHeader_t)); encode_e2sm_kpm_indication_header(ind_header_style1, plmnid_buf, sst_buf, sd_buf, fqival, qcival, nrcellid_buf, gnbid_buf, 0, cuupid_buf, duid_buf, cuupname_buf); - uint8_t e2sm_header_buf_style1[8192]; + uint8_t e2sm_header_buf_style1[8192] = {0, }; size_t e2sm_header_buf_size_style1 = 8192; asn_enc_rval_t er_header_style1 = asn_encode_to_buffer(opt_cod, @@ -672,6 +692,7 @@ void run_report_loop(long requestorId, long instanceId, long ranFunctionId, long &asn_DEF_E2SM_KPM_IndicationHeader, ind_header_style1, e2sm_header_buf_style1, e2sm_header_buf_size_style1); + ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, ind_header_style1); encoding::generate_e2apv1_indication_request_parameterized(pdu_style1, requestorId, instanceId, ranFunctionId,