2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
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>
28 // void initSubsRequest(RICSubscriptionRequest_t *data){
29 // bzero(data,sizeof(RICSubscriptionRequest_t));
31 // void initSubsResponse(RICSubscriptionResponse_t *data){
32 // bzero(data,sizeof(RICSubscriptionResponse_t));
34 // void initSubsFailure(RICSubscriptionFailure_t *data){
35 // bzero(data,sizeof(RICSubscriptionFailure_t));
37 // void initSubsDeleteRequest(RICSubscriptionDeleteRequest_t *data){
38 // bzero(data,sizeof(RICSubscriptionDeleteRequest_t));
40 // void initSubsDeleteResponse(RICSubscriptionDeleteResponse_t *data){
41 // bzero(data,sizeof(RICSubscriptionDeleteResponse_t));
43 // void initSubsDeleteFailure(RICSubscriptionDeleteFailure_t *data){
44 // bzero(data,sizeof(RICSubscriptionDeleteFailure_t));
46 // void initSubsDeleteRequired(RICSubsDeleteRequired_t *data){
47 // bzero(data,sizeof(RICSubsDeleteRequired_t));
58 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
59 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
62 const cLogBufferMaxSize = 40960
63 const cMsgBufferMaxSize = 40960
64 const cMsgBufferExtra = 512
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
69 func cMessageInfoToMessageInfo(minfo *C.E2MessageInfo_t) *e2ap.MessageInfo {
71 msgInfo := &e2ap.MessageInfo{}
73 switch minfo.messageType {
74 case C.cE2InitiatingMessage:
75 msgInfo.MsgType = e2ap.E2AP_InitiatingMessage
76 switch minfo.messageId {
77 case C.cRICSubscriptionRequest:
78 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionRequest
80 case C.cRICSubscriptionDeleteRequest:
81 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteRequest
84 case C.cE2SuccessfulOutcome:
85 msgInfo.MsgType = e2ap.E2AP_SuccessfulOutcome
86 switch minfo.messageId {
87 case C.cRICSubscriptionResponse:
88 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionResponse
90 case C.cRICsubscriptionDeleteResponse:
91 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteResponse
94 case C.cE2UnsuccessfulOutcome:
95 msgInfo.MsgType = e2ap.E2AP_UnsuccessfulOutcome
96 switch minfo.messageId {
97 case C.cRICSubscriptionFailure:
98 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionFailure
100 case C.cRICsubscriptionDeleteFailure:
101 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteFailure
108 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
111 type e2apEntryRequestID struct {
112 entry *C.RICRequestID_t
115 func (e2Item *e2apEntryRequestID) set(id *e2ap.RequestId) error {
116 e2Item.entry.ricRequestorID = (C.uint32_t)(id.Id)
117 e2Item.entry.ricInstanceID = (C.uint32_t)(id.InstanceId)
121 func (e2Item *e2apEntryRequestID) get(id *e2ap.RequestId) error {
122 id.Id = (uint32)(e2Item.entry.ricRequestorID)
123 id.InstanceId = (uint32)(e2Item.entry.ricInstanceID)
127 //-----------------------------------------------------------------------------
129 //-----------------------------------------------------------------------------
130 type e2apEntryActionToBeSetupItem struct {
131 entry *C.RICActionToBeSetupItem_t
134 func (e2Item *e2apEntryActionToBeSetupItem) set(id *e2ap.ActionToBeSetupItem) error {
136 e2Item.entry.ricActionID = (C.ulong)(id.ActionId)
137 e2Item.entry.ricActionType = (C.uint64_t)(id.ActionType)
138 if id.RicActionDefinitionPresent {
139 e2Item.entry.ricActionDefinitionPresent = true
140 if err := (&e2apEntryActionDefinitionChoice{entry: &e2Item.entry.ricActionDefinitionChoice}).set(&id.ActionDefinitionChoice); err != nil {
144 if id.SubsequentAction.Present {
145 e2Item.entry.ricSubsequentActionPresent = true
146 e2Item.entry.ricSubsequentAction.ricSubsequentActionType = (C.uint64_t)(id.SubsequentAction.Type)
147 e2Item.entry.ricSubsequentAction.ricTimeToWait = (C.uint64_t)(id.SubsequentAction.TimetoWait)
152 func (e2Item *e2apEntryActionToBeSetupItem) get(id *e2ap.ActionToBeSetupItem) error {
154 id.ActionId = (uint64)(e2Item.entry.ricActionID)
155 id.ActionType = (uint64)(e2Item.entry.ricActionType)
156 if e2Item.entry.ricActionDefinitionPresent {
157 id.RicActionDefinitionPresent = true
158 if err := (&e2apEntryActionDefinitionChoice{entry: &e2Item.entry.ricActionDefinitionChoice}).get(&id.ActionDefinitionChoice); err != nil {
162 if e2Item.entry.ricSubsequentActionPresent {
163 id.SubsequentAction.Present = true
164 id.SubsequentAction.Type = (uint64)(e2Item.entry.ricSubsequentAction.ricSubsequentActionType)
165 id.SubsequentAction.TimetoWait = (uint64)(e2Item.entry.ricSubsequentAction.ricTimeToWait)
170 //-----------------------------------------------------------------------------
172 //-----------------------------------------------------------------------------
173 type e2apEntryActionDefinitionChoice struct {
174 entry *C.RICActionDefinitionChoice_t
177 func (e2Item *e2apEntryActionDefinitionChoice) set(id *e2ap.ActionDefinitionChoice) error {
178 if id.Data.Length > 0 {
179 e2Item.entry.octetString.contentLength = C.size_t(id.Data.Length)
180 C.memcpy(unsafe.Pointer(&e2Item.entry.octetString.data[0]), unsafe.Pointer(&id.Data.Data[0]), C.size_t(e2Item.entry.octetString.contentLength))
185 func (e2Item *e2apEntryActionDefinitionChoice) get(id *e2ap.ActionDefinitionChoice) error {
186 id.Data.Length = (uint64)(e2Item.entry.octetString.contentLength)
187 if id.Data.Length > 0 {
188 id.Data.Data = make([]uint8, id.Data.Length)
189 C.memcpy(unsafe.Pointer(&id.Data.Data[0]), unsafe.Pointer(&e2Item.entry.octetString.data[0]), C.size_t(e2Item.entry.octetString.contentLength))
194 //-----------------------------------------------------------------------------
196 //-----------------------------------------------------------------------------
197 type e2apEntryPlmnIdentity struct {
198 entry *C.PLMNIdentity_t
201 func (plmnId *e2apEntryPlmnIdentity) set(id conv.PlmnIdentityIf) error {
203 buf := new(bytes.Buffer)
206 plmnId.entry.contentLength = (C.uint8_t)(len(data))
207 for i := 0; i < len(data); i++ {
208 plmnId.entry.pLMNIdentityVal[i] = (C.uint8_t)(data[i])
213 func (plmnId *e2apEntryPlmnIdentity) get(id conv.PlmnIdentityIf) error {
214 conlen := (int)(plmnId.entry.contentLength)
215 bcdBuf := make([]uint8, conlen)
216 for i := 0; i < conlen; i++ {
217 bcdBuf[i] = (uint8)(plmnId.entry.pLMNIdentityVal[i])
219 reader := bytes.NewReader(bcdBuf)
220 id.DecodeFrom(reader)
224 //-----------------------------------------------------------------------------
226 //-----------------------------------------------------------------------------
227 type e2apEntryGlobalEnbId struct {
228 entry *C.GlobalNodeID_t
231 func (enbId *e2apEntryGlobalEnbId) checkbits(bits uint8) error {
233 case e2ap.E2AP_ENBIDMacroPBits20:
235 case e2ap.E2AP_ENBIDHomeBits28:
237 case e2ap.E2AP_ENBIDShortMacroits18:
239 case e2ap.E2AP_ENBIDlongMacroBits21:
242 return fmt.Errorf("GlobalEnbId: given bits %d not match allowed: 20,28,18,21", bits)
245 func (enbId *e2apEntryGlobalEnbId) set(id *e2ap.GlobalNodeId) error {
246 if err := enbId.checkbits(id.NodeId.Bits); err != nil {
249 enbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
250 enbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
251 return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
254 func (enbId *e2apEntryGlobalEnbId) get(id *e2ap.GlobalNodeId) error {
255 if err := enbId.checkbits((uint8)(enbId.entry.nodeID.bits)); err != nil {
258 id.NodeId.Bits = (uint8)(enbId.entry.nodeID.bits)
259 id.NodeId.Id = (uint32)(enbId.entry.nodeID.nodeID)
260 return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
263 //-----------------------------------------------------------------------------
265 //-----------------------------------------------------------------------------
266 type e2apEntryGlobalGnbId struct {
267 entry *C.GlobalNodeID_t
270 func (gnbId *e2apEntryGlobalGnbId) checkbits(bits uint8) error {
271 if bits < 22 || bits > 32 {
272 return fmt.Errorf("GlobalGnbId: given bits %d not match allowed: 22-32", bits)
277 func (gnbId *e2apEntryGlobalGnbId) set(id *e2ap.GlobalNodeId) error {
278 if err := gnbId.checkbits(id.NodeId.Bits); err != nil {
281 gnbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
282 gnbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
283 return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
286 func (gnbId *e2apEntryGlobalGnbId) get(id *e2ap.GlobalNodeId) error {
287 if err := gnbId.checkbits((uint8)(gnbId.entry.nodeID.bits)); err != nil {
290 id.NodeId.Bits = (uint8)(gnbId.entry.nodeID.bits)
291 id.NodeId.Id = (uint32)(gnbId.entry.nodeID.nodeID)
292 return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
295 //-----------------------------------------------------------------------------
297 //-----------------------------------------------------------------------------
298 type e2apEntryInterfaceId struct {
299 entry *C.InterfaceID_t
302 func (indId *e2apEntryInterfaceId) set(id *e2ap.InterfaceId) error {
303 if id.GlobalEnbId.Present {
304 indId.entry.globalENBIDPresent = true
305 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).set(&id.GlobalEnbId); err != nil {
310 if id.GlobalGnbId.Present {
311 indId.entry.globalGNBIDPresent = true
312 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).set(&id.GlobalGnbId); err != nil {
319 func (indId *e2apEntryInterfaceId) get(id *e2ap.InterfaceId) error {
320 if indId.entry.globalENBIDPresent == true {
321 id.GlobalEnbId.Present = true
322 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).get(&id.GlobalEnbId); err != nil {
327 if indId.entry.globalGNBIDPresent == true {
328 id.GlobalGnbId.Present = true
329 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).get(&id.GlobalGnbId); err != nil {
336 //-----------------------------------------------------------------------------
338 //-----------------------------------------------------------------------------
339 type e2apEntryEventTrigger struct {
340 entry *C.RICEventTriggerDefinition_t
343 func (evtTrig *e2apEntryEventTrigger) set(id *e2ap.EventTriggerDefinition) error {
345 if id.Data.Length > 0 {
346 evtTrig.entry.octetString.contentLength = C.size_t(id.Data.Length)
347 C.memcpy(unsafe.Pointer(&evtTrig.entry.octetString.data[0]), unsafe.Pointer(&id.Data.Data[0]), C.size_t(evtTrig.entry.octetString.contentLength))
352 func (evtTrig *e2apEntryEventTrigger) get(id *e2ap.EventTriggerDefinition) error {
354 id.Data.Length = (uint64)(evtTrig.entry.octetString.contentLength)
355 if id.Data.Length > 0 {
356 id.Data.Data = make([]uint8, id.Data.Length)
357 C.memcpy(unsafe.Pointer(&id.Data.Data[0]), unsafe.Pointer(&evtTrig.entry.octetString.data[0]), C.size_t(evtTrig.entry.octetString.contentLength))
362 //-----------------------------------------------------------------------------
364 //-----------------------------------------------------------------------------
365 type e2apEntryAdmittedList struct {
366 entry *C.RICActionAdmittedList_t
369 func (item *e2apEntryAdmittedList) set(data *e2ap.ActionAdmittedList) error {
371 if len(data.Items) > 16 {
372 return fmt.Errorf("ActionAdmittedList: too long %d while allowed %d", len(data.Items), 16)
375 item.entry.contentLength = 0
376 for i := 0; i < len(data.Items); i++ {
377 item.entry.ricActionID[item.entry.contentLength] = (C.ulong)(data.Items[i].ActionId)
378 item.entry.contentLength++
383 func (item *e2apEntryAdmittedList) get(data *e2ap.ActionAdmittedList) error {
384 conlen := (int)(item.entry.contentLength)
385 data.Items = make([]e2ap.ActionAdmittedItem, conlen)
386 for i := 0; i < conlen; i++ {
387 data.Items[i].ActionId = (uint64)(item.entry.ricActionID[i])
392 //-----------------------------------------------------------------------------
394 //-----------------------------------------------------------------------------
395 type e2apEntryNotAdmittedList struct {
396 entry *C.RICActionNotAdmittedList_t
399 func (item *e2apEntryNotAdmittedList) set(data *e2ap.ActionNotAdmittedList) error {
401 if len(data.Items) > 16 {
402 return fmt.Errorf("e2apEntryNotAdmittedList: too long %d while allowed %d", len(data.Items), 16)
405 item.entry.contentLength = 0
406 for i := 0; i < len(data.Items); i++ {
407 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricActionID = (C.ulong)(data.Items[i].ActionId)
408 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].cause.content = (C.uchar)(data.Items[i].Cause.Content)
409 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].cause.causeVal = (C.uchar)(data.Items[i].Cause.Value)
410 item.entry.contentLength++
416 func (item *e2apEntryNotAdmittedList) get(data *e2ap.ActionNotAdmittedList) error {
417 conlen := (int)(item.entry.contentLength)
418 data.Items = make([]e2ap.ActionNotAdmittedItem, conlen)
419 for i := 0; i < conlen; i++ {
420 data.Items[i].ActionId = (uint64)(item.entry.RICActionNotAdmittedItem[i].ricActionID)
421 data.Items[i].Cause.Content = (uint8)(item.entry.RICActionNotAdmittedItem[i].cause.content)
422 data.Items[i].Cause.Value = (uint8)(item.entry.RICActionNotAdmittedItem[i].cause.causeVal)
427 //-----------------------------------------------------------------------------
429 //-----------------------------------------------------------------------------
430 type e2apEntryCriticalityDiagnostic struct {
431 entry *C.CriticalityDiagnostics__t
434 func (item *e2apEntryCriticalityDiagnostic) set(data *e2ap.CriticalityDiagnostics) error {
436 item.entry.procedureCodePresent = (C.bool)(data.ProcCodePresent)
437 item.entry.procedureCode = (C.uchar)(data.ProcCode)
439 item.entry.triggeringMessagePresent = (C.bool)(data.TrigMsgPresent)
440 item.entry.triggeringMessage = (C.uchar)(data.TrigMsg)
442 item.entry.procedureCriticalityPresent = (C.bool)(data.ProcCritPresent)
443 item.entry.procedureCriticality = (C.uchar)(data.ProcCrit)
445 item.entry.criticalityDiagnosticsIELength = 0
446 item.entry.iEsCriticalityDiagnosticsPresent = false
447 for i := 0; i < len(data.CriticalityDiagnosticsIEList.Items); i++ {
448 item.entry.criticalityDiagnosticsIEListItem[i].iECriticality = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].IeCriticality)
449 item.entry.criticalityDiagnosticsIEListItem[i].iE_ID = (C.uint32_t)(data.CriticalityDiagnosticsIEList.Items[i].IeID)
450 item.entry.criticalityDiagnosticsIEListItem[i].typeOfError = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].TypeOfError)
451 item.entry.criticalityDiagnosticsIELength++
452 item.entry.iEsCriticalityDiagnosticsPresent = true
457 func (item *e2apEntryCriticalityDiagnostic) get(data *e2ap.CriticalityDiagnostics) error {
459 data.ProcCodePresent = (bool)(item.entry.procedureCodePresent)
460 data.ProcCode = (uint64)(item.entry.procedureCode)
462 data.TrigMsgPresent = (bool)(item.entry.triggeringMessagePresent)
463 data.TrigMsg = (uint64)(item.entry.triggeringMessage)
465 data.ProcCritPresent = (bool)(item.entry.procedureCriticalityPresent)
466 data.ProcCrit = (uint8)(item.entry.procedureCriticality)
468 if item.entry.iEsCriticalityDiagnosticsPresent == true {
469 conlen := (int)(item.entry.criticalityDiagnosticsIELength)
470 data.CriticalityDiagnosticsIEList.Items = make([]e2ap.CriticalityDiagnosticsIEListItem, conlen)
471 for i := 0; i < conlen; i++ {
472 data.CriticalityDiagnosticsIEList.Items[i].IeCriticality = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].iECriticality)
473 data.CriticalityDiagnosticsIEList.Items[i].IeID = (uint32)(item.entry.criticalityDiagnosticsIEListItem[i].iE_ID)
474 data.CriticalityDiagnosticsIEList.Items[i].TypeOfError = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].typeOfError)
481 //-----------------------------------------------------------------------------
483 //-----------------------------------------------------------------------------
484 type e2apEntryCallProcessId struct {
485 entry *C.RICCallProcessID_t
488 func (callProcId *e2apEntryCallProcessId) set(data *e2ap.CallProcessId) error {
489 callProcId.entry.ricCallProcessIDVal = (C.uint64_t)(data.CallProcessIDVal)
493 func (callProcId *e2apEntryCallProcessId) get(data *e2ap.CallProcessId) error {
494 data.CallProcessIDVal = (uint32)(callProcId.entry.ricCallProcessIDVal)
499 //-----------------------------------------------------------------------------
501 //-----------------------------------------------------------------------------
503 type e2apMessagePacker struct {
504 expectedInfo C.E2MessageInfo_t
505 pduMsgInfo C.E2MessageInfo_t
506 pdu *C.e2ap_pdu_ptr_t
512 func (e2apMsg *e2apMessagePacker) init(minfo C.E2MessageInfo_t) {
513 e2apMsg.expectedInfo = minfo
514 e2apMsg.lb = make([]byte, cLogBufferMaxSize)
516 e2apMsg.p = C.malloc(C.size_t(cMsgBufferMaxSize))
517 e2apMsg.plen = C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
520 func (e2apMsg *e2apMessagePacker) fini() {
526 func (e2apMsg *e2apMessagePacker) lbString() string {
527 return "logbuffer(" + string(e2apMsg.lb[:strings.Index(string(e2apMsg.lb[:]), "\000")]) + ")"
530 func (e2apMsg *e2apMessagePacker) packeddata() *e2ap.PackedData {
531 return &e2ap.PackedData{C.GoBytes(e2apMsg.p, C.int(e2apMsg.plen))}
534 func (e2apMsg *e2apMessagePacker) checkerr(errorNro C.uint64_t) error {
535 if errorNro != C.e2err_OK {
536 return fmt.Errorf("e2err(%s) %s", C.GoString(C.getE2ErrorString(errorNro)), e2apMsg.lbString())
541 func (e2apMsg *e2apMessagePacker) unpacktopdu(data *e2ap.PackedData) error {
542 e2apMsg.pdu = C.unpackE2AP_pdu((C.size_t)(len(data.Buf)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), &e2apMsg.pduMsgInfo)
543 if e2apMsg.pduMsgInfo.messageType != e2apMsg.expectedInfo.messageType || e2apMsg.pduMsgInfo.messageId != e2apMsg.expectedInfo.messageId {
544 return fmt.Errorf("unpack e2ap %s %s", e2apMsg.lbString(), e2apMsg.String())
549 func (e2apMsg *e2apMessagePacker) messageInfoPdu() *e2ap.MessageInfo {
550 return cMessageInfoToMessageInfo(&e2apMsg.pduMsgInfo)
553 func (e2apMsg *e2apMessagePacker) messageInfoExpected() *e2ap.MessageInfo {
554 return cMessageInfoToMessageInfo(&e2apMsg.expectedInfo)
557 func (e2apMsg *e2apMessagePacker) String() string {
559 pduInfo := e2apMsg.messageInfoPdu()
561 ret += "pduinfo(" + pduInfo.String() + ")"
563 ret += "pduinfo(N/A)"
565 expInfo := e2apMsg.messageInfoExpected()
567 ret += " expinfo(" + expInfo.String() + ")"
569 ret += " expinfo(N/A)"
574 //-----------------------------------------------------------------------------
576 //-----------------------------------------------------------------------------
578 type e2apMsgPackerSubscriptionRequest struct {
580 msgC *C.RICSubscriptionRequest_t
581 msgG *e2ap.E2APSubscriptionRequest
584 func (e2apMsg *e2apMsgPackerSubscriptionRequest) init() {
585 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionRequest})
586 e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
587 e2apMsg.msgG = &e2ap.E2APSubscriptionRequest{}
588 C.initSubsRequest(e2apMsg.msgC)
591 func (e2apMsg *e2apMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
598 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
599 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
602 if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricEventTriggerDefinition}).set(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
605 if len(e2apMsg.msgG.ActionSetups) > 16 {
606 return fmt.Errorf("IndicationMessage.InterfaceMessage: too long %d while allowed %d", len(e2apMsg.msgG.ActionSetups), 16), nil
608 e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength = 0
609 for i := 0; i < len(e2apMsg.msgG.ActionSetups); i++ {
610 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength]}
611 e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength += 1
612 if err := item.set(&e2apMsg.msgG.ActionSetups[i]); err != nil {
616 errorNro := C.packRICSubscriptionRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
617 if err := e2apMsg.checkerr(errorNro); err != nil {
620 return nil, e2apMsg.packeddata()
623 func (e2apMsg *e2apMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
628 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
629 return err, e2apMsg.msgG
632 errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
633 if err := e2apMsg.checkerr(errorNro); err != nil {
634 return err, e2apMsg.msgG
637 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
638 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
639 return err, e2apMsg.msgG
641 if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricEventTriggerDefinition}).get(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
642 return err, e2apMsg.msgG
644 conlen := (int)(e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength)
645 e2apMsg.msgG.ActionSetups = make([]e2ap.ActionToBeSetupItem, conlen)
646 for i := 0; i < conlen; i++ {
647 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[i]}
648 if err := item.get(&e2apMsg.msgG.ActionSetups[i]); err != nil {
649 return err, e2apMsg.msgG
652 return nil, e2apMsg.msgG
656 func (e2apMsg *e2apMsgPackerSubscriptionRequest) String() string {
658 fmt.Fprintln(&b, "ricSubscriptionRequest.")
659 fmt.Fprintln(&b, " ricRequestID.")
660 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
661 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
662 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
663 fmt.Fprintln(&b, " ricSubscriptionDetails.")
664 fmt.Fprintln(&b, " ricActionToBeSetupItemIEs.")
665 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength)
668 for (C.uchar)(index) < e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength {
669 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionID =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionID)
670 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionType =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionType)
671 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionDefinitionPresent =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent)
672 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentActionPresent =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent)
673 if e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent {
674 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType)
675 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait)
682 //-----------------------------------------------------------------------------
684 //-----------------------------------------------------------------------------
685 type e2apMsgPackerSubscriptionResponse struct {
687 msgC *C.RICSubscriptionResponse_t
688 msgG *e2ap.E2APSubscriptionResponse
691 func (e2apMsg *e2apMsgPackerSubscriptionResponse) init() {
692 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICSubscriptionResponse})
693 e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
694 e2apMsg.msgG = &e2ap.E2APSubscriptionResponse{}
695 C.initSubsResponse(e2apMsg.msgC)
698 func (e2apMsg *e2apMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
703 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
704 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
707 if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&e2apMsg.msgG.ActionAdmittedList); err != nil {
710 e2apMsg.msgC.ricActionNotAdmittedListPresent = false
711 if len(e2apMsg.msgG.ActionNotAdmittedList.Items) > 0 {
712 e2apMsg.msgC.ricActionNotAdmittedListPresent = true
713 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
718 errorNro := C.packRICSubscriptionResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
719 if err := e2apMsg.checkerr(errorNro); err != nil {
722 return nil, e2apMsg.packeddata()
725 func (e2apMsg *e2apMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
730 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
731 return err, e2apMsg.msgG
734 errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
735 if err := e2apMsg.checkerr(errorNro); err != nil {
736 return err, e2apMsg.msgG
739 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
740 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
741 return err, e2apMsg.msgG
743 if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&e2apMsg.msgG.ActionAdmittedList); err != nil {
744 return err, e2apMsg.msgG
746 if e2apMsg.msgC.ricActionNotAdmittedListPresent == true {
747 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
748 return err, e2apMsg.msgG
751 return nil, e2apMsg.msgG
754 func (e2apMsg *e2apMsgPackerSubscriptionResponse) String() string {
756 fmt.Fprintln(&b, "ricSubscriptionResponse.")
757 fmt.Fprintln(&b, " ricRequestID.")
758 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
759 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
760 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
761 fmt.Fprintln(&b, " ricActionAdmittedList.")
762 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricActionAdmittedList.contentLength)
765 for (C.uchar)(index) < e2apMsg.msgC.ricActionAdmittedList.contentLength {
766 fmt.Fprintln(&b, " ricActionAdmittedList.ricActionID[index] =", e2apMsg.msgC.ricActionAdmittedList.ricActionID[index])
769 if e2apMsg.msgC.ricActionNotAdmittedListPresent {
770 fmt.Fprintln(&b, " ricActionNotAdmittedListPresent =", e2apMsg.msgC.ricActionNotAdmittedListPresent)
771 fmt.Fprintln(&b, " ricActionNotAdmittedList.")
772 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricActionNotAdmittedList.contentLength)
774 for (C.uchar)(index) < e2apMsg.msgC.ricActionNotAdmittedList.contentLength {
775 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].ricActionID =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID)
776 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].cause.content =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content)
777 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].cause.causeVal =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal)
784 //-----------------------------------------------------------------------------
786 //-----------------------------------------------------------------------------
787 type e2apMsgPackerSubscriptionFailure struct {
789 msgC *C.RICSubscriptionFailure_t
790 msgG *e2ap.E2APSubscriptionFailure
793 func (e2apMsg *e2apMsgPackerSubscriptionFailure) init() {
794 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICSubscriptionFailure})
795 e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
796 e2apMsg.msgG = &e2ap.E2APSubscriptionFailure{}
797 C.initSubsFailure(e2apMsg.msgC)
800 func (e2apMsg *e2apMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
805 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
806 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
809 e2apMsg.msgC.cause.content = (C.uchar)(e2apMsg.msgG.Cause.Content)
810 e2apMsg.msgC.cause.causeVal = (C.uchar)(e2apMsg.msgG.Cause.Value)
811 e2apMsg.msgC.criticalityDiagnosticsPresent = false
812 if e2apMsg.msgG.CriticalityDiagnostics.Present {
813 e2apMsg.msgC.criticalityDiagnosticsPresent = true
814 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
819 errorNro := C.packRICSubscriptionFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
820 if err := e2apMsg.checkerr(errorNro); err != nil {
823 return nil, e2apMsg.packeddata()
826 func (e2apMsg *e2apMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
830 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
831 return err, e2apMsg.msgG
833 errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
834 if err := e2apMsg.checkerr(errorNro); err != nil {
835 return err, e2apMsg.msgG
838 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
839 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
840 return err, e2apMsg.msgG
842 e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.cause.content)
843 e2apMsg.msgG.Cause.Value = (uint8)(e2apMsg.msgC.cause.causeVal)
844 if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
845 e2apMsg.msgG.CriticalityDiagnostics.Present = true
846 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
847 return err, e2apMsg.msgG
850 return nil, e2apMsg.msgG
853 func (e2apMsg *e2apMsgPackerSubscriptionFailure) String() string {
855 fmt.Fprintln(&b, "ricSubscriptionFailure.")
856 fmt.Fprintln(&b, " ricRequestID.")
857 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
858 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
859 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
860 fmt.Fprintln(&b, " ricActionNotAdmittedList.")
861 fmt.Fprintln(&b, " cause.content =", e2apMsg.msgC.cause.content)
862 fmt.Fprintln(&b, " cause.causeVal =", e2apMsg.msgC.cause.causeVal)
865 if e2apMsg.msgC.criticalityDiagnosticsPresent {
866 fmt.Fprintln(&b, " criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
867 fmt.Fprintln(&b, " criticalityDiagnostics.")
868 fmt.Fprintln(&b, " procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
869 fmt.Fprintln(&b, " procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
870 fmt.Fprintln(&b, " triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
871 fmt.Fprintln(&b, " triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
872 fmt.Fprintln(&b, " procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
873 fmt.Fprintln(&b, " procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
874 fmt.Fprintln(&b, " iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
875 fmt.Fprintln(&b, " criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
878 for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
879 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
880 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
881 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
889 //-----------------------------------------------------------------------------
891 //-----------------------------------------------------------------------------
892 type e2apMsgPackerSubscriptionDeleteRequest struct {
894 msgC *C.RICSubscriptionDeleteRequest_t
895 msgG *e2ap.E2APSubscriptionDeleteRequest
898 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) init() {
899 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionDeleteRequest})
900 e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
901 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteRequest{}
902 C.initSubsDeleteRequest(e2apMsg.msgC)
905 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
910 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
911 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
915 errorNro := C.packRICSubscriptionDeleteRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
916 if err := e2apMsg.checkerr(errorNro); err != nil {
919 return nil, e2apMsg.packeddata()
922 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
926 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
927 return err, e2apMsg.msgG
929 errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
930 if err := e2apMsg.checkerr(errorNro); err != nil {
931 return err, e2apMsg.msgG
934 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
935 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
936 return err, e2apMsg.msgG
938 return nil, e2apMsg.msgG
942 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) String() string {
944 fmt.Fprintln(&b, "ricSubscriptionDeleteRequest.")
945 fmt.Fprintln(&b, " ricRequestID.")
946 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
947 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
948 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
952 //-----------------------------------------------------------------------------
954 //-----------------------------------------------------------------------------
955 type e2apMsgPackerSubscriptionDeleteResponse struct {
957 msgC *C.RICSubscriptionDeleteResponse_t
958 msgG *e2ap.E2APSubscriptionDeleteResponse
961 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) init() {
962 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICsubscriptionDeleteResponse})
963 e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
964 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteResponse{}
965 C.initSubsDeleteResponse(e2apMsg.msgC)
968 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
973 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
974 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
978 errorNro := C.packRICSubscriptionDeleteResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
979 if err := e2apMsg.checkerr(errorNro); err != nil {
982 return nil, e2apMsg.packeddata()
985 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
989 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
990 return err, e2apMsg.msgG
992 errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
993 if err := e2apMsg.checkerr(errorNro); err != nil {
994 return err, e2apMsg.msgG
997 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
998 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
999 return err, e2apMsg.msgG
1001 return nil, e2apMsg.msgG
1004 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) String() string {
1006 fmt.Fprintln(&b, "ricSubscriptionDeleteResponse.")
1007 fmt.Fprintln(&b, " ricRequestID.")
1008 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1009 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
1010 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1014 //-----------------------------------------------------------------------------
1016 //-----------------------------------------------------------------------------
1017 type e2apMsgPackerSubscriptionDeleteFailure struct {
1019 msgC *C.RICSubscriptionDeleteFailure_t
1020 msgG *e2ap.E2APSubscriptionDeleteFailure
1023 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) init() {
1024 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICsubscriptionDeleteFailure})
1025 e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
1026 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteFailure{}
1027 C.initSubsDeleteFailure(e2apMsg.msgC)
1030 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
1032 defer e2apMsg.fini()
1035 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
1036 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
1039 e2apMsg.msgC.cause.content = (C.uchar)(e2apMsg.msgG.Cause.Content)
1040 e2apMsg.msgC.cause.causeVal = (C.uchar)(e2apMsg.msgG.Cause.Value)
1041 e2apMsg.msgC.criticalityDiagnosticsPresent = false
1042 if e2apMsg.msgG.CriticalityDiagnostics.Present {
1043 e2apMsg.msgC.criticalityDiagnosticsPresent = true
1044 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
1049 errorNro := C.packRICSubscriptionDeleteFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
1050 if err := e2apMsg.checkerr(errorNro); err != nil {
1053 return nil, e2apMsg.packeddata()
1056 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
1058 defer e2apMsg.fini()
1060 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
1061 return err, e2apMsg.msgG
1063 errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
1064 if err := e2apMsg.checkerr(errorNro); err != nil {
1065 return err, e2apMsg.msgG
1068 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
1069 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
1070 return err, e2apMsg.msgG
1072 e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.cause.content)
1073 e2apMsg.msgG.Cause.Value = (uint8)(e2apMsg.msgC.cause.causeVal)
1074 if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
1075 e2apMsg.msgG.CriticalityDiagnostics.Present = true
1076 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
1077 return err, e2apMsg.msgG
1080 return nil, e2apMsg.msgG
1083 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) String() string {
1085 fmt.Fprintln(&b, "ricSubscriptionDeleteFailure.")
1086 fmt.Fprintln(&b, " ricRequestID.")
1087 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1088 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
1089 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1091 if e2apMsg.msgC.criticalityDiagnosticsPresent {
1092 fmt.Fprintln(&b, " criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
1093 fmt.Fprintln(&b, " criticalityDiagnostics.")
1094 fmt.Fprintln(&b, " procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
1095 fmt.Fprintln(&b, " procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
1096 fmt.Fprintln(&b, " triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
1097 fmt.Fprintln(&b, " triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
1098 fmt.Fprintln(&b, " procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
1099 fmt.Fprintln(&b, " procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
1100 fmt.Fprintln(&b, " iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
1101 fmt.Fprintln(&b, " criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
1104 for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
1105 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
1106 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
1107 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
1115 //-----------------------------------------------------------------------------
1116 // Changes to support "RIC_SUB_DEL_REQUIRED"
1117 //-----------------------------------------------------------------------------
1118 type e2apMsgPackerSubscriptionDeleteRequired struct {
1120 msgC *C.RICSubsDeleteRequired_t
1121 msgG *e2ap.SubscriptionDeleteRequiredList
1124 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) init() {
1125 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionDeleteRequired})
1126 e2apMsg.msgC = &C.RICSubsDeleteRequired_t{}
1127 e2apMsg.msgG = &e2ap.SubscriptionDeleteRequiredList{}
1128 C.initSubsDeleteRequired(e2apMsg.msgC)
1131 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) Pack(data *e2ap.SubscriptionDeleteRequiredList) (error, *e2ap.PackedData) {
1133 defer e2apMsg.fini()
1136 e2apMsg.msgC.noOfRanSubscriptions = C.int(len(e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests))
1137 for idx, subs := range e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests {
1140 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricInstanceID = (C.uint32_t)(subs.RequestId.InstanceId)
1141 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricRequestorID = (C.uint32_t)(subs.RequestId.Id)
1144 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID = (C.uint16_t)(subs.FunctionId)
1147 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.content = (C.uint8_t)(subs.Cause.Content)
1148 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.causeVal = (C.uint8_t)(subs.Cause.Value)
1152 errorNro := C.packRICSubscriptionDeleteRequired(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
1153 if err := e2apMsg.checkerr(errorNro); err != nil {
1154 fmt.Printf("ERROR: %s", err.Error())
1157 return nil, e2apMsg.packeddata()
1160 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) UnPack(msg *e2ap.PackedData) (error, *e2ap.SubscriptionDeleteRequiredList) {
1162 defer e2apMsg.fini()
1164 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
1165 return err, e2apMsg.msgG
1167 errorNro := C.getRICSubscriptionDeleteRequiredData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
1168 if err := e2apMsg.checkerr(errorNro); err != nil {
1169 return err, e2apMsg.msgG
1172 //TODO: Fill List of RIC Subscriptions to be Removed
1173 for idx := 0; idx < int(e2apMsg.msgC.noOfRanSubscriptions); idx++ {
1174 var ricSubsToBeRemove e2ap.E2APSubscriptionDeleteRequired
1176 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID}).get(&ricSubsToBeRemove.RequestId); err != nil {
1177 return err, e2apMsg.msgG
1180 ricSubsToBeRemove.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID)
1183 ricSubsToBeRemove.Cause.Content = (uint8)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.content)
1184 ricSubsToBeRemove.Cause.Value = (uint8)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.causeVal)
1186 e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests = append(e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests, ricSubsToBeRemove)
1189 return nil, e2apMsg.msgG
1192 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) String() string {
1194 for idx := 0; idx < int(e2apMsg.msgC.noOfRanSubscriptions); idx++ {
1195 fmt.Fprintln(&b, "ricSubscriptionDeleteRequired.")
1196 fmt.Fprintln(&b, " ricRequestID.")
1197 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricRequestorID)
1198 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricInstanceID)
1199 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID)
1205 //-----------------------------------------------------------------------------
1207 //-----------------------------------------------------------------------------
1208 func SetASN1DebugPrintStatus(logLevel int) {
1210 //fmt.Println("ASN1 debug prints ON")
1211 C.allowASN1DebugPrints(true)
1213 //fmt.Println("ASN1 debug prints OFF")
1214 C.allowASN1DebugPrints(false)
1218 //-----------------------------------------------------------------------------
1220 //-----------------------------------------------------------------------------
1221 func SetE2IEOrderCheck(ieOrderCheck uint8) {
1222 C.allowOutOfOrderIEMsg(C.uchar(ieOrderCheck))
1225 //-----------------------------------------------------------------------------
1226 // Public E2AP packer creators
1227 //-----------------------------------------------------------------------------
1229 type cppasn1E2APPacker struct{}
1231 func (*cppasn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
1232 return &e2apMsgPackerSubscriptionRequest{}
1235 func (*cppasn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
1236 return &e2apMsgPackerSubscriptionResponse{}
1239 func (*cppasn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
1240 return &e2apMsgPackerSubscriptionFailure{}
1243 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
1244 return &e2apMsgPackerSubscriptionDeleteRequest{}
1247 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
1248 return &e2apMsgPackerSubscriptionDeleteResponse{}
1251 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
1252 return &e2apMsgPackerSubscriptionDeleteFailure{}
1255 // Changes to support "RIC_SUB_DEL_REQUIRED"
1256 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequired() e2ap.E2APMsgPackerSubscriptionDeleteRequiredIf {
1257 return &e2apMsgPackerSubscriptionDeleteRequired{}
1260 func NewAsn1E2Packer() e2ap.E2APPackerIf {
1261 return &cppasn1E2APPacker{}