67b773cf375282a8cd9ff82fb41e62106b07a238
[scp/ric-app/kpimon.git] / control / e2sm.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 package control
21
22 /*
23 #include <e2sm/wrapper.h>
24 #cgo LDFLAGS: -le2smwrapper
25 #cgo CFLAGS: -I/usr/local/include/e2sm
26 */
27 import "C"
28
29 import (
30         "bytes"
31         "encoding/binary"
32         "errors"
33         "strconv"
34         "unsafe"
35 )
36
37 type E2sm struct {
38 }
39
40 func (c *E2sm) SetEventTriggerDefinition(buffer []byte, eventTriggerCount int, RTPeriods []int64) (newBuffer []byte, err error) {
41         cptr := unsafe.Pointer(&buffer[0])
42         periods := unsafe.Pointer(&RTPeriods[0])
43         size := C.e2sm_encode_ric_event_trigger_definition(cptr, C.size_t(len(buffer)), C.size_t(eventTriggerCount), (*C.long)(periods))
44         if size < 0 {
45                 return make([]byte, 0), errors.New("e2sm wrapper is unable to set EventTriggerDefinition due to wrong or invalid input")
46         }
47         newBuffer = C.GoBytes(cptr, (C.int(size)+7)/8)
48         return
49 }
50
51 func (c *E2sm) SetActionDefinition(buffer []byte, ricStyleType int64) (newBuffer []byte, err error) {
52         cptr := unsafe.Pointer(&buffer[0])
53         size := C.e2sm_encode_ric_action_definition(cptr, C.size_t(len(buffer)), C.long(ricStyleType))
54         if size < 0 {
55                 return make([]byte, 0), errors.New("e2sm wrapper is unable to set ActionDefinition due to wrong or invalid input")
56         }
57         newBuffer = C.GoBytes(cptr, (C.int(size)+7)/8)
58         return
59 }
60
61 func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err error) {
62         cptr := unsafe.Pointer(&buffer[0])
63         indHdr = &IndicationHeader{}
64         decodedHdr := C.e2sm_decode_ric_indication_header(cptr, C.size_t(len(buffer)))
65         if decodedHdr == nil {
66                 return indHdr, errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")
67         }
68         defer C.e2sm_free_ric_indication_header(decodedHdr)
69
70         indHdr.IndHdrType = int32(decodedHdr.present)
71         if indHdr.IndHdrType == 1 {
72                 indHdrFormat1 := &IndicationHeaderFormat1{}
73                 indHdrFormat1_C := (*C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.choice[0]))
74
75                 if indHdrFormat1_C.id_GlobalKPMnode_ID != nil {
76                         globalKPMnodeID_C := (*C.GlobalKPMnode_ID_t)(indHdrFormat1_C.id_GlobalKPMnode_ID)
77
78                         indHdrFormat1.GlobalKPMnodeIDType = int32(globalKPMnodeID_C.present)
79                         if indHdrFormat1.GlobalKPMnodeIDType == 1 {
80                                 globalgNBID := &GlobalKPMnodegNBIDType{}
81                                 globalgNBID_C := (*C.GlobalKPMnode_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0]))
82
83                                 plmnID_C := globalgNBID_C.global_gNB_ID.plmn_id
84                                 globalgNBID.GlobalgNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
85                                 globalgNBID.GlobalgNBID.PlmnID.Size = int(plmnID_C.size)
86
87                                 globalgNBID_gNBID_C := globalgNBID_C.global_gNB_ID.gnb_id
88                                 globalgNBID.GlobalgNBID.GnbIDType = int(globalgNBID_gNBID_C.present)
89                                 if globalgNBID.GlobalgNBID.GnbIDType == 1 {
90                                         gNBID := &GNBID{}
91                                         gNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalgNBID_gNBID_C.choice[0]))
92
93                                         gNBID.Buf = C.GoBytes(unsafe.Pointer(gNBID_C.buf), C.int(gNBID_C.size))
94                                         gNBID.Size = int(gNBID_C.size)
95                                         gNBID.BitsUnused = int(gNBID_C.bits_unused)
96
97                                         globalgNBID.GlobalgNBID.GnbID = gNBID
98                                 }
99
100                                 if globalgNBID_C.gNB_CU_UP_ID != nil {
101                                         globalgNBID.GnbCUUPID = &Integer{}
102                                         globalgNBID.GnbCUUPID.Buf = C.GoBytes(unsafe.Pointer(globalgNBID_C.gNB_CU_UP_ID.buf), C.int(globalgNBID_C.gNB_CU_UP_ID.size))
103                                         globalgNBID.GnbCUUPID.Size = int(globalgNBID_C.gNB_CU_UP_ID.size)
104                                 }
105
106                                 if globalgNBID_C.gNB_DU_ID != nil {
107                                         globalgNBID.GnbDUID = &Integer{}
108                                         globalgNBID.GnbDUID.Buf = C.GoBytes(unsafe.Pointer(globalgNBID_C.gNB_DU_ID.buf), C.int(globalgNBID_C.gNB_DU_ID.size))
109                                         globalgNBID.GnbDUID.Size = int(globalgNBID_C.gNB_DU_ID.size)
110                                 }
111
112                                 indHdrFormat1.GlobalKPMnodeID = globalgNBID
113                         } else if indHdrFormat1.GlobalKPMnodeIDType == 2 {
114                                 globalengNBID := &GlobalKPMnodeengNBIDType{}
115                                 globalengNBID_C := (*C.GlobalKPMnode_en_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0]))
116
117                                 plmnID_C := globalengNBID_C.global_gNB_ID.pLMN_Identity
118                                 globalengNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
119                                 globalengNBID.PlmnID.Size = int(plmnID_C.size)
120
121                                 globalengNBID_gNBID_C := globalengNBID_C.global_gNB_ID.gNB_ID
122                                 globalengNBID.GnbIDType = int(globalengNBID_gNBID_C.present)
123                                 if globalengNBID.GnbIDType == 1 {
124                                         engNBID := &ENGNBID{}
125                                         engNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalengNBID_gNBID_C.choice[0]))
126
127                                         engNBID.Buf = C.GoBytes(unsafe.Pointer(engNBID_C.buf), C.int(engNBID_C.size))
128                                         engNBID.Size = int(engNBID_C.size)
129                                         engNBID.BitsUnused = int(engNBID_C.bits_unused)
130
131                                         globalengNBID.GnbID = engNBID
132                                 }
133
134                                 indHdrFormat1.GlobalKPMnodeID = globalengNBID
135                         } else if indHdrFormat1.GlobalKPMnodeIDType == 3 {
136                                 globalngeNBID := &GlobalKPMnodengeNBIDType{}
137                                 globalngeNBID_C := (*C.GlobalKPMnode_ng_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0]))
138
139                                 plmnID_C := globalngeNBID_C.global_ng_eNB_ID.plmn_id
140                                 globalngeNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
141                                 globalngeNBID.PlmnID.Size = int(plmnID_C.size)
142
143                                 globalngeNBID_eNBID_C := globalngeNBID_C.global_ng_eNB_ID.enb_id
144                                 globalngeNBID.EnbIDType = int(globalngeNBID_eNBID_C.present)
145                                 if globalngeNBID.EnbIDType == 1 {
146                                         ngeNBID := &NGENBID_Macro{}
147                                         ngeNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalngeNBID_eNBID_C.choice[0]))
148
149                                         ngeNBID.Buf = C.GoBytes(unsafe.Pointer(ngeNBID_C.buf), C.int(ngeNBID_C.size))
150                                         ngeNBID.Size = int(ngeNBID_C.size)
151                                         ngeNBID.BitsUnused = int(ngeNBID_C.bits_unused)
152
153                                         globalngeNBID.EnbID = ngeNBID
154                                 } else if globalngeNBID.EnbIDType == 2 {
155                                         ngeNBID := &NGENBID_ShortMacro{}
156                                         ngeNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalngeNBID_eNBID_C.choice[0]))
157
158                                         ngeNBID.Buf = C.GoBytes(unsafe.Pointer(ngeNBID_C.buf), C.int(ngeNBID_C.size))
159                                         ngeNBID.Size = int(ngeNBID_C.size)
160                                         ngeNBID.BitsUnused = int(ngeNBID_C.bits_unused)
161
162                                         globalngeNBID.EnbID = ngeNBID
163                                 } else if globalngeNBID.EnbIDType == 3 {
164                                         ngeNBID := &NGENBID_LongMacro{}
165                                         ngeNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalngeNBID_eNBID_C.choice[0]))
166
167                                         ngeNBID.Buf = C.GoBytes(unsafe.Pointer(ngeNBID_C.buf), C.int(ngeNBID_C.size))
168                                         ngeNBID.Size = int(ngeNBID_C.size)
169                                         ngeNBID.BitsUnused = int(ngeNBID_C.bits_unused)
170
171                                         globalngeNBID.EnbID = ngeNBID
172                                 }
173
174                                 indHdrFormat1.GlobalKPMnodeID = globalngeNBID
175                         } else if indHdrFormat1.GlobalKPMnodeIDType == 4 {
176                                 globaleNBID := &GlobalKPMnodeeNBIDType{}
177                                 globaleNBID_C := (*C.GlobalKPMnode_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0]))
178
179                                 plmnID_C := globaleNBID_C.global_eNB_ID.pLMN_Identity
180                                 globaleNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
181                                 globaleNBID.PlmnID.Size = int(plmnID_C.size)
182
183                                 globaleNBID_eNBID_C := globaleNBID_C.global_eNB_ID.eNB_ID
184                                 globaleNBID.EnbIDType = int(globaleNBID_eNBID_C.present)
185                                 if globaleNBID.EnbIDType == 1 {
186                                         eNBID := &ENBID_Macro{}
187                                         eNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globaleNBID_eNBID_C.choice[0]))
188
189                                         eNBID.Buf = C.GoBytes(unsafe.Pointer(eNBID_C.buf), C.int(eNBID_C.size))
190                                         eNBID.Size = int(eNBID_C.size)
191                                         eNBID.BitsUnused = int(eNBID_C.bits_unused)
192
193                                         globaleNBID.EnbID = eNBID
194                                 } else if globaleNBID.EnbIDType == 2 {
195                                         eNBID := &ENBID_Home{}
196                                         eNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globaleNBID_eNBID_C.choice[0]))
197
198                                         eNBID.Buf = C.GoBytes(unsafe.Pointer(eNBID_C.buf), C.int(eNBID_C.size))
199                                         eNBID.Size = int(eNBID_C.size)
200                                         eNBID.BitsUnused = int(eNBID_C.bits_unused)
201
202                                         globaleNBID.EnbID = eNBID
203                                 } else if globaleNBID.EnbIDType == 3 {
204                                         eNBID := &ENBID_ShortMacro{}
205                                         eNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globaleNBID_eNBID_C.choice[0]))
206
207                                         eNBID.Buf = C.GoBytes(unsafe.Pointer(eNBID_C.buf), C.int(eNBID_C.size))
208                                         eNBID.Size = int(eNBID_C.size)
209                                         eNBID.BitsUnused = int(eNBID_C.bits_unused)
210
211                                         globaleNBID.EnbID = eNBID
212                                 } else if globaleNBID.EnbIDType == 4 {
213                                         eNBID := &ENBID_LongMacro{}
214                                         eNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globaleNBID_eNBID_C.choice[0]))
215
216                                         eNBID.Buf = C.GoBytes(unsafe.Pointer(eNBID_C.buf), C.int(eNBID_C.size))
217                                         eNBID.Size = int(eNBID_C.size)
218                                         eNBID.BitsUnused = int(eNBID_C.bits_unused)
219
220                                         globaleNBID.EnbID = eNBID
221                                 }
222
223                                 indHdrFormat1.GlobalKPMnodeID = globaleNBID
224                         }
225                 } else {
226                         indHdrFormat1.GlobalKPMnodeIDType = 0
227                 }
228
229                 if indHdrFormat1_C.nRCGI != nil {
230                         indHdrFormat1.NRCGI = &NRCGIType{}
231
232                         plmnID := indHdrFormat1_C.nRCGI.pLMN_Identity
233                         indHdrFormat1.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID.buf), C.int(plmnID.size))
234                         indHdrFormat1.NRCGI.PlmnID.Size = int(plmnID.size)
235
236                         nRCellID := indHdrFormat1_C.nRCGI.nRCellIdentity
237                         indHdrFormat1.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(nRCellID.buf), C.int(nRCellID.size))
238                         indHdrFormat1.NRCGI.NRCellID.Size = int(nRCellID.size)
239                         indHdrFormat1.NRCGI.NRCellID.BitsUnused = int(nRCellID.bits_unused)
240                 }
241
242                 if indHdrFormat1_C.pLMN_Identity != nil {
243                         indHdrFormat1.PlmnID = &OctetString{}
244
245                         indHdrFormat1.PlmnID.Buf = C.GoBytes(unsafe.Pointer(indHdrFormat1_C.pLMN_Identity.buf), C.int(indHdrFormat1_C.pLMN_Identity.size))
246                         indHdrFormat1.PlmnID.Size = int(indHdrFormat1_C.pLMN_Identity.size)
247                 }
248
249                 if indHdrFormat1_C.sliceID != nil {
250                         indHdrFormat1.SliceID = &SliceIDType{}
251
252                         sST := indHdrFormat1_C.sliceID.sST
253                         indHdrFormat1.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(sST.buf), C.int(sST.size))
254                         indHdrFormat1.SliceID.SST.Size = int(sST.size)
255
256                         if indHdrFormat1_C.sliceID.sD != nil {
257                                 indHdrFormat1.SliceID.SD = &OctetString{}
258
259                                 sD := indHdrFormat1_C.sliceID.sD
260                                 indHdrFormat1.SliceID.SD.Buf = C.GoBytes(unsafe.Pointer(sD.buf), C.int(sD.size))
261                                 indHdrFormat1.SliceID.SD.Size = int(sD.size)
262                         }
263                 }
264
265                 if indHdrFormat1_C.fiveQI != nil {
266                         indHdrFormat1.FiveQI = int64(*indHdrFormat1_C.fiveQI)
267                 } else {
268                         indHdrFormat1.FiveQI = -1
269                 }
270
271                 if indHdrFormat1_C.qci != nil {
272                         indHdrFormat1.Qci = int64(*indHdrFormat1_C.qci)
273                 } else {
274                         indHdrFormat1.Qci = -1
275                 }
276
277                 if indHdrFormat1_C.message_Type != nil {
278                         indHdrFormat1.UeMessageType = int32(*indHdrFormat1_C.message_Type)
279                 } else {
280                         indHdrFormat1.UeMessageType = -1
281                 }
282
283                 if indHdrFormat1_C.gNB_DU_ID != nil {
284                         indHdrFormat1.GnbDUID = &Integer{}
285
286                         indHdrFormat1.GnbDUID.Buf = C.GoBytes(unsafe.Pointer(indHdrFormat1_C.gNB_DU_ID.buf), C.int(indHdrFormat1_C.gNB_DU_ID.size))
287                         indHdrFormat1.GnbDUID.Size = int(indHdrFormat1_C.gNB_DU_ID.size)
288                 }
289
290                 if indHdrFormat1_C.gNB_Name != nil {
291                         indHdrFormat1.GnbNameType = int32(indHdrFormat1_C.gNB_Name.present)
292                         if indHdrFormat1.GnbNameType == 1 {
293                                 gNBName := &GNB_DU_Name{}
294                                 gNBName_C := (*C.GNB_DU_Name_t)(unsafe.Pointer(&indHdrFormat1_C.gNB_Name.choice[0]))
295
296                                 gNBName.Buf = C.GoBytes(unsafe.Pointer(gNBName_C.buf), C.int(gNBName_C.size))
297                                 gNBName.Size = int(gNBName_C.size)
298
299                                 indHdrFormat1.GnbName = gNBName
300                         } else if indHdrFormat1.GnbNameType == 2 {
301                                 gNBName := &GNB_CU_CP_Name{}
302                                 gNBName_C := (*C.GNB_CU_CP_Name_t)(unsafe.Pointer(&indHdrFormat1_C.gNB_Name.choice[0]))
303
304                                 gNBName.Buf = C.GoBytes(unsafe.Pointer(gNBName_C.buf), C.int(gNBName_C.size))
305                                 gNBName.Size = int(gNBName_C.size)
306
307                                 indHdrFormat1.GnbName = gNBName
308                         } else if indHdrFormat1.GnbNameType == 3 {
309                                 gNBName := &GNB_CU_UP_Name{}
310                                 gNBName_C := (*C.GNB_CU_UP_Name_t)(unsafe.Pointer(&indHdrFormat1_C.gNB_Name.choice[0]))
311
312                                 gNBName.Buf = C.GoBytes(unsafe.Pointer(gNBName_C.buf), C.int(gNBName_C.size))
313                                 gNBName.Size = int(gNBName_C.size)
314
315                                 indHdrFormat1.GnbName = gNBName
316                         }
317                 } else {
318                         indHdrFormat1.GnbNameType = -1
319                 }
320
321                 if indHdrFormat1_C.global_GNB_ID != nil {
322                         plmnID_C := indHdrFormat1_C.global_GNB_ID.plmn_id
323                         indHdrFormat1.GlobalgNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
324                         indHdrFormat1.GlobalgNBID.PlmnID.Size = int(plmnID_C.size)
325
326                         globalgNBID_gNBID_C := indHdrFormat1_C.global_GNB_ID.gnb_id
327                         indHdrFormat1.GlobalgNBID.GnbIDType = int(globalgNBID_gNBID_C.present)
328                         if indHdrFormat1.GlobalgNBID.GnbIDType == 1 {
329                                 gNBID := &GNBID{}
330                                 gNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalgNBID_gNBID_C.choice[0]))
331
332                                 gNBID.Buf = C.GoBytes(unsafe.Pointer(gNBID_C.buf), C.int(gNBID_C.size))
333                                 gNBID.Size = int(gNBID_C.size)
334                                 gNBID.BitsUnused = int(gNBID_C.bits_unused)
335
336                                 indHdrFormat1.GlobalgNBID.GnbID = gNBID
337                         }
338                 }
339
340                 indHdr.IndHdr = indHdrFormat1
341         } else {
342                 return indHdr, errors.New("Unknown RIC Indication Header type")
343         }
344
345         return
346 }
347
348 func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, err error) {
349         cptr := unsafe.Pointer(&buffer[0])
350         indMsg = &IndicationMessage{}
351         decodedMsg := C.e2sm_decode_ric_indication_message(cptr, C.size_t(len(buffer)))
352         if decodedMsg == nil {
353                 return indMsg, errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")
354         }
355         defer C.e2sm_free_ric_indication_message(decodedMsg)
356
357         indMsg.StyleType = int64(decodedMsg.ric_Style_Type)
358
359         indMsg.IndMsgType = int32(decodedMsg.indicationMessage.present)
360
361         if indMsg.IndMsgType == 1 {
362                 indMsgFormat1 := &IndicationMessageFormat1{}
363                 indMsgFormat1_C := (*C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&decodedMsg.indicationMessage.choice[0]))
364
365                 indMsgFormat1.PMContainerCount = int(indMsgFormat1_C.pm_Containers.list.count)
366                 for i := 0; i < indMsgFormat1.PMContainerCount; i++ {
367                         pmContainer := indMsgFormat1.PMContainers[i]
368                         var sizeof_PM_Containers_List_t *C.PM_Containers_List_t
369                         pmContainer_C := (*C.PM_Containers_List_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(indMsgFormat1_C.pm_Containers.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_PM_Containers_List_t)))
370
371                         if pmContainer_C.performanceContainer != nil {
372                                 pfContainer := &PFContainerType{}
373
374                                 pfContainer.ContainerType = int32(pmContainer_C.performanceContainer.present)
375
376                                 if pfContainer.ContainerType == 1 {
377                                         oDU_PF := &ODUPFContainerType{}
378                                         oDU_PF_C := (*C.ODU_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
379
380                                         oDU_PF.CellResourceReportCount = int(oDU_PF_C.cellResourceReportList.list.count)
381                                         for j := 0; j < oDU_PF.CellResourceReportCount; j++ {
382                                                 cellResourceReport := oDU_PF.CellResourceReports[j]
383                                                 var sizeof_CellResourceReportListItem_t *C.CellResourceReportListItem_t
384                                                 cellResourceReport_C := (*C.CellResourceReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_PF_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CellResourceReportListItem_t)))
385
386                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
387                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
388
389                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
390                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
391                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
392
393                                                 if cellResourceReport_C.dl_TotalofAvailablePRBs != nil {
394                                                         cellResourceReport.TotalofAvailablePRBs.DL = int64(*cellResourceReport_C.dl_TotalofAvailablePRBs)
395                                                 } else {
396                                                         cellResourceReport.TotalofAvailablePRBs.DL = -1
397                                                 }
398
399                                                 if cellResourceReport_C.ul_TotalofAvailablePRBs != nil {
400                                                         cellResourceReport.TotalofAvailablePRBs.UL = int64(*cellResourceReport_C.ul_TotalofAvailablePRBs)
401                                                 } else {
402                                                         cellResourceReport.TotalofAvailablePRBs.UL = -1
403                                                 }
404
405                                                 cellResourceReport.ServedPlmnPerCellCount = int(cellResourceReport_C.servedPlmnPerCellList.list.count)
406                                                 for k := 0; k < cellResourceReport.ServedPlmnPerCellCount; k++ {
407                                                         servedPlmnPerCell := cellResourceReport.ServedPlmnPerCells[k]
408                                                         var sizeof_ServedPlmnPerCellListItem_t *C.ServedPlmnPerCellListItem_t
409                                                         servedPlmnPerCell_C := (*C.ServedPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.servedPlmnPerCellList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_ServedPlmnPerCellListItem_t)))
410
411                                                         servedPlmnPerCell.PlmnID.Buf = C.GoBytes(unsafe.Pointer(servedPlmnPerCell_C.pLMN_Identity.buf), C.int(servedPlmnPerCell_C.pLMN_Identity.size))
412                                                         servedPlmnPerCell.PlmnID.Size = int(servedPlmnPerCell_C.pLMN_Identity.size)
413
414                                                         if servedPlmnPerCell_C.du_PM_5GC != nil {
415                                                                 duPM5GC := &DUPM5GCContainerType{}
416                                                                 duPM5GC_C := (*C.FGC_DU_PM_Container_t)(servedPlmnPerCell_C.du_PM_5GC)
417
418                                                                 duPM5GC.SlicePerPlmnPerCellCount = int(duPM5GC_C.slicePerPlmnPerCellList.list.count)
419                                                                 for l := 0; l < duPM5GC.SlicePerPlmnPerCellCount; l++ {
420                                                                         slicePerPlmnPerCell := duPM5GC.SlicePerPlmnPerCells[l]
421                                                                         var sizeof_SlicePerPlmnPerCellListItem_t *C.SlicePerPlmnPerCellListItem_t
422                                                                         slicePerPlmnPerCell_C := (*C.SlicePerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPM5GC_C.slicePerPlmnPerCellList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SlicePerPlmnPerCellListItem_t)))
423
424                                                                         slicePerPlmnPerCell.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(slicePerPlmnPerCell_C.sliceID.sST.buf), C.int(slicePerPlmnPerCell_C.sliceID.sST.size))
425                                                                         slicePerPlmnPerCell.SliceID.SST.Size = int(slicePerPlmnPerCell_C.sliceID.sST.size)
426
427                                                                         if slicePerPlmnPerCell_C.sliceID.sD != nil {
428                                                                                 slicePerPlmnPerCell.SliceID.SD = &OctetString{}
429                                                                                 slicePerPlmnPerCell.SliceID.SD.Buf = C.GoBytes(unsafe.Pointer(slicePerPlmnPerCell_C.sliceID.sD.buf), C.int(slicePerPlmnPerCell_C.sliceID.sD.size))
430                                                                                 slicePerPlmnPerCell.SliceID.SD.Size = int(slicePerPlmnPerCell_C.sliceID.sD.size)
431                                                                         }
432
433                                                                         slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount = int(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.count)
434                                                                         for m := 0; m < slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount; m++ {
435                                                                                 fQIPerSlicesPerPlmnPerCell := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m]
436                                                                                 var sizeof_FQIPERSlicesPerPlmnPerCellListItem_t *C.FQIPERSlicesPerPlmnPerCellListItem_t
437                                                                                 fQIPerSlicesPerPlmnPerCell_C := (*C.FQIPERSlicesPerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnPerCellListItem_t)))
438
439                                                                                 fQIPerSlicesPerPlmnPerCell.FiveQI = int64(fQIPerSlicesPerPlmnPerCell_C.fiveQI)
440
441                                                                                 if fQIPerSlicesPerPlmnPerCell_C.dl_PRBUsage != nil {
442                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.DL = int64(*fQIPerSlicesPerPlmnPerCell_C.dl_PRBUsage)
443                                                                                 } else {
444                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.DL = -1
445                                                                                 }
446
447                                                                                 if fQIPerSlicesPerPlmnPerCell_C.ul_PRBUsage != nil {
448                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.UL = int64(*fQIPerSlicesPerPlmnPerCell_C.ul_PRBUsage)
449                                                                                 } else {
450                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.UL = -1
451                                                                                 }
452                                                                         }
453                                                                 }
454
455                                                                 servedPlmnPerCell.DUPM5GC = duPM5GC
456                                                         }
457
458                                                         if servedPlmnPerCell_C.du_PM_EPC != nil {
459                                                                 duPMEPC := &DUPMEPCContainerType{}
460                                                                 duPMEPC_C := (*C.EPC_DU_PM_Container_t)(servedPlmnPerCell_C.du_PM_EPC)
461
462                                                                 duPMEPC.PerQCIReportCount = int(duPMEPC_C.perQCIReportList.list.count)
463                                                                 for l := 0; l < duPMEPC.PerQCIReportCount; l++ {
464                                                                         perQCIReport := duPMEPC.PerQCIReports[l]
465                                                                         var sizeof_PerQCIReportListItem_t *C.PerQCIReportListItem_t
466                                                                         perQCIReport_C := (*C.PerQCIReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItem_t)))
467
468                                                                         perQCIReport.QCI = int64(perQCIReport_C.qci)
469
470                                                                         if perQCIReport_C.dl_PRBUsage != nil {
471                                                                                 perQCIReport.PrbUsage.DL = int64(*perQCIReport_C.dl_PRBUsage)
472                                                                         } else {
473                                                                                 perQCIReport.PrbUsage.DL = -1
474                                                                         }
475
476                                                                         if perQCIReport_C.ul_PRBUsage != nil {
477                                                                                 perQCIReport.PrbUsage.UL = int64(*perQCIReport_C.ul_PRBUsage)
478                                                                         } else {
479                                                                                 perQCIReport.PrbUsage.UL = -1
480                                                                         }
481                                                                 }
482
483                                                                 servedPlmnPerCell.DUPMEPC = duPMEPC
484                                                         }
485                                                 }
486                                         }
487
488                                         pfContainer.Container = oDU_PF
489                                 } else if pfContainer.ContainerType == 2 {
490                                         oCU_CP_PF := &OCUCPPFContainerType{}
491                                         oCU_CP_PF_C := (*C.OCUCP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
492
493                                         if oCU_CP_PF_C.gNB_CU_CP_Name != nil {
494                                                 oCU_CP_PF.GNBCUCPName = &PrintableString{}
495                                                 oCU_CP_PF.GNBCUCPName.Buf = C.GoBytes(unsafe.Pointer(oCU_CP_PF_C.gNB_CU_CP_Name.buf), C.int(oCU_CP_PF_C.gNB_CU_CP_Name.size))
496                                                 oCU_CP_PF.GNBCUCPName.Size = int(oCU_CP_PF_C.gNB_CU_CP_Name.size)
497                                         }
498
499                                         if oCU_CP_PF_C.cu_CP_Resource_Status.numberOfActive_UEs != nil {
500                                                 oCU_CP_PF.CUCPResourceStatus.NumberOfActiveUEs = int64(*oCU_CP_PF_C.cu_CP_Resource_Status.numberOfActive_UEs)
501                                         }
502
503                                         pfContainer.Container = oCU_CP_PF
504                                 } else if pfContainer.ContainerType == 3 {
505                                         oCU_UP_PF := &OCUUPPFContainerType{}
506                                         oCU_UP_PF_C := (*C.OCUUP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
507
508                                         if oCU_UP_PF_C.gNB_CU_UP_Name != nil {
509                                                 oCU_UP_PF.GNBCUUPName = &PrintableString{}
510                                                 oCU_UP_PF.GNBCUUPName.Buf = C.GoBytes(unsafe.Pointer(oCU_UP_PF_C.gNB_CU_UP_Name.buf), C.int(oCU_UP_PF_C.gNB_CU_UP_Name.size))
511                                                 oCU_UP_PF.GNBCUUPName.Size = int(oCU_UP_PF_C.gNB_CU_UP_Name.size)
512                                         }
513
514                                         oCU_UP_PF.CUUPPFContainerItemCount = int(oCU_UP_PF_C.pf_ContainerList.list.count)
515                                         for j := 0; j < oCU_UP_PF.CUUPPFContainerItemCount; j++ {
516                                                 cuUPPFContainer := oCU_UP_PF.CUUPPFContainerItems[j]
517                                                 var sizeof_PF_ContainerListItem_t *C.PF_ContainerListItem_t
518                                                 cuUPPFContainer_C := (*C.PF_ContainerListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_PF_C.pf_ContainerList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_PF_ContainerListItem_t)))
519
520                                                 cuUPPFContainer.InterfaceType = int64(cuUPPFContainer_C.interface_type)
521
522                                                 cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount = int(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.count)
523                                                 for k := 0; k < cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount; k++ {
524                                                         cuUPPlmn := cuUPPFContainer.OCUUPPMContainer.CUUPPlmns[k]
525                                                         var sizeof_PlmnID_List_t *C.PlmnID_List_t
526                                                         cuUPPlmn_C := (*C.PlmnID_List_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_PlmnID_List_t)))
527
528                                                         cuUPPlmn.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cuUPPlmn_C.pLMN_Identity.buf), C.int(cuUPPlmn_C.pLMN_Identity.size))
529                                                         cuUPPlmn.PlmnID.Size = int(cuUPPlmn_C.pLMN_Identity.size)
530
531                                                         if cuUPPlmn_C.cu_UP_PM_5GC != nil {
532                                                                 cuUPPM5GC := &CUUPPM5GCType{}
533                                                                 cuUPPM5GC_C := (*C.FGC_CUUP_PM_Format_t)(cuUPPlmn_C.cu_UP_PM_5GC)
534
535                                                                 cuUPPM5GC.SliceToReportCount = int(cuUPPM5GC_C.sliceToReportList.list.count)
536                                                                 for l := 0; l < cuUPPM5GC.SliceToReportCount; l++ {
537                                                                         sliceToReport := cuUPPM5GC.SliceToReports[l]
538                                                                         var sizeof_SliceToReportListItem_t *C.SliceToReportListItem_t
539                                                                         sliceToReport_C := (*C.SliceToReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPM5GC_C.sliceToReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SliceToReportListItem_t)))
540
541                                                                         sliceToReport.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(sliceToReport_C.sliceID.sST.buf), C.int(sliceToReport_C.sliceID.sST.size))
542                                                                         sliceToReport.SliceID.SST.Size = int(sliceToReport_C.sliceID.sST.size)
543
544                                                                         if sliceToReport_C.sliceID.sD != nil {
545                                                                                 sliceToReport.SliceID.SD = &OctetString{}
546                                                                                 sliceToReport.SliceID.SD.Buf = C.GoBytes(unsafe.Pointer(sliceToReport_C.sliceID.sD.buf), C.int(sliceToReport_C.sliceID.sD.size))
547                                                                                 sliceToReport.SliceID.SD.Size = int(sliceToReport_C.sliceID.sD.size)
548                                                                         }
549
550                                                                         sliceToReport.FQIPERSlicesPerPlmnCount = int(sliceToReport_C.fQIPERSlicesPerPlmnList.list.count)
551                                                                         for m := 0; m < sliceToReport.FQIPERSlicesPerPlmnCount; m++ {
552                                                                                 fQIPerSlicesPerPlmn := sliceToReport.FQIPERSlicesPerPlmns[m]
553                                                                                 var sizeof_FQIPERSlicesPerPlmnListItem_t *C.FQIPERSlicesPerPlmnListItem_t
554                                                                                 fQIPerSlicesPerPlmn_C := (*C.FQIPERSlicesPerPlmnListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(sliceToReport_C.fQIPERSlicesPerPlmnList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnListItem_t)))
555
556                                                                                 fQIPerSlicesPerPlmn.FiveQI = int64(fQIPerSlicesPerPlmn_C.fiveQI)
557
558                                                                                 if fQIPerSlicesPerPlmn_C.pDCPBytesDL != nil {
559                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL = &Integer{}
560                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(fQIPerSlicesPerPlmn_C.pDCPBytesDL.buf), C.int(fQIPerSlicesPerPlmn_C.pDCPBytesDL.size))
561                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL.Size = int(fQIPerSlicesPerPlmn_C.pDCPBytesDL.size)
562                                                                                 }
563
564                                                                                 if fQIPerSlicesPerPlmn_C.pDCPBytesUL != nil {
565                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL = &Integer{}
566                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(fQIPerSlicesPerPlmn_C.pDCPBytesUL.buf), C.int(fQIPerSlicesPerPlmn_C.pDCPBytesUL.size))
567                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL.Size = int(fQIPerSlicesPerPlmn_C.pDCPBytesUL.size)
568                                                                                 }
569                                                                         }
570                                                                 }
571
572                                                                 cuUPPlmn.CUUPPM5GC = cuUPPM5GC
573                                                         }
574
575                                                         if cuUPPlmn_C.cu_UP_PM_EPC != nil {
576                                                                 cuUPPMEPC := &CUUPPMEPCType{}
577                                                                 cuUPPMEPC_C := (*C.EPC_CUUP_PM_Format_t)(cuUPPlmn_C.cu_UP_PM_EPC)
578
579                                                                 cuUPPMEPC.CUUPPMEPCPerQCIReportCount = int(cuUPPMEPC_C.perQCIReportList.list.count)
580                                                                 for l := 0; l < cuUPPMEPC.CUUPPMEPCPerQCIReportCount; l++ {
581                                                                         perQCIReport := cuUPPMEPC.CUUPPMEPCPerQCIReports[l]
582                                                                         var sizeof_PerQCIReportListItemFormat_t *C.PerQCIReportListItemFormat_t
583                                                                         perQCIReport_C := (*C.PerQCIReportListItemFormat_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItemFormat_t)))
584
585                                                                         perQCIReport.QCI = int64(perQCIReport_C.qci)
586
587                                                                         if perQCIReport_C.pDCPBytesDL != nil {
588                                                                                 perQCIReport.PDCPBytesDL = &Integer{}
589                                                                                 perQCIReport.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(perQCIReport_C.pDCPBytesDL.buf), C.int(perQCIReport_C.pDCPBytesDL.size))
590                                                                                 perQCIReport.PDCPBytesDL.Size = int(perQCIReport_C.pDCPBytesDL.size)
591                                                                         }
592
593                                                                         if perQCIReport_C.pDCPBytesUL != nil {
594                                                                                 perQCIReport.PDCPBytesUL = &Integer{}
595                                                                                 perQCIReport.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(perQCIReport_C.pDCPBytesUL.buf), C.int(perQCIReport_C.pDCPBytesUL.size))
596                                                                                 perQCIReport.PDCPBytesUL.Size = int(perQCIReport_C.pDCPBytesUL.size)
597                                                                         }
598                                                                 }
599
600                                                                 cuUPPlmn.CUUPPMEPC = cuUPPMEPC
601                                                         }
602                                                 }
603                                         }
604
605                                         pfContainer.Container = oCU_UP_PF
606                                 } else {
607                                         return indMsg, errors.New("Unknown PF Container type")
608                                 }
609
610                                 pmContainer.PFContainer = pfContainer
611                         }
612
613                         if pmContainer_C.theRANContainer != nil {
614                                 ranContainer := &RANContainerType{}
615
616                                 ranContainer.Timestamp.Buf = C.GoBytes(unsafe.Pointer(pmContainer_C.theRANContainer.timestamp.buf), C.int(pmContainer_C.theRANContainer.timestamp.size))
617                                 ranContainer.Timestamp.Size = int(pmContainer_C.theRANContainer.timestamp.size)
618
619                                 ranContainer.ContainerType = int32(pmContainer_C.theRANContainer.reportContainer.present)
620
621                                 if ranContainer.ContainerType == 1 {
622                                         oDU_UE := &DUUsageReportType{}
623                                         oDU_UE_C := (*C.DU_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
624
625                                         oDU_UE.CellResourceReportItemCount = int(oDU_UE_C.cellResourceReportList.list.count)
626                                         for j := 0; j < oDU_UE.CellResourceReportItemCount; j++ {
627                                                 cellResourceReport := oDU_UE.CellResourceReportItems[j]
628                                                 var sizeof_DU_Usage_Report_CellResourceReportItem_t *C.DU_Usage_Report_CellResourceReportItem_t
629                                                 cellResourceReport_C := (*C.DU_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_DU_Usage_Report_CellResourceReportItem_t)))
630
631                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
632                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
633
634                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
635                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
636                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
637
638                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
639                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
640                                                         ueResourceReport := cellResourceReport.UeResourceReportItems[k]
641                                                         var sizeof_DU_Usage_Report_UeResourceReportItem_t *C.DU_Usage_Report_UeResourceReportItem_t
642                                                         ueResourceReport_C := (*C.DU_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_DU_Usage_Report_UeResourceReportItem_t)))
643
644                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
645                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
646
647                                                         if ueResourceReport_C.dl_PRBUsage != nil {
648                                                                 ueResourceReport.PRBUsageDL = int64(*ueResourceReport_C.dl_PRBUsage)
649                                                         } else {
650                                                                 ueResourceReport.PRBUsageDL = -1
651                                                         }
652
653                                                         if ueResourceReport_C.ul_PRBUsage != nil {
654                                                                 ueResourceReport.PRBUsageUL = int64(*ueResourceReport_C.ul_PRBUsage)
655                                                         } else {
656                                                                 ueResourceReport.PRBUsageUL = -1
657                                                         }
658                                                 }
659                                         }
660
661                                         ranContainer.Container = oDU_UE
662                                 } else if ranContainer.ContainerType == 2 {
663                                         oCU_CP_UE := &CUCPUsageReportType{}
664                                         oCU_CP_UE_C := (*C.CU_CP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
665
666                                         oCU_CP_UE.CellResourceReportItemCount = int(oCU_CP_UE_C.cellResourceReportList.list.count)
667                                         for j := 0; j < oCU_CP_UE.CellResourceReportItemCount; j++ {
668                                                 cellResourceReport := oCU_CP_UE.CellResourceReportItems[j]
669                                                 var sizeof_CU_CP_Usage_Report_CellResourceReportItem_t *C.CU_CP_Usage_Report_CellResourceReportItem_t
670                                                 cellResourceReport_C := (*C.CU_CP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_CP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_CellResourceReportItem_t)))
671
672                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
673                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
674
675                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
676                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
677                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
678
679                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
680                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
681                                                         ueResourceReport := cellResourceReport.UeResourceReportItems[k]
682                                                         var sizeof_CU_CP_Usage_Report_UeResourceReportItem_t *C.CU_CP_Usage_Report_UeResourceReportItem_t
683                                                         ueResourceReport_C := (*C.CU_CP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_UeResourceReportItem_t)))
684
685                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
686                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
687
688                                                         if ueResourceReport_C.serving_Cell_RF_Type != nil {
689                                                                 ueResourceReport.ServingCellRF = &OctetString{}
690                                                                 ueResourceReport.ServingCellRF.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.serving_Cell_RF_Type.buf), C.int(ueResourceReport_C.serving_Cell_RF_Type.size))
691                                                                 ueResourceReport.ServingCellRF.Size = int(ueResourceReport_C.serving_Cell_RF_Type.size)
692                                                         }
693
694                                                         if ueResourceReport_C.neighbor_Cell_RF != nil {
695                                                                 ueResourceReport.NeighborCellRF = &OctetString{}
696                                                                 ueResourceReport.NeighborCellRF.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.neighbor_Cell_RF.buf), C.int(ueResourceReport_C.neighbor_Cell_RF.size))
697                                                                 ueResourceReport.NeighborCellRF.Size = int(ueResourceReport_C.neighbor_Cell_RF.size)
698                                                         }
699                                                 }
700                                         }
701
702                                         ranContainer.Container = oCU_CP_UE
703                                 } else if ranContainer.ContainerType == 3 {
704                                         oCU_UP_UE := &CUUPUsageReportType{}
705                                         oCU_UP_UE_C := (*C.CU_UP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
706
707                                         oCU_UP_UE.CellResourceReportItemCount = int(oCU_UP_UE_C.cellResourceReportList.list.count)
708                                         for j := 0; j < oCU_UP_UE.CellResourceReportItemCount; j++ {
709                                                 cellResourceReport := oCU_UP_UE.CellResourceReportItems[j]
710                                                 var sizeof_CU_UP_Usage_Report_CellResourceReportItem_t *C.CU_UP_Usage_Report_CellResourceReportItem_t
711                                                 cellResourceReport_C := (*C.CU_UP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_CellResourceReportItem_t)))
712
713                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
714                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
715
716                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
717                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
718                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
719
720                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
721                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
722                                                         ueResourceReport := cellResourceReport.UeResourceReportItems[k]
723                                                         var sizeof_CU_UP_Usage_Report_UeResourceReportItem_t *C.CU_UP_Usage_Report_UeResourceReportItem_t
724                                                         ueResourceReport_C := (*C.CU_UP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_UeResourceReportItem_t)))
725
726                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
727                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
728
729                                                         if ueResourceReport_C.pDCPBytesDL != nil {
730                                                                 ueResourceReport.PDCPBytesDL = &Integer{}
731                                                                 ueResourceReport.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.pDCPBytesDL.buf), C.int(ueResourceReport_C.pDCPBytesDL.size))
732                                                                 ueResourceReport.PDCPBytesDL.Size = int(ueResourceReport_C.pDCPBytesDL.size)
733                                                         }
734
735                                                         if ueResourceReport_C.pDCPBytesUL != nil {
736                                                                 ueResourceReport.PDCPBytesUL = &Integer{}
737                                                                 ueResourceReport.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.pDCPBytesUL.buf), C.int(ueResourceReport_C.pDCPBytesUL.size))
738                                                                 ueResourceReport.PDCPBytesUL.Size = int(ueResourceReport_C.pDCPBytesUL.size)
739                                                         }
740                                                 }
741                                         }
742
743                                         ranContainer.Container = oCU_UP_UE
744                                 } else {
745                                         return indMsg, errors.New("Unknown RAN Container type")
746                                 }
747
748                                 pmContainer.RANContainer = ranContainer
749                         }
750                 }
751
752                 indMsg.IndMsg = indMsgFormat1
753         } else {
754                 return indMsg, errors.New("Unknown RIC Indication Message Format")
755         }
756
757         return
758 }
759
760 func (c *E2sm) ParseNRCGI(nRCGI NRCGIType) (CellID string, err error) {
761         var plmnID OctetString
762         var nrCellID BitString
763
764         if plmnID.Size != 3 || nrCellID.Size != 5 {
765                 return "", errors.New("Invalid input: illegal length of NRCGI")
766         }
767
768         plmnID = nRCGI.PlmnID
769         CellID, _ = c.ParsePLMNIdentity(plmnID.Buf, plmnID.Size)
770
771         nrCellID = nRCGI.NRCellID
772         var former []uint8 = make([]uint8, 3)
773         var latter []uint8 = make([]uint8, 6)
774
775         former[0] = nrCellID.Buf[0] >> 4
776         former[1] = nrCellID.Buf[0] & 0xf
777         former[2] = nrCellID.Buf[1] >> 4
778         latter[0] = nrCellID.Buf[1] & 0xf
779         latter[1] = nrCellID.Buf[2] >> 4
780         latter[2] = nrCellID.Buf[2] & 0xf
781         latter[3] = nrCellID.Buf[3] >> 4
782         latter[4] = nrCellID.Buf[3] & 0xf
783         latter[5] = nrCellID.Buf[4] >> uint(nrCellID.BitsUnused)
784
785         CellID = CellID + strconv.Itoa(int(former[0])) + strconv.Itoa(int(former[1])) + strconv.Itoa(int(former[2])) + strconv.Itoa(int(latter[0])) + strconv.Itoa(int(latter[1])) + strconv.Itoa(int(latter[2])) + strconv.Itoa(int(latter[3])) + strconv.Itoa(int(latter[4])) + strconv.Itoa(int(latter[5]))
786
787         return
788 }
789
790 func (c *E2sm) ParsePLMNIdentity(buffer []byte, size int) (PlmnID string, err error) {
791         if size != 3 {
792                 return "", errors.New("Invalid input: illegal length of PlmnID")
793         }
794
795         var mcc []uint8 = make([]uint8, 3)
796         var mnc []uint8 = make([]uint8, 3)
797
798         mcc[0] = buffer[0] >> 4
799         mcc[1] = buffer[0] & 0xf
800         mcc[2] = buffer[1] >> 4
801         mnc[0] = buffer[1] & 0xf
802         mnc[1] = buffer[2] >> 4
803         mnc[2] = buffer[2] & 0xf
804
805         if mnc[0] == 0xf {
806                 PlmnID = strconv.Itoa(int(mcc[0])) + strconv.Itoa(int(mcc[1])) + strconv.Itoa(int(mcc[2])) + strconv.Itoa(int(mnc[1])) + strconv.Itoa(int(mnc[2]))
807         } else {
808                 PlmnID = strconv.Itoa(int(mcc[0])) + strconv.Itoa(int(mcc[1])) + strconv.Itoa(int(mcc[2])) + strconv.Itoa(int(mnc[0])) + strconv.Itoa(int(mnc[1])) + strconv.Itoa(int(mnc[2]))
809         }
810
811         return
812 }
813
814 func (c *E2sm) ParseSliceID(sliceID SliceIDType) (combined int32, err error) {
815         if sliceID.SST.Size != 1 || (sliceID.SD != nil && sliceID.SD.Size != 3) {
816                 return 0, errors.New("Invalid input: illegal length of sliceID")
817         }
818
819         var temp uint8
820         var sst int32
821         var sd int32
822
823         byteBuffer := bytes.NewBuffer(sliceID.SST.Buf)
824         binary.Read(byteBuffer, binary.BigEndian, &temp)
825         sst = int32(temp)
826
827         if sliceID.SD == nil {
828                 combined = sst << 24
829         } else {
830                 for i := 0; i < sliceID.SD.Size; i++ {
831                         byteBuffer = bytes.NewBuffer(sliceID.SD.Buf[i : i+1])
832                         binary.Read(byteBuffer, binary.BigEndian, &temp)
833                         sd = sd*256 + int32(temp)
834                 }
835                 combined = sst<<24 + sd
836         }
837
838         return
839 }
840
841 func (c *E2sm) ParseInteger(buffer []byte, size int) (value int64, err error) {
842         var temp uint8
843         var byteBuffer *bytes.Buffer
844
845         for i := 0; i < size; i++ {
846                 byteBuffer = bytes.NewBuffer(buffer[i : i+1])
847                 binary.Read(byteBuffer, binary.BigEndian, &temp)
848                 value = value*256 + int64(temp)
849         }
850
851         return
852 }
853
854 func (c *E2sm) ParseTimestamp(buffer []byte, size int) (timestamp *Timestamp, err error) {
855         var temp uint8
856         var byteBuffer *bytes.Buffer
857         var index int
858         var sec int64
859         var nsec int64
860
861         for index := 0; index < size-8; index++ {
862                 byteBuffer = bytes.NewBuffer(buffer[index : index+1])
863                 binary.Read(byteBuffer, binary.BigEndian, &temp)
864                 sec = sec*256 + int64(temp)
865         }
866
867         for index = size - 8; index < size; index++ {
868                 byteBuffer = bytes.NewBuffer(buffer[index : index+1])
869                 binary.Read(byteBuffer, binary.BigEndian, &temp)
870                 nsec = nsec*256 + int64(temp)
871         }
872
873         timestamp = &Timestamp{TVsec: sec, TVnsec: nsec}
874         return
875 }