Issue-ID: SIM-18
[sim/e2-interface.git] / e2sim / e2apv1sim / ricsim / 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
1101   int array_size_dl;
1102
1103   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1104
1105   if (bytes_dl <= 64) {
1106     array_size_dl = 1;
1107
1108     uint8_t buffer[array_size_dl];
1109     buffer[0] = bytes_dl & 0xFF;
1110     bytesdl->buf = (uint8_t*)calloc(1,1);
1111     memcpy(bytesdl->buf,buffer,1);
1112     bytesdl->size = 1;
1113
1114   } else if (bytes_dl <= 16384) {
1115     array_size_dl = 2;
1116
1117     uint8_t buffer[array_size_dl];
1118     buffer[0] = (bytes_dl >> 8) & 0xFF;
1119     buffer[1] = bytes_dl & 0xFF;
1120     bytesdl->buf = (uint8_t*)calloc(2,1);
1121     memcpy(bytesdl->buf,buffer,2);
1122     bytesdl->size = 2;
1123     
1124   } else if (bytes_dl <= 4194304) {
1125     array_size_dl = 3;
1126
1127     uint8_t buffer[array_size_dl];
1128     buffer[0] = (bytes_dl >> 16) & 0xFF;
1129     buffer[1] = (bytes_dl >> 8) & 0xFF;
1130     buffer[2] = bytes_dl & 0xFF;
1131     bytesdl->buf = (uint8_t*)calloc(3,1);
1132     memcpy(bytesdl->buf,buffer,3);
1133     bytesdl->size = 3;    
1134     
1135   } else if (bytes_dl <= 1073741824) {
1136     array_size_dl = 4;
1137     uint8_t buffer[array_size_dl];
1138     buffer[0] = (bytes_dl >> 24) & 0xFF;
1139     buffer[1] = (bytes_dl >> 16) & 0xFF;
1140     buffer[2] = (bytes_dl >> 8) & 0xFF;
1141     buffer[3] = bytes_dl & 0xFF;
1142     bytesdl->buf = (uint8_t*)calloc(4,1);
1143     memcpy(bytesdl->buf,buffer,4);
1144     bytesdl->size = 4;
1145   }
1146   
1147   
1148   //We need to convert bytes_ul into array of uint8_t
1149   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1150
1151   int array_size_ul;
1152
1153   if (bytes_ul <= 64) {
1154     array_size_ul = 1;
1155
1156     uint8_t buffer[array_size_ul];
1157     buffer[0] = bytes_ul & 0xFF;
1158     bytesul->buf = (uint8_t*)calloc(1,1);
1159     memcpy(bytesul->buf,buffer,1);
1160     bytesul->size = 1;
1161
1162   } else if (bytes_ul <= 16384) {
1163     array_size_ul = 2;
1164
1165     uint8_t buffer[array_size_ul];
1166     buffer[0] = (bytes_ul >> 8) & 0xFF;
1167     buffer[1] = bytes_ul & 0xFF;
1168     bytesul->buf = (uint8_t*)calloc(2,1);
1169     memcpy(bytesul->buf,buffer,2);
1170     bytesul->size = 2;
1171     
1172   } else if (bytes_ul <= 4194304) {
1173     array_size_ul = 3;
1174
1175     uint8_t buffer[array_size_ul];
1176     buffer[0] = (bytes_ul >> 16) & 0xFF;
1177     buffer[1] = (bytes_ul >> 8) & 0xFF;
1178     buffer[2] = bytes_ul & 0xFF;
1179     bytesul->buf = (uint8_t*)calloc(3,1);
1180     memcpy(bytesul->buf,buffer,3);
1181     bytesul->size = 3;    
1182     
1183   } else if (bytes_ul <= 1073741824) {
1184     array_size_ul = 4;
1185     uint8_t buffer[array_size_ul];
1186     buffer[0] = (bytes_ul >> 24) & 0xFF;
1187     buffer[1] = (bytes_ul >> 16) & 0xFF;
1188     buffer[2] = (bytes_ul >> 8) & 0xFF;
1189     buffer[3] = bytes_ul & 0xFF;
1190     bytesul->buf = (uint8_t*)calloc(4,1);
1191     memcpy(bytesul->buf,buffer,4);
1192     bytesul->size = 4;
1193   }
1194   
1195
1196   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1197   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1198   fqilistitem->fiveQI = 9;
1199   fqilistitem->pDCPBytesDL = bytesdl;
1200   fqilistitem->pDCPBytesUL = bytesul;
1201
1202
1203   uint8_t *buf1 = (uint8_t*)"4";  
1204   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1205   sst->size = 6;
1206   sst->buf = (uint8_t*)calloc(1,6);
1207   memcpy(sst->buf,sst_buf,sst->size);
1208
1209
1210   uint8_t *bufz = (uint8_t*)"SD1";
1211   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1212   sds->size = 3;
1213   sds->buf = (uint8_t*)calloc(1,3);
1214   memcpy(sds->buf, sd_buf, sds->size);
1215
1216   
1217   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1218   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1219   snssai->sST.buf = (uint8_t*)calloc(1,1);
1220   snssai->sST.size = 1;
1221   memcpy(snssai->sST.buf, sst_buf, 1);
1222   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1223   snssai->sD->buf = (uint8_t*)calloc(1,3);
1224   snssai->sD->size = 3;
1225   memcpy(snssai->sD->buf, sd_buf, 3);
1226
1227   
1228
1229   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1230   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1231   slicelistitem->sliceID = *snssai;
1232   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1233
1234   asn_codec_ctx_t *opt_cod;  
1235
1236
1237   uint8_t e2smbuffera[8192];
1238   size_t e2smbuffer_sizea = 8192;
1239
1240
1241
1242   asn_enc_rval_t era =
1243     asn_encode_to_buffer(opt_cod,
1244                          ATS_ALIGNED_BASIC_PER,
1245                          &asn_DEF_SliceToReportListItem,
1246                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1247   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1248   fprintf(stderr, "after encoding message\n");      
1249
1250
1251
1252   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1253   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1254   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1255
1256   uint8_t *buf2 = (uint8_t*)"747";
1257   //  std::string pl = "PLMNID7";
1258   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1259   //  uint8_t *buf2 = &plvec[0];
1260   
1261   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1262   plmnid->buf = (uint8_t*)calloc(3,1);
1263   plmnid->size = 3;
1264   memcpy(plmnid->buf, plmnid_buf, plmnid->size);
1265
1266
1267   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1268   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1269   plmnidlist->pLMN_Identity = *plmnid;
1270   plmnidlist->cu_UP_PM_5GC = pm_format;
1271
1272   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1273   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1274   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1275
1276
1277   
1278   
1279   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1280   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1281   listitem1->interface_type = 2;
1282   listitem1->o_CU_UP_PM_Container = *meas_cont;
1283
1284   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1285   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1286   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1287   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1288   
1289   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1290
1291   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1292   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1293   pfcontainer->present = pres1;
1294   pfcontainer->choice.oCU_UP = *cuupcont;
1295
1296   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1297   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1298   containers_list->performanceContainer = pfcontainer;
1299
1300   E2SM_KPM_IndicationMessage_Format1_t *format =
1301     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1302   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1303
1304   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1305   
1306   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
1307
1308   indicationmessage->indicationMessage.present = pres;
1309
1310   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
1311
1312   char *error_buf = (char*)calloc(300, sizeof(char));
1313   size_t errlen;
1314
1315   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1316   printf("error length %d\n", errlen);
1317   printf("error buf %s\n", error_buf);
1318
1319   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1320   
1321
1322   uint8_t e2smbuffer[8192];
1323   size_t e2smbuffer_size = 8192;
1324
1325   uint8_t e2smbuffer2[8192];
1326   size_t e2smbuffer_size2 = 8192;  
1327
1328   asn_enc_rval_t er =
1329     asn_encode_to_buffer(opt_cod,
1330                          ATS_ALIGNED_BASIC_PER,
1331                          &asn_DEF_E2SM_KPM_IndicationMessage,
1332                          indicationmessage, e2smbuffer, e2smbuffer_size);
1333
1334   fprintf(stderr, "er encded is %d\n", er.encoded);
1335   fprintf(stderr, "after encoding message\n");  
1336
1337
1338 }
1339
1340 void encode_kpm_report_style5(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1341
1342   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1343
1344
1345   uint8_t *buf = (uint8_t*)"GNBCUUP5";
1346   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1347   gnbcuupname->size = 8;
1348   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1349   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1350
1351
1352   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1353   uint8_t buffer[1];
1354   buffer[0]= 40000;
1355   bytesdl->buf = (uint8_t*)calloc(1,1);
1356   memcpy(bytesdl->buf, buffer,1);
1357   bytesdl->size = 1;
1358
1359   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1360   uint8_t buffer1[1];
1361   buffer1[0] = 50000;
1362   bytesul->buf = (uint8_t*)calloc(1,1);
1363   memcpy(bytesul->buf, buffer1, 1);
1364   bytesul->size = 1;
1365
1366   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1367   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1368   fqilistitem->fiveQI = 9;
1369   fqilistitem->pDCPBytesDL = bytesdl;
1370   fqilistitem->pDCPBytesUL = bytesul;
1371
1372
1373   uint8_t *buf1 = (uint8_t*)"4";  
1374   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1375   sst->size = 6;
1376   sst->buf = (uint8_t*)calloc(1,6);
1377   memcpy(sst->buf,buf1,sst->size);
1378
1379
1380   uint8_t *bufz = (uint8_t*)"SD1";
1381   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1382   sds->size = 3;
1383   sds->buf = (uint8_t*)calloc(1,3);
1384   memcpy(sds->buf, bufz, sds->size);
1385
1386   
1387   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1388   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1389   snssai->sST.buf = (uint8_t*)calloc(1,1);
1390   snssai->sST.size = 1;
1391   memcpy(snssai->sST.buf, buf1, 1);
1392   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1393   snssai->sD->buf = (uint8_t*)calloc(1,3);
1394   snssai->sD->size = 3;
1395   memcpy(snssai->sD->buf, bufz, 3);
1396
1397   
1398
1399   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1400   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1401   slicelistitem->sliceID = *snssai;
1402   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1403
1404   asn_codec_ctx_t *opt_cod;  
1405
1406
1407   uint8_t e2smbuffera[8192];
1408   size_t e2smbuffer_sizea = 8192;
1409
1410
1411
1412   asn_enc_rval_t era =
1413     asn_encode_to_buffer(opt_cod,
1414                          ATS_ALIGNED_BASIC_PER,
1415                          &asn_DEF_SliceToReportListItem,
1416                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1417   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1418   fprintf(stderr, "after encoding message\n");
1419
1420
1421
1422   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1423   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1424   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1425
1426   uint8_t *buf2 = (uint8_t*)"747";
1427   //  std::string pl = "PLMNID7";
1428   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1429   //  uint8_t *buf2 = &plvec[0];
1430   
1431   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1432   plmnid->buf = (uint8_t*)calloc(3,1);
1433   plmnid->size = 3;
1434   memcpy(plmnid->buf, buf2, plmnid->size);
1435
1436
1437   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1438   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1439   plmnidlist->pLMN_Identity = *plmnid;
1440   plmnidlist->cu_UP_PM_5GC = pm_format;
1441
1442   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1443   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1444   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1445
1446
1447   
1448   
1449   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1450   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1451   listitem1->interface_type = 2;
1452   listitem1->o_CU_UP_PM_Container = *meas_cont;
1453
1454   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1455   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1456   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1457   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1458   
1459   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1460
1461   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1462   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1463   pfcontainer->present = pres1;
1464   pfcontainer->choice.oCU_UP = *cuupcont;
1465
1466   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1467   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1468   containers_list->performanceContainer = pfcontainer;
1469
1470   E2SM_KPM_IndicationMessage_Format1_t *format =
1471     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1472   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1473
1474   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1475   
1476   E2SM_KPM_IndicationMessage__indicationMessage_PR pres = E2SM_KPM_IndicationMessage__indicationMessage_PR_indicationMessage_Format1;
1477
1478   indicationmessage->indicationMessage.present = pres;
1479
1480   indicationmessage->indicationMessage.choice.indicationMessage_Format1 = *format;
1481
1482   char *error_buf = (char*)calloc(300, sizeof(char));
1483   size_t errlen;
1484
1485   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1486   printf("error length %d\n", errlen);
1487   printf("error buf %s\n", error_buf);
1488
1489   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1490   
1491
1492   uint8_t e2smbuffer[8192];
1493   size_t e2smbuffer_size = 8192;
1494
1495   uint8_t e2smbuffer2[8192];
1496   size_t e2smbuffer_size2 = 8192;  
1497
1498   asn_enc_rval_t er =
1499     asn_encode_to_buffer(opt_cod,
1500                          ATS_ALIGNED_BASIC_PER,
1501                          &asn_DEF_E2SM_KPM_IndicationMessage,
1502                          indicationmessage, e2smbuffer, e2smbuffer_size);
1503
1504   fprintf(stderr, "er encded is %d\n", er.encoded);
1505   fprintf(stderr, "after encoding message\n");
1506
1507 }
1508
1509
1510 void encode_kpm(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1511
1512   /*
1513   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1514   //std::string gn = "GNBCUUP5";
1515   //std::vector<uint8_t> gnvec(gn.begin(), gn.end());
1516   //uint8_t *buf = &gnvec[0];
1517   uint8_t *buf = (uint8_t*)"GNBCUUP5";
1518   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1519   gnbcuupname->size = 8;
1520   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1521   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1522
1523
1524   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1525   uint8_t buffer[1];
1526   buffer[0]= 40000;
1527   bytesdl->buf = (uint8_t*)calloc(1,1);
1528   memcpy(bytesdl->buf, buffer,1);
1529   bytesdl->size = 1;
1530
1531   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1532   uint8_t buffer1[1];
1533   buffer1[0] = 50000;
1534   bytesul->buf = (uint8_t*)calloc(1,1);
1535   memcpy(bytesul->buf, buffer1, 1);
1536   bytesul->size = 1;
1537
1538   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1539   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1540   fqilistitem->fiveQI = 9;
1541   fqilistitem->pDCPBytesDL = bytesdl;
1542   fqilistitem->pDCPBytesUL = bytesul;
1543
1544
1545
1546   //  std::string sl = "SLICE4";
1547   //  std::vector<uint8_t> slvec(sl.begin(), sl.end());
1548   //  uint8_t *buf1 = &slvec[0];
1549   uint8_t *buf1 = (uint8_t*)"4";  
1550   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1551   sst->size = 6;
1552   sst->buf = (uint8_t*)calloc(1,6);
1553   memcpy(sst->buf,buf1,sst->size);
1554
1555   //  std::string sd = "SD1";
1556   //  std::vector<uint8_t> sdvec(sd.begin(), sd.end());
1557   //  uint8_t *bufz = &sdvec[0];
1558   uint8_t *bufz = (uint8_t*)"SD1";
1559   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1560   sds->size = 3;
1561   sds->buf = (uint8_t*)calloc(1,3);
1562   memcpy(sds->buf, bufz, sds->size);
1563
1564   
1565   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1566   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1567   snssai->sST.buf = (uint8_t*)calloc(1,1);
1568   snssai->sST.size = 1;
1569   memcpy(snssai->sST.buf, buf1, 1);
1570   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1571   snssai->sD->buf = (uint8_t*)calloc(1,3);
1572   snssai->sD->size = 3;
1573   memcpy(snssai->sD->buf, bufz, 3);
1574
1575   
1576
1577   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1578   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1579   slicelistitem->sliceID = *snssai;
1580   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1581
1582   asn_codec_ctx_t *opt_cod;  
1583
1584
1585   uint8_t e2smbuffera[8192];
1586   size_t e2smbuffer_sizea = 8192;
1587
1588
1589
1590   asn_enc_rval_t era =
1591     asn_encode_to_buffer(opt_cod,
1592                          ATS_ALIGNED_BASIC_PER,
1593                          &asn_DEF_SliceToReportListItem,
1594                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1595   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1596   fprintf(stderr, "after encoding message\n");      
1597
1598
1599
1600   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1601   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1602   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1603
1604   uint8_t *buf2 = (uint8_t*)"747";
1605   //  std::string pl = "PLMNID7";
1606   //  std::vector<uint8_t> plvec(pl.begin(), pl.end());
1607   //  uint8_t *buf2 = &plvec[0];
1608   
1609   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1610   plmnid->buf = (uint8_t*)calloc(3,1);
1611   plmnid->size = 3;
1612   memcpy(plmnid->buf, buf2, plmnid->size);
1613
1614
1615   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1616   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1617   plmnidlist->pLMN_Identity = *plmnid;
1618   plmnidlist->cu_UP_PM_5GC = pm_format;
1619
1620   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1621   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1622   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1623
1624
1625   
1626   
1627   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1628   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1629   listitem1->interface_type = 2;
1630   listitem1->o_CU_UP_PM_Container = *meas_cont;
1631
1632   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1633   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1634   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1635   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1636   
1637   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1638
1639   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1640   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1641   pfcontainer->present = pres1;
1642   pfcontainer->choice.oCU_UP = *cuupcont;
1643
1644   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1645   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1646   containers_list->performanceContainer = pfcontainer;
1647
1648   E2SM_KPM_IndicationMessage_Format1_t *format =
1649     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1650   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1651
1652   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1653   
1654   E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
1655
1656   indicationmessage->present = pres;
1657
1658   indicationmessage->choice.indicationMessage_Format1 = *format;
1659
1660   char *error_buf = (char*)calloc(300, sizeof(char));
1661   size_t errlen;
1662
1663   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1664   printf("error length %d\n", errlen);
1665   printf("error buf %s\n", error_buf);
1666
1667   xer_fprint(stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1668   
1669
1670   uint8_t e2smbuffer[8192];
1671   size_t e2smbuffer_size = 8192;
1672
1673   uint8_t e2smbuffer2[8192];
1674   size_t e2smbuffer_size2 = 8192;  
1675
1676   asn_enc_rval_t er =
1677     asn_encode_to_buffer(opt_cod,
1678                          ATS_ALIGNED_BASIC_PER,
1679                          &asn_DEF_E2SM_KPM_IndicationMessage,
1680                          indicationmessage, e2smbuffer, e2smbuffer_size);
1681
1682   fprintf(stderr, "er encded is %d\n", er.encoded);
1683   fprintf(stderr, "after encoding message\n");
1684
1685   */
1686 }
1687
1688 /*
1689 void encode_kpm_bak(E2SM_KPM_IndicationMessage_t* indicationmessage) {
1690   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage);
1691   std::string gn = "GNBCUUP5";
1692   std::vector<uint8_t> gnvec(gn.begin(), gn.end());
1693   uint8_t *buf = &gnvec[0];
1694   OCTET_STRING_t *gnbcuupname = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1695   gnbcuupname->size = 8;
1696   gnbcuupname->buf = (uint8_t*)calloc(1,8);
1697   memcpy(gnbcuupname->buf, buf, gnbcuupname->size);
1698
1699
1700   INTEGER_t *bytesdl = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1701   uint8_t buffer[1];
1702   buffer[0]= 40000;
1703   bytesdl->buf = (uint8_t*)calloc(1,1);
1704   memcpy(bytesdl->buf, buffer,1);
1705   bytesdl->size = 1;
1706
1707   INTEGER_t *bytesul = (INTEGER_t*)calloc(1, sizeof(INTEGER_t));
1708   uint8_t buffer1[1];
1709   buffer1[0] = 50000;
1710   bytesul->buf = (uint8_t*)calloc(1,1);
1711   memcpy(bytesul->buf, buffer1, 1);
1712   bytesul->size = 1;
1713
1714   FQIPERSlicesPerPlmnListItem_t *fqilistitem = (FQIPERSlicesPerPlmnListItem_t*)calloc(1, sizeof(FQIPERSlicesPerPlmnListItem_t));
1715   ASN_STRUCT_RESET(asn_DEF_FQIPERSlicesPerPlmnListItem, fqilistitem);
1716   fqilistitem->fiveQI = 9;
1717   fqilistitem->pDCPBytesDL = bytesdl;
1718   fqilistitem->pDCPBytesUL = bytesul;
1719
1720
1721
1722   std::string sl = "SLICE4";
1723   std::vector<uint8_t> slvec(sl.begin(), sl.end());
1724   //  uint8_t *buf1 = &slvec[0];
1725   uint8_t *buf1 = (uint8_t*)"SLICE4";  
1726   OCTET_STRING_t *sst = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1727   sst->size = 6;
1728   sst->buf = (uint8_t*)calloc(1,6);
1729   memcpy(sst->buf,buf1,sst->size);
1730
1731   std::string sd = "SD1";
1732   std::vector<uint8_t> sdvec(sd.begin(), sd.end());
1733   //  uint8_t *bufz = &sdvec[0];
1734   uint8_t *bufz = (uint8_t*)"SD1";
1735   OCTET_STRING_t *sds = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1736   sds->size = 3;
1737   sds->buf = (uint8_t*)calloc(1,3);
1738   memcpy(sds->buf, bufz, sds->size);
1739
1740   
1741   SNSSAI_t *snssai = (SNSSAI_t*)calloc(1, sizeof(SNSSAI_t));
1742   ASN_STRUCT_RESET(asn_DEF_SNSSAI,snssai);
1743   snssai->sST.buf = (uint8_t*)calloc(6,1);
1744   snssai->sST.size = 6;
1745   memcpy(snssai->sST.buf, buf1, 6);
1746   snssai->sD = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t));
1747   snssai->sD->buf = (uint8_t*)calloc(1,3);
1748   snssai->sD->size = 3;
1749   memcpy(snssai->sD->buf, bufz, 3);
1750
1751   
1752
1753   SliceToReportListItem_t *slicelistitem = (SliceToReportListItem_t*)calloc(1,sizeof(SliceToReportListItem_t));
1754   ASN_STRUCT_RESET(asn_DEF_SliceToReportListItem, slicelistitem);
1755   slicelistitem->sliceID = *snssai;
1756   int ret = ASN_SEQUENCE_ADD(&slicelistitem->fQIPERSlicesPerPlmnList.list, fqilistitem);
1757
1758   uint8_t e2smbuffera[8192];
1759   size_t e2smbuffer_sizea = 8192;  
1760
1761   auto era =
1762     asn_encode_to_buffer(nullptr,
1763                          ATS_ALIGNED_BASIC_PER,
1764                          &asn_DEF_SliceToReportListItem,
1765                          slicelistitem, e2smbuffera, e2smbuffer_sizea);
1766   fprintf(stderr, "inner er encded is %d\n", era.encoded);
1767   fprintf(stderr, "after encoding message\n");      
1768
1769   FGC_CUUP_PM_Format_t *pm_format = (FGC_CUUP_PM_Format_t*)calloc(1,sizeof(FGC_CUUP_PM_Format_t));
1770   ASN_STRUCT_RESET(asn_DEF_FGC_CUUP_PM_Format, pm_format);
1771   ret = ASN_SEQUENCE_ADD(&pm_format->sliceToReportList.list, slicelistitem);
1772
1773   std::string pl = "PLMNID7";
1774   std::vector<uint8_t> plvec(pl.begin(), pl.end());
1775   uint8_t *buf2 = &plvec[0];
1776   
1777   OCTET_STRING_t *plmnid = (OCTET_STRING_t*)calloc(1,sizeof(OCTET_STRING_t));
1778   plmnid->buf = (uint8_t*)calloc(1,7);
1779   plmnid->size = 7;  
1780   memcpy(plmnid->buf, buf2, plmnid->size);
1781
1782
1783   PlmnID_List_t *plmnidlist = (PlmnID_List_t*)calloc(1,sizeof(PlmnID_List_t));
1784   ASN_STRUCT_RESET(asn_DEF_PlmnID_List, plmnidlist);
1785   plmnidlist->pLMN_Identity = *plmnid;
1786   plmnidlist->cu_UP_PM_5GC = pm_format;
1787
1788   CUUPMeasurement_Container_t *meas_cont = (CUUPMeasurement_Container_t*)calloc(1, sizeof(CUUPMeasurement_Container_t));
1789   ASN_STRUCT_RESET(asn_DEF_CUUPMeasurement_Container, meas_cont);
1790   ret = ASN_SEQUENCE_ADD(&meas_cont->plmnList.list, plmnidlist);
1791
1792
1793   
1794   
1795   PF_ContainerListItem_t *listitem1 = (PF_ContainerListItem_t*)calloc(1, sizeof(PF_ContainerListItem_t));
1796   ASN_STRUCT_RESET(asn_DEF_PF_ContainerListItem, listitem1);
1797   listitem1->interface_type = 2;
1798   listitem1->o_CU_UP_PM_Container = *meas_cont;
1799
1800   OCUUP_PF_Container_t *cuupcont = (OCUUP_PF_Container_t*)calloc(1,sizeof(OCUUP_PF_Container_t));
1801   ASN_STRUCT_RESET(asn_DEF_OCUUP_PF_Container, cuupcont);
1802   cuupcont->gNB_CU_UP_Name = gnbcuupname;
1803   ret = ASN_SEQUENCE_ADD(&cuupcont->pf_ContainerList.list, listitem1);
1804   
1805   PF_Container_PR pres1 = PF_Container_PR_oCU_UP;
1806
1807   PF_Container_t *pfcontainer = (PF_Container_t*)calloc(1, sizeof(PF_Container_t));
1808   ASN_STRUCT_RESET(asn_DEF_PF_Container, pfcontainer);
1809   pfcontainer->present = pres1;
1810   pfcontainer->choice.oCU_UP = *cuupcont;
1811
1812   PM_Containers_List_t *containers_list = (PM_Containers_List_t*)calloc(1, sizeof(PM_Containers_List_t));
1813   ASN_STRUCT_RESET(asn_DEF_PM_Containers_List, containers_list);
1814   containers_list->performanceContainer = pfcontainer;
1815
1816   E2SM_KPM_IndicationMessage_Format1_t *format =
1817     (E2SM_KPM_IndicationMessage_Format1_t*)calloc(1, sizeof(E2SM_KPM_IndicationMessage_Format1_t));
1818   ASN_STRUCT_RESET(asn_DEF_E2SM_KPM_IndicationMessage_Format1, format);
1819
1820   ret = ASN_SEQUENCE_ADD(&format->pm_Containers.list, containers_list);
1821   
1822   E2SM_KPM_IndicationMessage_PR pres = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1;
1823
1824   indicationmessage->present = pres;
1825
1826   indicationmessage->choice.indicationMessage_Format1 = *format;
1827
1828   char *error_buf = (char*)calloc(300, sizeof(char));
1829   size_t errlen;
1830
1831   asn_check_constraints(&asn_DEF_E2SM_KPM_IndicationMessage, indicationmessage, error_buf, &errlen);
1832   printf("error length %d\n", errlen);
1833   printf("error buf %s\n", error_buf);
1834   
1835
1836   uint8_t e2smbuffer[8192];
1837   size_t e2smbuffer_size = 8192;
1838
1839   uint8_t e2smbuffer2[8192];
1840   size_t e2smbuffer_size2 = 8192;  
1841
1842   auto er =
1843     asn_encode_to_buffer(nullptr,
1844                          ATS_ALIGNED_BASIC_PER,
1845                          &asn_DEF_E2SM_KPM_IndicationMessage,
1846                          indicationmessage, e2smbuffer, e2smbuffer_size);
1847
1848   fprintf(stderr, "er encded is %d\n", er.encoded);
1849   fprintf(stderr, "after encoding message\n");
1850
1851   
1852 }
1853 */