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