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