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