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