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_Filter",
32 "DRB.RlcSduTransmittedVolumeUL_Filter",
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;
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);
313 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
316 void cell_meas_kpm_report_indication_message_style_1_initialized(
317 E2SM_KPM_IndicationMessage_t* indicationmessage, long fiveqi, long dl_prb_usage,
318 long ul_prb_usage, uint8_t* nrcellid_buf, long* dl_prbs, long* ul_prbs) {
319 LOG_I("Preparing indication message for cell measurement report");
321 asn_codec_ctx_t* opt_cod;
323 GranularityPeriod_t period = 1;
324 MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
325 MeasurementDataItem_t* measDataItem =
326 (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
327 MeasurementRecord_t* measDataItem_record =
328 (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
329 MeasurementRecordItem_t* measDataRecordItem =
330 (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
332 measDataRecordItem->present = MeasurementRecordItem_PR_integer;
333 measDataRecordItem->choice.integer = 1;
335 ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
337 measDataItem->measRecord = *measDataItem_record;
338 measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
339 *measDataItem->incompleteFlag = 0;
340 ASN_SEQUENCE_ADD(&measData->list, measDataItem);
342 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
343 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
344 format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
345 *format->granulPeriod = period;
346 format->measData = *measData;
348 MeasurementInfoList_t* measList =
349 (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
350 MeasurementInfoItem_t* measItem =
351 (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
352 LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
353 LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
354 MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
356 uint8_t* plmnid_buf = (uint8_t*)"747";
357 uint8_t* sst_buf = (uint8_t*)"1";
358 uint8_t* sd_buf = (uint8_t*)"100";
360 S_NSSAI_t* snssai = (S_NSSAI_t*)calloc(1, sizeof(S_NSSAI_t));
361 snssai->sST.buf = (uint8_t*)calloc(strlen((char*)sst_buf), sizeof(uint8_t));
362 snssai->sST.size = strlen((char*)sst_buf);
363 memcpy(snssai->sST.buf, sst_buf, strlen((char*)sst_buf));
365 snssai->sD = (SD_t*)calloc(1, sizeof(SD_t));
366 snssai->sD->buf = (uint8_t*)calloc(strlen((char*)sd_buf), sizeof(uint8_t));
367 snssai->sD->size = strlen((char*)sd_buf);
368 memcpy(snssai->sD->buf, sd_buf, strlen((char*)sd_buf));
370 int plmnid_size = strlen((char*)plmnid_buf);
371 PLMNIdentity_t* plmnidstr = (PLMNIdentity_t*)calloc(1, sizeof(PLMNIdentity_t));
372 plmnidstr->buf = (uint8_t*)calloc(plmnid_size, 1);
373 plmnidstr->size = plmnid_size;
374 memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
376 measLabel->plmnID = plmnidstr;
377 measLabel->sliceID = snssai;
379 labelItem->measLabel = *measLabel;
380 ASN_SEQUENCE_ADD(&labelList->list, labelItem);
381 measItem->labelInfoList = *labelList;
382 if (labelList) free(labelList);
383 MeasurementType_t measType;
384 measType.present = MeasurementType_PR_measID;
385 measType.choice.measID = 1;
386 measItem->measType = measType;
387 ASN_SEQUENCE_ADD(&measList->list, measItem);
389 format->measInfoList = measList;
391 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
392 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
394 indicationmessage->indicationMessage_formats.present = pres;
395 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
397 char error_buf[300] = {
402 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
406 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
410 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
412 long dl_prb_usage = 50;
413 long ul_prb_usage = 70;
415 asn_codec_ctx_t* opt_cod;
417 GranularityPeriod_t period = 1;
418 MeasurementData_t measData;
419 MeasurementDataItem_t measDataItem;
420 MeasurementRecord_t measDataItem_record;
421 MeasurementRecordItem_t measDataRecordItem;
423 measDataRecordItem.present = MeasurementRecordItem_PR_real;
424 measDataRecordItem.choice.real = 1.5;
426 ASN_SEQUENCE_ADD(&measDataItem_record.list, &measDataRecordItem);
428 measDataItem.measRecord = measDataItem_record;
429 ASN_SEQUENCE_ADD(&measData.list, &measDataItem);
431 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
432 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
433 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
435 format->granulPeriod = .
436 format->measData = measData;
438 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
439 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
441 indicationmessage->indicationMessage_formats.present = pres;
443 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
444 if (format) free(format);
446 char error_buf[300] = {
451 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
455 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
458 uint8_t e2smbuffer[8192] = {
461 size_t e2smbuffer_size = 8192;
464 asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage,
465 indicationmessage, e2smbuffer, e2smbuffer_size);
467 if (er.encoded == -1) {
468 LOG_E("Failed to serialize message. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
470 } else if (er.encoded > e2smbuffer_size) {
471 LOG_E("Buffer of size %zu is too small for %s, need %zu\n", e2smbuffer_size, asn_DEF_E2SM_KPM_IndicationMessage.name, er.encoded);
476 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage) {
478 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
479 //std::string gn = "GNBCUUP5";
480 //std::vector<uint8_t> gnvec(gn.begin(), gn.end());
481 //uint8_t *buf = &gnvec[0];
482 uint8_t *buf = (uint8_t*)"GNBCUUP5";
483 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
484 gnbcuupname->size = 8;
485 gnbcuupname->buf = (uint8_t*)calloc(1,8);
486 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
489 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
492 bytesdl->buf = (uint8_t*)calloc(1,1);
493 memcpy(bytesdl->buf, buffer,1);
496 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
499 bytesul->buf = (uint8_t*)calloc(1,1);
500 memcpy(bytesul->buf, buffer1, 1);
503 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
504 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
505 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl;
506 fqilistitem->pDCPBytesUL = bytesul;
510 // std::string sl = "SLICE4";
511 // std::vector<uint8_t> slvec(sl.begin(), sl.end());
512 // uint8_t *buf1 = &slvec[0];
513 uint8_t *buf1 = (uint8_t*)"4";
514 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
516 sst->buf = (uint8_t*)calloc(1,6);
517 memcpy(sst->buf,buf1,sst->size);
519 // std::string sd = "SD1";
520 // std::vector<uint8_t> sdvec(sd.begin(), sd.end());
521 // uint8_t *bufz = &sdvec[0];
522 uint8_t *bufz = (uint8_t*)"SD1";
523 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
525 sds->buf = (uint8_t*)calloc(1,3);
526 memcpy(sds->buf, bufz, sds->size);
529 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
530 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
531 snssai->sST.buf = (uint8_t*)calloc(1,1);
532 snssai->sST.size = 1;
533 memcpy(snssai->sST.buf, buf1, 1);
534 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
535 snssai->sD->buf = (uint8_t*)calloc(1,3);
536 snssai->sD->size = 3;
537 memcpy(snssai->sD->buf, bufz, 3);
541 SliceToReportListItem_t *slicelistitem =
542 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
543 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
544 slicelistitem->sliceID = *snssai;
545 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
547 asn_codec_ctx_t *opt_cod;
550 uint8_t e2smbuffera[8192];
551 size_t e2smbuffer_sizea = 8192;
556 asn_encode_to_buffer(opt_cod,
557 ATS_ALIGNED_BASIC_PER,
558 &asn_DEF_SliceToReportListItem,
559 slicelistitem, e2smbuffera, e2smbuffer_sizea);
560 fprintf(stderr, "inner er encded is %d\n", era.encoded);
561 fprintf(stderr, "after encoding message");
565 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
566 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
567 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
569 uint8_t *buf2 = (uint8_t*)"747";
570 // std::string pl = "PLMNID7";
571 // std::vector<uint8_t> plvec(pl.begin(), pl.end());
572 // uint8_t *buf2 = &plvec[0];
574 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
575 plmnid->buf = (uint8_t*)calloc(3,1);
577 memcpy(plmnid->buf, buf2, plmnid->size);
580 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
581 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
582 plmnidlist->pLMN_Identity = *plmnid;
583 plmnidlist->cu_UP_PM_5GC = pm_format;
585 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
586 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
587 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
592 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
593 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
594 listitem1->interface_type = 2;
595 listitem1->o_CU_UP_PM_Container = *meas_cont;
597 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
598 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
599 cuupcont->gNB_CU_UP_Name = gnbcuupname;
600 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
602 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
604 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
605 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
606 pfcontainer->present = pres1;
607 pfcontainer->choice.oCU_UP = *cuupcont;
609 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
610 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
611 containers_list->performanceContainer = pfcontainer;
613 E2SM_KPM_IndicationMessage_Format1_t *format =
614 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
615 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
617 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
619 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
621 indicationmessage->present = pres;
623 indicationmessage->choice.indicationMessage_Format1 = *format;
625 char *error_buf = (char*)calloc(300, sizeof(char));
628 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
629 printf("error length %d\n", errlen);
630 printf("error buf %s\n", error_buf);
632 xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
635 uint8_t e2smbuffer[8192];
636 size_t e2smbuffer_size = 8192;
638 uint8_t e2smbuffer2[8192];
639 size_t e2smbuffer_size2 = 8192;
642 asn_encode_to_buffer(opt_cod,
643 ATS_ALIGNED_BASIC_PER,
644 &asn_DEF_E2SM_KPM_IndicationMessage,
645 indicationmessage, e2smbuffer, e2smbuffer_size);
647 fprintf(stderr, "er encded is %d\n", er.encoded);
648 fprintf(stderr, "after encoding message");
654 void encode_kpm_bak(E2SM_KPM_IndicationMessage_t* indicationmessage) {
655 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
656 std::string gn = "GNBCUUP5";
657 std::vector<uint8_t> gnvec(gn.begin(), gn.end());
658 uint8_t *buf = &gnvec[0];
659 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
660 gnbcuupname->size = 8;
661 gnbcuupname->buf = (uint8_t*)calloc(1,8);
662 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
665 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
668 bytesdl->buf = (uint8_t*)calloc(1,1);
669 memcpy(bytesdl->buf, buffer,1);
672 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
675 bytesul->buf = (uint8_t*)calloc(1,1);
676 memcpy(bytesul->buf, buffer1, 1);
679 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
680 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
681 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl; fqilistitem->pDCPBytesUL
686 std::string sl = "SLICE4";
687 std::vector<uint8_t> slvec(sl.begin(), sl.end());
688 // uint8_t *buf1 = &slvec[0];
689 uint8_t *buf1 = (uint8_t*)"SLICE4";
690 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
692 sst->buf = (uint8_t*)calloc(1,6);
693 memcpy(sst->buf,buf1,sst->size);
695 std::string sd = "SD1";
696 std::vector<uint8_t> sdvec(sd.begin(), sd.end());
697 // uint8_t *bufz = &sdvec[0];
698 uint8_t *bufz = (uint8_t*)"SD1";
699 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
701 sds->buf = (uint8_t*)calloc(1,3);
702 memcpy(sds->buf, bufz, sds->size);
705 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
706 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
707 snssai->sST.buf = (uint8_t*)calloc(6,1);
708 snssai->sST.size = 6;
709 memcpy(snssai->sST.buf, buf1, 6);
710 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
711 snssai->sD->buf = (uint8_t*)calloc(1,3);
712 snssai->sD->size = 3;
713 memcpy(snssai->sD->buf, bufz, 3);
717 SliceToReportListItem_t *slicelistitem =
718 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
719 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
720 slicelistitem->sliceID = *snssai;
721 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
723 uint8_t e2smbuffera[8192];
724 size_t e2smbuffer_sizea = 8192;
727 asn_encode_to_buffer(nullptr,
728 ATS_ALIGNED_BASIC_PER,
729 &asn_DEF_SliceToReportListItem,
730 slicelistitem, e2smbuffera, e2smbuffer_sizea);
731 fprintf(stderr, "inner er encded is %d\n", era.encoded);
732 fprintf(stderr, "after encoding message");
734 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
735 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
736 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
738 std::string pl = "PLMNID7";
739 std::vector<uint8_t> plvec(pl.begin(), pl.end());
740 uint8_t *buf2 = &plvec[0];
742 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
743 plmnid->buf = (uint8_t*)calloc(1,7);
745 memcpy(plmnid->buf, buf2, plmnid->size);
748 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
749 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
750 plmnidlist->pLMN_Identity = *plmnid;
751 plmnidlist->cu_UP_PM_5GC = pm_format;
753 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
754 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
755 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
760 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
761 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
762 listitem1->interface_type = 2;
763 listitem1->o_CU_UP_PM_Container = *meas_cont;
765 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
766 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
767 cuupcont->gNB_CU_UP_Name = gnbcuupname;
768 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
770 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
772 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
773 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
774 pfcontainer->present = pres1;
775 pfcontainer->choice.oCU_UP = *cuupcont;
777 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
778 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
779 containers_list->performanceContainer = pfcontainer;
781 E2SM_KPM_IndicationMessage_Format1_t *format =
782 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
783 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
785 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
787 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
789 indicationmessage->present = pres;
791 indicationmessage->choice.indicationMessage_Format1 = *format;
793 char *error_buf = (char*)calloc(300, sizeof(char));
796 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
797 printf("error length %d\n", errlen);
798 printf("error buf %s\n", error_buf);
801 uint8_t e2smbuffer[8192];
802 size_t e2smbuffer_size = 8192;
804 uint8_t e2smbuffer2[8192];
805 size_t e2smbuffer_size2 = 8192;
808 asn_encode_to_buffer(nullptr,
809 ATS_ALIGNED_BASIC_PER,
810 &asn_DEF_E2SM_KPM_IndicationMessage,
811 indicationmessage, e2smbuffer, e2smbuffer_size);
813 fprintf(stderr, "er encded is %d\n", er.encoded);
814 fprintf(stderr, "after encoding message");