868c3441700d3d53fad04ff9febdc6deb36261ca
[ric-plt/submgr.git] / e2ap / pkg / e2ap_wrapper / packer_e2ap.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 e2ap_wrapper
21
22 // #cgo LDFLAGS: -le2ap_wrapper -le2ap -lstdc++
23 // #include <stdlib.h>
24 // #include <c_types.h>
25 // #include <E2AP_if.h>
26 // #include <strings.h>
27 //
28 // void initSubsRequest(RICSubscriptionRequest_t *data){
29 //   bzero(data,sizeof(RICSubscriptionRequest_t));
30 // }
31 // void initSubsResponse(RICSubscriptionResponse_t *data){
32 //   bzero(data,sizeof(RICSubscriptionResponse_t));
33 // }
34 // void initSubsFailure(RICSubscriptionFailure_t *data){
35 //   bzero(data,sizeof(RICSubscriptionFailure_t));
36 // }
37 // void initSubsDeleteRequest(RICSubscriptionDeleteRequest_t *data){
38 //   bzero(data,sizeof(RICSubscriptionDeleteRequest_t));
39 // }
40 // void initSubsDeleteResponse(RICSubscriptionDeleteResponse_t *data){
41 //   bzero(data,sizeof(RICSubscriptionDeleteResponse_t));
42 // }
43 // void initSubsDeleteFailure(RICSubscriptionDeleteFailure_t *data){
44 //   bzero(data,sizeof(RICSubscriptionDeleteFailure_t));
45 // }
46 //
47 import "C"
48
49 import (
50         "bytes"
51         "fmt"
52         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
53         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
54         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
55         "unsafe"
56 )
57
58 //-----------------------------------------------------------------------------
59 //
60 //-----------------------------------------------------------------------------
61 type e2apEntryRequestID struct {
62         entry *C.RICRequestID_t
63 }
64
65 func (e2Item *e2apEntryRequestID) set(id *e2ap.RequestId) error {
66         e2Item.entry.ricRequestorID = (C.uint32_t)(id.Id)
67         e2Item.entry.ricRequestSequenceNumber = (C.uint32_t)(id.Seq)
68         return nil
69 }
70
71 func (e2Item *e2apEntryRequestID) get(id *e2ap.RequestId) error {
72         id.Id = (uint32)(e2Item.entry.ricRequestorID)
73         id.Seq = (uint32)(e2Item.entry.ricRequestSequenceNumber)
74         return nil
75 }
76
77 //-----------------------------------------------------------------------------
78 //
79 //-----------------------------------------------------------------------------
80 type e2apEntryActionToBeSetupItem struct {
81         entry *C.RICActionToBeSetupItem_t
82 }
83
84 func (e2Item *e2apEntryActionToBeSetupItem) set(id *e2ap.ActionToBeSetupItem) error {
85
86         e2Item.entry.ricActionID = (C.ulong)(id.ActionId)
87         e2Item.entry.ricActionType = (C.uint64_t)(id.ActionType)
88
89         if id.ActionDefinition.Present {
90                 e2Item.entry.ricActionDefinitionPresent = true
91                 e2Item.entry.ricActionDefinition.styleID = (C.uint64_t)(id.ActionDefinition.StyleId)
92                 e2Item.entry.ricActionDefinition.sequenceOfActionParameters.parameterID = (C.uint32_t)(id.ActionDefinition.ParamId)
93                 //e2Item.entry.ricActionDefinition.sequenceOfActionParameters.ParameterValue = id.ActionDefinition.ParamValue
94         }
95
96         if id.SubsequentAction.Present {
97                 e2Item.entry.ricSubsequentActionPresent = true
98                 e2Item.entry.ricSubsequentAction.ricSubsequentActionType = (C.uint64_t)(id.SubsequentAction.Type)
99                 e2Item.entry.ricSubsequentAction.ricTimeToWait = (C.uint64_t)(id.SubsequentAction.TimetoWait)
100         }
101         return nil
102 }
103
104 func (e2Item *e2apEntryActionToBeSetupItem) get(id *e2ap.ActionToBeSetupItem) error {
105
106         id.ActionId = (uint64)(e2Item.entry.ricActionID)
107         id.ActionType = (uint64)(e2Item.entry.ricActionType)
108
109         if e2Item.entry.ricActionDefinitionPresent {
110                 id.ActionDefinition.Present = true
111                 id.ActionDefinition.StyleId = (uint64)(e2Item.entry.ricActionDefinition.styleID)
112                 id.ActionDefinition.ParamId = (uint32)(e2Item.entry.ricActionDefinition.sequenceOfActionParameters.parameterID)
113                 //id.ActionDefinition.ParamValue=e2Item.entry.ricActionDefinition.sequenceOfActionParameters.ParameterValue
114         }
115
116         if e2Item.entry.ricSubsequentActionPresent {
117                 id.SubsequentAction.Present = true
118                 id.SubsequentAction.Type = (uint64)(e2Item.entry.ricSubsequentAction.ricSubsequentActionType)
119                 id.SubsequentAction.TimetoWait = (uint64)(e2Item.entry.ricSubsequentAction.ricTimeToWait)
120         }
121         return nil
122 }
123
124 //-----------------------------------------------------------------------------
125 //
126 //-----------------------------------------------------------------------------
127 type e2apEntryPlmnIdentity struct {
128         entry *C.PLMNIdentity_t
129 }
130
131 func (plmnId *e2apEntryPlmnIdentity) set(id *conv.PlmnIdentity) error {
132
133         plmnId.entry.contentLength = (C.uint8_t)(len(id.Val))
134         for i := 0; i < len(id.Val); i++ {
135                 plmnId.entry.pLMNIdentityVal[i] = (C.uint8_t)(id.Val[i])
136         }
137         return nil
138 }
139
140 func (plmnId *e2apEntryPlmnIdentity) get(id *conv.PlmnIdentity) error {
141         conlen := (int)(plmnId.entry.contentLength)
142         bcdBuf := make([]uint8, conlen)
143         for i := 0; i < conlen; i++ {
144                 bcdBuf[i] = (uint8)(plmnId.entry.pLMNIdentityVal[i])
145         }
146         id.BcdPut(bcdBuf)
147         return nil
148 }
149
150 //-----------------------------------------------------------------------------
151 //
152 //-----------------------------------------------------------------------------
153 type e2apEntryGlobalEnbId struct {
154         entry *C.GlobalNodeID_t
155 }
156
157 func (enbId *e2apEntryGlobalEnbId) checkbits(bits uint8) error {
158         switch bits {
159         case e2ap.E2AP_ENBIDMacroPBits20:
160                 return nil
161         case e2ap.E2AP_ENBIDHomeBits28:
162                 return nil
163         case e2ap.E2AP_ENBIDShortMacroits18:
164                 return nil
165         case e2ap.E2AP_ENBIDlongMacroBits21:
166                 return nil
167         }
168         return fmt.Errorf("GlobalEnbId: given bits %d not match allowed: 20,28,18,21", bits)
169 }
170
171 func (enbId *e2apEntryGlobalEnbId) set(id *e2ap.GlobalNodeId) error {
172         if err := enbId.checkbits(id.NodeId.Bits); err != nil {
173                 return err
174         }
175         enbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
176         enbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
177         return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
178 }
179
180 func (enbId *e2apEntryGlobalEnbId) get(id *e2ap.GlobalNodeId) error {
181         if err := enbId.checkbits((uint8)(enbId.entry.nodeID.bits)); err != nil {
182                 return err
183         }
184         id.NodeId.Bits = (uint8)(enbId.entry.nodeID.bits)
185         id.NodeId.Id = (uint32)(enbId.entry.nodeID.nodeID)
186         return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
187 }
188
189 //-----------------------------------------------------------------------------
190 //
191 //-----------------------------------------------------------------------------
192 type e2apEntryGlobalGnbId struct {
193         entry *C.GlobalNodeID_t
194 }
195
196 func (gnbId *e2apEntryGlobalGnbId) checkbits(bits uint8) error {
197         if bits < 22 || bits > 32 {
198                 return fmt.Errorf("GlobalGnbId: given bits %d not match allowed: 22-32", bits)
199         }
200         return nil
201 }
202
203 func (gnbId *e2apEntryGlobalGnbId) set(id *e2ap.GlobalNodeId) error {
204         if err := gnbId.checkbits(id.NodeId.Bits); err != nil {
205                 return err
206         }
207         gnbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
208         gnbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
209         return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
210 }
211
212 func (gnbId *e2apEntryGlobalGnbId) get(id *e2ap.GlobalNodeId) error {
213         if err := gnbId.checkbits((uint8)(gnbId.entry.nodeID.bits)); err != nil {
214                 return err
215         }
216         id.NodeId.Bits = (uint8)(gnbId.entry.nodeID.bits)
217         id.NodeId.Id = (uint32)(gnbId.entry.nodeID.nodeID)
218         return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
219 }
220
221 //-----------------------------------------------------------------------------
222 //
223 //-----------------------------------------------------------------------------
224 type e2apEntryInterfaceId struct {
225         entry *C.InterfaceID_t
226 }
227
228 func (indId *e2apEntryInterfaceId) set(id *e2ap.InterfaceId) error {
229         if id.GlobalEnbId.Present {
230                 indId.entry.globalENBIDPresent = true
231                 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).set(&id.GlobalEnbId); err != nil {
232                         return err
233                 }
234         }
235
236         if id.GlobalGnbId.Present {
237                 indId.entry.globalGNBIDPresent = true
238                 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).set(&id.GlobalGnbId); err != nil {
239                         return err
240                 }
241         }
242         return nil
243 }
244
245 func (indId *e2apEntryInterfaceId) get(id *e2ap.InterfaceId) error {
246         if indId.entry.globalENBIDPresent == true {
247                 id.GlobalEnbId.Present = true
248                 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).get(&id.GlobalEnbId); err != nil {
249                         return err
250                 }
251         }
252
253         if indId.entry.globalGNBIDPresent == true {
254                 id.GlobalGnbId.Present = true
255                 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).get(&id.GlobalGnbId); err != nil {
256                         return err
257                 }
258         }
259         return nil
260 }
261
262 //-----------------------------------------------------------------------------
263 //
264 //-----------------------------------------------------------------------------
265 type e2apEntryEventTrigger struct {
266         entry *C.RICEventTriggerDefinition_t
267 }
268
269 func (evtTrig *e2apEntryEventTrigger) set(id *e2ap.EventTriggerDefinition) error {
270         evtTrig.entry.interfaceDirection = (C.uint8_t)(id.InterfaceDirection)
271         evtTrig.entry.interfaceMessageType.procedureCode = (C.uint8_t)(id.ProcedureCode)
272         evtTrig.entry.interfaceMessageType.typeOfMessage = (C.uint8_t)(id.TypeOfMessage)
273         return (&e2apEntryInterfaceId{entry: &evtTrig.entry.interfaceID}).set(&id.InterfaceId)
274 }
275
276 func (evtTrig *e2apEntryEventTrigger) get(id *e2ap.EventTriggerDefinition) error {
277         id.InterfaceDirection = (uint32)(evtTrig.entry.interfaceDirection)
278         id.ProcedureCode = (uint32)(evtTrig.entry.interfaceMessageType.procedureCode)
279         id.TypeOfMessage = (uint64)(evtTrig.entry.interfaceMessageType.typeOfMessage)
280         return (&e2apEntryInterfaceId{entry: &evtTrig.entry.interfaceID}).get(&id.InterfaceId)
281 }
282
283 //-----------------------------------------------------------------------------
284 //
285 //-----------------------------------------------------------------------------
286 type e2apEntryAdmittedList struct {
287         entry *C.RICActionAdmittedList_t
288 }
289
290 func (item *e2apEntryAdmittedList) set(data *e2ap.ActionAdmittedList) error {
291
292         if len(data.Items) > 16 {
293                 return fmt.Errorf("ActionAdmittedList: too long %d while allowed %d", len(data.Items), 16)
294         }
295
296         item.entry.contentLength = 0
297         for i := 0; i < len(data.Items); i++ {
298                 item.entry.ricActionID[item.entry.contentLength] = (C.ulong)(data.Items[i].ActionId)
299                 item.entry.contentLength++
300         }
301         return nil
302 }
303
304 func (item *e2apEntryAdmittedList) get(data *e2ap.ActionAdmittedList) error {
305         conlen := (int)(item.entry.contentLength)
306         data.Items = make([]e2ap.ActionAdmittedItem, conlen)
307         for i := 0; i < conlen; i++ {
308                 data.Items[i].ActionId = (uint64)(item.entry.ricActionID[i])
309         }
310         return nil
311 }
312
313 //-----------------------------------------------------------------------------
314 //
315 //-----------------------------------------------------------------------------
316 type e2apEntryNotAdmittedList struct {
317         entry *C.RICActionNotAdmittedList_t
318 }
319
320 func (item *e2apEntryNotAdmittedList) set(data *e2ap.ActionNotAdmittedList) error {
321
322         if len(data.Items) > 16 {
323                 return fmt.Errorf("e2apEntryNotAdmittedList: too long %d while allowed %d", len(data.Items), 16)
324         }
325
326         item.entry.contentLength = 0
327         for i := 0; i < len(data.Items); i++ {
328                 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricActionID = (C.ulong)(data.Items[i].ActionId)
329                 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.content = (C.uchar)(data.Items[i].Cause.Content)
330                 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.cause = (C.uchar)(data.Items[i].Cause.CauseVal)
331                 item.entry.contentLength++
332         }
333
334         return nil
335 }
336
337 func (item *e2apEntryNotAdmittedList) get(data *e2ap.ActionNotAdmittedList) error {
338         conlen := (int)(item.entry.contentLength)
339         data.Items = make([]e2ap.ActionNotAdmittedItem, conlen)
340         for i := 0; i < conlen; i++ {
341                 data.Items[i].ActionId = (uint64)(item.entry.RICActionNotAdmittedItem[i].ricActionID)
342                 data.Items[i].Cause.Content = (uint8)(item.entry.RICActionNotAdmittedItem[i].ricCause.content)
343                 data.Items[i].Cause.CauseVal = (uint8)(item.entry.RICActionNotAdmittedItem[i].ricCause.cause)
344         }
345         return nil
346 }
347
348 //-----------------------------------------------------------------------------
349 //
350 //-----------------------------------------------------------------------------
351 type e2apEntryCriticalityDiagnostic struct {
352         entry *C.CriticalityDiagnostics__t
353 }
354
355 func (item *e2apEntryCriticalityDiagnostic) set(data *e2ap.CriticalityDiagnostics) error {
356
357         item.entry.procedureCodePresent = (C.bool)(data.ProcCodePresent)
358         item.entry.procedureCode = (C.uchar)(data.ProcCode)
359
360         item.entry.triggeringMessagePresent = (C.bool)(data.TrigMsgPresent)
361         item.entry.triggeringMessage = (C.uchar)(data.TrigMsg)
362
363         item.entry.procedureCriticalityPresent = (C.bool)(data.ProcCritPresent)
364         item.entry.procedureCriticality = (C.uchar)(data.ProcCrit)
365
366         item.entry.criticalityDiagnosticsIELength = 0
367         item.entry.iEsCriticalityDiagnosticsPresent = false
368         for i := 0; i < len(data.CriticalityDiagnosticsIEList.Items); i++ {
369                 item.entry.criticalityDiagnosticsIEListItem[i].iECriticality = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].IeCriticality)
370                 item.entry.criticalityDiagnosticsIEListItem[i].iE_ID = (C.uint32_t)(data.CriticalityDiagnosticsIEList.Items[i].IeID)
371                 item.entry.criticalityDiagnosticsIEListItem[i].typeOfError = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].TypeOfError)
372                 item.entry.criticalityDiagnosticsIELength++
373                 item.entry.iEsCriticalityDiagnosticsPresent = true
374         }
375         return nil
376 }
377
378 func (item *e2apEntryCriticalityDiagnostic) get(data *e2ap.CriticalityDiagnostics) error {
379
380         data.ProcCodePresent = (bool)(item.entry.procedureCodePresent)
381         data.ProcCode = (uint64)(item.entry.procedureCode)
382
383         data.TrigMsgPresent = (bool)(item.entry.triggeringMessagePresent)
384         data.TrigMsg = (uint64)(item.entry.triggeringMessage)
385
386         data.ProcCritPresent = (bool)(item.entry.procedureCriticalityPresent)
387         data.ProcCrit = (uint8)(item.entry.procedureCriticality)
388
389         if item.entry.iEsCriticalityDiagnosticsPresent == true {
390                 conlen := (int)(item.entry.criticalityDiagnosticsIELength)
391                 data.CriticalityDiagnosticsIEList.Items = make([]e2ap.CriticalityDiagnosticsIEListItem, conlen)
392                 for i := 0; i < conlen; i++ {
393                         data.CriticalityDiagnosticsIEList.Items[i].IeCriticality = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].iECriticality)
394                         data.CriticalityDiagnosticsIEList.Items[i].IeID = (uint32)(item.entry.criticalityDiagnosticsIEListItem[i].iE_ID)
395                         data.CriticalityDiagnosticsIEList.Items[i].TypeOfError = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].typeOfError)
396                 }
397         }
398         return nil
399 }
400
401 /*
402 //-----------------------------------------------------------------------------
403 //
404 //-----------------------------------------------------------------------------
405 type e2apEntryCallProcessId struct {
406         entry *C.RICCallProcessID_t
407 }
408
409 func (callProcId *e2apEntryCallProcessId) set(data *e2ap.CallProcessId) error {
410         callProcId.entry.ricCallProcessIDVal = (C.uint64_t)(data.CallProcessIDVal)
411         return nil
412 }
413
414 func (callProcId *e2apEntryCallProcessId) get(data *e2ap.CallProcessId) error {
415         data.CallProcessIDVal = (uint32)(callProcId.entry.ricCallProcessIDVal)
416         return nil
417 }
418 */
419
420 //-----------------------------------------------------------------------------
421 //
422 //-----------------------------------------------------------------------------
423
424 type e2apMessage struct {
425         pdu         *C.e2ap_pdu_ptr_t
426         messageInfo C.E2MessageInfo_t
427 }
428
429 func (e2apMsg *e2apMessage) PduUnPack(logBuf []byte, data *packer.PackedData) error {
430         e2apMsg.pdu = C.unpackE2AP_pdu((C.size_t)(len(data.Buf)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), &e2apMsg.messageInfo)
431         return nil
432 }
433
434 func (e2apMsg *e2apMessage) MessageInfo() *packer.MessageInfo {
435
436         msgInfo := &packer.MessageInfo{}
437
438         switch e2apMsg.messageInfo.messageType {
439         case C.cE2InitiatingMessage:
440                 msgInfo.MsgType = e2ap.E2AP_InitiatingMessage
441                 switch e2apMsg.messageInfo.messageId {
442                 case C.cRICSubscriptionRequest:
443                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionRequest
444                         return msgInfo
445                 case C.cRICSubscriptionDeleteRequest:
446                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteRequest
447                         return msgInfo
448                 }
449         case C.cE2SuccessfulOutcome:
450                 msgInfo.MsgType = e2ap.E2AP_SuccessfulOutcome
451                 switch e2apMsg.messageInfo.messageId {
452                 case C.cRICSubscriptionResponse:
453                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionResponse
454                         return msgInfo
455                 case C.cRICsubscriptionDeleteResponse:
456                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteResponse
457                         return msgInfo
458                 }
459         case C.cE2UnsuccessfulOutcome:
460                 msgInfo.MsgType = e2ap.E2AP_UnsuccessfulOutcome
461                 switch e2apMsg.messageInfo.messageId {
462                 case C.cRICSubscriptionFailure:
463                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionFailure
464                         return msgInfo
465                 case C.cRICsubscriptionDeleteFailure:
466                         msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteFailure
467                         return msgInfo
468                 }
469
470         }
471         return nil
472 }
473
474 func (e2apMsg *e2apMessage) UnPack(msg *packer.PackedData) *packer.MessageInfo {
475         err := packer.PduPackerUnPack(e2apMsg, msg)
476         if err != nil {
477                 return nil
478         }
479         return e2apMsg.MessageInfo()
480 }
481
482 func (e2apMsg *e2apMessage) String() string {
483         msgInfo := e2apMsg.MessageInfo()
484         if msgInfo == nil {
485                 return "N/A"
486         }
487         return msgInfo.String()
488 }
489
490 //-----------------------------------------------------------------------------
491 //
492 //-----------------------------------------------------------------------------
493
494 type e2apMsgSubscriptionRequest struct {
495         e2apMessage
496         msgC *C.RICSubscriptionRequest_t
497 }
498
499 func (e2apMsg *e2apMsgSubscriptionRequest) Set(data *e2ap.E2APSubscriptionRequest) error {
500
501         e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
502         C.initSubsRequest(e2apMsg.msgC)
503
504         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
505
506         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
507                 return err
508         }
509         if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).set(&data.EventTriggerDefinition); err != nil {
510                 return err
511         }
512
513         if len(data.ActionSetups) > 16 {
514                 return fmt.Errorf("IndicationMessage.InterfaceMessage: too long %d while allowed %d", len(data.ActionSetups), 16)
515         }
516
517         e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength = 0
518         for i := 0; i < len(data.ActionSetups); i++ {
519                 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength]}
520                 e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength += 1
521                 if err := item.set(&data.ActionSetups[i]); err != nil {
522                         return err
523                 }
524         }
525         return nil
526 }
527
528 func (e2apMsg *e2apMsgSubscriptionRequest) Get() (error, *e2ap.E2APSubscriptionRequest) {
529
530         data := &e2ap.E2APSubscriptionRequest{}
531
532         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
533
534         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
535                 return err, data
536         }
537         if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).get(&data.EventTriggerDefinition); err != nil {
538                 return err, data
539         }
540
541         conlen := (int)(e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength)
542         data.ActionSetups = make([]e2ap.ActionToBeSetupItem, conlen)
543         for i := 0; i < conlen; i++ {
544                 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[i]}
545                 if err := item.get(&data.ActionSetups[i]); err != nil {
546                         return err, data
547                 }
548         }
549         return nil, data
550
551 }
552
553 func (e2apMsg *e2apMsgSubscriptionRequest) PduPack(logBuf []byte, data *packer.PackedData) error {
554         /*
555            Not needed anymore
556
557                 evtTrig := e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}
558                 if err := evtTrig.pack(); err != nil {
559                         return err
560                 }
561         */
562         var buflen uint32 = (uint32)(len(data.Buf))
563         errorNro := C.packRICSubscriptionRequest((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
564         if errorNro != C.e2err_OK {
565                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
566         }
567         data.Buf = data.Buf[0:buflen]
568         return nil
569
570 }
571
572 func (e2apMsg *e2apMsgSubscriptionRequest) PduUnPack(logBuf []byte, data *packer.PackedData) error {
573
574         e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
575         C.initSubsRequest(e2apMsg.msgC)
576
577         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
578         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2InitiatingMessage || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionRequest {
579                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
580         }
581         errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
582         if errorNro != C.e2err_OK {
583                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
584         }
585         /*
586            Not needed anymore
587
588                 evtTrig := e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}
589                 if err := evtTrig.unpack(); err != nil {
590                         return err
591                 }
592         */
593         return nil
594 }
595
596 func (e2apMsg *e2apMsgSubscriptionRequest) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
597         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
598 }
599
600 func (e2apMsg *e2apMsgSubscriptionRequest) UnPack(msg *packer.PackedData) error {
601         return packer.PduPackerUnPack(e2apMsg, msg)
602 }
603
604 func (e2apMsg *e2apMsgSubscriptionRequest) String() string {
605         var b bytes.Buffer
606         fmt.Fprintln(&b, "ricSubscriptionRequest.")
607         fmt.Fprintln(&b, "  ricRequestID.")
608         fmt.Fprintln(&b, "     ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
609         fmt.Fprintln(&b, "     ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
610         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
611         fmt.Fprintln(&b, "  ricSubscription.")
612         fmt.Fprintln(&b, "    ricEventTriggerDefinition.")
613         fmt.Fprintln(&b, "      contentLength =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.octetString.contentLength)
614         fmt.Fprintln(&b, "      interfaceID.globalENBIDPresent =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBIDPresent)
615         if e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBIDPresent {
616                 fmt.Fprintln(&b, "      interfaceID.globalENBID.pLMNIdentity.contentLength =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.pLMNIdentity.contentLength)
617                 fmt.Fprintln(&b, "      interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[0] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[0])
618                 fmt.Fprintln(&b, "      interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[1] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[1])
619                 fmt.Fprintln(&b, "      interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[2] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.pLMNIdentity.pLMNIdentityVal[2])
620                 fmt.Fprintln(&b, "      interfaceID.globalENBID.nodeID.bits =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.nodeID.bits)
621                 fmt.Fprintln(&b, "      interfaceID.globalENBID.nodeID.nodeID =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalENBID.nodeID.nodeID)
622         }
623         fmt.Fprintln(&b, "      interfaceID.globalGNBIDPresent =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBIDPresent)
624         if e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBIDPresent {
625                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.pLMNIdentity.contentLength =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.pLMNIdentity.contentLength)
626                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[0] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[0])
627                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[1] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[1])
628                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[2] =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.pLMNIdentity.pLMNIdentityVal[2])
629                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.nodeID.bits =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.nodeID.bits)
630                 fmt.Fprintln(&b, "      interfaceID.globalGNBID.nodeID.nodeID =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceID.globalGNBID.nodeID.nodeID)
631         }
632         fmt.Fprintln(&b, "      interfaceDirection= ", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceDirection)
633         fmt.Fprintln(&b, "      interfaceMessageType.procedureCode =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceMessageType.procedureCode)
634         fmt.Fprintln(&b, "      interfaceMessageType.typeOfMessage =", e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition.interfaceMessageType.typeOfMessage)
635         fmt.Fprintln(&b, "    ricActionToBeSetupItemIEs.")
636         fmt.Fprintln(&b, "      contentLength =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength)
637         var index uint8
638         index = 0
639         for (C.uchar)(index) < e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength {
640                 fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricActionID =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionID)
641                 fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricActionType =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionType)
642
643                 fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricActionDefinitionPresent =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent)
644                 if e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent {
645                         fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricActionDefinition.styleID =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinition.styleID)
646                         fmt.Fprintln(&b, "      ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinition.sequenceOfActionParameters.parameterID =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinition.sequenceOfActionParameters.parameterID)
647                 }
648
649                 fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricSubsequentActionPresent =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent)
650                 if e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent {
651                         fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType)
652                         fmt.Fprintln(&b, "      ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait =", e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait)
653                 }
654                 index++
655         }
656         return b.String()
657 }
658
659 //-----------------------------------------------------------------------------
660 //
661 //-----------------------------------------------------------------------------
662 type e2apMsgSubscriptionResponse struct {
663         e2apMessage
664         msgC *C.RICSubscriptionResponse_t
665 }
666
667 func (e2apMsg *e2apMsgSubscriptionResponse) Set(data *e2ap.E2APSubscriptionResponse) error {
668
669         e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
670         C.initSubsResponse(e2apMsg.msgC)
671
672         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
673
674         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
675                 return err
676         }
677
678         if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&data.ActionAdmittedList); err != nil {
679                 return err
680         }
681
682         e2apMsg.msgC.ricActionNotAdmittedListPresent = false
683         if len(data.ActionNotAdmittedList.Items) > 0 {
684                 e2apMsg.msgC.ricActionNotAdmittedListPresent = true
685                 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&data.ActionNotAdmittedList); err != nil {
686                         return err
687                 }
688         }
689         return nil
690 }
691
692 func (e2apMsg *e2apMsgSubscriptionResponse) Get() (error, *e2ap.E2APSubscriptionResponse) {
693
694         data := &e2ap.E2APSubscriptionResponse{}
695
696         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
697
698         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
699                 return err, data
700         }
701
702         if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&data.ActionAdmittedList); err != nil {
703                 return err, data
704         }
705
706         if e2apMsg.msgC.ricActionNotAdmittedListPresent == true {
707                 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&data.ActionNotAdmittedList); err != nil {
708                         return err, data
709                 }
710         }
711         return nil, data
712
713 }
714
715 func (e2apMsg *e2apMsgSubscriptionResponse) PduPack(logBuf []byte, data *packer.PackedData) error {
716         var buflen uint32 = (uint32)(len(data.Buf))
717         errorNro := C.packRICSubscriptionResponse((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
718         if errorNro != C.e2err_OK {
719                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
720         }
721         data.Buf = data.Buf[0:buflen]
722         return nil
723 }
724
725 func (e2apMsg *e2apMsgSubscriptionResponse) PduUnPack(logBuf []byte, data *packer.PackedData) error {
726         e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
727         C.initSubsResponse(e2apMsg.msgC)
728
729         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
730         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2SuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionResponse {
731                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
732         }
733         errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
734         if errorNro != C.e2err_OK {
735                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
736         }
737         return nil
738 }
739
740 func (e2apMsg *e2apMsgSubscriptionResponse) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
741         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
742 }
743
744 func (e2apMsg *e2apMsgSubscriptionResponse) UnPack(msg *packer.PackedData) error {
745         return packer.PduPackerUnPack(e2apMsg, msg)
746 }
747
748 func (e2apMsg *e2apMsgSubscriptionResponse) String() string {
749         var b bytes.Buffer
750         fmt.Fprintln(&b, "ricSubscriptionResponse.")
751         fmt.Fprintln(&b, "  ricRequestID.")
752         fmt.Fprintln(&b, "    ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
753         fmt.Fprintln(&b, "    ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
754         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
755         fmt.Fprintln(&b, "  ricActionAdmittedList.")
756         fmt.Fprintln(&b, "    contentLength =", e2apMsg.msgC.ricActionAdmittedList.contentLength)
757         var index uint8
758         index = 0
759         for (C.uchar)(index) < e2apMsg.msgC.ricActionAdmittedList.contentLength {
760                 fmt.Fprintln(&b, "    ricActionAdmittedList.ricActionID[index] =", e2apMsg.msgC.ricActionAdmittedList.ricActionID[index])
761                 index++
762         }
763         if e2apMsg.msgC.ricActionNotAdmittedListPresent {
764                 fmt.Fprintln(&b, "  ricActionNotAdmittedListPresent =", e2apMsg.msgC.ricActionNotAdmittedListPresent)
765                 fmt.Fprintln(&b, "    ricActionNotAdmittedList.")
766                 fmt.Fprintln(&b, "    contentLength =", e2apMsg.msgC.ricActionNotAdmittedList.contentLength)
767                 index = 0
768                 for (C.uchar)(index) < e2apMsg.msgC.ricActionNotAdmittedList.contentLength {
769                         fmt.Fprintln(&b, "      RICActionNotAdmittedItem[index].ricActionID =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID)
770                         fmt.Fprintln(&b, "      RICActionNotAdmittedItem[index].ricCause.content =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content)
771                         fmt.Fprintln(&b, "      RICActionNotAdmittedItem[index].ricCause.cause =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause)
772                         index++
773                 }
774         }
775         return b.String()
776 }
777
778 //-----------------------------------------------------------------------------
779 //
780 //-----------------------------------------------------------------------------
781 type e2apMsgSubscriptionFailure struct {
782         e2apMessage
783         msgC *C.RICSubscriptionFailure_t
784 }
785
786 func (e2apMsg *e2apMsgSubscriptionFailure) Set(data *e2ap.E2APSubscriptionFailure) error {
787
788         e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
789         C.initSubsFailure(e2apMsg.msgC)
790
791         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
792
793         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
794                 return err
795         }
796
797         if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&data.ActionNotAdmittedList); err != nil {
798                 return err
799         }
800
801         e2apMsg.msgC.criticalityDiagnosticsPresent = false
802         if data.CriticalityDiagnostics.Present {
803                 e2apMsg.msgC.criticalityDiagnosticsPresent = true
804                 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&data.CriticalityDiagnostics); err != nil {
805                         return err
806                 }
807         }
808
809         return nil
810 }
811
812 func (e2apMsg *e2apMsgSubscriptionFailure) Get() (error, *e2ap.E2APSubscriptionFailure) {
813
814         data := &e2ap.E2APSubscriptionFailure{}
815
816         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
817
818         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
819                 return err, data
820         }
821
822         if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&data.ActionNotAdmittedList); err != nil {
823                 return err, data
824         }
825
826         if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
827                 data.CriticalityDiagnostics.Present = true
828                 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&data.CriticalityDiagnostics); err != nil {
829                         return err, data
830                 }
831         }
832
833         return nil, data
834 }
835
836 func (e2apMsg *e2apMsgSubscriptionFailure) PduPack(logBuf []byte, data *packer.PackedData) error {
837         var buflen uint32 = (uint32)(len(data.Buf))
838         errorNro := C.packRICSubscriptionFailure((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
839         if errorNro != C.e2err_OK {
840                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
841         }
842         data.Buf = data.Buf[0:buflen]
843         return nil
844 }
845
846 func (e2apMsg *e2apMsgSubscriptionFailure) PduUnPack(logBuf []byte, data *packer.PackedData) error {
847
848         e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
849         C.initSubsFailure(e2apMsg.msgC)
850
851         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
852         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2UnsuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionFailure {
853                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
854         }
855         errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
856         if errorNro != C.e2err_OK {
857                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
858         }
859         return nil
860
861 }
862
863 func (e2apMsg *e2apMsgSubscriptionFailure) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
864         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
865 }
866
867 func (e2apMsg *e2apMsgSubscriptionFailure) UnPack(msg *packer.PackedData) error {
868         return packer.PduPackerUnPack(e2apMsg, msg)
869 }
870
871 func (e2apMsg *e2apMsgSubscriptionFailure) String() string {
872         var b bytes.Buffer
873         fmt.Fprintln(&b, "ricSubscriptionFailure.")
874         fmt.Fprintln(&b, "  ricRequestID.")
875         fmt.Fprintln(&b, "    ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
876         fmt.Fprintln(&b, "    ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
877         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
878         fmt.Fprintln(&b, "  ricActionNotAdmittedList.")
879         fmt.Fprintln(&b, "    contentLength =", e2apMsg.msgC.ricActionNotAdmittedList.contentLength)
880         var index uint8
881         index = 0
882         for (C.uchar)(index) < e2apMsg.msgC.ricActionNotAdmittedList.contentLength {
883                 fmt.Fprintln(&b, "    RICActionNotAdmittedItem[index].ricActionID =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID)
884                 fmt.Fprintln(&b, "    RICActionNotAdmittedItem[index].ricCause.content =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.content)
885                 fmt.Fprintln(&b, "    RICActionNotAdmittedItem[index].ricCause.cause =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricCause.cause)
886                 index++
887         }
888         /* NOT SUPPORTED
889         if e2apMsg.msgC.criticalityDiagnosticsPresent {
890                 fmt.Fprintln(&b, "  criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
891                 fmt.Fprintln(&b, "    criticalityDiagnostics.")
892                 fmt.Fprintln(&b, "    procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
893                 fmt.Fprintln(&b, "      procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
894                 fmt.Fprintln(&b, "    triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
895                 fmt.Fprintln(&b, "      triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
896                 fmt.Fprintln(&b, "    procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
897                 fmt.Fprintln(&b, "      procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
898                 fmt.Fprintln(&b, "    iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
899                 fmt.Fprintln(&b, "      criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
900                 var index2 uint16
901                 index2 = 0
902                 for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
903                         fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
904                         fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
905                         fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
906                         index2++
907                 }
908         }
909         */
910         return b.String()
911 }
912
913 //-----------------------------------------------------------------------------
914 //
915 //-----------------------------------------------------------------------------
916 type e2apMsgSubscriptionDeleteRequest struct {
917         e2apMessage
918         msgC *C.RICSubscriptionDeleteRequest_t
919 }
920
921 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Set(data *e2ap.E2APSubscriptionDeleteRequest) error {
922
923         e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
924         C.initSubsDeleteRequest(e2apMsg.msgC)
925
926         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
927
928         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
929                 return err
930         }
931         return nil
932 }
933
934 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Get() (error, *e2ap.E2APSubscriptionDeleteRequest) {
935
936         data := &e2ap.E2APSubscriptionDeleteRequest{}
937
938         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
939
940         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
941                 return err, data
942         }
943
944         return nil, data
945 }
946
947 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduPack(logBuf []byte, data *packer.PackedData) error {
948         var buflen uint32 = (uint32)(len(data.Buf))
949         errorNro := C.packRICSubscriptionDeleteRequest((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
950         if errorNro != C.e2err_OK {
951                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
952         }
953         data.Buf = data.Buf[0:buflen]
954         return nil
955
956 }
957
958 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduUnPack(logBuf []byte, data *packer.PackedData) error {
959
960         e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
961         C.initSubsDeleteRequest(e2apMsg.msgC)
962
963         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
964         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2InitiatingMessage || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionDeleteRequest {
965                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
966         }
967         errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
968         if errorNro != C.e2err_OK {
969                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
970         }
971         return nil
972 }
973
974 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
975         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
976 }
977
978 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) UnPack(msg *packer.PackedData) error {
979         return packer.PduPackerUnPack(e2apMsg, msg)
980 }
981
982 func (e2apMsg *e2apMsgSubscriptionDeleteRequest) String() string {
983         var b bytes.Buffer
984         fmt.Fprintln(&b, "ricSubscriptionDeleteRequest.")
985         fmt.Fprintln(&b, "  ricRequestID.")
986         fmt.Fprintln(&b, "     ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
987         fmt.Fprintln(&b, "     ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
988         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
989         return b.String()
990 }
991
992 //-----------------------------------------------------------------------------
993 //
994 //-----------------------------------------------------------------------------
995 type e2apMsgSubscriptionDeleteResponse struct {
996         e2apMessage
997         msgC *C.RICSubscriptionDeleteResponse_t
998 }
999
1000 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Set(data *e2ap.E2APSubscriptionDeleteResponse) error {
1001
1002         e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
1003         C.initSubsDeleteResponse(e2apMsg.msgC)
1004
1005         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
1006
1007         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
1008                 return err
1009         }
1010         return nil
1011 }
1012
1013 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Get() (error, *e2ap.E2APSubscriptionDeleteResponse) {
1014
1015         data := &e2ap.E2APSubscriptionDeleteResponse{}
1016
1017         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
1018
1019         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
1020                 return err, data
1021         }
1022
1023         return nil, data
1024 }
1025 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduPack(logBuf []byte, data *packer.PackedData) error {
1026         var buflen uint32 = (uint32)(len(data.Buf))
1027         errorNro := C.packRICSubscriptionDeleteResponse((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
1028         if errorNro != C.e2err_OK {
1029                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
1030         }
1031         data.Buf = data.Buf[0:buflen]
1032         return nil
1033 }
1034
1035 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduUnPack(logBuf []byte, data *packer.PackedData) error {
1036         e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
1037         C.initSubsDeleteResponse(e2apMsg.msgC)
1038
1039         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
1040         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2SuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICsubscriptionDeleteResponse {
1041                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
1042         }
1043         errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
1044         if errorNro != C.e2err_OK {
1045                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
1046         }
1047         return nil
1048 }
1049
1050 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
1051         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
1052 }
1053
1054 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) UnPack(msg *packer.PackedData) error {
1055         return packer.PduPackerUnPack(e2apMsg, msg)
1056 }
1057
1058 func (e2apMsg *e2apMsgSubscriptionDeleteResponse) String() string {
1059         var b bytes.Buffer
1060         fmt.Fprintln(&b, "ricSubscriptionDeleteResponse.")
1061         fmt.Fprintln(&b, "  ricRequestID.")
1062         fmt.Fprintln(&b, "    ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1063         fmt.Fprintln(&b, "    ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
1064         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1065         return b.String()
1066 }
1067
1068 //-----------------------------------------------------------------------------
1069 //
1070 //-----------------------------------------------------------------------------
1071 type e2apMsgSubscriptionDeleteFailure struct {
1072         e2apMessage
1073         msgC *C.RICSubscriptionDeleteFailure_t
1074 }
1075
1076 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Set(data *e2ap.E2APSubscriptionDeleteFailure) error {
1077
1078         e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
1079         C.initSubsDeleteFailure(e2apMsg.msgC)
1080
1081         e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
1082
1083         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
1084                 return err
1085         }
1086
1087         e2apMsg.msgC.ricCause.content = (C.uchar)(data.Cause.Content)
1088         e2apMsg.msgC.ricCause.cause = (C.uchar)(data.Cause.CauseVal)
1089
1090         e2apMsg.msgC.criticalityDiagnosticsPresent = false
1091         if data.CriticalityDiagnostics.Present {
1092                 e2apMsg.msgC.criticalityDiagnosticsPresent = true
1093                 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&data.CriticalityDiagnostics); err != nil {
1094                         return err
1095                 }
1096         }
1097         return nil
1098 }
1099
1100 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Get() (error, *e2ap.E2APSubscriptionDeleteFailure) {
1101
1102         data := &e2ap.E2APSubscriptionDeleteFailure{}
1103
1104         data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
1105
1106         if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
1107                 return err, data
1108         }
1109
1110         data.Cause.Content = (uint8)(e2apMsg.msgC.ricCause.content)
1111         data.Cause.CauseVal = (uint8)(e2apMsg.msgC.ricCause.cause)
1112
1113         if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
1114                 data.CriticalityDiagnostics.Present = true
1115                 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&data.CriticalityDiagnostics); err != nil {
1116                         return err, data
1117                 }
1118         }
1119         return nil, data
1120 }
1121
1122 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduPack(logBuf []byte, data *packer.PackedData) error {
1123         var buflen uint32 = (uint32)(len(data.Buf))
1124         errorNro := C.packRICSubscriptionDeleteFailure((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
1125         if errorNro != C.e2err_OK {
1126                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
1127         }
1128         data.Buf = data.Buf[0:buflen]
1129         return nil
1130 }
1131
1132 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduUnPack(logBuf []byte, data *packer.PackedData) error {
1133
1134         e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
1135         C.initSubsDeleteFailure(e2apMsg.msgC)
1136
1137         e2apMsg.e2apMessage.PduUnPack(logBuf, data)
1138         if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2UnsuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICsubscriptionDeleteFailure {
1139                 return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
1140         }
1141         errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
1142         if errorNro != C.e2err_OK {
1143                 return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
1144         }
1145         return nil
1146
1147 }
1148
1149 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
1150         return packer.PduPackerPackAllocTrg(e2apMsg, trg)
1151 }
1152
1153 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) UnPack(msg *packer.PackedData) error {
1154         return packer.PduPackerUnPack(e2apMsg, msg)
1155 }
1156
1157 func (e2apMsg *e2apMsgSubscriptionDeleteFailure) String() string {
1158         var b bytes.Buffer
1159         fmt.Fprintln(&b, "ricSubscriptionDeleteFailure.")
1160         fmt.Fprintln(&b, "  ricRequestID.")
1161         fmt.Fprintln(&b, "    ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1162         fmt.Fprintln(&b, "    ricRequestSequenceNumber =", e2apMsg.msgC.ricRequestID.ricRequestSequenceNumber)
1163         fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1164         /*      NOT SUPPORTED
1165                 if e2apMsg.msgC.criticalityDiagnosticsPresent {
1166                         fmt.Fprintln(&b, "  criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
1167                         fmt.Fprintln(&b, "    criticalityDiagnostics.")
1168                         fmt.Fprintln(&b, "    procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
1169                         fmt.Fprintln(&b, "      procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
1170                         fmt.Fprintln(&b, "    triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
1171                         fmt.Fprintln(&b, "      triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
1172                         fmt.Fprintln(&b, "    procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
1173                         fmt.Fprintln(&b, "      procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
1174                         fmt.Fprintln(&b, "    iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
1175                         fmt.Fprintln(&b, "      criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
1176                         var index2 uint16
1177                         index2 = 0
1178                         for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
1179                                 fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
1180                                 fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
1181                                 fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
1182                                 index2++
1183                         }
1184                 }
1185         */
1186         return b.String()
1187 }
1188
1189 //-----------------------------------------------------------------------------
1190 // Public E2AP packer creators
1191 //-----------------------------------------------------------------------------
1192
1193 type cppasn1E2APPacker struct{}
1194
1195 func (*cppasn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
1196         return &e2apMsgSubscriptionRequest{}
1197 }
1198
1199 func (*cppasn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
1200         return &e2apMsgSubscriptionResponse{}
1201 }
1202
1203 func (*cppasn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
1204         return &e2apMsgSubscriptionFailure{}
1205 }
1206
1207 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
1208         return &e2apMsgSubscriptionDeleteRequest{}
1209 }
1210
1211 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
1212         return &e2apMsgSubscriptionDeleteResponse{}
1213 }
1214
1215 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
1216         return &e2apMsgSubscriptionDeleteFailure{}
1217 }
1218
1219 func (*cppasn1E2APPacker) MessageInfo(msg *packer.PackedData) *packer.MessageInfo {
1220         e2apMsg := &e2apMessage{}
1221         return e2apMsg.UnPack(msg)
1222 }
1223
1224 func NewAsn1E2Packer() e2ap.E2APPackerIf {
1225         return &cppasn1E2APPacker{}
1226 }