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