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