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 void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc_desc) {
31 uint8_t* short_name = (uint8_t*)"ORAN-E2SM-KPM";
32 uint8_t* func_desc = (uint8_t*)"KPM Monitor";
33 uint8_t* e2sm_odi = (uint8_t*)"OID123";
35 LOG_I("short_name: %s, func_desc: %s, e2sm_odi: %s", short_name, func_desc, e2sm_odi);
39 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
41 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size = strlen((char*)short_name);
42 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf =
43 (uint8_t*)calloc(strlen((char*)short_name), sizeof(uint8_t));
44 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_ShortName.buf, short_name,
45 ranfunc_desc->ranFunction_Name.ranFunction_ShortName.size);
47 ranfunc_desc->ranFunction_Name.ranFunction_Description.buf =
48 (uint8_t*)calloc(1, strlen((char*)func_desc));
49 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, func_desc,
50 strlen((char*)func_desc));
51 ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen((char*)func_desc);
52 ranfunc_desc->ranFunction_Name.ranFunction_Instance = &inst;
54 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf =
55 (uint8_t*)calloc(1, strlen((char*)e2sm_odi));
56 memcpy(ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, e2sm_odi,
57 strlen((char*)e2sm_odi));
58 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen((char*)e2sm_odi);
60 LOG_I("Initialize event trigger style list structure");
62 RIC_EventTriggerStyle_Item_t* trigger_style =
63 (RIC_EventTriggerStyle_Item_t*)calloc(1, sizeof(RIC_EventTriggerStyle_Item_t));
64 trigger_style->ric_EventTriggerStyle_Type = 1;
65 uint8_t* style_name = (uint8_t*)"Periodic Report";
66 trigger_style->ric_EventTriggerStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)style_name));
67 memcpy(trigger_style->ric_EventTriggerStyle_Name.buf, style_name, strlen((char*)style_name));
68 trigger_style->ric_EventTriggerStyle_Name.size = strlen((char*)style_name);
69 trigger_style->ric_EventTriggerFormat_Type = 5;
71 ranfunc_desc->ric_EventTriggerStyle_List =
72 (E2SM_KPM_RANfunction_Description::
73 E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List*)
74 calloc(1, sizeof(E2SM_KPM_RANfunction_Description::
75 E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List));
77 int ret = ASN_SEQUENCE_ADD(&ranfunc_desc->ric_EventTriggerStyle_List->list, trigger_style);
79 LOG_I("Initialize report style structure");
81 MeasurementInfo_Action_List_t* measInfo_Action_List =
82 (MeasurementInfo_Action_List_t*)calloc(1, sizeof(MeasurementInfo_Action_List_t));
83 uint8_t* measured_metrics[] = {(uint8_t*)"CQI", (uint8_t*)"RSRP", (uint8_t*)"RSRQ"};
85 for (int i = 0; i < 3; i++) {
86 uint8_t* metrics = measured_metrics[i];
87 MeasurementInfo_Action_Item_t* measItem =
88 (MeasurementInfo_Action_Item_t*)calloc(1, sizeof(MeasurementInfo_Action_Item_t));
89 measItem->measName.buf = (uint8_t*)calloc(1, strlen((char*)metrics));
90 memcpy(measItem->measName.buf, metrics, strlen((char*)metrics));
92 measItem->measName.size = strlen((char*)metrics);
94 measItem->measID = (MeasurementTypeID_t*)calloc(1, sizeof(MeasurementTypeID_t));
95 *measItem->measID = i;
97 ASN_SEQUENCE_ADD(&measInfo_Action_List->list, measItem);
100 RIC_ReportStyle_Item_t* report_style1 =
101 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
102 report_style1->ric_ReportStyle_Type = 1;
104 uint8_t* buf5 = (uint8_t*)"E2 Node Measurement";
105 report_style1->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf5));
106 memcpy(report_style1->ric_ReportStyle_Name.buf, buf5, strlen((char*)buf5));
107 report_style1->ric_ReportStyle_Name.size = strlen((char*)buf5);
108 report_style1->ric_ActionFormat_Type = 1;
109 report_style1->ric_IndicationHeaderFormat_Type = 1;
110 report_style1->ric_IndicationMessageFormat_Type = 1;
111 report_style1->measInfo_Action_List = *measInfo_Action_List;
113 RIC_ReportStyle_Item_t* report_style2 =
114 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
115 report_style2->ric_ReportStyle_Type = 2;
117 uint8_t* buf6 = (uint8_t*)"E2 Node Measurement for a single UE";
118 report_style2->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf6));
119 memcpy(report_style2->ric_ReportStyle_Name.buf, buf6, strlen((char*)buf6));
120 report_style2->ric_ReportStyle_Name.size = strlen((char*)buf6);
121 report_style2->ric_ActionFormat_Type = 2;
122 report_style2->ric_IndicationHeaderFormat_Type = 1;
123 report_style2->ric_IndicationMessageFormat_Type = 1;
124 report_style2->measInfo_Action_List = *measInfo_Action_List;
126 RIC_ReportStyle_Item_t* report_style3 =
127 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
128 report_style3->ric_ReportStyle_Type = 3;
130 uint8_t* buf7 = (uint8_t*)"Condition-based, UE-level E2 Node Measurement";
132 report_style3->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf7));
133 memcpy(report_style3->ric_ReportStyle_Name.buf, buf7, strlen((char*)buf7));
134 report_style3->ric_ReportStyle_Name.size = strlen((char*)buf7);
135 report_style3->ric_ActionFormat_Type = 3;
136 report_style3->ric_IndicationHeaderFormat_Type = 1;
137 report_style3->ric_IndicationMessageFormat_Type = 2;
138 report_style3->measInfo_Action_List = *measInfo_Action_List;
140 RIC_ReportStyle_Item_t* report_style4 =
141 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
142 report_style4->ric_ReportStyle_Type = 4;
144 uint8_t* buf8 = (uint8_t*)"Common Condition-based, UE-level Measurement";
146 report_style4->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf8));
147 memcpy(report_style4->ric_ReportStyle_Name.buf, buf8, strlen((char*)buf8));
148 report_style4->ric_ReportStyle_Name.size = strlen((char*)buf8);
149 report_style4->ric_ActionFormat_Type = 4;
150 report_style4->ric_IndicationHeaderFormat_Type = 1;
151 report_style4->ric_IndicationMessageFormat_Type = 3;
152 report_style4->measInfo_Action_List = *measInfo_Action_List;
154 RIC_ReportStyle_Item_t* report_style5 =
155 (RIC_ReportStyle_Item_t*)calloc(1, sizeof(RIC_ReportStyle_Item_t));
156 report_style5->ric_ReportStyle_Type = 5;
158 uint8_t* buf9 = (uint8_t*)"E2 Node Measurement for multiple UEs";
160 report_style5->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1, strlen((char*)buf9));
161 memcpy(report_style5->ric_ReportStyle_Name.buf, buf9, strlen((char*)buf9));
162 report_style5->ric_ReportStyle_Name.size = strlen((char*)buf9);
163 report_style5->ric_ActionFormat_Type = 5;
164 report_style5->ric_IndicationHeaderFormat_Type = 1;
165 report_style5->ric_IndicationMessageFormat_Type = 3;
166 report_style5->measInfo_Action_List = *measInfo_Action_List;
168 ranfunc_desc->ric_ReportStyle_List =
169 (E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__ric_ReportStyle_List*)
170 calloc(1, sizeof(E2SM_KPM_RANfunction_Description::
171 E2SM_KPM_RANfunction_Description__ric_ReportStyle_List));
173 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style1);
174 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style2);
175 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style3);
176 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style4);
177 ASN_SEQUENCE_ADD(&ranfunc_desc->ric_ReportStyle_List->list, report_style5);
179 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
182 void kpm_report_indication_header_initialized(E2SM_KPM_IndicationHeader_t* ihead,
183 uint8_t* plmnid_buf, uint8_t* sst_buf,
184 uint8_t* sd_buf, long fqival, long qcival,
185 uint8_t* nrcellid_buf, uint8_t* gnbid_buf,
186 int gnbid_unused, uint8_t* cuupid_buf,
187 uint8_t* duid_buf, uint8_t* cuupname_buf) {
188 LOG_I("Start initializing mocked indication header");
189 E2SM_KPM_IndicationHeader_Format1_t* ind_header =
190 (E2SM_KPM_IndicationHeader_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationHeader_Format1_t));
192 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, ind_header);
194 uint8_t* buf2 = (uint8_t*)"ORANSim";
195 ind_header->senderName = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
196 ind_header->senderName->buf = (uint8_t*)calloc(1, strlen((char*)buf2));
197 memcpy(ind_header->senderName->buf, buf2, strlen((char*)buf2));
198 ind_header->senderName->size = strlen((char*)buf2);
200 uint8_t* buf3 = (uint8_t*)"simulator";
201 ind_header->senderType = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
202 ind_header->senderType->buf = (uint8_t*)calloc(1, strlen((char*)buf3));
203 memcpy(ind_header->senderType->buf, buf3, strlen((char*)buf3));
204 ind_header->senderType->size = strlen((char*)buf3);
206 uint8_t* buf4 = (uint8_t*)"ORAN-SC";
207 ind_header->vendorName = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
208 ind_header->vendorName->buf = (uint8_t*)calloc(1, strlen((char*)buf4));
209 memcpy(ind_header->vendorName->buf, buf4, strlen((char*)buf4));
210 ind_header->vendorName->size = strlen((char*)buf4);
212 uint8_t* buf = (uint8_t*)"20200613";
213 TimeStamp_t* ts = (TimeStamp_t*)calloc(1, sizeof(TimeStamp_t));
214 ts->buf = (uint8_t*)calloc(strlen((char*)buf), 1);
215 ts->size = strlen((char*)buf);
216 memcpy(ts->buf, buf, ts->size);
218 ind_header->colletStartTime = *ts;
221 uint8_t* buf5 = (uint8_t*)"1.0";
222 ind_header->fileFormatversion = (PrintableString_t*)calloc(1, sizeof(PrintableString_t));
223 ind_header->fileFormatversion->buf = (uint8_t*)calloc(1, strlen((char*)buf5));
224 memcpy(ind_header->fileFormatversion->buf, buf5, strlen((char*)buf5));
225 ind_header->fileFormatversion->size = strlen((char*)buf5);
227 ihead->indicationHeader_formats.present =
228 E2SM_KPM_IndicationHeader__indicationHeader_formats_PR_indicationHeader_Format1;
229 ihead->indicationHeader_formats.choice.indicationHeader_Format1 = ind_header;
231 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationHeader, ihead);
234 void ue_meas_kpm_report_indication_message_initialized(
235 E2SM_KPM_IndicationMessage_t* indicationmessage, uint8_t* nrcellid_buf, uint8_t* crnti_buf,
236 const uint8_t* serving_buf, const uint8_t* neighbor_buf) {
237 GranularityPeriod_t period = 1;
238 MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
239 MeasurementDataItem_t* measDataItem =
240 (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
241 MeasurementRecord_t* measDataItem_record =
242 (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
243 MeasurementRecordItem_t* measDataRecordItem =
244 (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
246 unsigned long val = 1;
247 measDataRecordItem->present = MeasurementRecordItem_PR_integer;
248 measDataRecordItem->choice.integer = val;
250 ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
252 measDataItem->measRecord = *measDataItem_record;
254 measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
255 *measDataItem->incompleteFlag = incomplete;
256 ASN_SEQUENCE_ADD(&measData->list, measDataItem);
258 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
259 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
260 format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
261 *format->granulPeriod = period;
262 format->measData = *measData;
264 MeasurementInfoList_t* measList =
265 (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
266 MeasurementInfoItem_t* measItem =
267 (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
268 LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
269 LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
270 MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
272 uint8_t* plmnid_buf = (uint8_t*)"747";
273 uint8_t* sst_buf = (uint8_t*)"1";
274 uint8_t* sd_buf = (uint8_t*)"100";
276 S_NSSAI_t* snssai = (S_NSSAI_t*)calloc(1, sizeof(S_NSSAI_t));
277 snssai->sST.buf = (uint8_t*)calloc(strlen((char*)sst_buf), sizeof(uint8_t));
278 snssai->sST.size = strlen((char*)sst_buf);
279 memcpy(snssai->sST.buf, sst_buf, strlen((char*)sst_buf));
281 snssai->sD = (SD_t*)calloc(1, sizeof(SD_t));
282 snssai->sD->buf = (uint8_t*)calloc(strlen((char*)sd_buf), sizeof(uint8_t));
283 snssai->sD->size = strlen((char*)sd_buf);
284 memcpy(snssai->sD->buf, sd_buf, strlen((char*)sd_buf));
286 int plmnid_size = strlen((char*)plmnid_buf);
287 PLMNIdentity_t* plmnidstr = (PLMNIdentity_t*)calloc(1, sizeof(PLMNIdentity_t));
288 plmnidstr->buf = (uint8_t*)calloc(plmnid_size, 1);
289 plmnidstr->size = plmnid_size;
290 memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
292 measLabel->plmnID = plmnidstr;
293 measLabel->sliceID = snssai;
295 labelItem->measLabel = *measLabel;
296 ASN_SEQUENCE_ADD(&labelList->list, labelItem);
297 measItem->labelInfoList = *labelList;
298 if (labelList) free(labelList);
299 MeasurementType_t measType;
300 measType.present = MeasurementType_PR_measID;
301 measType.choice.measID = 1;
302 measItem->measType = measType;
303 ASN_SEQUENCE_ADD(&measList->list, measItem);
305 format->measInfoList = measList;
307 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
308 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
310 indicationmessage->indicationMessage_formats.present = pres;
311 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
313 char error_buf[300] = {
318 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
322 LOG_I("Constraint validation of indication message failed: %s", error_buf);
325 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
328 void cell_meas_kpm_report_indication_message_style_1_initialized(
329 E2SM_KPM_IndicationMessage_t* indicationmessage, long fiveqi, long dl_prb_usage,
330 long ul_prb_usage, uint8_t* nrcellid_buf, long* dl_prbs, long* ul_prbs) {
331 LOG_I("Preparing indication message for cell measurement report");
333 asn_codec_ctx_t* opt_cod;
335 GranularityPeriod_t period = 1;
336 MeasurementData_t* measData = (MeasurementData_t*)calloc(1, sizeof(MeasurementData_t));
337 MeasurementDataItem_t* measDataItem =
338 (MeasurementDataItem_t*)calloc(1, sizeof(MeasurementDataItem_t));
339 MeasurementRecord_t* measDataItem_record =
340 (MeasurementRecord_t*)calloc(1, sizeof(MeasurementRecord_t));
341 MeasurementRecordItem_t* measDataRecordItem =
342 (MeasurementRecordItem_t*)calloc(1, sizeof(MeasurementRecordItem_t));
344 measDataRecordItem->present = MeasurementRecordItem_PR_integer;
345 measDataRecordItem->choice.integer = 1;
347 ASN_SEQUENCE_ADD(&measDataItem_record->list, measDataRecordItem);
349 measDataItem->measRecord = *measDataItem_record;
350 measDataItem->incompleteFlag = (long*)calloc(1, sizeof(long));
351 *measDataItem->incompleteFlag = 0;
352 ASN_SEQUENCE_ADD(&measData->list, measDataItem);
354 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
355 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
356 format->granulPeriod = (GranularityPeriod_t*)calloc(1, sizeof(GranularityPeriod_t));
357 *format->granulPeriod = period;
358 format->measData = *measData;
360 MeasurementInfoList_t* measList =
361 (MeasurementInfoList_t*)calloc(1, sizeof(MeasurementInfoList_t));
362 MeasurementInfoItem_t* measItem =
363 (MeasurementInfoItem_t*)calloc(1, sizeof(MeasurementInfoItem_t));
364 LabelInfoList_t* labelList = (LabelInfoList_t*)calloc(1, sizeof(LabelInfoList_t));
365 LabelInfoItem_t* labelItem = (LabelInfoItem_t*)calloc(1, sizeof(LabelInfoItem_t));
366 MeasurementLabel_t* measLabel = (MeasurementLabel_t*)calloc(1, sizeof(MeasurementLabel_t));
368 uint8_t* plmnid_buf = (uint8_t*)"747";
369 uint8_t* sst_buf = (uint8_t*)"1";
370 uint8_t* sd_buf = (uint8_t*)"100";
372 S_NSSAI_t* snssai = (S_NSSAI_t*)calloc(1, sizeof(S_NSSAI_t));
373 snssai->sST.buf = (uint8_t*)calloc(strlen((char*)sst_buf), sizeof(uint8_t));
374 snssai->sST.size = strlen((char*)sst_buf);
375 memcpy(snssai->sST.buf, sst_buf, strlen((char*)sst_buf));
377 snssai->sD = (SD_t*)calloc(1, sizeof(SD_t));
378 snssai->sD->buf = (uint8_t*)calloc(strlen((char*)sd_buf), sizeof(uint8_t));
379 snssai->sD->size = strlen((char*)sd_buf);
380 memcpy(snssai->sD->buf, sd_buf, strlen((char*)sd_buf));
382 int plmnid_size = strlen((char*)plmnid_buf);
383 PLMNIdentity_t* plmnidstr = (PLMNIdentity_t*)calloc(1, sizeof(PLMNIdentity_t));
384 plmnidstr->buf = (uint8_t*)calloc(plmnid_size, 1);
385 plmnidstr->size = plmnid_size;
386 memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
388 measLabel->plmnID = plmnidstr;
389 measLabel->sliceID = snssai;
391 labelItem->measLabel = *measLabel;
392 ASN_SEQUENCE_ADD(&labelList->list, labelItem);
393 measItem->labelInfoList = *labelList;
394 if (labelList) free(labelList);
395 MeasurementType_t measType;
396 measType.present = MeasurementType_PR_measID;
397 measType.choice.measID = 1;
398 measItem->measType = measType;
399 ASN_SEQUENCE_ADD(&measList->list, measItem);
401 format->measInfoList = measList;
403 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
404 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
406 indicationmessage->indicationMessage_formats.present = pres;
407 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
409 char error_buf[300] = {
414 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
418 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
420 // xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
423 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
425 long dl_prb_usage = 50;
426 long ul_prb_usage = 70;
428 asn_codec_ctx_t* opt_cod;
430 GranularityPeriod_t period = 1;
431 MeasurementData_t measData;
432 MeasurementDataItem_t measDataItem;
433 MeasurementRecord_t measDataItem_record;
434 MeasurementRecordItem_t measDataRecordItem;
436 measDataRecordItem.present = MeasurementRecordItem_PR_real;
437 measDataRecordItem.choice.real = 1.5;
439 ASN_SEQUENCE_ADD(&measDataItem_record.list, &measDataRecordItem);
441 measDataItem.measRecord = measDataItem_record;
442 ASN_SEQUENCE_ADD(&measData.list, &measDataItem);
444 E2SM_KPM_IndicationMessage_Format1_t* format = (E2SM_KPM_IndicationMessage_Format1_t*)calloc(
445 1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
446 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
448 format->granulPeriod = .
449 format->measData = measData;
451 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR pres =
452 E2SM_KPM_IndicationMessage__indicationMessage_formats_PR_indicationMessage_Format1;
454 indicationmessage->indicationMessage_formats.present = pres;
456 indicationmessage->indicationMessage_formats.choice.indicationMessage_Format1 = format;
457 if (format) free(format);
459 char error_buf[300] = {
464 int ret = asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf,
468 LOG_I("Constraint validation of indication message failed: %s\n", error_buf);
471 uint8_t e2smbuffer[8192] = {
474 size_t e2smbuffer_size = 8192;
477 asn_encode_to_buffer(opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage,
478 indicationmessage, e2smbuffer, e2smbuffer_size);
480 if (er.encoded == -1) {
481 LOG_I("Failed to serialize message. Detail: %s.\n", asn_DEF_E2SM_KPM_IndicationMessage.name);
482 } else if (er.encoded > e2smbuffer_size) {
483 LOG_I("Buffer of size %zu is too small for %s, need %zu\n", e2smbuffer_size, asn_DEF_E2SM_KPM_IndicationMessage.name, er.encoded);
487 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage) {
489 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
490 //std::string gn = "GNBCUUP5";
491 //std::vector<uint8_t> gnvec(gn.begin(), gn.end());
492 //uint8_t *buf = &gnvec[0];
493 uint8_t *buf = (uint8_t*)"GNBCUUP5";
494 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
495 gnbcuupname->size = 8;
496 gnbcuupname->buf = (uint8_t*)calloc(1,8);
497 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
500 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
503 bytesdl->buf = (uint8_t*)calloc(1,1);
504 memcpy(bytesdl->buf, buffer,1);
507 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
510 bytesul->buf = (uint8_t*)calloc(1,1);
511 memcpy(bytesul->buf, buffer1, 1);
514 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
515 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
516 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl;
517 fqilistitem->pDCPBytesUL = bytesul;
521 // std::string sl = "SLICE4";
522 // std::vector<uint8_t> slvec(sl.begin(), sl.end());
523 // uint8_t *buf1 = &slvec[0];
524 uint8_t *buf1 = (uint8_t*)"4";
525 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
527 sst->buf = (uint8_t*)calloc(1,6);
528 memcpy(sst->buf,buf1,sst->size);
530 // std::string sd = "SD1";
531 // std::vector<uint8_t> sdvec(sd.begin(), sd.end());
532 // uint8_t *bufz = &sdvec[0];
533 uint8_t *bufz = (uint8_t*)"SD1";
534 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
536 sds->buf = (uint8_t*)calloc(1,3);
537 memcpy(sds->buf, bufz, sds->size);
540 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
541 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
542 snssai->sST.buf = (uint8_t*)calloc(1,1);
543 snssai->sST.size = 1;
544 memcpy(snssai->sST.buf, buf1, 1);
545 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
546 snssai->sD->buf = (uint8_t*)calloc(1,3);
547 snssai->sD->size = 3;
548 memcpy(snssai->sD->buf, bufz, 3);
552 SliceToReportListItem_t *slicelistitem =
553 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
554 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
555 slicelistitem->sliceID = *snssai;
556 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
558 asn_codec_ctx_t *opt_cod;
561 uint8_t e2smbuffera[8192];
562 size_t e2smbuffer_sizea = 8192;
567 asn_encode_to_buffer(opt_cod,
568 ATS_ALIGNED_BASIC_PER,
569 &asn_DEF_SliceToReportListItem,
570 slicelistitem, e2smbuffera, e2smbuffer_sizea);
571 fprintf(stderr, "inner er encded is %d\n", era.encoded);
572 fprintf(stderr, "after encoding message");
576 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
577 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
578 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
580 uint8_t *buf2 = (uint8_t*)"747";
581 // std::string pl = "PLMNID7";
582 // std::vector<uint8_t> plvec(pl.begin(), pl.end());
583 // uint8_t *buf2 = &plvec[0];
585 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
586 plmnid->buf = (uint8_t*)calloc(3,1);
588 memcpy(plmnid->buf, buf2, plmnid->size);
591 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
592 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
593 plmnidlist->pLMN_Identity = *plmnid;
594 plmnidlist->cu_UP_PM_5GC = pm_format;
596 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
597 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
598 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
603 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
604 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
605 listitem1->interface_type = 2;
606 listitem1->o_CU_UP_PM_Container = *meas_cont;
608 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
609 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
610 cuupcont->gNB_CU_UP_Name = gnbcuupname;
611 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
613 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
615 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
616 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
617 pfcontainer->present = pres1;
618 pfcontainer->choice.oCU_UP = *cuupcont;
620 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
621 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
622 containers_list->performanceContainer = pfcontainer;
624 E2SM_KPM_IndicationMessage_Format1_t *format =
625 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
626 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
628 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
630 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
632 indicationmessage->present = pres;
634 indicationmessage->choice.indicationMessage_Format1 = *format;
636 char *error_buf = (char*)calloc(300, sizeof(char));
639 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
640 printf("error length %d\n", errlen);
641 printf("error buf %s\n", error_buf);
643 xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
646 uint8_t e2smbuffer[8192];
647 size_t e2smbuffer_size = 8192;
649 uint8_t e2smbuffer2[8192];
650 size_t e2smbuffer_size2 = 8192;
653 asn_encode_to_buffer(opt_cod,
654 ATS_ALIGNED_BASIC_PER,
655 &asn_DEF_E2SM_KPM_IndicationMessage,
656 indicationmessage, e2smbuffer, e2smbuffer_size);
658 fprintf(stderr, "er encded is %d\n", er.encoded);
659 fprintf(stderr, "after encoding message");
665 void encode_kpm_bak(E2SM_KPM_IndicationMessage_t* indicationmessage) {
666 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
667 std::string gn = "GNBCUUP5";
668 std::vector<uint8_t> gnvec(gn.begin(), gn.end());
669 uint8_t *buf = &gnvec[0];
670 OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
671 gnbcuupname->size = 8;
672 gnbcuupname->buf = (uint8_t*)calloc(1,8);
673 memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
676 INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
679 bytesdl->buf = (uint8_t*)calloc(1,1);
680 memcpy(bytesdl->buf, buffer,1);
683 INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
686 bytesul->buf = (uint8_t*)calloc(1,1);
687 memcpy(bytesul->buf, buffer1, 1);
690 FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1,
691 sizeof(FQIPERSlicesPerPlmnListItem_t)); ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem,
692 fqilistitem); fqilistitem->fiveQI = 9; fqilistitem->pDCPBytesDL = bytesdl; fqilistitem->pDCPBytesUL
697 std::string sl = "SLICE4";
698 std::vector<uint8_t> slvec(sl.begin(), sl.end());
699 // uint8_t *buf1 = &slvec[0];
700 uint8_t *buf1 = (uint8_t*)"SLICE4";
701 OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
703 sst->buf = (uint8_t*)calloc(1,6);
704 memcpy(sst->buf,buf1,sst->size);
706 std::string sd = "SD1";
707 std::vector<uint8_t> sdvec(sd.begin(), sd.end());
708 // uint8_t *bufz = &sdvec[0];
709 uint8_t *bufz = (uint8_t*)"SD1";
710 OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
712 sds->buf = (uint8_t*)calloc(1,3);
713 memcpy(sds->buf, bufz, sds->size);
716 SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
717 ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
718 snssai->sST.buf = (uint8_t*)calloc(6,1);
719 snssai->sST.size = 6;
720 memcpy(snssai->sST.buf, buf1, 6);
721 snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
722 snssai->sD->buf = (uint8_t*)calloc(1,3);
723 snssai->sD->size = 3;
724 memcpy(snssai->sD->buf, bufz, 3);
728 SliceToReportListItem_t *slicelistitem =
729 (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
730 ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
731 slicelistitem->sliceID = *snssai;
732 int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
734 uint8_t e2smbuffera[8192];
735 size_t e2smbuffer_sizea = 8192;
738 asn_encode_to_buffer(nullptr,
739 ATS_ALIGNED_BASIC_PER,
740 &asn_DEF_SliceToReportListItem,
741 slicelistitem, e2smbuffera, e2smbuffer_sizea);
742 fprintf(stderr, "inner er encded is %d\n", era.encoded);
743 fprintf(stderr, "after encoding message");
745 FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
746 ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
747 ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
749 std::string pl = "PLMNID7";
750 std::vector<uint8_t> plvec(pl.begin(), pl.end());
751 uint8_t *buf2 = &plvec[0];
753 OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
754 plmnid->buf = (uint8_t*)calloc(1,7);
756 memcpy(plmnid->buf, buf2, plmnid->size);
759 PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
760 ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
761 plmnidlist->pLMN_Identity = *plmnid;
762 plmnidlist->cu_UP_PM_5GC = pm_format;
764 CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1,
765 sizeof(CUUPMeasurement_Container_t)); ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container,
766 meas_cont); ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
771 PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1,
772 sizeof(PF_ContainerListItem_t)); ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
773 listitem1->interface_type = 2;
774 listitem1->o_CU_UP_PM_Container = *meas_cont;
776 OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
777 ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
778 cuupcont->gNB_CU_UP_Name = gnbcuupname;
779 ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
781 PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
783 PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
784 ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
785 pfcontainer->present = pres1;
786 pfcontainer->choice.oCU_UP = *cuupcont;
788 PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1,
789 sizeof(PM_Containers_List_t)); ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
790 containers_list->performanceContainer = pfcontainer;
792 E2SM_KPM_IndicationMessage_Format1_t *format =
793 (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
794 ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
796 ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
798 E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
800 indicationmessage->present = pres;
802 indicationmessage->choice.indicationMessage_Format1 = *format;
804 char *error_buf = (char*)calloc(300, sizeof(char));
807 asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
808 printf("error length %d\n", errlen);
809 printf("error buf %s\n", error_buf);
812 uint8_t e2smbuffer[8192];
813 size_t e2smbuffer_size = 8192;
815 uint8_t e2smbuffer2[8192];
816 size_t e2smbuffer_size2 = 8192;
819 asn_encode_to_buffer(nullptr,
820 ATS_ALIGNED_BASIC_PER,
821 &asn_DEF_E2SM_KPM_IndicationMessage,
822 indicationmessage, e2smbuffer, e2smbuffer_size);
824 fprintf(stderr, "er encded is %d\n", er.encoded);
825 fprintf(stderr, "after encoding message");