Add User-level metrics
[sim/e2-interface.git] / e2sim / e2apv1sim / encode_kpm.cpp
1 #include <stdio.h>
2 #include <string.h>
3 #include <iostream>
4 #include <unistd.h>
5 #include <vector>
6
7 #include "encode_kpm.hpp"
8
9 using namespace std;
10
11 void encode_kpm_function_description(E2SM_KPM_RANfunction_Description_t* ranfunc_desc) {
12
13   printf("kpm0\n");
14
15   uint8_t *buf = (uint8_t*)"ORAN-E2SM-KPM";
16   uint8_t *buf2 = (uint8_t*)"KPM monitor";
17   uint8_t *buf3 = (uint8_t*)"OID123";
18
19   OCTET_STRING_t *sname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
20   sname->buf = (uint8_t*)calloc(1,13);
21   
22   memcpy(sname->buf, buf, 13);
23   sname->size = strlen((char*)buf);
24   ranfunc_desc->ranFunction_Name.ranFunction_ShortName = *sname;
25
26   long inst = 1;
27
28   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
29
30   //  ranfunc_desc->ranFunction_Name.ranFunction_Description = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
31   ranfunc_desc->ranFunction_Name.ranFunction_Description.buf = (uint8_t*)calloc(1,strlen((char*)buf2));
32   memcpy(ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, buf2, strlen((char*)buf2));
33   ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen((char*)buf2);
34   ranfunc_desc->ranFunction_Name.ranFunction_Instance = &inst;
35
36   printf("kpm0.9\n");
37
38   //  ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
39   ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf = (uint8_t*)calloc(1,strlen((char*)buf3));
40   memcpy(ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, buf3, strlen((char*)buf3));
41   ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen((char*)buf3);
42
43   printf("kpm2\n");
44   
45
46   RIC_EventTriggerStyle_List_t *trigger_style =
47     (RIC_EventTriggerStyle_List_t*)calloc(1, sizeof(RIC_EventTriggerStyle_List_t));
48   trigger_style->ric_EventTriggerStyle_Type = 1;
49   uint8_t *buf4 = (uint8_t*)"Periodic report";
50   //  trigger_style->ric_EventTriggerStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
51   trigger_style->ric_EventTriggerStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf4));
52   memcpy(trigger_style->ric_EventTriggerStyle_Name.buf, buf4, strlen((char*)buf4));
53   trigger_style->ric_EventTriggerStyle_Name.size = strlen((char*)buf4);
54   trigger_style->ric_EventTriggerFormat_Type = 5;
55
56   printf("kpm3\n");
57
58   ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_EventTriggerStyle_List =
59     (E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item__ric_EventTriggerStyle_List*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item__ric_EventTriggerStyle_List));
60
61   int ret = ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_EventTriggerStyle_List->list , trigger_style);
62   printf("ret is %d\n", ret);
63
64   RIC_ReportStyle_List_t *report_style1 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
65   report_style1->ric_ReportStyle_Type = 1;
66
67   uint8_t *buf5 = (uint8_t*)"O-DU Measurement Container for the 5GC connected deployment";
68
69   printf("kpm4\n");  
70   
71   //  report_style1->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
72   report_style1->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf5));
73   memcpy(report_style1->ric_ReportStyle_Name.buf, buf5, strlen((char*)buf5));
74   report_style1->ric_ReportStyle_Name.size = strlen((char*)buf5);  
75   report_style1->ric_IndicationHeaderFormat_Type = 1;
76   report_style1->ric_IndicationMessageFormat_Type = 1;
77   
78   printf("kpm5\n");  
79
80   RIC_ReportStyle_List_t *report_style2 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
81   report_style2->ric_ReportStyle_Type = 2;
82   
83   uint8_t *buf6 = (uint8_t*)"O-DU Measurement Container for the EPC connected deployment";
84   
85   //  report_style2->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
86
87   
88   report_style2->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf6));
89   memcpy(report_style2->ric_ReportStyle_Name.buf, buf6, strlen((char*)buf6));
90   report_style2->ric_ReportStyle_Name.size = strlen((char*)buf6);  
91   report_style2->ric_IndicationHeaderFormat_Type = 1;
92   report_style2->ric_IndicationMessageFormat_Type = 1;
93
94   printf("kpm6\n");  
95
96   RIC_ReportStyle_List_t *report_style3 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
97   report_style3->ric_ReportStyle_Type = 3;
98
99   uint8_t *buf7 = (uint8_t*)"O-CU-CP Measurement Container for the 5GC connected deployment";
100
101   //  report_style3->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
102   report_style3->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf7));
103   memcpy(report_style3->ric_ReportStyle_Name.buf, buf7, strlen((char*)buf7));
104   report_style3->ric_ReportStyle_Name.size = strlen((char*)buf7);
105   report_style3->ric_IndicationHeaderFormat_Type = 1;
106   report_style3->ric_IndicationMessageFormat_Type = 1;
107
108   RIC_ReportStyle_List_t *report_style4 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
109   report_style4->ric_ReportStyle_Type = 4;
110
111   uint8_t *buf8 = (uint8_t*)"O-CU-CP Measurement Container for the EPC connected deployment";
112
113   //  report_style3->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
114   report_style4->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf8));
115   memcpy(report_style4->ric_ReportStyle_Name.buf, buf8, strlen((char*)buf8));
116   report_style4->ric_ReportStyle_Name.size = strlen((char*)buf8);
117   report_style4->ric_IndicationHeaderFormat_Type = 1;
118   report_style4->ric_IndicationMessageFormat_Type = 1;
119
120   RIC_ReportStyle_List_t *report_style5 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
121   report_style5->ric_ReportStyle_Type = 5;
122
123   uint8_t *buf9 = (uint8_t*)"O-CU-UP Measurement Container for the 5GC connected deployment";
124
125   //  report_style3->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
126   report_style5->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf9));
127   memcpy(report_style5->ric_ReportStyle_Name.buf, buf9, strlen((char*)buf9));
128   report_style5->ric_ReportStyle_Name.size = strlen((char*)buf9);
129   report_style5->ric_IndicationHeaderFormat_Type = 1;
130   report_style5->ric_IndicationMessageFormat_Type = 1;
131
132
133   RIC_ReportStyle_List_t *report_style6 = (RIC_ReportStyle_List_t*)calloc(1, sizeof(RIC_ReportStyle_List_t));
134   report_style6->ric_ReportStyle_Type = 6;
135
136   uint8_t *buf10 = (uint8_t*)"O-CU-UP Measurement Container for the EPC connected deployment";
137
138   //  report_style3->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
139   report_style6->ric_ReportStyle_Name.buf = (uint8_t*)calloc(1,strlen((char*)buf10));
140   memcpy(report_style6->ric_ReportStyle_Name.buf, buf10, strlen((char*)buf10));
141   report_style6->ric_ReportStyle_Name.size = strlen((char*)buf10);
142   report_style6->ric_IndicationHeaderFormat_Type = 1;
143   report_style6->ric_IndicationMessageFormat_Type = 1;  
144   
145
146   ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List =
147     (E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item__ric_ReportStyle_List*)calloc(1,sizeof(E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item::E2SM_KPM_RANfunction_Description__e2SM_KPM_RANfunction_Item__ric_ReportStyle_List));
148   
149   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style1);
150   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style2);
151   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style3);
152   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style4);
153   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style5);
154   ASN_SEQUENCE_ADD(&ranfunc_desc->e2SM_KPM_RANfunction_Item.ric_ReportStyle_List->list, report_style6);
155
156   xer_fprint(stderr, &asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc);
157 }
158
159 void encode_kpm_ocuup_user_level(RAN_Container_t *ranco) {
160
161   uint8_t *buf = (uint8_t*)"2020.06.13 13:01:05.222";
162   Timestamp_t *ts = (Timestamp_t*)calloc(1,sizeof(Timestamp_t));
163   ts->buf = (uint8_t*)calloc(strlen((char*)buf),1);
164   ts->size = strlen((char*)buf);
165   memcpy(ts->buf,buf,ts->size);
166
167   printf("enc1\n");
168
169   CU_UP_Usage_Report_CellResourceReportItem_t  *report_item =
170     (CU_UP_Usage_Report_CellResourceReportItem_t*)calloc(1,sizeof(CU_UP_Usage_Report_CellResourceReportItem_t));
171
172   uint8_t *buf2 = (uint8_t*)"747";
173   
174   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
175   plmnidstr->buf = (uint8_t*)calloc(3,1);
176   plmnidstr->size = 3;
177   memcpy(plmnidstr->buf, buf2, plmnidstr->size);
178
179   printf("enc2\n");  
180
181   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
182   uint8_t* buf3 = (uint8_t*)"12340";
183   nrcellid->buf = (uint8_t*)calloc(1,5);
184   memcpy(nrcellid->buf, buf3, 5);
185   nrcellid->size = 5;
186   nrcellid->bits_unused = 4;
187
188   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
189   nrcgi->pLMN_Identity = *plmnidstr;
190   nrcgi->nRCellIdentity = *nrcellid;
191  
192   printf("enc3\n");
193   
194   report_item->nRCGI = *nrcgi;
195
196   CU_UP_Usage_Report_UeResourceReportItem *ue_report_item =
197     (CU_UP_Usage_Report_UeResourceReportItem*)calloc(1,sizeof(CU_UP_Usage_Report_UeResourceReportItem));
198
199   printf("enc3.2\n");   
200   
201   uint8_t* crnti_str = (uint8_t*)"1111";
202   OCTET_STRING *crnti = (OCTET_STRING*)calloc(1,sizeof(OCTET_STRING));
203   crnti->buf = (uint8_t*)calloc(1,4);
204   
205   printf("enc3.3\n");
206   
207   crnti->size = strlen((char*)crnti_str);
208
209   printf("enc3.4\n");
210   memcpy(crnti->buf, crnti_str, crnti->size);
211
212   printf("enc4\n");
213
214   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
215   uint8_t buffer[1];
216   buffer[0]= 40000;
217   bytesdl->buf = (uint8_t*)calloc(1,1);
218   memcpy(bytesdl->buf, buffer,1);
219   bytesdl->size = 1;
220
221   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
222   uint8_t buffer1[1];
223   buffer1[0] = 50000;
224   bytesul->buf = (uint8_t*)calloc(1,1);
225   memcpy(bytesul->buf, buffer1, 1);
226   bytesul->size = 1;  
227
228   
229   ue_report_item->c_RNTI = *crnti;
230   ue_report_item->pDCPBytesDL = bytesdl;
231   ue_report_item->pDCPBytesUL = bytesul;
232
233
234   ASN_SEQUENCE_ADD(&report_item->ueResourceReportList.list, ue_report_item);  
235
236   ranco->timestamp = *ts;
237   ranco->reportContainer.present = RAN_Container__reportContainer_PR_oCU_UP_UE;
238   ASN_SEQUENCE_ADD(&ranco->reportContainer.choice.oCU_UP_UE.cellResourceReportList.list, report_item);
239
240   xer_fprint(stderr, &asn_DEF_RAN_Container, ranco);
241
242 }
243
244 void encode_kpm_ocucp_user_level(RAN_Container_t *ranco,
245                                  uint8_t *plmnid_buf,
246                                  uint8_t *nrcellid_buf,
247                                  uint8_t *crnti_buf,
248                                  const uint8_t *serving_buf,
249                                  const uint8_t *neighbor_buf) {
250   uint8_t *buf = (uint8_t*)"2020.06.13 13:01:05.222";
251   Timestamp_t *ts = (Timestamp_t*)calloc(1,sizeof(Timestamp_t));
252   ts->buf = (uint8_t*)calloc(strlen((char*)buf),1);
253   ts->size = strlen((char*)buf);
254   memcpy(ts->buf,buf,ts->size);
255
256   printf("enc1\n");
257
258   CU_CP_Usage_Report_CellResourceReportItem_t  *report_item =
259     (CU_CP_Usage_Report_CellResourceReportItem_t*)calloc(1,sizeof(CU_CP_Usage_Report_CellResourceReportItem_t));
260
261   int plmnid_size = strlen((char*)plmnid_buf);  
262   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
263   plmnidstr->buf = (uint8_t*)calloc(plmnid_size,1);
264   plmnidstr->size = plmnid_size;
265   memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
266
267   printf("enc2\n");
268
269   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
270
271   int nrcellid_size = strlen((char*)nrcellid_buf);
272   nrcellid->buf = (uint8_t*)calloc(1, nrcellid_size);
273   memcpy(nrcellid->buf, nrcellid_buf, nrcellid_size);
274   nrcellid->size = 5;
275   nrcellid->bits_unused = 4;
276
277   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
278   nrcgi->pLMN_Identity = *plmnidstr;
279   nrcgi->nRCellIdentity = *nrcellid;
280  
281   printf("enc3\n");
282   
283   report_item->nRCGI = *nrcgi;
284
285   CU_CP_Usage_Report_UeResourceReportItem *ue_report_item =
286     (CU_CP_Usage_Report_UeResourceReportItem*)calloc(1,sizeof(CU_CP_Usage_Report_UeResourceReportItem));
287
288   printf("enc3.2\n");
289
290
291   int crnti_size = strlen((char*)crnti_buf);
292   OCTET_STRING *crnti = (OCTET_STRING*)calloc(1,sizeof(OCTET_STRING));
293   crnti->buf = (uint8_t*)calloc(1, crnti_size);
294   
295   printf("enc3.3\n");
296   
297   crnti->size = strlen((char*)crnti_buf);
298
299   printf("enc3.4\n");
300   memcpy(crnti->buf, crnti_buf, crnti->size);
301
302   //  uint8_t *buf_serving = (uint8_t*)"RSRP10";
303
304   int serving_buf_len = strlen((char*)serving_buf);
305   OCTET_STRING_t *servingstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
306   servingstr->buf = (uint8_t*)calloc(serving_buf_len,1);
307   servingstr->size = serving_buf_len;
308   memcpy(servingstr->buf, serving_buf, servingstr->size);
309
310
311   int neighbor_buf_len = strlen((char*)neighbor_buf);
312   //  uint8_t *buf_neighbor = (uint8_t*)"-10,-15";
313   OCTET_STRING_t *neighborstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
314   ts->buf = (uint8_t*)calloc(neighbor_buf_len,1);
315   neighborstr->buf = (uint8_t*)calloc(neighbor_buf_len,1);
316   neighborstr->size = neighbor_buf_len;
317   memcpy(neighborstr->buf, neighbor_buf, neighborstr->size);
318
319   ue_report_item->c_RNTI = *crnti;
320   ue_report_item->serving_Cell_RF_Type = servingstr;
321   ue_report_item->neighbor_Cell_RF = neighborstr;
322
323
324   ASN_SEQUENCE_ADD(&report_item->ueResourceReportList.list, ue_report_item);  
325
326   ranco->timestamp = *ts;
327   ranco->reportContainer.present = RAN_Container__reportContainer_PR_oCU_CP_UE;
328   ASN_SEQUENCE_ADD(&ranco->reportContainer.choice.oCU_CP_UE.cellResourceReportList.list, report_item);
329
330   xer_fprint(stderr, &asn_DEF_RAN_Container, ranco);
331   
332
333 }
334
335 void encode_kpm_ocucp_user_level(RAN_Container_t *ranco) {
336
337   uint8_t *buf = (uint8_t*)"2020.06.13 13:01:05.222";
338   Timestamp_t *ts = (Timestamp_t*)calloc(1,sizeof(Timestamp_t));
339   ts->buf = (uint8_t*)calloc(strlen((char*)buf),1);
340   ts->size = strlen((char*)buf);
341   memcpy(ts->buf,buf,ts->size);
342
343   printf("enc1\n");
344
345   CU_CP_Usage_Report_CellResourceReportItem_t  *report_item =
346     (CU_CP_Usage_Report_CellResourceReportItem_t*)calloc(1,sizeof(CU_CP_Usage_Report_CellResourceReportItem_t));
347
348   uint8_t *buf2 = (uint8_t*)"747";
349   
350   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
351   plmnidstr->buf = (uint8_t*)calloc(3,1);
352   plmnidstr->size = 3;
353   memcpy(plmnidstr->buf, buf2, plmnidstr->size);
354
355   printf("enc2\n");
356
357   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
358   uint8_t* buf3 = (uint8_t*)"12340";
359   nrcellid->buf = (uint8_t*)calloc(1,5);
360   memcpy(nrcellid->buf, buf3, 5);
361   nrcellid->size = 5;
362   nrcellid->bits_unused = 4;
363
364   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
365   nrcgi->pLMN_Identity = *plmnidstr;
366   nrcgi->nRCellIdentity = *nrcellid;
367  
368   printf("enc3\n");
369   
370   report_item->nRCGI = *nrcgi;
371
372   CU_CP_Usage_Report_UeResourceReportItem *ue_report_item =
373     (CU_CP_Usage_Report_UeResourceReportItem*)calloc(1,sizeof(CU_CP_Usage_Report_UeResourceReportItem));
374
375   printf("enc3.2\n");
376
377   uint8_t* crnti_str = (uint8_t*)"1111";
378   OCTET_STRING *crnti = (OCTET_STRING*)calloc(1,sizeof(OCTET_STRING));
379   crnti->buf = (uint8_t*)calloc(1,4);
380   
381   printf("enc3.3\n");
382   
383   crnti->size = strlen((char*)crnti_str);
384
385   printf("enc3.4\n");
386   memcpy(crnti->buf, crnti_str, crnti->size);
387
388   uint8_t *buf_serving = (uint8_t*)"RSRP10";
389   OCTET_STRING_t *servingstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
390   servingstr->buf = (uint8_t*)calloc(6,1);
391   servingstr->size = 6;
392   memcpy(servingstr->buf, buf_serving, servingstr->size);
393
394   uint8_t *buf_neighbor = (uint8_t*)"-10,-15";
395   OCTET_STRING_t *neighborstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
396   neighborstr->buf = (uint8_t*)calloc(7,1);
397   neighborstr->size = 7;
398   memcpy(neighborstr->buf, buf_neighbor, neighborstr->size);
399
400   ue_report_item->c_RNTI = *crnti;
401   ue_report_item->serving_Cell_RF_Type = servingstr;
402   ue_report_item->neighbor_Cell_RF = neighborstr;
403
404
405   ASN_SEQUENCE_ADD(&report_item->ueResourceReportList.list, ue_report_item);  
406
407   ranco->timestamp = *ts;
408   ranco->reportContainer.present = RAN_Container__reportContainer_PR_oCU_CP_UE;
409   ASN_SEQUENCE_ADD(&ranco->reportContainer.choice.oCU_CP_UE.cellResourceReportList.list, report_item);
410
411   xer_fprint(stderr, &asn_DEF_RAN_Container, ranco);
412
413 }
414
415
416 void encode_kpm_odu_user_level(RAN_Container_t *ranco) {
417
418   uint8_t *buf = (uint8_t*)"2020.06.13 13:01:05.222";
419   Timestamp_t *ts = (Timestamp_t*)calloc(1,sizeof(Timestamp_t));
420   ts->buf = (uint8_t*)calloc(strlen((char*)buf),1);
421   ts->size = strlen((char*)buf);
422   memcpy(ts->buf,buf,ts->size);
423
424   printf("enc1\n");
425
426   DU_Usage_Report_CellResourceReportItem_t *report_item =
427     (DU_Usage_Report_CellResourceReportItem_t*)calloc(1,sizeof(DU_Usage_Report_CellResourceReportItem_t));
428
429   uint8_t *buf2 = (uint8_t*)"747";
430   
431   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
432   plmnidstr->buf = (uint8_t*)calloc(3,1);
433   plmnidstr->size = 3;
434   memcpy(plmnidstr->buf, buf2, plmnidstr->size);
435
436   printf("enc2\n");  
437
438   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
439   uint8_t* buf3 = (uint8_t*)"12340";
440   nrcellid->buf = (uint8_t*)calloc(1,5);
441   memcpy(nrcellid->buf, buf3, 5);
442   nrcellid->size = 5;
443   nrcellid->bits_unused = 4;
444
445   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
446   nrcgi->pLMN_Identity = *plmnidstr;
447   nrcgi->nRCellIdentity = *nrcellid;
448  
449   printf("enc3\n"); 
450   
451   report_item->nRCGI = *nrcgi;
452
453   printf("enc3.1\n");   
454
455   DU_Usage_Report_UeResourceReportItem *ue_report_item =
456     (DU_Usage_Report_UeResourceReportItem*)calloc(1,sizeof(DU_Usage_Report_UeResourceReportItem));
457
458   printf("enc3.2\n");   
459   
460   uint8_t* crnti_str = (uint8_t*)"1111";
461   OCTET_STRING *crnti = (OCTET_STRING*)calloc(1,sizeof(OCTET_STRING));
462   crnti->buf = (uint8_t*)calloc(1,4);
463   
464   printf("enc3.3\n");
465   
466   crnti->size = strlen((char*)crnti_str);
467
468   printf("enc3.4\n");
469   memcpy(crnti->buf, crnti_str, crnti->size);
470
471   printf("enc4\n");  
472
473   long lval1 = 2;
474   long lval2 = 1;
475   
476   ue_report_item->c_RNTI = *crnti;
477   ue_report_item->dl_PRBUsage = &lval1;
478
479   printf("enc5\n");
480   
481   ue_report_item->ul_PRBUsage = &lval2;
482
483   printf("enc6\n");
484   
485   ASN_SEQUENCE_ADD(&report_item->ueResourceReportList.list, ue_report_item);
486
487   
488   ranco->timestamp = *ts;
489   ranco->reportContainer.present = RAN_Container__reportContainer_PR_oDU_UE;
490   ASN_SEQUENCE_ADD(&ranco->reportContainer.choice.oDU_UE.cellResourceReportList.list, report_item);
491
492   xer_fprint(stderr, &asn_DEF_RAN_Container, ranco);
493
494   
495 }
496
497 void encode_kpm_report_rancontainer_du(E2SM_KPM_IndicationMessage_t* indicationmessage) {
498
499   RAN_Container_t *ranco = (RAN_Container_t*)calloc(1,sizeof(RAN_Container_t));
500   encode_kpm_odu_user_level(ranco);
501
502   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
503   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
504   containers_list->theRANContainer = ranco;
505
506   E2SM_KPM_IndicationMessage_Format1_t *format =
507     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
508   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
509
510   int ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
511   
512   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
513
514   indicationmessage->indicationMessage.present = pres;
515
516   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
517
518   char *error_buf = (char*)calloc(300, sizeof(char));
519   size_t errlen;
520
521   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
522   printf("error length %d\n", errlen);
523   printf("error buf %s\n", error_buf);
524
525   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
526
527   asn_codec_ctx_t *opt_cod;
528
529   uint8_t e2smbuffer[8192];
530   size_t e2smbuffer_size = 8192;
531
532   uint8_t e2smbuffer2[8192];
533   size_t e2smbuffer_size2 = 8192;
534
535   asn_enc_rval_t er =
536     asn_encode_to_buffer(opt_cod,
537                          ATS_ALIGNED_BASIC_PER,
538                          &asn_DEF_E2SM_KPM_IndicationMessage,
539                          indicationmessage, e2smbuffer, e2smbuffer_size);
540
541   fprintf(stderr, "er encded is %d\n", er.encoded);
542   fprintf(stderr, "after encoding message\n");
543
544
545 }
546
547 void encode_kpm_report_rancontainer_cucp_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage,
548                                                        uint8_t *plmnid_buf,
549                                                        uint8_t *nrcellid_buf,
550                                                        uint8_t *crnti_buf,
551                                                        const uint8_t *serving_buf,
552                                                        const uint8_t *neighbor_buf) {
553
554   RAN_Container_t *ranco = (RAN_Container_t*)calloc(1,sizeof(RAN_Container_t));
555   encode_kpm_ocucp_user_level(ranco, plmnid_buf,
556                               nrcellid_buf, crnti_buf,
557                               serving_buf, neighbor_buf);
558
559   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
560   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
561   containers_list->theRANContainer = ranco;
562
563   E2SM_KPM_IndicationMessage_Format1_t *format =
564     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
565   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
566
567   int ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
568   
569   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
570
571   indicationmessage->indicationMessage.present = pres;
572
573   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
574
575   char *error_buf = (char*)calloc(300, sizeof(char));
576   size_t errlen;
577
578   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
579   printf("error length %d\n", errlen);
580   printf("error buf %s\n", error_buf);
581
582   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
583
584   asn_codec_ctx_t *opt_cod;
585
586   uint8_t e2smbuffer[8192];
587   size_t e2smbuffer_size = 8192;
588
589   uint8_t e2smbuffer2[8192];
590   size_t e2smbuffer_size2 = 8192;
591
592   asn_enc_rval_t er =
593     asn_encode_to_buffer(opt_cod,
594                          ATS_ALIGNED_BASIC_PER,
595                          &asn_DEF_E2SM_KPM_IndicationMessage,
596                          indicationmessage, e2smbuffer, e2smbuffer_size);
597
598   fprintf(stderr, "er encded is %d\n", er.encoded);
599   fprintf(stderr, "after encoding message\n");
600   
601 }
602                                                        
603                                                        
604 void encode_kpm_report_rancontainer_cucp(E2SM_KPM_IndicationMessage_t* indicationmessage) {
605
606   RAN_Container_t *ranco = (RAN_Container_t*)calloc(1,sizeof(RAN_Container_t));
607   encode_kpm_ocucp_user_level(ranco);
608
609   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
610   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
611   containers_list->theRANContainer = ranco;
612
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);
616
617   int ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
618   
619   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
620
621   indicationmessage->indicationMessage.present = pres;
622
623   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
624
625   char *error_buf = (char*)calloc(300, sizeof(char));
626   size_t errlen;
627
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);
631
632   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
633
634   asn_codec_ctx_t *opt_cod;
635
636   uint8_t e2smbuffer[8192];
637   size_t e2smbuffer_size = 8192;
638
639   uint8_t e2smbuffer2[8192];
640   size_t e2smbuffer_size2 = 8192;
641
642   asn_enc_rval_t er =
643     asn_encode_to_buffer(opt_cod,
644                          ATS_ALIGNED_BASIC_PER,
645                          &asn_DEF_E2SM_KPM_IndicationMessage,
646                          indicationmessage, e2smbuffer, e2smbuffer_size);
647
648   fprintf(stderr, "er encded is %d\n", er.encoded);
649   fprintf(stderr, "after encoding message\n");
650
651
652 }
653
654 void encode_kpm_report_rancontainer_cuup_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage,
655                                                        uint8_t *plmnid_buf,
656                                                        uint8_t *nrcellid_buf,
657                                                        uint8_t *crnti_buf,
658                                                        int pdcp_bytesdl,
659                                                        int pdcp_bytesul) {
660
661
662 }
663
664 void encode_kpm_report_rancontainer_cuup(E2SM_KPM_IndicationMessage_t* indicationmessage) {
665
666   RAN_Container_t *ranco = (RAN_Container_t*)calloc(1,sizeof(RAN_Container_t));
667   //encode_kpm_ocuup_user_level(ranco);
668
669   
670   uint8_t *buf = (uint8_t*)"2020.06.13 13:01:05.222";
671   Timestamp_t *ts = (Timestamp_t*)calloc(1,sizeof(Timestamp_t));
672   ts->buf = (uint8_t*)calloc(strlen((char*)buf),1);
673   ts->size = strlen((char*)buf);
674   memcpy(ts->buf,buf,ts->size);
675
676   printf("enc1\n");
677
678   CU_CP_Usage_Report_CellResourceReportItem_t  *report_item =
679     (CU_CP_Usage_Report_CellResourceReportItem_t*)calloc(1,sizeof(CU_CP_Usage_Report_CellResourceReportItem_t));
680
681   uint8_t *buf2 = (uint8_t*)"747";
682   
683   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
684   plmnidstr->buf = (uint8_t*)calloc(3,1);
685   plmnidstr->size = 3;
686   memcpy(plmnidstr->buf, buf2, plmnidstr->size);
687
688   printf("enc2\n");  
689
690   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
691   uint8_t* buf3 = (uint8_t*)"12340";
692   nrcellid->buf = (uint8_t*)calloc(1,5);
693   memcpy(nrcellid->buf, buf3, 5);
694   nrcellid->size = 5;
695   nrcellid->bits_unused = 4;
696
697   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
698   nrcgi->pLMN_Identity = *plmnidstr;
699   nrcgi->nRCellIdentity = *nrcellid;
700  
701   printf("enc3\n"); 
702   
703   report_item->nRCGI = *nrcgi;
704
705   CU_CP_Usage_Report_UeResourceReportItem *ue_report_item =
706     (CU_CP_Usage_Report_UeResourceReportItem*)calloc(1,sizeof(CU_CP_Usage_Report_UeResourceReportItem));
707
708   printf("enc3.2\n");
709
710   uint8_t* crnti_str = (uint8_t*)"1111";
711   OCTET_STRING *crnti = (OCTET_STRING*)calloc(1,sizeof(OCTET_STRING));
712   crnti->buf = (uint8_t*)calloc(1,4);
713   
714   printf("enc3.3\n");
715   
716   crnti->size = strlen((char*)crnti_str);
717
718   printf("enc3.4\n");
719   memcpy(crnti->buf, crnti_str, crnti->size);
720
721   uint8_t *buf_serving = (uint8_t*)"RSRP10";
722   OCTET_STRING_t *servingstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
723   servingstr->buf = (uint8_t*)calloc(6,1);
724   servingstr->size = 6;
725   memcpy(servingstr->buf, buf_serving, servingstr->size);
726
727   uint8_t *buf_neighbor = (uint8_t*)"-10,-15";
728   OCTET_STRING_t *neighborstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
729   neighborstr->buf = (uint8_t*)calloc(7,1);
730   neighborstr->size = 7;
731   memcpy(neighborstr->buf, buf_neighbor, neighborstr->size);
732
733   ue_report_item->c_RNTI = *crnti;
734   ue_report_item->serving_Cell_RF_Type = servingstr;
735   ue_report_item->neighbor_Cell_RF = neighborstr;
736
737
738   ASN_SEQUENCE_ADD(&report_item->ueResourceReportList.list, ue_report_item);
739
740   ranco->timestamp = *ts;
741   ranco->reportContainer.present = RAN_Container__reportContainer_PR_oCU_CP_UE;
742   ASN_SEQUENCE_ADD(&ranco->reportContainer.choice.oCU_CP_UE.cellResourceReportList.list, report_item);
743
744   //  xer_fprint(stderr, &asn_DEF_RAN_Container, ranco);
745   
746
747   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
748   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
749   containers_list->theRANContainer = ranco;
750
751   E2SM_KPM_IndicationMessage_Format1_t *format =
752     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
753   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
754
755   int ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
756   
757   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
758
759   indicationmessage->indicationMessage.present = pres;
760
761   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
762
763   char *error_buf = (char*)calloc(300, sizeof(char));
764   size_t errlen;
765
766   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
767   printf("error length %d\n", errlen);
768   printf("error buf %s\n", error_buf);
769
770   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
771
772   asn_codec_ctx_t *opt_cod;
773
774   uint8_t e2smbuffer[8192];
775   size_t e2smbuffer_size = 8192;
776
777   uint8_t e2smbuffer2[8192];
778   size_t e2smbuffer_size2 = 8192;
779
780   asn_enc_rval_t er =
781     asn_encode_to_buffer(opt_cod,
782                          ATS_ALIGNED_BASIC_PER,
783                          &asn_DEF_E2SM_KPM_IndicationMessage,
784                          indicationmessage, e2smbuffer, e2smbuffer_size);
785
786   fprintf(stderr, "er encded is %d\n", er.encoded);
787   fprintf(stderr, "after encoding message\n");
788
789
790 }
791
792 void encode_kpm_report_style1_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage,
793                                             long fiveqi,
794                                             long dl_prb_usage,
795                                             long ul_prb_usage,
796                                             uint8_t* sd_buf,
797                                             uint8_t* sst_buf,
798                                             uint8_t* plmnid_buf,
799                                             uint8_t* nrcellid_buf,
800                                             long *dl_prbs,
801                                             long *ul_prbs) {
802
803
804   asn_codec_ctx_t *opt_cod;
805
806   FQIPERSlicesPerPlmnPerCellListItem_t *fqi_item =
807     (FQIPERSlicesPerPlmnPerCellListItem_t*)calloc(1,sizeof(FQIPERSlicesPerPlmnPerCellListItem_t));
808   fqi_item->fiveQI = fiveqi;
809   fqi_item->dl_PRBUsage = &dl_prb_usage;
810   fqi_item->ul_PRBUsage = &ul_prb_usage;
811
812   uint8_t *buf1 = (uint8_t*)"4";  
813   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
814   sst->size = 6;
815   sst->buf = (uint8_t*)calloc(1,6);
816   memcpy(sst->buf,buf1,sst->size);
817
818   //  std::string sd = "SD1";
819   //  std::vector<uint8_t> sdvec(sd.begin(), sd.end());
820   //  uint8_t *bufz = &sdvec[0];
821   uint8_t *bufz = (uint8_t*)"SD1";
822   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
823   sds->size = 3;
824   sds->buf = (uint8_t*)calloc(1,3);
825   memcpy(sds->buf, bufz, sds->size);
826
827   
828   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
829   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
830   snssai->sST.buf = (uint8_t*)calloc(1,1);
831   snssai->sST.size = 1;
832   memcpy(snssai->sST.buf, sst_buf, 1);
833   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
834   snssai->sD->buf = (uint8_t*)calloc(1,3);
835   snssai->sD->size = 3;
836   memcpy(snssai->sD->buf, sd_buf, 3);
837   
838   
839   SlicePerPlmnPerCellListItem_t *sliceitem =
840     (SlicePerPlmnPerCellListItem_t*)calloc(1,sizeof(SlicePerPlmnPerCellListItem_t));
841   sliceitem->sliceID = *snssai;
842   ASN_SEQUENCE_ADD(&sliceitem->fQIPERSlicesPerPlmnPerCellList.list, fqi_item);
843
844   uint8_t *buf2 = (uint8_t*)"747";
845   
846   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
847   plmnid->buf = (uint8_t*)calloc(3,1);
848   plmnid->size = 3;
849   memcpy(plmnid->buf, plmnid_buf, plmnid->size);  
850
851   ServedPlmnPerCellListItem_t *percellitem1 =
852     (ServedPlmnPerCellListItem_t*)calloc(1,sizeof(ServedPlmnPerCellListItem_t));
853   percellitem1->pLMN_Identity = *plmnid;
854   percellitem1->du_PM_5GC = (FGC_DU_PM_Container*)calloc(1,sizeof(FGC_DU_PM_Container));
855   ASN_SEQUENCE_ADD(&percellitem1->du_PM_5GC->slicePerPlmnPerCellList.list, sliceitem);
856
857   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
858   plmnidstr->buf = (uint8_t*)calloc(3,1);
859   plmnidstr->size = 3;
860   memcpy(plmnidstr->buf, plmnid_buf, plmnidstr->size);
861
862   printf("enc2\n");  
863
864   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
865   uint8_t* buf3 = (uint8_t*)"12340";
866   nrcellid->buf = (uint8_t*)calloc(1,5);
867   memcpy(nrcellid->buf, nrcellid_buf, 5);
868   nrcellid->size = 5;
869   nrcellid->bits_unused = 4;
870
871   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
872   nrcgi->pLMN_Identity = *plmnidstr;
873   nrcgi->nRCellIdentity = *nrcellid;
874     
875
876   CellResourceReportListItem_t *listitem1 = (CellResourceReportListItem_t*)calloc(1,sizeof(CellResourceReportListItem_t));
877   listitem1->nRCGI = *nrcgi;
878   listitem1->dl_TotalofAvailablePRBs = dl_prbs;
879   listitem1->ul_TotalofAvailablePRBs = ul_prbs;
880   ASN_SEQUENCE_ADD(&listitem1->servedPlmnPerCellList.list, percellitem1);
881   
882
883   ODU_PF_Container_t *ducont = (ODU_PF_Container_t*)calloc(1,sizeof(ODU_PF_Container_t));
884   ASN_STRUCT_RESET(asn_DEF_ODU_PF_Container, ducont);
885   int ret = ASN_SEQUENCE_ADD(&ducont->cellResourceReportList.list, listitem1);
886   
887   PF_Container_PR pres1 = PF_Container_PR_oDU;
888
889   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
890   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
891   pfcontainer->present = pres1;
892   pfcontainer->choice.oDU = *ducont;
893
894   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
895   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
896   containers_list->performanceContainer = pfcontainer;
897
898   E2SM_KPM_IndicationMessage_Format1_t *format =
899     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
900   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
901
902   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
903   
904   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
905
906   indicationmessage->indicationMessage.present = pres;
907
908   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
909
910   char *error_buf = (char*)calloc(300, sizeof(char));
911   size_t errlen;
912
913   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
914   printf("error length %d\n", errlen);
915   printf("error buf %s\n", error_buf);
916
917   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
918   
919
920   uint8_t e2smbuffer[8192];
921   size_t e2smbuffer_size = 8192;
922
923   uint8_t e2smbuffer2[8192];
924   size_t e2smbuffer_size2 = 8192;  
925
926   asn_enc_rval_t er =
927     asn_encode_to_buffer(opt_cod,
928                          ATS_ALIGNED_BASIC_PER,
929                          &asn_DEF_E2SM_KPM_IndicationMessage,
930                          indicationmessage, e2smbuffer, e2smbuffer_size);
931
932   fprintf(stderr, "er encded is %d\n", er.encoded);
933   fprintf(stderr, "after encoding message\n");
934
935
936 }
937
938
939 void encode_kpm_report_style1(E2SM_KPM_IndicationMessage_t* indicationmessage) {
940
941   long fiveqi = 8;
942   long dl_prb_usage = 50;
943   long ul_prb_usage = 70;
944
945   asn_codec_ctx_t *opt_cod;
946
947   FQIPERSlicesPerPlmnPerCellListItem_t *fqi_item =
948     (FQIPERSlicesPerPlmnPerCellListItem_t*)calloc(1,sizeof(FQIPERSlicesPerPlmnPerCellListItem_t));
949   fqi_item->fiveQI = fiveqi;
950   fqi_item->dl_PRBUsage = &dl_prb_usage;
951   fqi_item->ul_PRBUsage = &ul_prb_usage;
952
953   uint8_t *buf1 = (uint8_t*)"4";  
954   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
955   sst->size = 6;
956   sst->buf = (uint8_t*)calloc(1,6);
957   memcpy(sst->buf,buf1,sst->size);
958
959   //  std::string sd = "SD1";
960   //  std::vector<uint8_t> sdvec(sd.begin(), sd.end());
961   //  uint8_t *bufz = &sdvec[0];
962   uint8_t *bufz = (uint8_t*)"SD1";
963   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
964   sds->size = 3;
965   sds->buf = (uint8_t*)calloc(1,3);
966   memcpy(sds->buf, bufz, sds->size);
967
968   
969   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
970   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
971   snssai->sST.buf = (uint8_t*)calloc(1,1);
972   snssai->sST.size = 1;
973   memcpy(snssai->sST.buf, buf1, 1);
974   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
975   snssai->sD->buf = (uint8_t*)calloc(1,3);
976   snssai->sD->size = 3;
977   memcpy(snssai->sD->buf, bufz, 3);
978   
979   
980   SlicePerPlmnPerCellListItem_t *sliceitem =
981     (SlicePerPlmnPerCellListItem_t*)calloc(1,sizeof(SlicePerPlmnPerCellListItem_t));
982   sliceitem->sliceID = *snssai;
983   ASN_SEQUENCE_ADD(&sliceitem->fQIPERSlicesPerPlmnPerCellList.list, fqi_item);
984
985   uint8_t *buf2 = (uint8_t*)"747";
986   
987   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
988   plmnid->buf = (uint8_t*)calloc(3,1);
989   plmnid->size = 3;
990   memcpy(plmnid->buf, buf2, plmnid->size);  
991
992   ServedPlmnPerCellListItem_t *percellitem1 =
993     (ServedPlmnPerCellListItem_t*)calloc(1,sizeof(ServedPlmnPerCellListItem_t));
994   percellitem1->pLMN_Identity = *plmnid;
995   percellitem1->du_PM_5GC = (FGC_DU_PM_Container*)calloc(1,sizeof(FGC_DU_PM_Container));
996   ASN_SEQUENCE_ADD(&percellitem1->du_PM_5GC->slicePerPlmnPerCellList.list, sliceitem);
997
998   OCTET_STRING_t *plmnidstr = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
999   plmnidstr->buf = (uint8_t*)calloc(3,1);
1000   plmnidstr->size = 3;
1001   memcpy(plmnidstr->buf, buf2, plmnidstr->size);
1002
1003   printf("enc2\n");  
1004
1005   NRCellIdentity_t *nrcellid = (NRCellIdentity_t*)calloc(1,sizeof(NRCellIdentity_t));
1006   uint8_t* buf3 = (uint8_t*)"12340";
1007   nrcellid->buf = (uint8_t*)calloc(1,5);
1008   memcpy(nrcellid->buf, buf3, 5);
1009   nrcellid->size = 5;
1010   nrcellid->bits_unused = 4;
1011
1012   NRCGI *nrcgi = (NRCGI*)calloc(1,sizeof(NRCGI));
1013   nrcgi->pLMN_Identity = *plmnidstr;
1014   nrcgi->nRCellIdentity = *nrcellid;
1015     
1016   long dl_prbs = (long)100;
1017   long ul_prbs = (long)120;
1018
1019   CellResourceReportListItem_t *listitem1 = (CellResourceReportListItem_t*)calloc(1,sizeof(CellResourceReportListItem_t));
1020   listitem1->nRCGI = *nrcgi;
1021   listitem1->dl_TotalofAvailablePRBs = &dl_prbs;
1022   listitem1->ul_TotalofAvailablePRBs = &ul_prbs;
1023   ASN_SEQUENCE_ADD(&listitem1->servedPlmnPerCellList.list, percellitem1);
1024   
1025
1026   ODU_PF_Container_t *ducont = (ODU_PF_Container_t*)calloc(1,sizeof(ODU_PF_Container_t));
1027   ASN_STRUCT_RESET(asn_DEF_ODU_PF_Container, ducont);
1028   int ret = ASN_SEQUENCE_ADD(&ducont->cellResourceReportList.list, listitem1);
1029   
1030   PF_Container_PR pres1 = PF_Container_PR_oDU;
1031
1032   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1033   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1034   pfcontainer->present = pres1;
1035   pfcontainer->choice.oDU = *ducont;
1036
1037   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1038   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1039   containers_list->performanceContainer = pfcontainer;
1040
1041   E2SM_KPM_IndicationMessage_Format1_t *format =
1042     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1043   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1044
1045   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1046   
1047   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
1048
1049   indicationmessage->indicationMessage.present = pres;
1050
1051   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
1052
1053   char *error_buf = (char*)calloc(300, sizeof(char));
1054   size_t errlen;
1055
1056   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1057   printf("error length %d\n", errlen);
1058   printf("error buf %s\n", error_buf);
1059
1060   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1061   
1062
1063   uint8_t e2smbuffer[8192];
1064   size_t e2smbuffer_size = 8192;
1065
1066   uint8_t e2smbuffer2[8192];
1067   size_t e2smbuffer_size2 = 8192;  
1068
1069   asn_enc_rval_t er =
1070     asn_encode_to_buffer(opt_cod,
1071                          ATS_ALIGNED_BASIC_PER,
1072                          &asn_DEF_E2SM_KPM_IndicationMessage,
1073                          indicationmessage, e2smbuffer, e2smbuffer_size);
1074
1075   fprintf(stderr, "er encded is %d\n", er.encoded);
1076   fprintf(stderr, "after encoding message\n");
1077
1078
1079 }
1080
1081 void encode_kpm_report_style5_parameterized(E2SM_KPM_IndicationMessage_t* indicationmessage,
1082                                             uint8_t *gnbcuupname_buf,
1083                                             int bytes_dl,
1084                                             int bytes_ul,
1085                                             uint8_t *sst_buf,
1086                                             uint8_t *sd_buf,
1087                                             uint8_t *plmnid_buf) {
1088   
1089   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1090
1091
1092   //  uint8_t *buf = (uint8_t*)"GNBCUUP5";
1093   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1094   gnbcuupname->size = 8;
1095   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1096   memcpy(gnbcuupname->buf, gnbcuupname_buf, gnbcuupname->size);
1097
1098
1099   //We need to convert bytes_dl into array of uint8_t
1100   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1101   uint8_t buffer[1];
1102   buffer[0]= 40000;
1103   bytesdl->buf = (uint8_t*)calloc(1,1);
1104   memcpy(bytesdl->buf, buffer,1);
1105   bytesdl->size = 1;
1106
1107   
1108   //We need to convert bytes_ul into array of uint8_t
1109   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1110   uint8_t buffer1[1];
1111   buffer1[0] = 50000;
1112   bytesul->buf = (uint8_t*)calloc(1,1);
1113   memcpy(bytesul->buf, buffer1, 1);
1114   bytesul->size = 1;
1115
1116   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1117   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1118   fqilistitem->fiveQI = 9;
1119   fqilistitem->pDCPBytesDL = bytesdl;
1120   fqilistitem->pDCPBytesUL = bytesul;
1121
1122
1123   uint8_t *buf1 = (uint8_t*)"4";  
1124   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1125   sst->size = 6;
1126   sst->buf = (uint8_t*)calloc(1,6);
1127   memcpy(sst->buf,sst_buf,sst->size);
1128
1129
1130   uint8_t *bufz = (uint8_t*)"SD1";
1131   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1132   sds->size = 3;
1133   sds->buf = (uint8_t*)calloc(1,3);
1134   memcpy(sds->buf, sd_buf, sds->size);
1135
1136   
1137   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1138   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1139   snssai->sST.buf = (uint8_t*)calloc(1,1);
1140   snssai->sST.size = 1;
1141   memcpy(snssai->sST.buf, sst_buf, 1);
1142   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1143   snssai->sD->buf = (uint8_t*)calloc(1,3);
1144   snssai->sD->size = 3;
1145   memcpy(snssai->sD->buf, sd_buf, 3);
1146
1147   
1148
1149   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1150   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1151   slicelistitem->sliceID = *snssai;
1152   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1153
1154   asn_codec_ctx_t *opt_cod;  
1155
1156
1157   uint8_t e2smbuffera[8192];
1158   size_t e2smbuffer_sizea = 8192;
1159
1160
1161
1162   asn_enc_rval_t era =
1163     asn_encode_to_buffer(opt_cod,
1164                          ATS_ALIGNED_BASIC_PER,
1165                          &asn_DEF_SliceToReportListItem,
1166                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1167   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1168   fprintf(stderr, "after encoding message\n");      
1169
1170
1171
1172   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1173   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1174   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1175
1176   uint8_t *buf2 = (uint8_t*)"747";
1177   //  std::string pl = "PLMNID7";
1178   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1179   //  uint8_t *buf2 = &plvec[0];
1180   
1181   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1182   plmnid->buf = (uint8_t*)calloc(3,1);
1183   plmnid->size = 3;
1184   memcpy(plmnid->buf, plmnid_buf, plmnid->size);
1185
1186
1187   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1188   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1189   plmnidlist->pLMN_Identity = *plmnid;
1190   plmnidlist->cu_UP_PM_5GC = pm_format;
1191
1192   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1193   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1194   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1195
1196
1197   
1198   
1199   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1200   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1201   listitem1->interface_type = 2;
1202   listitem1->o_CU_UP_PM_Container = *meas_cont;
1203
1204   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1205   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1206   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1207   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1208   
1209   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1210
1211   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1212   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1213   pfcontainer->present = pres1;
1214   pfcontainer->choice.oCU_UP = *cuupcont;
1215
1216   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1217   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1218   containers_list->performanceContainer = pfcontainer;
1219
1220   E2SM_KPM_IndicationMessage_Format1_t *format =
1221     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1222   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1223
1224   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1225   
1226   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
1227
1228   indicationmessage->indicationMessage.present = pres;
1229
1230   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
1231
1232   char *error_buf = (char*)calloc(300, sizeof(char));
1233   size_t errlen;
1234
1235   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1236   printf("error length %d\n", errlen);
1237   printf("error buf %s\n", error_buf);
1238
1239   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1240   
1241
1242   uint8_t e2smbuffer[8192];
1243   size_t e2smbuffer_size = 8192;
1244
1245   uint8_t e2smbuffer2[8192];
1246   size_t e2smbuffer_size2 = 8192;  
1247
1248   asn_enc_rval_t er =
1249     asn_encode_to_buffer(opt_cod,
1250                          ATS_ALIGNED_BASIC_PER,
1251                          &asn_DEF_E2SM_KPM_IndicationMessage,
1252                          indicationmessage, e2smbuffer, e2smbuffer_size);
1253
1254   fprintf(stderr, "er encded is %d\n", er.encoded);
1255   fprintf(stderr, "after encoding message\n");  
1256
1257
1258 }
1259
1260 void encode_kpm_report_style5(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1261
1262   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1263
1264
1265   uint8_t *buf = (uint8_t*)"GNBCUUP5";
1266   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1267   gnbcuupname->size = 8;
1268   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1269   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1270
1271
1272   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1273   uint8_t buffer[1];
1274   buffer[0]= 40000;
1275   bytesdl->buf = (uint8_t*)calloc(1,1);
1276   memcpy(bytesdl->buf, buffer,1);
1277   bytesdl->size = 1;
1278
1279   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1280   uint8_t buffer1[1];
1281   buffer1[0] = 50000;
1282   bytesul->buf = (uint8_t*)calloc(1,1);
1283   memcpy(bytesul->buf, buffer1, 1);
1284   bytesul->size = 1;
1285
1286   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1287   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1288   fqilistitem->fiveQI = 9;
1289   fqilistitem->pDCPBytesDL = bytesdl;
1290   fqilistitem->pDCPBytesUL = bytesul;
1291
1292
1293   uint8_t *buf1 = (uint8_t*)"4";  
1294   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1295   sst->size = 6;
1296   sst->buf = (uint8_t*)calloc(1,6);
1297   memcpy(sst->buf,buf1,sst->size);
1298
1299
1300   uint8_t *bufz = (uint8_t*)"SD1";
1301   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1302   sds->size = 3;
1303   sds->buf = (uint8_t*)calloc(1,3);
1304   memcpy(sds->buf, bufz, sds->size);
1305
1306   
1307   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1308   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1309   snssai->sST.buf = (uint8_t*)calloc(1,1);
1310   snssai->sST.size = 1;
1311   memcpy(snssai->sST.buf, buf1, 1);
1312   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1313   snssai->sD->buf = (uint8_t*)calloc(1,3);
1314   snssai->sD->size = 3;
1315   memcpy(snssai->sD->buf, bufz, 3);
1316
1317   
1318
1319   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1320   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1321   slicelistitem->sliceID = *snssai;
1322   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1323
1324   asn_codec_ctx_t *opt_cod;  
1325
1326
1327   uint8_t e2smbuffera[8192];
1328   size_t e2smbuffer_sizea = 8192;
1329
1330
1331
1332   asn_enc_rval_t era =
1333     asn_encode_to_buffer(opt_cod,
1334                          ATS_ALIGNED_BASIC_PER,
1335                          &asn_DEF_SliceToReportListItem,
1336                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1337   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1338   fprintf(stderr, "after encoding message\n");
1339
1340
1341
1342   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1343   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1344   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1345
1346   uint8_t *buf2 = (uint8_t*)"747";
1347   //  std::string pl = "PLMNID7";
1348   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1349   //  uint8_t *buf2 = &plvec[0];
1350   
1351   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1352   plmnid->buf = (uint8_t*)calloc(3,1);
1353   plmnid->size = 3;
1354   memcpy(plmnid->buf, buf2, plmnid->size);
1355
1356
1357   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1358   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1359   plmnidlist->pLMN_Identity = *plmnid;
1360   plmnidlist->cu_UP_PM_5GC = pm_format;
1361
1362   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1363   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1364   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1365
1366
1367   
1368   
1369   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1370   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1371   listitem1->interface_type = 2;
1372   listitem1->o_CU_UP_PM_Container = *meas_cont;
1373
1374   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1375   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1376   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1377   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1378   
1379   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1380
1381   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1382   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1383   pfcontainer->present = pres1;
1384   pfcontainer->choice.oCU_UP = *cuupcont;
1385
1386   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1387   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1388   containers_list->performanceContainer = pfcontainer;
1389
1390   E2SM_KPM_IndicationMessage_Format1_t *format =
1391     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1392   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1393
1394   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1395   
1396   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
1397
1398   indicationmessage->indicationMessage.present = pres;
1399
1400   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
1401
1402   char *error_buf = (char*)calloc(300, sizeof(char));
1403   size_t errlen;
1404
1405   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1406   printf("error length %d\n", errlen);
1407   printf("error buf %s\n", error_buf);
1408
1409   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1410   
1411
1412   uint8_t e2smbuffer[8192];
1413   size_t e2smbuffer_size = 8192;
1414
1415   uint8_t e2smbuffer2[8192];
1416   size_t e2smbuffer_size2 = 8192;  
1417
1418   asn_enc_rval_t er =
1419     asn_encode_to_buffer(opt_cod,
1420                          ATS_ALIGNED_BASIC_PER,
1421                          &asn_DEF_E2SM_KPM_IndicationMessage,
1422                          indicationmessage, e2smbuffer, e2smbuffer_size);
1423
1424   fprintf(stderr, "er encded is %d\n", er.encoded);
1425   fprintf(stderr, "after encoding message\n");
1426
1427 }
1428
1429
1430 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1431
1432   /*
1433   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1434   //std::string gn = "GNBCUUP5";
1435   //std::vector<uint8_t> gnvec(gn.begin(), gn.end());
1436   //uint8_t *buf = &gnvec[0];
1437   uint8_t *buf = (uint8_t*)"GNBCUUP5";
1438   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1439   gnbcuupname->size = 8;
1440   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1441   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1442
1443
1444   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1445   uint8_t buffer[1];
1446   buffer[0]= 40000;
1447   bytesdl->buf = (uint8_t*)calloc(1,1);
1448   memcpy(bytesdl->buf, buffer,1);
1449   bytesdl->size = 1;
1450
1451   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1452   uint8_t buffer1[1];
1453   buffer1[0] = 50000;
1454   bytesul->buf = (uint8_t*)calloc(1,1);
1455   memcpy(bytesul->buf, buffer1, 1);
1456   bytesul->size = 1;
1457
1458   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1459   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1460   fqilistitem->fiveQI = 9;
1461   fqilistitem->pDCPBytesDL = bytesdl;
1462   fqilistitem->pDCPBytesUL = bytesul;
1463
1464
1465
1466   //  std::string sl = "SLICE4";
1467   //  std::vector<uint8_t> slvec(sl.begin(), sl.end());
1468   //  uint8_t *buf1 = &slvec[0];
1469   uint8_t *buf1 = (uint8_t*)"4";  
1470   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1471   sst->size = 6;
1472   sst->buf = (uint8_t*)calloc(1,6);
1473   memcpy(sst->buf,buf1,sst->size);
1474
1475   //  std::string sd = "SD1";
1476   //  std::vector<uint8_t> sdvec(sd.begin(), sd.end());
1477   //  uint8_t *bufz = &sdvec[0];
1478   uint8_t *bufz = (uint8_t*)"SD1";
1479   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1480   sds->size = 3;
1481   sds->buf = (uint8_t*)calloc(1,3);
1482   memcpy(sds->buf, bufz, sds->size);
1483
1484   
1485   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1486   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1487   snssai->sST.buf = (uint8_t*)calloc(1,1);
1488   snssai->sST.size = 1;
1489   memcpy(snssai->sST.buf, buf1, 1);
1490   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1491   snssai->sD->buf = (uint8_t*)calloc(1,3);
1492   snssai->sD->size = 3;
1493   memcpy(snssai->sD->buf, bufz, 3);
1494
1495   
1496
1497   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1498   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1499   slicelistitem->sliceID = *snssai;
1500   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1501
1502   asn_codec_ctx_t *opt_cod;  
1503
1504
1505   uint8_t e2smbuffera[8192];
1506   size_t e2smbuffer_sizea = 8192;
1507
1508
1509
1510   asn_enc_rval_t era =
1511     asn_encode_to_buffer(opt_cod,
1512                          ATS_ALIGNED_BASIC_PER,
1513                          &asn_DEF_SliceToReportListItem,
1514                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1515   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1516   fprintf(stderr, "after encoding message\n");      
1517
1518
1519
1520   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1521   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1522   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1523
1524   uint8_t *buf2 = (uint8_t*)"747";
1525   //  std::string pl = "PLMNID7";
1526   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1527   //  uint8_t *buf2 = &plvec[0];
1528   
1529   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1530   plmnid->buf = (uint8_t*)calloc(3,1);
1531   plmnid->size = 3;
1532   memcpy(plmnid->buf, buf2, plmnid->size);
1533
1534
1535   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1536   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1537   plmnidlist->pLMN_Identity = *plmnid;
1538   plmnidlist->cu_UP_PM_5GC = pm_format;
1539
1540   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1541   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1542   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1543
1544
1545   
1546   
1547   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1548   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1549   listitem1->interface_type = 2;
1550   listitem1->o_CU_UP_PM_Container = *meas_cont;
1551
1552   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1553   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1554   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1555   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1556   
1557   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1558
1559   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1560   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1561   pfcontainer->present = pres1;
1562   pfcontainer->choice.oCU_UP = *cuupcont;
1563
1564   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1565   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1566   containers_list->performanceContainer = pfcontainer;
1567
1568   E2SM_KPM_IndicationMessage_Format1_t *format =
1569     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1570   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1571
1572   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1573   
1574   E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
1575
1576   indicationmessage->present = pres;
1577
1578   indicationmessage->choice.indicationMessage_Format1 = *format;
1579
1580   char *error_buf = (char*)calloc(300, sizeof(char));
1581   size_t errlen;
1582
1583   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1584   printf("error length %d\n", errlen);
1585   printf("error buf %s\n", error_buf);
1586
1587   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1588   
1589
1590   uint8_t e2smbuffer[8192];
1591   size_t e2smbuffer_size = 8192;
1592
1593   uint8_t e2smbuffer2[8192];
1594   size_t e2smbuffer_size2 = 8192;  
1595
1596   asn_enc_rval_t er =
1597     asn_encode_to_buffer(opt_cod,
1598                          ATS_ALIGNED_BASIC_PER,
1599                          &asn_DEF_E2SM_KPM_IndicationMessage,
1600                          indicationmessage, e2smbuffer, e2smbuffer_size);
1601
1602   fprintf(stderr, "er encded is %d\n", er.encoded);
1603   fprintf(stderr, "after encoding message\n");
1604
1605   */
1606 }
1607
1608 /*
1609 void encode_kpm_bak(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1610   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1611   std::string gn = "GNBCUUP5";
1612   std::vector<uint8_t> gnvec(gn.begin(), gn.end());
1613   uint8_t *buf = &gnvec[0];
1614   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1615   gnbcuupname->size = 8;
1616   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1617   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1618
1619
1620   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1621   uint8_t buffer[1];
1622   buffer[0]= 40000;
1623   bytesdl->buf = (uint8_t*)calloc(1,1);
1624   memcpy(bytesdl->buf, buffer,1);
1625   bytesdl->size = 1;
1626
1627   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1628   uint8_t buffer1[1];
1629   buffer1[0] = 50000;
1630   bytesul->buf = (uint8_t*)calloc(1,1);
1631   memcpy(bytesul->buf, buffer1, 1);
1632   bytesul->size = 1;
1633
1634   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1635   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1636   fqilistitem->fiveQI = 9;
1637   fqilistitem->pDCPBytesDL = bytesdl;
1638   fqilistitem->pDCPBytesUL = bytesul;
1639
1640
1641
1642   std::string sl = "SLICE4";
1643   std::vector<uint8_t> slvec(sl.begin(), sl.end());
1644   //  uint8_t *buf1 = &slvec[0];
1645   uint8_t *buf1 = (uint8_t*)"SLICE4";  
1646   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1647   sst->size = 6;
1648   sst->buf = (uint8_t*)calloc(1,6);
1649   memcpy(sst->buf,buf1,sst->size);
1650
1651   std::string sd = "SD1";
1652   std::vector<uint8_t> sdvec(sd.begin(), sd.end());
1653   //  uint8_t *bufz = &sdvec[0];
1654   uint8_t *bufz = (uint8_t*)"SD1";
1655   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1656   sds->size = 3;
1657   sds->buf = (uint8_t*)calloc(1,3);
1658   memcpy(sds->buf, bufz, sds->size);
1659
1660   
1661   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1662   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1663   snssai->sST.buf = (uint8_t*)calloc(6,1);
1664   snssai->sST.size = 6;
1665   memcpy(snssai->sST.buf, buf1, 6);
1666   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1667   snssai->sD->buf = (uint8_t*)calloc(1,3);
1668   snssai->sD->size = 3;
1669   memcpy(snssai->sD->buf, bufz, 3);
1670
1671   
1672
1673   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1674   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1675   slicelistitem->sliceID = *snssai;
1676   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1677
1678   uint8_t e2smbuffera[8192];
1679   size_t e2smbuffer_sizea = 8192;  
1680
1681   auto era =
1682     asn_encode_to_buffer(nullptr,
1683                          ATS_ALIGNED_BASIC_PER,
1684                          &asn_DEF_SliceToReportListItem,
1685                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1686   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1687   fprintf(stderr, "after encoding message\n");      
1688
1689   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1690   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1691   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1692
1693   std::string pl = "PLMNID7";
1694   std::vector<uint8_t> plvec(pl.begin(), pl.end());
1695   uint8_t *buf2 = &plvec[0];
1696   
1697   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1698   plmnid->buf = (uint8_t*)calloc(1,7);
1699   plmnid->size = 7;  
1700   memcpy(plmnid->buf, buf2, plmnid->size);
1701
1702
1703   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1704   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1705   plmnidlist->pLMN_Identity = *plmnid;
1706   plmnidlist->cu_UP_PM_5GC = pm_format;
1707
1708   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1709   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1710   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1711
1712
1713   
1714   
1715   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1716   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1717   listitem1->interface_type = 2;
1718   listitem1->o_CU_UP_PM_Container = *meas_cont;
1719
1720   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1721   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1722   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1723   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1724   
1725   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1726
1727   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1728   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1729   pfcontainer->present = pres1;
1730   pfcontainer->choice.oCU_UP = *cuupcont;
1731
1732   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1733   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1734   containers_list->performanceContainer = pfcontainer;
1735
1736   E2SM_KPM_IndicationMessage_Format1_t *format =
1737     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1738   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1739
1740   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1741   
1742   E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
1743
1744   indicationmessage->present = pres;
1745
1746   indicationmessage->choice.indicationMessage_Format1 = *format;
1747
1748   char *error_buf = (char*)calloc(300, sizeof(char));
1749   size_t errlen;
1750
1751   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1752   printf("error length %d\n", errlen);
1753   printf("error buf %s\n", error_buf);
1754   
1755
1756   uint8_t e2smbuffer[8192];
1757   size_t e2smbuffer_size = 8192;
1758
1759   uint8_t e2smbuffer2[8192];
1760   size_t e2smbuffer_size2 = 8192;  
1761
1762   auto er =
1763     asn_encode_to_buffer(nullptr,
1764                          ATS_ALIGNED_BASIC_PER,
1765                          &asn_DEF_E2SM_KPM_IndicationMessage,
1766                          indicationmessage, e2smbuffer, e2smbuffer_size);
1767
1768   fprintf(stderr, "er encded is %d\n", er.encoded);
1769   fprintf(stderr, "after encoding message\n");
1770
1771   
1772 }
1773 */