Fix E2SM Indication message RANContainer parsing issue.
[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                         indHdrFormat1.GlobalgNBID = &GlobalgNBIDType{}
323
324                         plmnID_C := indHdrFormat1_C.global_GNB_ID.plmn_id
325                         indHdrFormat1.GlobalgNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size))
326                         indHdrFormat1.GlobalgNBID.PlmnID.Size = int(plmnID_C.size)
327
328                         globalgNBID_gNBID_C := indHdrFormat1_C.global_GNB_ID.gnb_id
329                         indHdrFormat1.GlobalgNBID.GnbIDType = int(globalgNBID_gNBID_C.present)
330                         if indHdrFormat1.GlobalgNBID.GnbIDType == 1 {
331                                 gNBID := &GNBID{}
332                                 gNBID_C := (*C.BIT_STRING_t)(unsafe.Pointer(&globalgNBID_gNBID_C.choice[0]))
333
334                                 gNBID.Buf = C.GoBytes(unsafe.Pointer(gNBID_C.buf), C.int(gNBID_C.size))
335                                 gNBID.Size = int(gNBID_C.size)
336                                 gNBID.BitsUnused = int(gNBID_C.bits_unused)
337
338                                 indHdrFormat1.GlobalgNBID.GnbID = gNBID
339                         }
340                 }
341
342                 indHdr.IndHdr = indHdrFormat1
343         } else {
344                 return indHdr, errors.New("Unknown RIC Indication Header type")
345         }
346
347         return
348 }
349
350 func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, err error) {
351         cptr := unsafe.Pointer(&buffer[0])
352         indMsg = &IndicationMessage{}
353         decodedMsg := C.e2sm_decode_ric_indication_message(cptr, C.size_t(len(buffer)))
354         if decodedMsg == nil {
355                 return indMsg, errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")
356         }
357         defer C.e2sm_free_ric_indication_message(decodedMsg)
358
359         indMsg.StyleType = int64(decodedMsg.ric_Style_Type)
360
361         indMsg.IndMsgType = int32(decodedMsg.indicationMessage.present)
362
363         if indMsg.IndMsgType == 1 {
364                 indMsgFormat1 := &IndicationMessageFormat1{}
365                 indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&decodedMsg.indicationMessage.choice[0]))
366
367                 indMsgFormat1.PMContainerCount = int(indMsgFormat1_C.pm_Containers.list.count)
368                 for i := 0; i < indMsgFormat1.PMContainerCount; i++ {
369                         pmContainer := &indMsgFormat1.PMContainers[i]
370                         var sizeof_PM_Containers_List_t *C.PM_Containers_List_t
371                         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)))
372
373                         if pmContainer_C.performanceContainer != nil {
374                                 pfContainer := &PFContainerType{}
375
376                                 pfContainer.ContainerType = int32(pmContainer_C.performanceContainer.present)
377
378                                 if pfContainer.ContainerType == 1 {
379                                         oDU_PF := &ODUPFContainerType{}
380                                         oDU_PF_C := *(**C.ODU_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
381
382                                         oDU_PF.CellResourceReportCount = int(oDU_PF_C.cellResourceReportList.list.count)
383                                         for j := 0; j < oDU_PF.CellResourceReportCount; j++ {
384                                                 cellResourceReport := &oDU_PF.CellResourceReports[j]
385                                                 var sizeof_CellResourceReportListItem_t *C.CellResourceReportListItem_t
386                                                 cellResourceReport_C := *(**C.CellResourceReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_PF_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CellResourceReportListItem_t)))
387
388                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
389                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
390
391                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
392                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
393                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
394
395                                                 if cellResourceReport_C.dl_TotalofAvailablePRBs != nil {
396                                                         cellResourceReport.TotalofAvailablePRBs.DL = int64(*cellResourceReport_C.dl_TotalofAvailablePRBs)
397                                                 } else {
398                                                         cellResourceReport.TotalofAvailablePRBs.DL = -1
399                                                 }
400
401                                                 if cellResourceReport_C.ul_TotalofAvailablePRBs != nil {
402                                                         cellResourceReport.TotalofAvailablePRBs.UL = int64(*cellResourceReport_C.ul_TotalofAvailablePRBs)
403                                                 } else {
404                                                         cellResourceReport.TotalofAvailablePRBs.UL = -1
405                                                 }
406
407                                                 cellResourceReport.ServedPlmnPerCellCount = int(cellResourceReport_C.servedPlmnPerCellList.list.count)
408                                                 for k := 0; k < cellResourceReport.ServedPlmnPerCellCount; k++ {
409                                                         servedPlmnPerCell := cellResourceReport.ServedPlmnPerCells[k]
410                                                         var sizeof_ServedPlmnPerCellListItem_t *C.ServedPlmnPerCellListItem_t
411                                                         servedPlmnPerCell_C := *(**C.ServedPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.servedPlmnPerCellList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_ServedPlmnPerCellListItem_t)))
412
413                                                         servedPlmnPerCell.PlmnID.Buf = C.GoBytes(unsafe.Pointer(servedPlmnPerCell_C.pLMN_Identity.buf), C.int(servedPlmnPerCell_C.pLMN_Identity.size))
414                                                         servedPlmnPerCell.PlmnID.Size = int(servedPlmnPerCell_C.pLMN_Identity.size)
415
416                                                         if servedPlmnPerCell_C.du_PM_5GC != nil {
417                                                                 duPM5GC := &DUPM5GCContainerType{}
418                                                                 duPM5GC_C := (*C.FGC_DU_PM_Container_t)(servedPlmnPerCell_C.du_PM_5GC)
419
420                                                                 duPM5GC.SlicePerPlmnPerCellCount = int(duPM5GC_C.slicePerPlmnPerCellList.list.count)
421                                                                 for l := 0; l < duPM5GC.SlicePerPlmnPerCellCount; l++ {
422                                                                         slicePerPlmnPerCell := &duPM5GC.SlicePerPlmnPerCells[l]
423                                                                         var sizeof_SlicePerPlmnPerCellListItem_t *C.SlicePerPlmnPerCellListItem_t
424                                                                         slicePerPlmnPerCell_C := *(**C.SlicePerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPM5GC_C.slicePerPlmnPerCellList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SlicePerPlmnPerCellListItem_t)))
425
426                                                                         slicePerPlmnPerCell.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(slicePerPlmnPerCell_C.sliceID.sST.buf), C.int(slicePerPlmnPerCell_C.sliceID.sST.size))
427                                                                         slicePerPlmnPerCell.SliceID.SST.Size = int(slicePerPlmnPerCell_C.sliceID.sST.size)
428
429                                                                         if slicePerPlmnPerCell_C.sliceID.sD != nil {
430                                                                                 slicePerPlmnPerCell.SliceID.SD = &OctetString{}
431                                                                                 slicePerPlmnPerCell.SliceID.SD.Buf = C.GoBytes(unsafe.Pointer(slicePerPlmnPerCell_C.sliceID.sD.buf), C.int(slicePerPlmnPerCell_C.sliceID.sD.size))
432                                                                                 slicePerPlmnPerCell.SliceID.SD.Size = int(slicePerPlmnPerCell_C.sliceID.sD.size)
433                                                                         }
434
435                                                                         slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount = int(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.count)
436                                                                         for m := 0; m < slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount; m++ {
437                                                                                 fQIPerSlicesPerPlmnPerCell := &slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m]
438                                                                                 var sizeof_FQIPERSlicesPerPlmnPerCellListItem_t *C.FQIPERSlicesPerPlmnPerCellListItem_t
439                                                                                 fQIPerSlicesPerPlmnPerCell_C := *(**C.FQIPERSlicesPerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnPerCellListItem_t)))
440
441                                                                                 fQIPerSlicesPerPlmnPerCell.FiveQI = int64(fQIPerSlicesPerPlmnPerCell_C.fiveQI)
442
443                                                                                 if fQIPerSlicesPerPlmnPerCell_C.dl_PRBUsage != nil {
444                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.DL = int64(*fQIPerSlicesPerPlmnPerCell_C.dl_PRBUsage)
445                                                                                 } else {
446                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.DL = -1
447                                                                                 }
448
449                                                                                 if fQIPerSlicesPerPlmnPerCell_C.ul_PRBUsage != nil {
450                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.UL = int64(*fQIPerSlicesPerPlmnPerCell_C.ul_PRBUsage)
451                                                                                 } else {
452                                                                                         fQIPerSlicesPerPlmnPerCell.PrbUsage.UL = -1
453                                                                                 }
454                                                                         }
455                                                                 }
456
457                                                                 servedPlmnPerCell.DUPM5GC = duPM5GC
458                                                         }
459
460                                                         if servedPlmnPerCell_C.du_PM_EPC != nil {
461                                                                 duPMEPC := &DUPMEPCContainerType{}
462                                                                 duPMEPC_C := (*C.EPC_DU_PM_Container_t)(servedPlmnPerCell_C.du_PM_EPC)
463
464                                                                 duPMEPC.PerQCIReportCount = int(duPMEPC_C.perQCIReportList.list.count)
465                                                                 for l := 0; l < duPMEPC.PerQCIReportCount; l++ {
466                                                                         perQCIReport := &duPMEPC.PerQCIReports[l]
467                                                                         var sizeof_PerQCIReportListItem_t *C.PerQCIReportListItem_t
468                                                                         perQCIReport_C := *(**C.PerQCIReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItem_t)))
469
470                                                                         perQCIReport.QCI = int64(perQCIReport_C.qci)
471
472                                                                         if perQCIReport_C.dl_PRBUsage != nil {
473                                                                                 perQCIReport.PrbUsage.DL = int64(*perQCIReport_C.dl_PRBUsage)
474                                                                         } else {
475                                                                                 perQCIReport.PrbUsage.DL = -1
476                                                                         }
477
478                                                                         if perQCIReport_C.ul_PRBUsage != nil {
479                                                                                 perQCIReport.PrbUsage.UL = int64(*perQCIReport_C.ul_PRBUsage)
480                                                                         } else {
481                                                                                 perQCIReport.PrbUsage.UL = -1
482                                                                         }
483                                                                 }
484
485                                                                 servedPlmnPerCell.DUPMEPC = duPMEPC
486                                                         }
487                                                 }
488                                         }
489
490                                         pfContainer.Container = oDU_PF
491                                 } else if pfContainer.ContainerType == 2 {
492                                         oCU_CP_PF := &OCUCPPFContainerType{}
493                                         oCU_CP_PF_C := *(**C.OCUCP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
494
495                                         if oCU_CP_PF_C.gNB_CU_CP_Name != nil {
496                                                 oCU_CP_PF.GNBCUCPName = &PrintableString{}
497                                                 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))
498                                                 oCU_CP_PF.GNBCUCPName.Size = int(oCU_CP_PF_C.gNB_CU_CP_Name.size)
499                                         }
500
501                                         if oCU_CP_PF_C.cu_CP_Resource_Status.numberOfActive_UEs != nil {
502                                                 oCU_CP_PF.CUCPResourceStatus.NumberOfActiveUEs = int64(*oCU_CP_PF_C.cu_CP_Resource_Status.numberOfActive_UEs)
503                                         }
504
505                                         pfContainer.Container = oCU_CP_PF
506                                 } else if pfContainer.ContainerType == 3 {
507                                         oCU_UP_PF := &OCUUPPFContainerType{}
508                                         oCU_UP_PF_C := *(**C.OCUUP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0]))
509
510                                         if oCU_UP_PF_C.gNB_CU_UP_Name != nil {
511                                                 oCU_UP_PF.GNBCUUPName = &PrintableString{}
512                                                 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))
513                                                 oCU_UP_PF.GNBCUUPName.Size = int(oCU_UP_PF_C.gNB_CU_UP_Name.size)
514                                         }
515
516                                         oCU_UP_PF.CUUPPFContainerItemCount = int(oCU_UP_PF_C.pf_ContainerList.list.count)
517                                         for j := 0; j < oCU_UP_PF.CUUPPFContainerItemCount; j++ {
518                                                 cuUPPFContainer := &oCU_UP_PF.CUUPPFContainerItems[j]
519                                                 var sizeof_PF_ContainerListItem_t *C.PF_ContainerListItem_t
520                                                 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)))
521
522                                                 cuUPPFContainer.InterfaceType = int64(cuUPPFContainer_C.interface_type)
523
524                                                 cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount = int(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.count)
525                                                 for k := 0; k < cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount; k++ {
526                                                         cuUPPlmn := &cuUPPFContainer.OCUUPPMContainer.CUUPPlmns[k]
527                                                         var sizeof_PlmnID_List_t *C.PlmnID_List_t
528                                                         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)))
529
530                                                         cuUPPlmn.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cuUPPlmn_C.pLMN_Identity.buf), C.int(cuUPPlmn_C.pLMN_Identity.size))
531                                                         cuUPPlmn.PlmnID.Size = int(cuUPPlmn_C.pLMN_Identity.size)
532
533                                                         if cuUPPlmn_C.cu_UP_PM_5GC != nil {
534                                                                 cuUPPM5GC := &CUUPPM5GCType{}
535                                                                 cuUPPM5GC_C := (*C.FGC_CUUP_PM_Format_t)(cuUPPlmn_C.cu_UP_PM_5GC)
536
537                                                                 cuUPPM5GC.SliceToReportCount = int(cuUPPM5GC_C.sliceToReportList.list.count)
538                                                                 for l := 0; l < cuUPPM5GC.SliceToReportCount; l++ {
539                                                                         sliceToReport := &cuUPPM5GC.SliceToReports[l]
540                                                                         var sizeof_SliceToReportListItem_t *C.SliceToReportListItem_t
541                                                                         sliceToReport_C := *(**C.SliceToReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPM5GC_C.sliceToReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SliceToReportListItem_t)))
542
543                                                                         sliceToReport.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(sliceToReport_C.sliceID.sST.buf), C.int(sliceToReport_C.sliceID.sST.size))
544                                                                         sliceToReport.SliceID.SST.Size = int(sliceToReport_C.sliceID.sST.size)
545
546                                                                         if sliceToReport_C.sliceID.sD != nil {
547                                                                                 sliceToReport.SliceID.SD = &OctetString{}
548                                                                                 sliceToReport.SliceID.SD.Buf = C.GoBytes(unsafe.Pointer(sliceToReport_C.sliceID.sD.buf), C.int(sliceToReport_C.sliceID.sD.size))
549                                                                                 sliceToReport.SliceID.SD.Size = int(sliceToReport_C.sliceID.sD.size)
550                                                                         }
551
552                                                                         sliceToReport.FQIPERSlicesPerPlmnCount = int(sliceToReport_C.fQIPERSlicesPerPlmnList.list.count)
553                                                                         for m := 0; m < sliceToReport.FQIPERSlicesPerPlmnCount; m++ {
554                                                                                 fQIPerSlicesPerPlmn := &sliceToReport.FQIPERSlicesPerPlmns[m]
555                                                                                 var sizeof_FQIPERSlicesPerPlmnListItem_t *C.FQIPERSlicesPerPlmnListItem_t
556                                                                                 fQIPerSlicesPerPlmn_C := *(**C.FQIPERSlicesPerPlmnListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(sliceToReport_C.fQIPERSlicesPerPlmnList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnListItem_t)))
557
558                                                                                 fQIPerSlicesPerPlmn.FiveQI = int64(fQIPerSlicesPerPlmn_C.fiveQI)
559
560                                                                                 if fQIPerSlicesPerPlmn_C.pDCPBytesDL != nil {
561                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL = &Integer{}
562                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(fQIPerSlicesPerPlmn_C.pDCPBytesDL.buf), C.int(fQIPerSlicesPerPlmn_C.pDCPBytesDL.size))
563                                                                                         fQIPerSlicesPerPlmn.PDCPBytesDL.Size = int(fQIPerSlicesPerPlmn_C.pDCPBytesDL.size)
564                                                                                 }
565
566                                                                                 if fQIPerSlicesPerPlmn_C.pDCPBytesUL != nil {
567                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL = &Integer{}
568                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(fQIPerSlicesPerPlmn_C.pDCPBytesUL.buf), C.int(fQIPerSlicesPerPlmn_C.pDCPBytesUL.size))
569                                                                                         fQIPerSlicesPerPlmn.PDCPBytesUL.Size = int(fQIPerSlicesPerPlmn_C.pDCPBytesUL.size)
570                                                                                 }
571                                                                         }
572                                                                 }
573
574                                                                 cuUPPlmn.CUUPPM5GC = cuUPPM5GC
575                                                         }
576
577                                                         if cuUPPlmn_C.cu_UP_PM_EPC != nil {
578                                                                 cuUPPMEPC := &CUUPPMEPCType{}
579                                                                 cuUPPMEPC_C := (*C.EPC_CUUP_PM_Format_t)(cuUPPlmn_C.cu_UP_PM_EPC)
580
581                                                                 cuUPPMEPC.CUUPPMEPCPerQCIReportCount = int(cuUPPMEPC_C.perQCIReportList.list.count)
582                                                                 for l := 0; l < cuUPPMEPC.CUUPPMEPCPerQCIReportCount; l++ {
583                                                                         perQCIReport := &cuUPPMEPC.CUUPPMEPCPerQCIReports[l]
584                                                                         var sizeof_PerQCIReportListItemFormat_t *C.PerQCIReportListItemFormat_t
585                                                                         perQCIReport_C := *(**C.PerQCIReportListItemFormat_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItemFormat_t)))
586
587                                                                         perQCIReport.QCI = int64(perQCIReport_C.qci)
588
589                                                                         if perQCIReport_C.pDCPBytesDL != nil {
590                                                                                 perQCIReport.PDCPBytesDL = &Integer{}
591                                                                                 perQCIReport.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(perQCIReport_C.pDCPBytesDL.buf), C.int(perQCIReport_C.pDCPBytesDL.size))
592                                                                                 perQCIReport.PDCPBytesDL.Size = int(perQCIReport_C.pDCPBytesDL.size)
593                                                                         }
594
595                                                                         if perQCIReport_C.pDCPBytesUL != nil {
596                                                                                 perQCIReport.PDCPBytesUL = &Integer{}
597                                                                                 perQCIReport.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(perQCIReport_C.pDCPBytesUL.buf), C.int(perQCIReport_C.pDCPBytesUL.size))
598                                                                                 perQCIReport.PDCPBytesUL.Size = int(perQCIReport_C.pDCPBytesUL.size)
599                                                                         }
600                                                                 }
601
602                                                                 cuUPPlmn.CUUPPMEPC = cuUPPMEPC
603                                                         }
604                                                 }
605                                         }
606
607                                         pfContainer.Container = oCU_UP_PF
608                                 } else {
609                                         return indMsg, errors.New("Unknown PF Container type")
610                                 }
611
612                                 pmContainer.PFContainer = pfContainer
613                         }
614
615                         if pmContainer_C.theRANContainer != nil {
616                                 ranContainer := &RANContainerType{}
617
618                                 ranContainer.Timestamp.Buf = C.GoBytes(unsafe.Pointer(pmContainer_C.theRANContainer.timestamp.buf), C.int(pmContainer_C.theRANContainer.timestamp.size))
619                                 ranContainer.Timestamp.Size = int(pmContainer_C.theRANContainer.timestamp.size)
620
621                                 ranContainer.ContainerType = int32(pmContainer_C.theRANContainer.reportContainer.present)
622
623                                 if ranContainer.ContainerType == 1 {
624                                         oDU_UE := &DUUsageReportType{}
625                                         oDU_UE_C := *(**C.DU_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
626
627                                         oDU_UE.CellResourceReportItemCount = int(oDU_UE_C.cellResourceReportList.list.count)
628                                         for j := 0; j < oDU_UE.CellResourceReportItemCount; j++ {
629                                                 cellResourceReport := &oDU_UE.CellResourceReportItems[j]
630                                                 var sizeof_DU_Usage_Report_CellResourceReportItem_t *C.DU_Usage_Report_CellResourceReportItem_t
631                                                 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)))
632
633                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
634                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
635
636                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
637                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
638                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
639
640                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
641                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
642                                                         ueResourceReport := &cellResourceReport.UeResourceReportItems[k]
643                                                         var sizeof_DU_Usage_Report_UeResourceReportItem_t *C.DU_Usage_Report_UeResourceReportItem_t
644                                                         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)))
645
646                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
647                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
648
649                                                         if ueResourceReport_C.dl_PRBUsage != nil {
650                                                                 ueResourceReport.PRBUsageDL = int64(*ueResourceReport_C.dl_PRBUsage)
651                                                         } else {
652                                                                 ueResourceReport.PRBUsageDL = -1
653                                                         }
654
655                                                         if ueResourceReport_C.ul_PRBUsage != nil {
656                                                                 ueResourceReport.PRBUsageUL = int64(*ueResourceReport_C.ul_PRBUsage)
657                                                         } else {
658                                                                 ueResourceReport.PRBUsageUL = -1
659                                                         }
660                                                 }
661                                         }
662
663                                         ranContainer.Container = oDU_UE
664                                 } else if ranContainer.ContainerType == 2 {
665                                         oCU_CP_UE := &CUCPUsageReportType{}
666                                         oCU_CP_UE_C := *(**C.CU_CP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
667
668                                         oCU_CP_UE.CellResourceReportItemCount = int(oCU_CP_UE_C.cellResourceReportList.list.count)
669                                         for j := 0; j < oCU_CP_UE.CellResourceReportItemCount; j++ {
670                                                 cellResourceReport := &oCU_CP_UE.CellResourceReportItems[j]
671                                                 var sizeof_CU_CP_Usage_Report_CellResourceReportItem_t *C.CU_CP_Usage_Report_CellResourceReportItem_t
672                                                 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)))
673
674                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
675                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
676
677                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
678                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
679                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
680
681                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
682                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
683                                                         ueResourceReport := &cellResourceReport.UeResourceReportItems[k]
684                                                         var sizeof_CU_CP_Usage_Report_UeResourceReportItem_t *C.CU_CP_Usage_Report_UeResourceReportItem_t
685                                                         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)))
686
687                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
688                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
689
690                                                         if ueResourceReport_C.serving_Cell_RF_Type != nil {
691                                                                 ueResourceReport.ServingCellRF = &OctetString{}
692                                                                 ueResourceReport.ServingCellRF.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.serving_Cell_RF_Type.buf), C.int(ueResourceReport_C.serving_Cell_RF_Type.size))
693                                                                 ueResourceReport.ServingCellRF.Size = int(ueResourceReport_C.serving_Cell_RF_Type.size)
694                                                         }
695
696                                                         if ueResourceReport_C.neighbor_Cell_RF != nil {
697                                                                 ueResourceReport.NeighborCellRF = &OctetString{}
698                                                                 ueResourceReport.NeighborCellRF.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.neighbor_Cell_RF.buf), C.int(ueResourceReport_C.neighbor_Cell_RF.size))
699                                                                 ueResourceReport.NeighborCellRF.Size = int(ueResourceReport_C.neighbor_Cell_RF.size)
700                                                         }
701                                                 }
702                                         }
703
704                                         ranContainer.Container = oCU_CP_UE
705                                 } else if ranContainer.ContainerType == 3 {
706                                         oCU_UP_UE := &CUUPUsageReportType{}
707                                         oCU_UP_UE_C := *(**C.CU_UP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0]))
708
709                                         oCU_UP_UE.CellResourceReportItemCount = int(oCU_UP_UE_C.cellResourceReportList.list.count)
710                                         for j := 0; j < oCU_UP_UE.CellResourceReportItemCount; j++ {
711                                                 cellResourceReport := &oCU_UP_UE.CellResourceReportItems[j]
712                                                 var sizeof_CU_UP_Usage_Report_CellResourceReportItem_t *C.CU_UP_Usage_Report_CellResourceReportItem_t
713                                                 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)))
714
715                                                 cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size))
716                                                 cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size)
717
718                                                 cellResourceReport.NRCGI.NRCellID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.nRCellIdentity.buf), C.int(cellResourceReport_C.nRCGI.nRCellIdentity.size))
719                                                 cellResourceReport.NRCGI.NRCellID.Size = int(cellResourceReport_C.nRCGI.nRCellIdentity.size)
720                                                 cellResourceReport.NRCGI.NRCellID.BitsUnused = int(cellResourceReport_C.nRCGI.nRCellIdentity.bits_unused)
721
722                                                 cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count)
723                                                 for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ {
724                                                         ueResourceReport := &cellResourceReport.UeResourceReportItems[k]
725                                                         var sizeof_CU_UP_Usage_Report_UeResourceReportItem_t *C.CU_UP_Usage_Report_UeResourceReportItem_t
726                                                         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)))
727
728                                                         ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size))
729                                                         ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size)
730
731                                                         if ueResourceReport_C.pDCPBytesDL != nil {
732                                                                 ueResourceReport.PDCPBytesDL = &Integer{}
733                                                                 ueResourceReport.PDCPBytesDL.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.pDCPBytesDL.buf), C.int(ueResourceReport_C.pDCPBytesDL.size))
734                                                                 ueResourceReport.PDCPBytesDL.Size = int(ueResourceReport_C.pDCPBytesDL.size)
735                                                         }
736
737                                                         if ueResourceReport_C.pDCPBytesUL != nil {
738                                                                 ueResourceReport.PDCPBytesUL = &Integer{}
739                                                                 ueResourceReport.PDCPBytesUL.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.pDCPBytesUL.buf), C.int(ueResourceReport_C.pDCPBytesUL.size))
740                                                                 ueResourceReport.PDCPBytesUL.Size = int(ueResourceReport_C.pDCPBytesUL.size)
741                                                         }
742                                                 }
743                                         }
744
745                                         ranContainer.Container = oCU_UP_UE
746                                 } else {
747                                         return indMsg, errors.New("Unknown RAN Container type")
748                                 }
749
750                                 pmContainer.RANContainer = ranContainer
751                         }
752                 }
753
754                 indMsg.IndMsg = indMsgFormat1
755         } else {
756                 return indMsg, errors.New("Unknown RIC Indication Message Format")
757         }
758
759         return
760 }
761
762 func (c *E2sm) ParseNRCGI(nRCGI NRCGIType) (CellID string, err error) {
763         var plmnID OctetString
764         var nrCellID BitString
765
766         plmnID = nRCGI.PlmnID
767         CellID, _ = c.ParsePLMNIdentity(plmnID.Buf, plmnID.Size)
768
769         nrCellID = nRCGI.NRCellID
770
771         if plmnID.Size != 3 || nrCellID.Size != 5 {
772                 return "", errors.New("Invalid input: illegal length of NRCGI")
773         }
774
775         var former []uint8 = make([]uint8, 3)
776         var latter []uint8 = make([]uint8, 6)
777
778         former[0] = nrCellID.Buf[0] >> 4
779         former[1] = nrCellID.Buf[0] & 0xf
780         former[2] = nrCellID.Buf[1] >> 4
781         latter[0] = nrCellID.Buf[1] & 0xf
782         latter[1] = nrCellID.Buf[2] >> 4
783         latter[2] = nrCellID.Buf[2] & 0xf
784         latter[3] = nrCellID.Buf[3] >> 4
785         latter[4] = nrCellID.Buf[3] & 0xf
786         latter[5] = nrCellID.Buf[4] >> uint(nrCellID.BitsUnused)
787
788         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]))
789
790         return
791 }
792
793 func (c *E2sm) ParsePLMNIdentity(buffer []byte, size int) (PlmnID string, err error) {
794         if size != 3 {
795                 return "", errors.New("Invalid input: illegal length of PlmnID")
796         }
797
798         var mcc []uint8 = make([]uint8, 3)
799         var mnc []uint8 = make([]uint8, 3)
800
801         mcc[0] = buffer[0] >> 4
802         mcc[1] = buffer[0] & 0xf
803         mcc[2] = buffer[1] >> 4
804         mnc[0] = buffer[1] & 0xf
805         mnc[1] = buffer[2] >> 4
806         mnc[2] = buffer[2] & 0xf
807
808         if mnc[0] == 0xf {
809                 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]))
810         } else {
811                 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]))
812         }
813
814         return
815 }
816
817 func (c *E2sm) ParseSliceID(sliceID SliceIDType) (combined int32, err error) {
818         if sliceID.SST.Size != 1 || (sliceID.SD != nil && sliceID.SD.Size != 3) {
819                 return 0, errors.New("Invalid input: illegal length of sliceID")
820         }
821
822         var temp uint8
823         var sst int32
824         var sd int32
825
826         byteBuffer := bytes.NewBuffer(sliceID.SST.Buf)
827         binary.Read(byteBuffer, binary.BigEndian, &temp)
828         sst = int32(temp)
829
830         if sliceID.SD == nil {
831                 combined = sst << 24
832         } else {
833                 for i := 0; i < sliceID.SD.Size; i++ {
834                         byteBuffer = bytes.NewBuffer(sliceID.SD.Buf[i : i+1])
835                         binary.Read(byteBuffer, binary.BigEndian, &temp)
836                         sd = sd*256 + int32(temp)
837                 }
838                 combined = sst<<24 + sd
839         }
840
841         return
842 }
843
844 func (c *E2sm) ParseInteger(buffer []byte, size int) (value int64, err error) {
845         var temp uint8
846         var byteBuffer *bytes.Buffer
847
848         for i := 0; i < size; i++ {
849                 byteBuffer = bytes.NewBuffer(buffer[i : i+1])
850                 binary.Read(byteBuffer, binary.BigEndian, &temp)
851                 value = value*256 + int64(temp)
852         }
853
854         return
855 }
856
857 func (c *E2sm) ParseTimestamp(buffer []byte, size int) (timestamp *Timestamp, err error) {
858         var temp uint8
859         var byteBuffer *bytes.Buffer
860         var index int
861         var sec int64
862         var nsec int64
863
864         for index := 0; index < size-8; index++ {
865                 byteBuffer = bytes.NewBuffer(buffer[index : index+1])
866                 binary.Read(byteBuffer, binary.BigEndian, &temp)
867                 sec = sec*256 + int64(temp)
868         }
869
870         for index = size - 8; index < size; index++ {
871                 byteBuffer = bytes.NewBuffer(buffer[index : index+1])
872                 binary.Read(byteBuffer, binary.BigEndian, &temp)
873                 nsec = nsec*256 + int64(temp)
874         }
875
876         timestamp = &Timestamp{TVsec: sec, TVnsec: nsec}
877         return
878 }