1 /*****************************************************************************
3 # Copyright 2020 AT&T Intellectual Property *
5 # Licensed under the Apache License, Version 2.0 (the "License"); *
6 # you may not use this file except in compliance with the License. *
7 # You may obtain a copy of the License at *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
11 # Unless required by applicable law or agreed to in writing, software *
12 # distributed under the License is distributed on an "AS IS" BASIS, *
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 # See the License for the specific language governing permissions and *
15 # limitations under the License. *
17 ******************************************************************************/
26 #include "encode_kpm.hpp"
27 #include "e2sim_defs.h"
30 const char* performance_measurements[] = {
31 "DRB.RlcSduTransmittedVolumeDL",
32 "DRB.RlcSduTransmittedVolumeUL",
33 "DRB.PerDataVolumeDLDist.Bin",
34 "DRB.PerDataVolumeULDist.Bin",
35 "DRB.RlcPacketDropRateDLDist",
36 "DRB.PacketLossRateULDist",
42 int NUMBER_MEASUREMENTS = 9;
44 void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc_desc) {
45 uint8_t* short_name = (uint8_t*)"ORAN-E2SM-KPM";
46 uint8_t* func_desc = (uint8_t*)"KPM Monitor";
47 uint8_t* e2sm_odi = (uint8_t*)"OID123";
49 LOG_I("short_name: %s, func_desc: %s, e2sm_odi: %s", short_name, func_desc, e2sm_odi);
50 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
52 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size = strlen((char*)short_name);
53 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf =
54 (uint8_t*)calloc(strlen((char*)short_name), sizeof(uint8_t));
55 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf, short_name,
56 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size);
58 ranfunc_desc->ranFunction_Name.ranFunction_Description.buf =
59 (uint8_t*)calloc(1, strlen((char*)func_desc));
60 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, func_desc,
61 strlen((char*)func_desc));
62 ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen((char*)func_desc);
63 ranfunc_desc->ranFunction_Name.ranFunction_Instance = (long *)calloc(1, sizeof(long));
64 *ranfunc_desc->ranFunction_Name.ranFunction_Instance = 1;
66 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf =
67 (uint8_t*)calloc(1, strlen((char*)e2sm_odi));
68 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, e2sm_odi,
69 strlen((char*)e2sm_odi));
70 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen((char*)e2sm_odi);
72 LOG_I("Initialize event trigger style list structure");
74 RIC_EventTriggerStyle_Item_t* trigger_style =
75 (RIC_EventTriggerStyle_Item_t*)calloc(1, sizeof(RIC_EventTriggerStyle_Item_t));
76 trigger_style->ric_EventTriggerStyle_Type = 1;
77 uint8_t* style_name = (uint8_t*)"Periodic Report";
78 trigger_style->ric_EventTriggerStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)style_name));
79 memcpy(trigger_style->ric_EventTriggerStyle_Name.buf, style_name, strlen((char*)style_name));
80 trigger_style->ric_EventTriggerStyle_Name.size = strlen((char*)style_name);
81 trigger_style->ric_EventTriggerFormat_Type = 1;
83 ranfunc_desc->ric_EventTriggerStyle_List =
84 (E2SM_KPM_RANfunction_Description::
85 E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List*)
86 calloc(1, sizeof(E2SM_KPM_RANfunction_Description::
87 E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
89 int ret = ASN_SEQUENCE_ADD(&ranfunc_desc->ric_EventTriggerStyle_List->list, trigger_style);
91 LOG_I("Initialize report style structure");
93 MeasurementInfo_Action_List_t* measInfo_Action_List =
94 (MeasurementInfo_Action_List_t*)calloc(1, sizeof(MeasurementInfo_Action_List_t));
96 for (int i = 0; i < NUMBER_MEASUREMENTS; i++) {
97 uint8_t* metrics = (uint8_t *)performance_measurements[i];
98 MeasurementInfo_Action_Item_t* measItem =
99 (MeasurementInfo_Action_Item_t*)calloc(1, sizeof(MeasurementInfo_Action_Item_t));
100 measItem->measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
101 memcpy(measItem->measName.buf, metrics, strlen((char*)metrics));
103 measItem->measName.size = strlen((char*)metrics);
105 measItem->measID = (MeasurementTypeID_t*)calloc(1, sizeof(MeasurementTypeID_t));
106 *measItem->measID = i+1;
108 ASN_SEQUENCE_ADD(&measInfo_Action_List->list, measItem);
111 RIC_ReportStyle_Item_t* report_style1 =
112 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
113 report_style1->ric_ReportStyle_Type = 1;
115 uint8_t* buf5 = (uint8_t*)"E2 Node Measurement";
116 report_style1->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf5));
117 memcpy(report_style1->ric_ReportStyle_Name.buf, buf5, strlen((char*)buf5));
118 report_style1->ric_ReportStyle_Name.size = strlen((char*)buf5);
119 report_style1->ric_ActionFormat_Type = 1;
120 report_style1->ric_IndicationHeaderFormat_Type = 1;
121 report_style1->ric_IndicationMessageFormat_Type = 1;
122 report_style1->measInfo_Action_List = *measInfo_Action_List;
124 RIC_ReportStyle_Item_t* report_style2 =
125 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
126 report_style2->ric_ReportStyle_Type = 2;
128 uint8_t* buf6 = (uint8_t*)"E2 Node Measurement for a single UE";
129 report_style2->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf6));
130 memcpy(report_style2->ric_ReportStyle_Name.buf, buf6, strlen((char*)buf6));
131 report_style2->ric_ReportStyle_Name.size = strlen((char*)buf6);
132 report_style2->ric_ActionFormat_Type = 2;
133 report_style2->ric_IndicationHeaderFormat_Type = 1;
134 report_style2->ric_IndicationMessageFormat_Type = 1;
135 report_style2->measInfo_Action_List = *measInfo_Action_List;
137 RIC_ReportStyle_Item_t* report_style3 =
138 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
139 report_style3->ric_ReportStyle_Type = 3;
141 uint8_t* buf7 = (uint8_t*)"Condition-based, UE-level E2 Node Measurement";
143 report_style3->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf7));
144 memcpy(report_style3->ric_ReportStyle_Name.buf, buf7, strlen((char*)buf7));
145 report_style3->ric_ReportStyle_Name.size = strlen((char*)buf7);
146 report_style3->ric_ActionFormat_Type = 3;
147 report_style3->ric_IndicationHeaderFormat_Type = 1;
148 report_style3->ric_IndicationMessageFormat_Type = 2;
149 report_style3->measInfo_Action_List = *measInfo_Action_List;
151 RIC_ReportStyle_Item_t* report_style4 =
152 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
153 report_style4->ric_ReportStyle_Type = 4;
155 uint8_t* buf8 = (uint8_t*)"Common Condition-based, UE-level Measurement";
157 report_style4->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf8));
158 memcpy(report_style4->ric_ReportStyle_Name.buf, buf8, strlen((char*)buf8));
159 report_style4->ric_ReportStyle_Name.size = strlen((char*)buf8);
160 report_style4->ric_ActionFormat_Type = 4;
161 report_style4->ric_IndicationHeaderFormat_Type = 1;
162 report_style4->ric_IndicationMessageFormat_Type = 3;
163 report_style4->measInfo_Action_List = *measInfo_Action_List;
165 RIC_ReportStyle_Item_t* report_style5 =
166 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
167 report_style5->ric_ReportStyle_Type = 5;
169 uint8_t* buf9 = (uint8_t*)"E2 Node Measurement for multiple UEs";
171 report_style5->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf9));
172 memcpy(report_style5->ric_ReportStyle_Name.buf, buf9, strlen((char*)buf9));
173 report_style5->ric_ReportStyle_Name.size = strlen((char*)buf9);
174 report_style5->ric_ActionFormat_Type = 5;
175 report_style5->ric_IndicationHeaderFormat_Type = 1;
176 report_style5->ric_IndicationMessageFormat_Type = 3;
177 report_style5->measInfo_Action_List = *measInfo_Action_List;
179 ranfunc_desc->ric_ReportStyle_List =
180 (E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__ric_ReportStyle_List*)
181 calloc(1, sizeof(E2SM_KPM_RANfunction_Description::
182 E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
184 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style1);
185 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style2);
186 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style3);
187 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style4);
188 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style5);
190 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
193 void kpm_report_indication_header_initialized(E2SM_KPM_IndicationHeader_t* ihead,
194 uint8_t* plmnid_buf, uint8_t* sst_buf,
195 uint8_t* sd_buf, long fqival, long qcival,
196 uint8_t* nrcellid_buf, uint8_t* gnbid_buf,
197 int gnbid_unused, uint8_t* cuupid_buf,
198 uint8_t* duid_buf, uint8_t* cuupname_buf) {
199 LOG_I("Start initializing mocked indication header");
200 E2SM_KPM_IndicationHeader_Format1_t* ind_header =
201 (E2SM_KPM_IndicationHeader_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationHeader_Format1_t));
203 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, ind_header);
205 uint8_t* buf2 = (uint8_t*)"ORANSim";
206 ind_header->senderName = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
207 ind_header->senderName->buf = (uint8_t*)calloc(1, strlen((char*)buf2));
208 memcpy(ind_header->senderName->buf, buf2, strlen((char*)buf2));
209 ind_header->senderName->size = strlen((char*)buf2);
211 uint8_t* buf3 = (uint8_t*)"simulator";
212 ind_header->senderType = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
213 ind_header->senderType->buf = (uint8_t*)calloc(1, strlen((char*)buf3));
214 memcpy(ind_header->senderType->buf, buf3, strlen((char*)buf3));
215 ind_header->senderType->size = strlen((char*)buf3);
217 uint8_t* buf4 = (uint8_t*)"ORAN-SC";
218 ind_header->vendorName = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
219 ind_header->vendorName->buf = (uint8_t*)calloc(1, strlen((char*)buf4));
220 memcpy(ind_header->vendorName->buf, buf4, strlen((char*)buf4));
221 ind_header->vendorName->size = strlen((char*)buf4);
223 uint8_t* buf = (uint8_t*)"20200613";
224 TimeStamp_t* ts = (TimeStamp_t*)calloc(1, sizeof(TimeStamp_t));
225 ts->buf = (uint8_t*)calloc(strlen((char*)buf), 1);
226 ts->size = strlen((char*)buf);
227 memcpy(ts->buf, buf, ts->size);
229 ind_header->colletStartTime = *ts;
232 ihead->indicationHeader_formats.present =
233 E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1;
234 ihead->indicationHeader_formats.choice.indicationHeader_Format1 = ind_header;
238 void ue_meas_kpm_report_indication_message_initialized(
239 E2SM_KPM_IndicationMessage_t* indicationmessage, uint8_t* nrcellid_buf, uint8_t* crnti_buf,
240 const uint8_t* serving_buf, const uint8_t* neighbor_buf) {
242 MeasurementRecord_t* measDataItem_record = (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
243 for (size_t i = 0; i < NUMBER_MEASUREMENTS; i++)
245 MeasurementRecordItem_t* measDataRecordItem = (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
246 measDataRecordItem->present = MeasurementRecordItem_PR_integer;
247 measDataRecordItem->choice.integer = 1;
249 ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
252 MeasurementDataItem_t* measDataItem = (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
253 measDataItem->measRecord = *measDataItem_record;
254 measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
255 *measDataItem->incompleteFlag = 0;
257 MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
258 ASN_SEQUENCE_ADD(&measData->list, measDataItem);
260 MeasurementInfoList_t* measList = (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
261 for (size_t i = 0; i < NUMBER_MEASUREMENTS; i++)
263 MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
264 measLabel->noLabel = (long *)calloc(1, sizeof(long));
265 *measLabel->noLabel = 0;
267 LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
268 labelItem->measLabel = *measLabel;
270 LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
271 ASN_SEQUENCE_ADD(&labelList->list, labelItem);
273 MeasurementType_t measType;
274 measType.present = MeasurementType_PR_measID;
275 uint8_t* metrics = (uint8_t *)performance_measurements[i];
276 measType.choice.measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
277 memcpy(measType.choice.measName.buf, metrics, strlen((char*)metrics));
278 measType.choice.measName.size = strlen((char*)metrics);
280 MeasurementInfoItem_t* measItem = (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
281 measItem->measType = measType;
282 measItem->labelInfoList = *labelList;
283 if (labelList) free(labelList);
285 ASN_SEQUENCE_ADD(&measList->list, measItem);
288 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
289 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
290 format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
291 *format->granulPeriod = 1;
292 format->measData = *measData;
293 format->measInfoList = measList;
295 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
296 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
298 indicationmessage->indicationMessage_formats.present = pres;
299 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
301 char error_buf[300] = {
306 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
310 LOG_I("Constraint validation of indication message failed: %s", error_buf);
314 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
317 void cell_meas_kpm_report_indication_message_style_1_initialized(
318 E2SM_KPM_IndicationMessage_t* indicationmessage, long fiveqi, long dl_prb_usage,
319 long ul_prb_usage, uint8_t* nrcellid_buf, long* dl_prbs, long* ul_prbs) {
320 LOG_I("Preparing indication message for cell measurement report");
322 asn_codec_ctx_t* opt_cod;
324 GranularityPeriod_t period = 1;
325 MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
326 MeasurementDataItem_t* measDataItem =
327 (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
328 MeasurementRecord_t* measDataItem_record =
329 (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
330 MeasurementRecordItem_t* measDataRecordItem =
331 (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
333 measDataRecordItem->present = MeasurementRecordItem_PR_integer;
334 measDataRecordItem->choice.integer = 1;
336 ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
338 measDataItem->measRecord = *measDataItem_record;
339 measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
340 *measDataItem->incompleteFlag = 0;
341 ASN_SEQUENCE_ADD(&measData->list, measDataItem);
343 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
344 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
345 format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
346 *format->granulPeriod = period;
347 format->measData = *measData;
349 MeasurementInfoList_t* measList =
350 (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
351 MeasurementInfoItem_t* measItem =
352 (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
353 LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
354 LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
355 MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
357 uint8_t* plmnid_buf = (uint8_t*)"747";
358 uint8_t* sst_buf = (uint8_t*)"1";
359 uint8_t* sd_buf = (uint8_t*)"100";
361 S_NSSAI_t* snssai = (S_NSSAI_t*)calloc(1, sizeof(S_NSSAI_t));
362 snssai->sST.buf = (uint8_t*)calloc(strlen((char*)sst_buf), sizeof(uint8_t));
363 snssai->sST.size = strlen((char*)sst_buf);
364 memcpy(snssai->sST.buf, sst_buf, strlen((char*)sst_buf));
366 snssai->sD = (SD_t*)calloc(1, sizeof(SD_t));
367 snssai->sD->buf = (uint8_t*)calloc(strlen((char*)sd_buf), sizeof(uint8_t));
368 snssai->sD->size = strlen((char*)sd_buf);
369 memcpy(snssai->sD->buf, sd_buf, strlen((char*)sd_buf));
371 int plmnid_size = strlen((char*)plmnid_buf);
372 PLMNIdentity_t* plmnidstr = (PLMNIdentity_t*)calloc(1, sizeof(PLMNIdentity_t));
373 plmnidstr->buf = (uint8_t*)calloc(plmnid_size, 1);
374 plmnidstr->size = plmnid_size;
375 memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
377 measLabel->plmnID = plmnidstr;
378 measLabel->sliceID = snssai;
380 labelItem->measLabel = *measLabel;
381 ASN_SEQUENCE_ADD(&labelList->list, labelItem);
382 measItem->labelInfoList = *labelList;
383 if (labelList) free(labelList);
384 MeasurementType_t measType;
385 measType.present = MeasurementType_PR_measID;
386 measType.choice.measID = 1;
387 measItem->measType = measType;
388 ASN_SEQUENCE_ADD(&measList->list, measItem);
390 format->measInfoList = measList;
392 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
393 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
395 indicationmessage->indicationMessage_formats.present = pres;
396 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
398 char error_buf[300] = {
403 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
407 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
412 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
414 long dl_prb_usage = 50;
415 long ul_prb_usage = 70;
417 asn_codec_ctx_t* opt_cod;
419 GranularityPeriod_t period = 1;
420 MeasurementData_t measData;
421 MeasurementDataItem_t measDataItem;
422 MeasurementRecord_t measDataItem_record;
423 MeasurementRecordItem_t measDataRecordItem;
425 measDataRecordItem.present = MeasurementRecordItem_PR_real;
426 measDataRecordItem.choice.real = 1.5;
428 ASN_SEQUENCE_ADD(&measDataItem_record.list, &measDataRecordItem);
430 measDataItem.measRecord = measDataItem_record;
431 ASN_SEQUENCE_ADD(&measData.list, &measDataItem);
433 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
434 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
435 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
437 format->granulPeriod = .
438 format->measData = measData;
440 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
441 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
443 indicationmessage->indicationMessage_formats.present = pres;
445 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
446 if (format) free(format);
448 char error_buf[300] = {
453 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
457 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
461 uint8_t e2smbuffer[8192] = {
464 size_t e2smbuffer_size = 8192;
467 asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage,
468 indicationmessage, e2smbuffer, e2smbuffer_size);
470 if (er.encoded == -1) {
471 LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
473 } else if (er.encoded > e2smbuffer_size) {
474 LOG_E("Buffer of size %zu is too small for %s, need %zu\n", e2smbuffer_size, asn_DEF_E2SM_KPM_IndicationMessage.name, er.encoded);
479 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage) {
481 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
482 //std::string gn = "GNBCUUP5";
483 //std::vector<uint8_t> gnvec(gn.begin(), gn.end());
484 //uint8_t *buf = &gnvec[0];
485 uint8_t *buf = (uint8_t*)"GNBCUUP5";
486 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
487 gnbcuupname->size = 8;
488 gnbcuupname->buf = (uint8_t*)calloc(1,8);
489 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
492 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
495 bytesdl->buf = (uint8_t*)calloc(1,1);
496 memcpy(bytesdl->buf, buffer,1);
499 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
502 bytesul->buf = (uint8_t*)calloc(1,1);
503 memcpy(bytesul->buf, buffer1, 1);
506 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
507 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
508 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl;
509 fqilistitem->pDCPBytesUL = bytesul;
513 // std::string sl = "SLICE4";
514 // std::vector<uint8_t> slvec(sl.begin(), sl.end());
515 // uint8_t *buf1 = &slvec[0];
516 uint8_t *buf1 = (uint8_t*)"4";
517 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
519 sst->buf = (uint8_t*)calloc(1,6);
520 memcpy(sst->buf,buf1,sst->size);
522 // std::string sd = "SD1";
523 // std::vector<uint8_t> sdvec(sd.begin(), sd.end());
524 // uint8_t *bufz = &sdvec[0];
525 uint8_t *bufz = (uint8_t*)"SD1";
526 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
528 sds->buf = (uint8_t*)calloc(1,3);
529 memcpy(sds->buf, bufz, sds->size);
532 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
533 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
534 snssai->sST.buf = (uint8_t*)calloc(1,1);
535 snssai->sST.size = 1;
536 memcpy(snssai->sST.buf, buf1, 1);
537 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
538 snssai->sD->buf = (uint8_t*)calloc(1,3);
539 snssai->sD->size = 3;
540 memcpy(snssai->sD->buf, bufz, 3);
544 SliceToReportListItem_t *slicelistitem =
545 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
546 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
547 slicelistitem->sliceID = *snssai;
548 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
550 asn_codec_ctx_t *opt_cod;
553 uint8_t e2smbuffera[8192];
554 size_t e2smbuffer_sizea = 8192;
559 asn_encode_to_buffer(opt_cod,
560 ATS_ALIGNED_BASIC_PER,
561 &asn_DEF_SliceToReportListItem,
562 slicelistitem, e2smbuffera, e2smbuffer_sizea);
563 fprintf(stderr, "inner er encded is %d\n", era.encoded);
564 fprintf(stderr, "after encoding message");
568 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
569 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
570 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
572 uint8_t *buf2 = (uint8_t*)"747";
573 // std::string pl = "PLMNID7";
574 // std::vector<uint8_t> plvec(pl.begin(), pl.end());
575 // uint8_t *buf2 = &plvec[0];
577 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
578 plmnid->buf = (uint8_t*)calloc(3,1);
580 memcpy(plmnid->buf, buf2, plmnid->size);
583 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
584 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
585 plmnidlist->pLMN_Identity = *plmnid;
586 plmnidlist->cu_UP_PM_5GC = pm_format;
588 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
589 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
590 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
595 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
596 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
597 listitem1->interface_type = 2;
598 listitem1->o_CU_UP_PM_Container = *meas_cont;
600 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
601 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
602 cuupcont->gNB_CU_UP_Name = gnbcuupname;
603 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
605 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
607 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
608 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
609 pfcontainer->present = pres1;
610 pfcontainer->choice.oCU_UP = *cuupcont;
612 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
613 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
614 containers_list->performanceContainer = pfcontainer;
616 E2SM_KPM_IndicationMessage_Format1_t *format =
617 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
618 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
620 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
622 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
624 indicationmessage->present = pres;
626 indicationmessage->choice.indicationMessage_Format1 = *format;
628 char *error_buf = (char*)calloc(300, sizeof(char));
631 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
632 printf("error length %d\n", errlen);
633 printf("error buf %s\n", error_buf);
635 xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
638 uint8_t e2smbuffer[8192];
639 size_t e2smbuffer_size = 8192;
641 uint8_t e2smbuffer2[8192];
642 size_t e2smbuffer_size2 = 8192;
645 asn_encode_to_buffer(opt_cod,
646 ATS_ALIGNED_BASIC_PER,
647 &asn_DEF_E2SM_KPM_IndicationMessage,
648 indicationmessage, e2smbuffer, e2smbuffer_size);
650 fprintf(stderr, "er encded is %d\n", er.encoded);
651 fprintf(stderr, "after encoding message");
657 void encode_kpm_bak(E2SM_KPM_IndicationMessage_t* indicationmessage) {
658 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
659 std::string gn = "GNBCUUP5";
660 std::vector<uint8_t> gnvec(gn.begin(), gn.end());
661 uint8_t *buf = &gnvec[0];
662 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
663 gnbcuupname->size = 8;
664 gnbcuupname->buf = (uint8_t*)calloc(1,8);
665 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
668 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
671 bytesdl->buf = (uint8_t*)calloc(1,1);
672 memcpy(bytesdl->buf, buffer,1);
675 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
678 bytesul->buf = (uint8_t*)calloc(1,1);
679 memcpy(bytesul->buf, buffer1, 1);
682 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
683 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
684 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl; fqilistitem->pDCPBytesUL
689 std::string sl = "SLICE4";
690 std::vector<uint8_t> slvec(sl.begin(), sl.end());
691 // uint8_t *buf1 = &slvec[0];
692 uint8_t *buf1 = (uint8_t*)"SLICE4";
693 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
695 sst->buf = (uint8_t*)calloc(1,6);
696 memcpy(sst->buf,buf1,sst->size);
698 std::string sd = "SD1";
699 std::vector<uint8_t> sdvec(sd.begin(), sd.end());
700 // uint8_t *bufz = &sdvec[0];
701 uint8_t *bufz = (uint8_t*)"SD1";
702 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
704 sds->buf = (uint8_t*)calloc(1,3);
705 memcpy(sds->buf, bufz, sds->size);
708 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
709 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
710 snssai->sST.buf = (uint8_t*)calloc(6,1);
711 snssai->sST.size = 6;
712 memcpy(snssai->sST.buf, buf1, 6);
713 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
714 snssai->sD->buf = (uint8_t*)calloc(1,3);
715 snssai->sD->size = 3;
716 memcpy(snssai->sD->buf, bufz, 3);
720 SliceToReportListItem_t *slicelistitem =
721 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
722 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
723 slicelistitem->sliceID = *snssai;
724 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
726 uint8_t e2smbuffera[8192];
727 size_t e2smbuffer_sizea = 8192;
730 asn_encode_to_buffer(nullptr,
731 ATS_ALIGNED_BASIC_PER,
732 &asn_DEF_SliceToReportListItem,
733 slicelistitem, e2smbuffera, e2smbuffer_sizea);
734 fprintf(stderr, "inner er encded is %d\n", era.encoded);
735 fprintf(stderr, "after encoding message");
737 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
738 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
739 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
741 std::string pl = "PLMNID7";
742 std::vector<uint8_t> plvec(pl.begin(), pl.end());
743 uint8_t *buf2 = &plvec[0];
745 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
746 plmnid->buf = (uint8_t*)calloc(1,7);
748 memcpy(plmnid->buf, buf2, plmnid->size);
751 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
752 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
753 plmnidlist->pLMN_Identity = *plmnid;
754 plmnidlist->cu_UP_PM_5GC = pm_format;
756 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
757 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
758 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
763 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
764 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
765 listitem1->interface_type = 2;
766 listitem1->o_CU_UP_PM_Container = *meas_cont;
768 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
769 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
770 cuupcont->gNB_CU_UP_Name = gnbcuupname;
771 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
773 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
775 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
776 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
777 pfcontainer->present = pres1;
778 pfcontainer->choice.oCU_UP = *cuupcont;
780 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
781 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
782 containers_list->performanceContainer = pfcontainer;
784 E2SM_KPM_IndicationMessage_Format1_t *format =
785 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
786 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
788 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
790 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
792 indicationmessage->present = pres;
794 indicationmessage->choice.indicationMessage_Format1 = *format;
796 char *error_buf = (char*)calloc(300, sizeof(char));
799 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
800 printf("error length %d\n", errlen);
801 printf("error buf %s\n", error_buf);
804 uint8_t e2smbuffer[8192];
805 size_t e2smbuffer_size = 8192;
807 uint8_t e2smbuffer2[8192];
808 size_t e2smbuffer_size2 = 8192;
811 asn_encode_to_buffer(nullptr,
812 ATS_ALIGNED_BASIC_PER,
813 &asn_DEF_E2SM_KPM_IndicationMessage,
814 indicationmessage, e2smbuffer, e2smbuffer_size);
816 fprintf(stderr, "er encded is %d\n", er.encoded);
817 fprintf(stderr, "after encoding message");