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));
55 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
56 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
61 const cLogBufferMaxSize = 40960
62 const cMsgBufferMaxSize = 40960
63 const cMsgBufferExtra = 512
65 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
68 func cMessageInfoToMessageInfo(minfo *C.E2MessageInfo_t) *e2ap.MessageInfo {
70 msgInfo := &e2ap.MessageInfo{}
72 switch minfo.messageType {
73 case C.cE2InitiatingMessage:
74 msgInfo.MsgType = e2ap.E2AP_InitiatingMessage
75 switch minfo.messageId {
76 case C.cRICSubscriptionRequest:
77 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionRequest
79 case C.cRICSubscriptionDeleteRequest:
80 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteRequest
83 case C.cE2SuccessfulOutcome:
84 msgInfo.MsgType = e2ap.E2AP_SuccessfulOutcome
85 switch minfo.messageId {
86 case C.cRICSubscriptionResponse:
87 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionResponse
89 case C.cRICsubscriptionDeleteResponse:
90 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteResponse
93 case C.cE2UnsuccessfulOutcome:
94 msgInfo.MsgType = e2ap.E2AP_UnsuccessfulOutcome
95 switch minfo.messageId {
96 case C.cRICSubscriptionFailure:
97 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionFailure
99 case C.cRICsubscriptionDeleteFailure:
100 msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteFailure
107 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
110 type e2apEntryRequestID struct {
111 entry *C.RICRequestID_t
114 func (e2Item *e2apEntryRequestID) set(id *e2ap.RequestId) error {
115 e2Item.entry.ricRequestorID = (C.uint32_t)(id.Id)
116 e2Item.entry.ricInstanceID = (C.uint32_t)(id.InstanceId)
120 func (e2Item *e2apEntryRequestID) get(id *e2ap.RequestId) error {
121 id.Id = (uint32)(e2Item.entry.ricRequestorID)
122 id.InstanceId = (uint32)(e2Item.entry.ricInstanceID)
126 //-----------------------------------------------------------------------------
128 //-----------------------------------------------------------------------------
129 type e2apEntryActionToBeSetupItem struct {
130 entry *C.RICActionToBeSetupItem_t
133 func (e2Item *e2apEntryActionToBeSetupItem) set(id *e2ap.ActionToBeSetupItem) error {
135 e2Item.entry.ricActionID = (C.ulong)(id.ActionId)
136 e2Item.entry.ricActionType = (C.uint64_t)(id.ActionType)
137 if id.RicActionDefinitionPresent {
138 e2Item.entry.ricActionDefinitionPresent = true
139 if err := (&e2apEntryActionDefinitionChoice{entry: &e2Item.entry.ricActionDefinitionChoice}).set(&id.ActionDefinitionChoice); err != nil {
143 if id.SubsequentAction.Present {
144 e2Item.entry.ricSubsequentActionPresent = true
145 e2Item.entry.ricSubsequentAction.ricSubsequentActionType = (C.uint64_t)(id.SubsequentAction.Type)
146 e2Item.entry.ricSubsequentAction.ricTimeToWait = (C.uint64_t)(id.SubsequentAction.TimetoWait)
151 func (e2Item *e2apEntryActionToBeSetupItem) get(id *e2ap.ActionToBeSetupItem) error {
153 id.ActionId = (uint64)(e2Item.entry.ricActionID)
154 id.ActionType = (uint64)(e2Item.entry.ricActionType)
155 if e2Item.entry.ricActionDefinitionPresent {
156 id.RicActionDefinitionPresent = true
157 if err := (&e2apEntryActionDefinitionChoice{entry: &e2Item.entry.ricActionDefinitionChoice}).get(&id.ActionDefinitionChoice); err != nil {
161 if e2Item.entry.ricSubsequentActionPresent {
162 id.SubsequentAction.Present = true
163 id.SubsequentAction.Type = (uint64)(e2Item.entry.ricSubsequentAction.ricSubsequentActionType)
164 id.SubsequentAction.TimetoWait = (uint64)(e2Item.entry.ricSubsequentAction.ricTimeToWait)
169 //-----------------------------------------------------------------------------
171 //-----------------------------------------------------------------------------
172 type e2apEntryActionDefinitionChoice struct {
173 entry *C.RICActionDefinitionChoice_t
176 func (e2Item *e2apEntryActionDefinitionChoice) set(id *e2ap.ActionDefinitionChoice) error {
177 if id.Data.Length > 0 {
178 e2Item.entry.octetString.contentLength = C.size_t(id.Data.Length)
179 C.memcpy(unsafe.Pointer(&e2Item.entry.octetString.data[0]), unsafe.Pointer(&id.Data.Data[0]), C.size_t(e2Item.entry.octetString.contentLength))
184 func (e2Item *e2apEntryActionDefinitionChoice) get(id *e2ap.ActionDefinitionChoice) error {
185 id.Data.Length = (uint64)(e2Item.entry.octetString.contentLength)
186 if id.Data.Length > 0 {
187 id.Data.Data = make([]uint8, id.Data.Length)
188 C.memcpy(unsafe.Pointer(&id.Data.Data[0]), unsafe.Pointer(&e2Item.entry.octetString.data[0]), C.size_t(e2Item.entry.octetString.contentLength))
193 //-----------------------------------------------------------------------------
195 //-----------------------------------------------------------------------------
196 type e2apEntryPlmnIdentity struct {
197 entry *C.PLMNIdentity_t
200 func (plmnId *e2apEntryPlmnIdentity) set(id conv.PlmnIdentityIf) error {
202 buf := new(bytes.Buffer)
205 plmnId.entry.contentLength = (C.uint8_t)(len(data))
206 for i := 0; i < len(data); i++ {
207 plmnId.entry.pLMNIdentityVal[i] = (C.uint8_t)(data[i])
212 func (plmnId *e2apEntryPlmnIdentity) get(id conv.PlmnIdentityIf) error {
213 conlen := (int)(plmnId.entry.contentLength)
214 bcdBuf := make([]uint8, conlen)
215 for i := 0; i < conlen; i++ {
216 bcdBuf[i] = (uint8)(plmnId.entry.pLMNIdentityVal[i])
218 reader := bytes.NewReader(bcdBuf)
219 id.DecodeFrom(reader)
223 //-----------------------------------------------------------------------------
225 //-----------------------------------------------------------------------------
226 type e2apEntryGlobalEnbId struct {
227 entry *C.GlobalNodeID_t
230 func (enbId *e2apEntryGlobalEnbId) checkbits(bits uint8) error {
232 case e2ap.E2AP_ENBIDMacroPBits20:
234 case e2ap.E2AP_ENBIDHomeBits28:
236 case e2ap.E2AP_ENBIDShortMacroits18:
238 case e2ap.E2AP_ENBIDlongMacroBits21:
241 return fmt.Errorf("GlobalEnbId: given bits %d not match allowed: 20,28,18,21", bits)
244 func (enbId *e2apEntryGlobalEnbId) set(id *e2ap.GlobalNodeId) error {
245 if err := enbId.checkbits(id.NodeId.Bits); err != nil {
248 enbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
249 enbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
250 return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
253 func (enbId *e2apEntryGlobalEnbId) get(id *e2ap.GlobalNodeId) error {
254 if err := enbId.checkbits((uint8)(enbId.entry.nodeID.bits)); err != nil {
257 id.NodeId.Bits = (uint8)(enbId.entry.nodeID.bits)
258 id.NodeId.Id = (uint32)(enbId.entry.nodeID.nodeID)
259 return (&e2apEntryPlmnIdentity{entry: &enbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
262 //-----------------------------------------------------------------------------
264 //-----------------------------------------------------------------------------
265 type e2apEntryGlobalGnbId struct {
266 entry *C.GlobalNodeID_t
269 func (gnbId *e2apEntryGlobalGnbId) checkbits(bits uint8) error {
270 if bits < 22 || bits > 32 {
271 return fmt.Errorf("GlobalGnbId: given bits %d not match allowed: 22-32", bits)
276 func (gnbId *e2apEntryGlobalGnbId) set(id *e2ap.GlobalNodeId) error {
277 if err := gnbId.checkbits(id.NodeId.Bits); err != nil {
280 gnbId.entry.nodeID.bits = (C.uchar)(id.NodeId.Bits)
281 gnbId.entry.nodeID.nodeID = (C.uint32_t)(id.NodeId.Id)
282 return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).set(&id.PlmnIdentity)
285 func (gnbId *e2apEntryGlobalGnbId) get(id *e2ap.GlobalNodeId) error {
286 if err := gnbId.checkbits((uint8)(gnbId.entry.nodeID.bits)); err != nil {
289 id.NodeId.Bits = (uint8)(gnbId.entry.nodeID.bits)
290 id.NodeId.Id = (uint32)(gnbId.entry.nodeID.nodeID)
291 return (&e2apEntryPlmnIdentity{entry: &gnbId.entry.pLMNIdentity}).get(&id.PlmnIdentity)
294 //-----------------------------------------------------------------------------
296 //-----------------------------------------------------------------------------
297 type e2apEntryInterfaceId struct {
298 entry *C.InterfaceID_t
301 func (indId *e2apEntryInterfaceId) set(id *e2ap.InterfaceId) error {
302 if id.GlobalEnbId.Present {
303 indId.entry.globalENBIDPresent = true
304 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).set(&id.GlobalEnbId); err != nil {
309 if id.GlobalGnbId.Present {
310 indId.entry.globalGNBIDPresent = true
311 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).set(&id.GlobalGnbId); err != nil {
318 func (indId *e2apEntryInterfaceId) get(id *e2ap.InterfaceId) error {
319 if indId.entry.globalENBIDPresent == true {
320 id.GlobalEnbId.Present = true
321 if err := (&e2apEntryGlobalEnbId{entry: &indId.entry.globalENBID}).get(&id.GlobalEnbId); err != nil {
326 if indId.entry.globalGNBIDPresent == true {
327 id.GlobalGnbId.Present = true
328 if err := (&e2apEntryGlobalGnbId{entry: &indId.entry.globalGNBID}).get(&id.GlobalGnbId); err != nil {
335 //-----------------------------------------------------------------------------
337 //-----------------------------------------------------------------------------
338 type e2apEntryEventTrigger struct {
339 entry *C.RICEventTriggerDefinition_t
342 func (evtTrig *e2apEntryEventTrigger) set(id *e2ap.EventTriggerDefinition) error {
344 if id.Data.Length > 0 {
345 evtTrig.entry.octetString.contentLength = C.size_t(id.Data.Length)
346 C.memcpy(unsafe.Pointer(&evtTrig.entry.octetString.data[0]), unsafe.Pointer(&id.Data.Data[0]), C.size_t(evtTrig.entry.octetString.contentLength))
351 func (evtTrig *e2apEntryEventTrigger) get(id *e2ap.EventTriggerDefinition) error {
353 id.Data.Length = (uint64)(evtTrig.entry.octetString.contentLength)
354 if id.Data.Length > 0 {
355 id.Data.Data = make([]uint8, id.Data.Length)
356 C.memcpy(unsafe.Pointer(&id.Data.Data[0]), unsafe.Pointer(&evtTrig.entry.octetString.data[0]), C.size_t(evtTrig.entry.octetString.contentLength))
361 //-----------------------------------------------------------------------------
363 //-----------------------------------------------------------------------------
364 type e2apEntryAdmittedList struct {
365 entry *C.RICActionAdmittedList_t
368 func (item *e2apEntryAdmittedList) set(data *e2ap.ActionAdmittedList) error {
370 if len(data.Items) > 16 {
371 return fmt.Errorf("ActionAdmittedList: too long %d while allowed %d", len(data.Items), 16)
374 item.entry.contentLength = 0
375 for i := 0; i < len(data.Items); i++ {
376 item.entry.ricActionID[item.entry.contentLength] = (C.ulong)(data.Items[i].ActionId)
377 item.entry.contentLength++
382 func (item *e2apEntryAdmittedList) get(data *e2ap.ActionAdmittedList) error {
383 conlen := (int)(item.entry.contentLength)
384 data.Items = make([]e2ap.ActionAdmittedItem, conlen)
385 for i := 0; i < conlen; i++ {
386 data.Items[i].ActionId = (uint64)(item.entry.ricActionID[i])
391 //-----------------------------------------------------------------------------
393 //-----------------------------------------------------------------------------
394 type e2apEntryNotAdmittedList struct {
395 entry *C.RICActionNotAdmittedList_t
398 func (item *e2apEntryNotAdmittedList) set(data *e2ap.ActionNotAdmittedList) error {
400 if len(data.Items) > 16 {
401 return fmt.Errorf("e2apEntryNotAdmittedList: too long %d while allowed %d", len(data.Items), 16)
404 item.entry.contentLength = 0
405 for i := 0; i < len(data.Items); i++ {
406 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricActionID = (C.ulong)(data.Items[i].ActionId)
407 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].cause.content = (C.uchar)(data.Items[i].Cause.Content)
408 item.entry.RICActionNotAdmittedItem[item.entry.contentLength].cause.causeVal = (C.uchar)(data.Items[i].Cause.Value)
409 item.entry.contentLength++
415 func (item *e2apEntryNotAdmittedList) get(data *e2ap.ActionNotAdmittedList) error {
416 conlen := (int)(item.entry.contentLength)
417 data.Items = make([]e2ap.ActionNotAdmittedItem, conlen)
418 for i := 0; i < conlen; i++ {
419 data.Items[i].ActionId = (uint64)(item.entry.RICActionNotAdmittedItem[i].ricActionID)
420 data.Items[i].Cause.Content = (uint8)(item.entry.RICActionNotAdmittedItem[i].cause.content)
421 data.Items[i].Cause.Value = (uint8)(item.entry.RICActionNotAdmittedItem[i].cause.causeVal)
426 //-----------------------------------------------------------------------------
428 //-----------------------------------------------------------------------------
429 type e2apEntryCriticalityDiagnostic struct {
430 entry *C.CriticalityDiagnostics__t
433 func (item *e2apEntryCriticalityDiagnostic) set(data *e2ap.CriticalityDiagnostics) error {
435 item.entry.procedureCodePresent = (C.bool)(data.ProcCodePresent)
436 item.entry.procedureCode = (C.uchar)(data.ProcCode)
438 item.entry.triggeringMessagePresent = (C.bool)(data.TrigMsgPresent)
439 item.entry.triggeringMessage = (C.uchar)(data.TrigMsg)
441 item.entry.procedureCriticalityPresent = (C.bool)(data.ProcCritPresent)
442 item.entry.procedureCriticality = (C.uchar)(data.ProcCrit)
444 item.entry.criticalityDiagnosticsIELength = 0
445 item.entry.iEsCriticalityDiagnosticsPresent = false
446 for i := 0; i < len(data.CriticalityDiagnosticsIEList.Items); i++ {
447 item.entry.criticalityDiagnosticsIEListItem[i].iECriticality = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].IeCriticality)
448 item.entry.criticalityDiagnosticsIEListItem[i].iE_ID = (C.uint32_t)(data.CriticalityDiagnosticsIEList.Items[i].IeID)
449 item.entry.criticalityDiagnosticsIEListItem[i].typeOfError = (C.uint8_t)(data.CriticalityDiagnosticsIEList.Items[i].TypeOfError)
450 item.entry.criticalityDiagnosticsIELength++
451 item.entry.iEsCriticalityDiagnosticsPresent = true
456 func (item *e2apEntryCriticalityDiagnostic) get(data *e2ap.CriticalityDiagnostics) error {
458 data.ProcCodePresent = (bool)(item.entry.procedureCodePresent)
459 data.ProcCode = (uint64)(item.entry.procedureCode)
461 data.TrigMsgPresent = (bool)(item.entry.triggeringMessagePresent)
462 data.TrigMsg = (uint64)(item.entry.triggeringMessage)
464 data.ProcCritPresent = (bool)(item.entry.procedureCriticalityPresent)
465 data.ProcCrit = (uint8)(item.entry.procedureCriticality)
467 if item.entry.iEsCriticalityDiagnosticsPresent == true {
468 conlen := (int)(item.entry.criticalityDiagnosticsIELength)
469 data.CriticalityDiagnosticsIEList.Items = make([]e2ap.CriticalityDiagnosticsIEListItem, conlen)
470 for i := 0; i < conlen; i++ {
471 data.CriticalityDiagnosticsIEList.Items[i].IeCriticality = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].iECriticality)
472 data.CriticalityDiagnosticsIEList.Items[i].IeID = (uint32)(item.entry.criticalityDiagnosticsIEListItem[i].iE_ID)
473 data.CriticalityDiagnosticsIEList.Items[i].TypeOfError = (uint8)(item.entry.criticalityDiagnosticsIEListItem[i].typeOfError)
480 //-----------------------------------------------------------------------------
482 //-----------------------------------------------------------------------------
483 type e2apEntryCallProcessId struct {
484 entry *C.RICCallProcessID_t
487 func (callProcId *e2apEntryCallProcessId) set(data *e2ap.CallProcessId) error {
488 callProcId.entry.ricCallProcessIDVal = (C.uint64_t)(data.CallProcessIDVal)
492 func (callProcId *e2apEntryCallProcessId) get(data *e2ap.CallProcessId) error {
493 data.CallProcessIDVal = (uint32)(callProcId.entry.ricCallProcessIDVal)
498 //-----------------------------------------------------------------------------
500 //-----------------------------------------------------------------------------
502 type e2apMessagePacker struct {
503 expectedInfo C.E2MessageInfo_t
504 pduMsgInfo C.E2MessageInfo_t
505 pdu *C.e2ap_pdu_ptr_t
511 func (e2apMsg *e2apMessagePacker) init(minfo C.E2MessageInfo_t) {
512 e2apMsg.expectedInfo = minfo
513 e2apMsg.lb = make([]byte, cLogBufferMaxSize)
515 e2apMsg.p = C.malloc(C.size_t(cMsgBufferMaxSize))
516 e2apMsg.plen = C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
519 func (e2apMsg *e2apMessagePacker) fini() {
525 func (e2apMsg *e2apMessagePacker) lbString() string {
526 return "logbuffer(" + string(e2apMsg.lb[:strings.Index(string(e2apMsg.lb[:]), "\000")]) + ")"
529 func (e2apMsg *e2apMessagePacker) packeddata() *e2ap.PackedData {
530 return &e2ap.PackedData{C.GoBytes(e2apMsg.p, C.int(e2apMsg.plen))}
533 func (e2apMsg *e2apMessagePacker) checkerr(errorNro C.uint64_t) error {
534 if errorNro != C.e2err_OK {
535 return fmt.Errorf("e2err(%s) %s", C.GoString(C.getE2ErrorString(errorNro)), e2apMsg.lbString())
540 func (e2apMsg *e2apMessagePacker) unpacktopdu(data *e2ap.PackedData) error {
541 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)
542 if e2apMsg.pduMsgInfo.messageType != e2apMsg.expectedInfo.messageType || e2apMsg.pduMsgInfo.messageId != e2apMsg.expectedInfo.messageId {
543 return fmt.Errorf("unpack e2ap %s %s", e2apMsg.lbString(), e2apMsg.String())
548 func (e2apMsg *e2apMessagePacker) messageInfoPdu() *e2ap.MessageInfo {
549 return cMessageInfoToMessageInfo(&e2apMsg.pduMsgInfo)
552 func (e2apMsg *e2apMessagePacker) messageInfoExpected() *e2ap.MessageInfo {
553 return cMessageInfoToMessageInfo(&e2apMsg.expectedInfo)
556 func (e2apMsg *e2apMessagePacker) String() string {
558 pduInfo := e2apMsg.messageInfoPdu()
560 ret += "pduinfo(" + pduInfo.String() + ")"
562 ret += "pduinfo(N/A)"
564 expInfo := e2apMsg.messageInfoExpected()
566 ret += " expinfo(" + expInfo.String() + ")"
568 ret += " expinfo(N/A)"
573 //-----------------------------------------------------------------------------
575 //-----------------------------------------------------------------------------
577 type e2apMsgPackerSubscriptionRequest struct {
579 msgC *C.RICSubscriptionRequest_t
580 msgG *e2ap.E2APSubscriptionRequest
583 func (e2apMsg *e2apMsgPackerSubscriptionRequest) init() {
584 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionRequest})
585 e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
586 e2apMsg.msgG = &e2ap.E2APSubscriptionRequest{}
587 C.initSubsRequest(e2apMsg.msgC)
590 func (e2apMsg *e2apMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
597 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
598 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
601 if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricEventTriggerDefinition}).set(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
604 if len(e2apMsg.msgG.ActionSetups) > 16 {
605 return fmt.Errorf("IndicationMessage.InterfaceMessage: too long %d while allowed %d", len(e2apMsg.msgG.ActionSetups), 16), nil
607 e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength = 0
608 for i := 0; i < len(e2apMsg.msgG.ActionSetups); i++ {
609 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength]}
610 e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength += 1
611 if err := item.set(&e2apMsg.msgG.ActionSetups[i]); err != nil {
615 errorNro := C.packRICSubscriptionRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
616 if err := e2apMsg.checkerr(errorNro); err != nil {
619 return nil, e2apMsg.packeddata()
622 func (e2apMsg *e2apMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
627 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
628 return err, e2apMsg.msgG
631 errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
632 if err := e2apMsg.checkerr(errorNro); err != nil {
633 return err, e2apMsg.msgG
636 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
637 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
638 return err, e2apMsg.msgG
640 if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricEventTriggerDefinition}).get(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
641 return err, e2apMsg.msgG
643 conlen := (int)(e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength)
644 e2apMsg.msgG.ActionSetups = make([]e2ap.ActionToBeSetupItem, conlen)
645 for i := 0; i < conlen; i++ {
646 item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[i]}
647 if err := item.get(&e2apMsg.msgG.ActionSetups[i]); err != nil {
648 return err, e2apMsg.msgG
651 return nil, e2apMsg.msgG
655 func (e2apMsg *e2apMsgPackerSubscriptionRequest) String() string {
657 fmt.Fprintln(&b, "ricSubscriptionRequest.")
658 fmt.Fprintln(&b, " ricRequestID.")
659 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
660 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
661 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
662 fmt.Fprintln(&b, " ricSubscriptionDetails.")
663 fmt.Fprintln(&b, " ricActionToBeSetupItemIEs.")
664 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength)
667 for (C.uchar)(index) < e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.contentLength {
668 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionID =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionID)
669 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionType =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionType)
670 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricActionDefinitionPresent =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricActionDefinitionPresent)
671 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentActionPresent =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent)
672 if e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent {
673 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType)
674 fmt.Fprintln(&b, " ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait =", e2apMsg.msgC.ricSubscriptionDetails.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait)
681 //-----------------------------------------------------------------------------
683 //-----------------------------------------------------------------------------
684 type e2apMsgPackerSubscriptionResponse struct {
686 msgC *C.RICSubscriptionResponse_t
687 msgG *e2ap.E2APSubscriptionResponse
690 func (e2apMsg *e2apMsgPackerSubscriptionResponse) init() {
691 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICSubscriptionResponse})
692 e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
693 e2apMsg.msgG = &e2ap.E2APSubscriptionResponse{}
694 C.initSubsResponse(e2apMsg.msgC)
697 func (e2apMsg *e2apMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
702 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
703 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
706 if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&e2apMsg.msgG.ActionAdmittedList); err != nil {
709 e2apMsg.msgC.ricActionNotAdmittedListPresent = false
710 if len(e2apMsg.msgG.ActionNotAdmittedList.Items) > 0 {
711 e2apMsg.msgC.ricActionNotAdmittedListPresent = true
712 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
717 errorNro := C.packRICSubscriptionResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
718 if err := e2apMsg.checkerr(errorNro); err != nil {
721 return nil, e2apMsg.packeddata()
724 func (e2apMsg *e2apMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
729 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
730 return err, e2apMsg.msgG
732 errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
733 if err := e2apMsg.checkerr(errorNro); err != nil {
734 return err, e2apMsg.msgG
737 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
738 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
739 return err, e2apMsg.msgG
741 if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&e2apMsg.msgG.ActionAdmittedList); err != nil {
742 return err, e2apMsg.msgG
744 if e2apMsg.msgC.ricActionNotAdmittedListPresent == true {
745 if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
746 return err, e2apMsg.msgG
749 return nil, e2apMsg.msgG
752 func (e2apMsg *e2apMsgPackerSubscriptionResponse) String() string {
754 fmt.Fprintln(&b, "ricSubscriptionResponse.")
755 fmt.Fprintln(&b, " ricRequestID.")
756 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
757 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
758 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
759 fmt.Fprintln(&b, " ricActionAdmittedList.")
760 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricActionAdmittedList.contentLength)
763 for (C.uchar)(index) < e2apMsg.msgC.ricActionAdmittedList.contentLength {
764 fmt.Fprintln(&b, " ricActionAdmittedList.ricActionID[index] =", e2apMsg.msgC.ricActionAdmittedList.ricActionID[index])
767 if e2apMsg.msgC.ricActionNotAdmittedListPresent {
768 fmt.Fprintln(&b, " ricActionNotAdmittedListPresent =", e2apMsg.msgC.ricActionNotAdmittedListPresent)
769 fmt.Fprintln(&b, " ricActionNotAdmittedList.")
770 fmt.Fprintln(&b, " contentLength =", e2apMsg.msgC.ricActionNotAdmittedList.contentLength)
772 for (C.uchar)(index) < e2apMsg.msgC.ricActionNotAdmittedList.contentLength {
773 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].ricActionID =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].ricActionID)
774 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].cause.content =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.content)
775 fmt.Fprintln(&b, " RICActionNotAdmittedItem[index].cause.causeVal =", e2apMsg.msgC.ricActionNotAdmittedList.RICActionNotAdmittedItem[index].cause.causeVal)
782 //-----------------------------------------------------------------------------
784 //-----------------------------------------------------------------------------
785 type e2apMsgPackerSubscriptionFailure struct {
787 msgC *C.RICSubscriptionFailure_t
788 msgG *e2ap.E2APSubscriptionFailure
791 func (e2apMsg *e2apMsgPackerSubscriptionFailure) init() {
792 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICSubscriptionFailure})
793 e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
794 e2apMsg.msgG = &e2ap.E2APSubscriptionFailure{}
795 C.initSubsFailure(e2apMsg.msgC)
798 func (e2apMsg *e2apMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
803 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
804 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
807 e2apMsg.msgC.cause.content = (C.uchar)(e2apMsg.msgG.Cause.Content)
808 e2apMsg.msgC.cause.causeVal = (C.uchar)(e2apMsg.msgG.Cause.Value)
809 e2apMsg.msgC.criticalityDiagnosticsPresent = false
810 if e2apMsg.msgG.CriticalityDiagnostics.Present {
811 e2apMsg.msgC.criticalityDiagnosticsPresent = true
812 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
817 errorNro := C.packRICSubscriptionFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
818 if err := e2apMsg.checkerr(errorNro); err != nil {
821 return nil, e2apMsg.packeddata()
824 func (e2apMsg *e2apMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
828 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
829 return err, e2apMsg.msgG
831 errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
832 if err := e2apMsg.checkerr(errorNro); err != nil {
833 return err, e2apMsg.msgG
836 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
837 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
838 return err, e2apMsg.msgG
840 e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.cause.content)
841 e2apMsg.msgG.Cause.Value = (uint8)(e2apMsg.msgC.cause.causeVal)
842 if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
843 e2apMsg.msgG.CriticalityDiagnostics.Present = true
844 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
845 return err, e2apMsg.msgG
848 return nil, e2apMsg.msgG
851 func (e2apMsg *e2apMsgPackerSubscriptionFailure) String() string {
853 fmt.Fprintln(&b, "ricSubscriptionFailure.")
854 fmt.Fprintln(&b, " ricRequestID.")
855 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
856 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
857 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
858 fmt.Fprintln(&b, " ricActionNotAdmittedList.")
859 fmt.Fprintln(&b, " cause.content =", e2apMsg.msgC.cause.content)
860 fmt.Fprintln(&b, " cause.causeVal =", e2apMsg.msgC.cause.causeVal)
863 if e2apMsg.msgC.criticalityDiagnosticsPresent {
864 fmt.Fprintln(&b, " criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
865 fmt.Fprintln(&b, " criticalityDiagnostics.")
866 fmt.Fprintln(&b, " procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
867 fmt.Fprintln(&b, " procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
868 fmt.Fprintln(&b, " triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
869 fmt.Fprintln(&b, " triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
870 fmt.Fprintln(&b, " procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
871 fmt.Fprintln(&b, " procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
872 fmt.Fprintln(&b, " iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
873 fmt.Fprintln(&b, " criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
876 for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
877 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
878 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
879 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
887 //-----------------------------------------------------------------------------
889 //-----------------------------------------------------------------------------
890 type e2apMsgPackerSubscriptionDeleteRequest struct {
892 msgC *C.RICSubscriptionDeleteRequest_t
893 msgG *e2ap.E2APSubscriptionDeleteRequest
896 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) init() {
897 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionDeleteRequest})
898 e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
899 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteRequest{}
900 C.initSubsDeleteRequest(e2apMsg.msgC)
903 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
908 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
909 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
913 errorNro := C.packRICSubscriptionDeleteRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
914 if err := e2apMsg.checkerr(errorNro); err != nil {
917 return nil, e2apMsg.packeddata()
920 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
924 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
925 return err, e2apMsg.msgG
927 errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
928 if err := e2apMsg.checkerr(errorNro); err != nil {
929 return err, e2apMsg.msgG
932 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
933 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
934 return err, e2apMsg.msgG
936 return nil, e2apMsg.msgG
940 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) String() string {
942 fmt.Fprintln(&b, "ricSubscriptionDeleteRequest.")
943 fmt.Fprintln(&b, " ricRequestID.")
944 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
945 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
946 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
950 //-----------------------------------------------------------------------------
952 //-----------------------------------------------------------------------------
953 type e2apMsgPackerSubscriptionDeleteResponse struct {
955 msgC *C.RICSubscriptionDeleteResponse_t
956 msgG *e2ap.E2APSubscriptionDeleteResponse
959 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) init() {
960 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICsubscriptionDeleteResponse})
961 e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
962 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteResponse{}
963 C.initSubsDeleteResponse(e2apMsg.msgC)
966 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
971 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
972 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
976 errorNro := C.packRICSubscriptionDeleteResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
977 if err := e2apMsg.checkerr(errorNro); err != nil {
980 return nil, e2apMsg.packeddata()
983 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
987 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
988 return err, e2apMsg.msgG
990 errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
991 if err := e2apMsg.checkerr(errorNro); err != nil {
992 return err, e2apMsg.msgG
995 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
996 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
997 return err, e2apMsg.msgG
999 return nil, e2apMsg.msgG
1002 func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) String() string {
1004 fmt.Fprintln(&b, "ricSubscriptionDeleteResponse.")
1005 fmt.Fprintln(&b, " ricRequestID.")
1006 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1007 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
1008 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1012 //-----------------------------------------------------------------------------
1014 //-----------------------------------------------------------------------------
1015 type e2apMsgPackerSubscriptionDeleteFailure struct {
1017 msgC *C.RICSubscriptionDeleteFailure_t
1018 msgG *e2ap.E2APSubscriptionDeleteFailure
1021 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) init() {
1022 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICsubscriptionDeleteFailure})
1023 e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
1024 e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteFailure{}
1025 C.initSubsDeleteFailure(e2apMsg.msgC)
1028 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
1030 defer e2apMsg.fini()
1033 e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
1034 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
1037 e2apMsg.msgC.cause.content = (C.uchar)(e2apMsg.msgG.Cause.Content)
1038 e2apMsg.msgC.cause.causeVal = (C.uchar)(e2apMsg.msgG.Cause.Value)
1039 e2apMsg.msgC.criticalityDiagnosticsPresent = false
1040 if e2apMsg.msgG.CriticalityDiagnostics.Present {
1041 e2apMsg.msgC.criticalityDiagnosticsPresent = true
1042 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
1047 errorNro := C.packRICSubscriptionDeleteFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
1048 if err := e2apMsg.checkerr(errorNro); err != nil {
1051 return nil, e2apMsg.packeddata()
1054 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
1056 defer e2apMsg.fini()
1058 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
1059 return err, e2apMsg.msgG
1061 errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
1062 if err := e2apMsg.checkerr(errorNro); err != nil {
1063 return err, e2apMsg.msgG
1066 e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
1067 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
1068 return err, e2apMsg.msgG
1070 e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.cause.content)
1071 e2apMsg.msgG.Cause.Value = (uint8)(e2apMsg.msgC.cause.causeVal)
1072 if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
1073 e2apMsg.msgG.CriticalityDiagnostics.Present = true
1074 if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
1075 return err, e2apMsg.msgG
1078 return nil, e2apMsg.msgG
1081 func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) String() string {
1083 fmt.Fprintln(&b, "ricSubscriptionDeleteFailure.")
1084 fmt.Fprintln(&b, " ricRequestID.")
1085 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
1086 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
1087 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranFunctionID)
1089 if e2apMsg.msgC.criticalityDiagnosticsPresent {
1090 fmt.Fprintln(&b, " criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
1091 fmt.Fprintln(&b, " criticalityDiagnostics.")
1092 fmt.Fprintln(&b, " procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
1093 fmt.Fprintln(&b, " procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
1094 fmt.Fprintln(&b, " triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
1095 fmt.Fprintln(&b, " triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
1096 fmt.Fprintln(&b, " procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
1097 fmt.Fprintln(&b, " procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
1098 fmt.Fprintln(&b, " iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
1099 fmt.Fprintln(&b, " criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
1102 for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
1103 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
1104 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
1105 fmt.Fprintln(&b, " criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
1113 //-----------------------------------------------------------------------------
1114 // Changes to support "RIC_SUB_DEL_REQUIRED"
1115 //-----------------------------------------------------------------------------
1116 type e2apMsgPackerSubscriptionDeleteRequired struct {
1118 msgC *C.RICSubsDeleteRequired_t
1119 msgG *e2ap.SubscriptionDeleteRequiredList
1122 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) init() {
1123 e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionDeleteRequired})
1124 e2apMsg.msgC = &C.RICSubsDeleteRequired_t{}
1125 e2apMsg.msgG = &e2ap.SubscriptionDeleteRequiredList{}
1126 C.initSubsDeleteRequired(e2apMsg.msgC)
1129 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) Pack(data *e2ap.SubscriptionDeleteRequiredList) (error, *e2ap.PackedData) {
1131 defer e2apMsg.fini()
1134 e2apMsg.msgC.noOfRanSubscriptions = C.int(len(e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests))
1135 for idx, subs := range e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests {
1138 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricInstanceID = (C.uint32_t)(subs.RequestId.InstanceId)
1139 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricRequestorID = (C.uint32_t)(subs.RequestId.Id)
1142 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID = (C.uint16_t)(subs.FunctionId)
1145 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.content = (C.uint8_t)(subs.Cause.Content)
1146 e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.causeVal = (C.uint8_t)(subs.Cause.Value)
1150 errorNro := C.packRICSubscriptionDeleteRequired(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
1151 if err := e2apMsg.checkerr(errorNro); err != nil {
1152 fmt.Printf("ERROR: %s", err.Error())
1155 return nil, e2apMsg.packeddata()
1158 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) UnPack(msg *e2ap.PackedData) (error, *e2ap.SubscriptionDeleteRequiredList) {
1160 defer e2apMsg.fini()
1162 if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
1163 return err, e2apMsg.msgG
1165 errorNro := C.getRICSubscriptionDeleteRequiredData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
1166 if err := e2apMsg.checkerr(errorNro); err != nil {
1167 return err, e2apMsg.msgG
1170 //TODO: Fill List of RIC Subscriptions to be Removed
1171 for idx := 0; idx < int(e2apMsg.msgC.noOfRanSubscriptions); idx++ {
1172 var ricSubsToBeRemove e2ap.E2APSubscriptionDeleteRequired
1174 if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID}).get(&ricSubsToBeRemove.RequestId); err != nil {
1175 return err, e2apMsg.msgG
1178 ricSubsToBeRemove.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID)
1181 ricSubsToBeRemove.Cause.Content = (uint8)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.content)
1182 ricSubsToBeRemove.Cause.Value = (uint8)(e2apMsg.msgC.ranSubscriptionsDelRequired[idx].cause.causeVal)
1184 e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests = append(e2apMsg.msgG.E2APSubscriptionDeleteRequiredRequests, ricSubsToBeRemove)
1187 return nil, e2apMsg.msgG
1190 func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) String() string {
1192 for idx := 0; idx < int(e2apMsg.msgC.noOfRanSubscriptions); idx++ {
1193 fmt.Fprintln(&b, "ricSubscriptionDeleteRequired.")
1194 fmt.Fprintln(&b, " ricRequestID.")
1195 fmt.Fprintln(&b, " ricRequestorID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricRequestorID)
1196 fmt.Fprintln(&b, " ricInstanceID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ricRequestID.ricInstanceID)
1197 fmt.Fprintln(&b, " ranFunctionID =", e2apMsg.msgC.ranSubscriptionsDelRequired[idx].ranFunctionID)
1203 //-----------------------------------------------------------------------------
1205 //-----------------------------------------------------------------------------
1206 func SetASN1DebugPrintStatus(logLevel int) {
1208 //fmt.Println("ASN1 debug prints ON")
1209 C.allowASN1DebugPrints(true)
1211 //fmt.Println("ASN1 debug prints OFF")
1212 C.allowASN1DebugPrints(false)
1216 //-----------------------------------------------------------------------------
1217 // Public E2AP packer creators
1218 //-----------------------------------------------------------------------------
1220 type cppasn1E2APPacker struct{}
1222 func (*cppasn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
1223 return &e2apMsgPackerSubscriptionRequest{}
1226 func (*cppasn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
1227 return &e2apMsgPackerSubscriptionResponse{}
1230 func (*cppasn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
1231 return &e2apMsgPackerSubscriptionFailure{}
1234 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
1235 return &e2apMsgPackerSubscriptionDeleteRequest{}
1238 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
1239 return &e2apMsgPackerSubscriptionDeleteResponse{}
1242 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
1243 return &e2apMsgPackerSubscriptionDeleteFailure{}
1246 // Changes to support "RIC_SUB_DEL_REQUIRED"
1247 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequired() e2ap.E2APMsgPackerSubscriptionDeleteRequiredIf {
1248 return &e2apMsgPackerSubscriptionDeleteRequired{}
1251 func NewAsn1E2Packer() e2ap.E2APPackerIf {
1252 return &cppasn1E2APPacker{}