Subsfailure case internal delete and retry in duplicate cause case
[ric-plt/submgr.git] / e2ap / pkg / e2ap_wrapper / packer_e2ap.go
index 868c344..46836f6 100644 (file)
@@ -51,10 +51,57 @@ import (
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
+       "strings"
        "unsafe"
 )
 
+const cLogBufferMaxSize = 40960
+const cMsgBufferMaxSize = 40960
+const cMsgBufferExtra = 512
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func cMessageInfoToMessageInfo(minfo *C.E2MessageInfo_t) *e2ap.MessageInfo {
+
+       msgInfo := &e2ap.MessageInfo{}
+
+       switch minfo.messageType {
+       case C.cE2InitiatingMessage:
+               msgInfo.MsgType = e2ap.E2AP_InitiatingMessage
+               switch minfo.messageId {
+               case C.cRICSubscriptionRequest:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionRequest
+                       return msgInfo
+               case C.cRICSubscriptionDeleteRequest:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteRequest
+                       return msgInfo
+               }
+       case C.cE2SuccessfulOutcome:
+               msgInfo.MsgType = e2ap.E2AP_SuccessfulOutcome
+               switch minfo.messageId {
+               case C.cRICSubscriptionResponse:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionResponse
+                       return msgInfo
+               case C.cRICsubscriptionDeleteResponse:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteResponse
+                       return msgInfo
+               }
+       case C.cE2UnsuccessfulOutcome:
+               msgInfo.MsgType = e2ap.E2AP_UnsuccessfulOutcome
+               switch minfo.messageId {
+               case C.cRICSubscriptionFailure:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionFailure
+                       return msgInfo
+               case C.cRICsubscriptionDeleteFailure:
+                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteFailure
+                       return msgInfo
+               }
+
+       }
+       return nil
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -128,22 +175,26 @@ type e2apEntryPlmnIdentity struct {
        entry *C.PLMNIdentity_t
 }
 
-func (plmnId *e2apEntryPlmnIdentity) set(id *conv.PlmnIdentity) error {
+func (plmnId *e2apEntryPlmnIdentity) set(id conv.PlmnIdentityIf) error {
 
-       plmnId.entry.contentLength = (C.uint8_t)(len(id.Val))
-       for i := 0; i < len(id.Val); i++ {
-               plmnId.entry.pLMNIdentityVal[i] = (C.uint8_t)(id.Val[i])
+       buf := new(bytes.Buffer)
+       id.EncodeTo(buf)
+       data := buf.Bytes()
+       plmnId.entry.contentLength = (C.uint8_t)(len(data))
+       for i := 0; i < len(data); i++ {
+               plmnId.entry.pLMNIdentityVal[i] = (C.uint8_t)(data[i])
        }
        return nil
 }
 
-func (plmnId *e2apEntryPlmnIdentity) get(id *conv.PlmnIdentity) error {
+func (plmnId *e2apEntryPlmnIdentity) get(id conv.PlmnIdentityIf) error {
        conlen := (int)(plmnId.entry.contentLength)
        bcdBuf := make([]uint8, conlen)
        for i := 0; i < conlen; i++ {
                bcdBuf[i] = (uint8)(plmnId.entry.pLMNIdentityVal[i])
        }
-       id.BcdPut(bcdBuf)
+       reader := bytes.NewReader(bcdBuf)
+       id.DecodeFrom(reader)
        return nil
 }
 
@@ -327,7 +378,7 @@ func (item *e2apEntryNotAdmittedList) set(data *e2ap.ActionNotAdmittedList) erro
        for i := 0; i < len(data.Items); i++ {
                item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricActionID = (C.ulong)(data.Items[i].ActionId)
                item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.content = (C.uchar)(data.Items[i].Cause.Content)
-               item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.cause = (C.uchar)(data.Items[i].Cause.CauseVal)
+               item.entry.RICActionNotAdmittedItem[item.entry.contentLength].ricCause.cause = (C.uchar)(data.Items[i].Cause.Value)
                item.entry.contentLength++
        }
 
@@ -340,7 +391,7 @@ func (item *e2apEntryNotAdmittedList) get(data *e2ap.ActionNotAdmittedList) erro
        for i := 0; i < conlen; i++ {
                data.Items[i].ActionId = (uint64)(item.entry.RICActionNotAdmittedItem[i].ricActionID)
                data.Items[i].Cause.Content = (uint8)(item.entry.RICActionNotAdmittedItem[i].ricCause.content)
-               data.Items[i].Cause.CauseVal = (uint8)(item.entry.RICActionNotAdmittedItem[i].ricCause.cause)
+               data.Items[i].Cause.Value = (uint8)(item.entry.RICActionNotAdmittedItem[i].ricCause.cause)
        }
        return nil
 }
@@ -421,187 +472,159 @@ func (callProcId *e2apEntryCallProcessId) get(data *e2ap.CallProcessId) error {
 //
 //-----------------------------------------------------------------------------
 
-type e2apMessage struct {
-       pdu         *C.e2ap_pdu_ptr_t
-       messageInfo C.E2MessageInfo_t
+type e2apMessagePacker struct {
+       expectedInfo C.E2MessageInfo_t
+       pduMsgInfo   C.E2MessageInfo_t
+       pdu          *C.e2ap_pdu_ptr_t
+       lb           []byte
+       p            unsafe.Pointer
+       plen         C.size_t
 }
 
-func (e2apMsg *e2apMessage) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-       e2apMsg.pdu = C.unpackE2AP_pdu((C.size_t)(len(data.Buf)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), &e2apMsg.messageInfo)
-       return nil
+func (e2apMsg *e2apMessagePacker) init(minfo C.E2MessageInfo_t) {
+       e2apMsg.expectedInfo = minfo
+       e2apMsg.lb = make([]byte, cLogBufferMaxSize)
+       e2apMsg.lb[0] = 0
+       e2apMsg.p = C.malloc(C.size_t(cMsgBufferMaxSize))
+       e2apMsg.plen = C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
 }
 
-func (e2apMsg *e2apMessage) MessageInfo() *packer.MessageInfo {
+func (e2apMsg *e2apMessagePacker) fini() {
+       C.free(e2apMsg.p)
+       e2apMsg.plen = 0
+       e2apMsg.p = nil
+}
 
-       msgInfo := &packer.MessageInfo{}
+func (e2apMsg *e2apMessagePacker) lbString() string {
+       return "logbuffer(" + string(e2apMsg.lb[:strings.Index(string(e2apMsg.lb[:]), "\000")]) + ")"
+}
 
-       switch e2apMsg.messageInfo.messageType {
-       case C.cE2InitiatingMessage:
-               msgInfo.MsgType = e2ap.E2AP_InitiatingMessage
-               switch e2apMsg.messageInfo.messageId {
-               case C.cRICSubscriptionRequest:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionRequest
-                       return msgInfo
-               case C.cRICSubscriptionDeleteRequest:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteRequest
-                       return msgInfo
-               }
-       case C.cE2SuccessfulOutcome:
-               msgInfo.MsgType = e2ap.E2AP_SuccessfulOutcome
-               switch e2apMsg.messageInfo.messageId {
-               case C.cRICSubscriptionResponse:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionResponse
-                       return msgInfo
-               case C.cRICsubscriptionDeleteResponse:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteResponse
-                       return msgInfo
-               }
-       case C.cE2UnsuccessfulOutcome:
-               msgInfo.MsgType = e2ap.E2AP_UnsuccessfulOutcome
-               switch e2apMsg.messageInfo.messageId {
-               case C.cRICSubscriptionFailure:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionFailure
-                       return msgInfo
-               case C.cRICsubscriptionDeleteFailure:
-                       msgInfo.MsgId = e2ap.E2AP_RICSubscriptionDeleteFailure
-                       return msgInfo
-               }
+func (e2apMsg *e2apMessagePacker) packeddata() *e2ap.PackedData {
+       return &e2ap.PackedData{C.GoBytes(e2apMsg.p, C.int(e2apMsg.plen))}
+}
 
+func (e2apMsg *e2apMessagePacker) checkerr(errorNro C.uint64_t) error {
+       if errorNro != C.e2err_OK {
+               return fmt.Errorf("e2err(%s) %s", C.GoString(C.getE2ErrorString(errorNro)), e2apMsg.lbString())
        }
        return nil
 }
 
-func (e2apMsg *e2apMessage) UnPack(msg *packer.PackedData) *packer.MessageInfo {
-       err := packer.PduPackerUnPack(e2apMsg, msg)
-       if err != nil {
-               return nil
+func (e2apMsg *e2apMessagePacker) unpacktopdu(data *e2ap.PackedData) error {
+       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)
+       if e2apMsg.pduMsgInfo.messageType != e2apMsg.expectedInfo.messageType || e2apMsg.pduMsgInfo.messageId != e2apMsg.expectedInfo.messageId {
+               return fmt.Errorf("unpack e2ap %s %s", e2apMsg.lbString(), e2apMsg.String())
        }
-       return e2apMsg.MessageInfo()
+       return nil
+}
+
+func (e2apMsg *e2apMessagePacker) messageInfoPdu() *e2ap.MessageInfo {
+       return cMessageInfoToMessageInfo(&e2apMsg.pduMsgInfo)
+}
+
+func (e2apMsg *e2apMessagePacker) messageInfoExpected() *e2ap.MessageInfo {
+       return cMessageInfoToMessageInfo(&e2apMsg.expectedInfo)
 }
 
-func (e2apMsg *e2apMessage) String() string {
-       msgInfo := e2apMsg.MessageInfo()
-       if msgInfo == nil {
-               return "N/A"
+func (e2apMsg *e2apMessagePacker) String() string {
+       var ret string
+       pduInfo := e2apMsg.messageInfoPdu()
+       if pduInfo != nil {
+               ret += "pduinfo(" + pduInfo.String() + ")"
+       } else {
+               ret += "pduinfo(N/A)"
+       }
+       expInfo := e2apMsg.messageInfoExpected()
+       if expInfo != nil {
+               ret += " expinfo(" + expInfo.String() + ")"
+       } else {
+               ret += " expinfo(N/A)"
        }
-       return msgInfo.String()
+       return ret
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
 
-type e2apMsgSubscriptionRequest struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionRequest struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionRequest_t
+       msgG *e2ap.E2APSubscriptionRequest
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) Set(data *e2ap.E2APSubscriptionRequest) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionRequest})
        e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionRequest{}
        C.initSubsRequest(e2apMsg.msgC)
+}
 
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
+
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
-       if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).set(&data.EventTriggerDefinition); err != nil {
-               return err
+       if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).set(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
+               return err, nil
        }
-
-       if len(data.ActionSetups) > 16 {
-               return fmt.Errorf("IndicationMessage.InterfaceMessage: too long %d while allowed %d", len(data.ActionSetups), 16)
+       if len(e2apMsg.msgG.ActionSetups) > 16 {
+               return fmt.Errorf("IndicationMessage.InterfaceMessage: too long %d while allowed %d", len(e2apMsg.msgG.ActionSetups), 16), nil
        }
-
        e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength = 0
-       for i := 0; i < len(data.ActionSetups); i++ {
+       for i := 0; i < len(e2apMsg.msgG.ActionSetups); i++ {
                item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength]}
                e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength += 1
-               if err := item.set(&data.ActionSetups[i]); err != nil {
-                       return err
+               if err := item.set(&e2apMsg.msgG.ActionSetups[i]); err != nil {
+                       return err, nil
                }
        }
-       return nil
-}
 
-func (e2apMsg *e2apMsgSubscriptionRequest) Get() (error, *e2ap.E2APSubscriptionRequest) {
+       errorNro := C.packRICSubscriptionRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
+       }
+       return nil, e2apMsg.packeddata()
+}
 
-       data := &e2ap.E2APSubscriptionRequest{}
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
 
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).get(&data.EventTriggerDefinition); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
 
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
+       }
+       if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).get(&e2apMsg.msgG.EventTriggerDefinition); err != nil {
+               return err, e2apMsg.msgG
+       }
        conlen := (int)(e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.contentLength)
-       data.ActionSetups = make([]e2ap.ActionToBeSetupItem, conlen)
+       e2apMsg.msgG.ActionSetups = make([]e2ap.ActionToBeSetupItem, conlen)
        for i := 0; i < conlen; i++ {
                item := &e2apEntryActionToBeSetupItem{entry: &e2apMsg.msgC.ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[i]}
-               if err := item.get(&data.ActionSetups[i]); err != nil {
-                       return err, data
+               if err := item.get(&e2apMsg.msgG.ActionSetups[i]); err != nil {
+                       return err, e2apMsg.msgG
                }
        }
-       return nil, data
-
-}
-
-func (e2apMsg *e2apMsgSubscriptionRequest) PduPack(logBuf []byte, data *packer.PackedData) error {
-       /*
-          Not needed anymore
-
-               evtTrig := e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}
-               if err := evtTrig.pack(); err != nil {
-                       return err
-               }
-       */
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionRequest((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       data.Buf = data.Buf[0:buflen]
-       return nil
-
-}
-
-func (e2apMsg *e2apMsgSubscriptionRequest) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-
-       e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
-       C.initSubsRequest(e2apMsg.msgC)
-
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2InitiatingMessage || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionRequest {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
-       }
-       errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       /*
-          Not needed anymore
-
-               evtTrig := e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}
-               if err := evtTrig.unpack(); err != nil {
-                       return err
-               }
-       */
-       return nil
-}
+       return nil, e2apMsg.msgG
 
-func (e2apMsg *e2apMsgSubscriptionRequest) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
-}
-
-func (e2apMsg *e2apMsgSubscriptionRequest) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionRequest.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -659,93 +682,75 @@ func (e2apMsg *e2apMsgSubscriptionRequest) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionResponse struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionResponse struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionResponse_t
+       msgG *e2ap.E2APSubscriptionResponse
 }
 
-func (e2apMsg *e2apMsgSubscriptionResponse) Set(data *e2ap.E2APSubscriptionResponse) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICSubscriptionResponse})
        e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionResponse{}
        C.initSubsResponse(e2apMsg.msgC)
+}
 
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
-
-       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&data.ActionAdmittedList); err != nil {
-               return err
+       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&e2apMsg.msgG.ActionAdmittedList); err != nil {
+               return err, nil
        }
-
        e2apMsg.msgC.ricActionNotAdmittedListPresent = false
-       if len(data.ActionNotAdmittedList.Items) > 0 {
+       if len(e2apMsg.msgG.ActionNotAdmittedList.Items) > 0 {
                e2apMsg.msgC.ricActionNotAdmittedListPresent = true
-               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&data.ActionNotAdmittedList); err != nil {
-                       return err
+               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
+                       return err, nil
                }
        }
-       return nil
-}
 
-func (e2apMsg *e2apMsgSubscriptionResponse) Get() (error, *e2ap.E2APSubscriptionResponse) {
+       errorNro := C.packRICSubscriptionResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
+       }
+       return nil, e2apMsg.packeddata()
+}
 
-       data := &e2ap.E2APSubscriptionResponse{}
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
 
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-
-       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&data.ActionAdmittedList); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
 
-       if e2apMsg.msgC.ricActionNotAdmittedListPresent == true {
-               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&data.ActionNotAdmittedList); err != nil {
-                       return err, data
-               }
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil, data
-
-}
-
-func (e2apMsg *e2apMsgSubscriptionResponse) PduPack(logBuf []byte, data *packer.PackedData) error {
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionResponse((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       data.Buf = data.Buf[0:buflen]
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionResponse) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-       e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
-       C.initSubsResponse(e2apMsg.msgC)
-
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2SuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionResponse {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
+       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&e2apMsg.msgG.ActionAdmittedList); err != nil {
+               return err, e2apMsg.msgG
        }
-       errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       if e2apMsg.msgC.ricActionNotAdmittedListPresent == true {
+               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
+                       return err, e2apMsg.msgG
+               }
        }
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionResponse) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
-}
-
-func (e2apMsg *e2apMsgSubscriptionResponse) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionResponse) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionResponse.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -778,97 +783,75 @@ func (e2apMsg *e2apMsgSubscriptionResponse) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionFailure struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionFailure struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionFailure_t
+       msgG *e2ap.E2APSubscriptionFailure
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) Set(data *e2ap.E2APSubscriptionFailure) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICSubscriptionFailure})
        e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionFailure{}
        C.initSubsFailure(e2apMsg.msgC)
+}
 
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
-
-       if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&data.ActionNotAdmittedList); err != nil {
-               return err
+       if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
+               return err, nil
        }
-
        e2apMsg.msgC.criticalityDiagnosticsPresent = false
-       if data.CriticalityDiagnostics.Present {
+       if e2apMsg.msgG.CriticalityDiagnostics.Present {
                e2apMsg.msgC.criticalityDiagnosticsPresent = true
-               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&data.CriticalityDiagnostics); err != nil {
-                       return err
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, nil
                }
        }
 
-       return nil
+       errorNro := C.packRICSubscriptionFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
+       }
+       return nil, e2apMsg.packeddata()
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) Get() (error, *e2ap.E2APSubscriptionFailure) {
-
-       data := &e2ap.E2APSubscriptionFailure{}
-
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
-       }
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&data.ActionNotAdmittedList); err != nil {
-               return err, data
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-
-       if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
-               data.CriticalityDiagnostics.Present = true
-               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&data.CriticalityDiagnostics); err != nil {
-                       return err, data
-               }
+       errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
 
-       return nil, data
-}
-
-func (e2apMsg *e2apMsgSubscriptionFailure) PduPack(logBuf []byte, data *packer.PackedData) error {
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionFailure((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.Buf = data.Buf[0:buflen]
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionFailure) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-
-       e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
-       C.initSubsFailure(e2apMsg.msgC)
-
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2UnsuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionFailure {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
+       if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
+               return err, e2apMsg.msgG
        }
-       errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
+               e2apMsg.msgG.CriticalityDiagnostics.Present = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, e2apMsg.msgG
+               }
        }
-       return nil
-
-}
-
-func (e2apMsg *e2apMsgSubscriptionFailure) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
-}
-
-func (e2apMsg *e2apMsgSubscriptionFailure) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionFailure.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -913,73 +896,57 @@ func (e2apMsg *e2apMsgSubscriptionFailure) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteRequest struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteRequest struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteRequest_t
+       msgG *e2ap.E2APSubscriptionDeleteRequest
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Set(data *e2ap.E2APSubscriptionDeleteRequest) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICSubscriptionDeleteRequest})
        e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteRequest{}
        C.initSubsDeleteRequest(e2apMsg.msgC)
-
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Get() (error, *e2ap.E2APSubscriptionDeleteRequest) {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
 
-       data := &e2ap.E2APSubscriptionDeleteRequest{}
-
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
 
-       return nil, data
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduPack(logBuf []byte, data *packer.PackedData) error {
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionDeleteRequest((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       errorNro := C.packRICSubscriptionDeleteRequest(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
        }
-       data.Buf = data.Buf[0:buflen]
-       return nil
-
+       return nil, e2apMsg.packeddata()
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-
-       e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
-       C.initSubsDeleteRequest(e2apMsg.msgC)
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2InitiatingMessage || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICSubscriptionDeleteRequest {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil
-}
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
-}
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
+       }
+       return nil, e2apMsg.msgG
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteRequest.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -992,70 +959,56 @@ func (e2apMsg *e2apMsgSubscriptionDeleteRequest) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteResponse struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteResponse struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteResponse_t
+       msgG *e2ap.E2APSubscriptionDeleteResponse
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Set(data *e2ap.E2APSubscriptionDeleteResponse) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2SuccessfulOutcome, C.cRICsubscriptionDeleteResponse})
        e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteResponse{}
        C.initSubsDeleteResponse(e2apMsg.msgC)
-
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Get() (error, *e2ap.E2APSubscriptionDeleteResponse) {
-
-       data := &e2ap.E2APSubscriptionDeleteResponse{}
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
 
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
 
-       return nil, data
-}
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduPack(logBuf []byte, data *packer.PackedData) error {
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionDeleteResponse((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       errorNro := C.packRICSubscriptionDeleteResponse(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
        }
-       data.Buf = data.Buf[0:buflen]
-       return nil
+       return nil, e2apMsg.packeddata()
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-       e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
-       C.initSubsDeleteResponse(e2apMsg.msgC)
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2SuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICsubscriptionDeleteResponse {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
-}
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
+       }
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteResponse.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -1068,93 +1021,73 @@ func (e2apMsg *e2apMsgSubscriptionDeleteResponse) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteFailure struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteFailure struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteFailure_t
+       msgG *e2ap.E2APSubscriptionDeleteFailure
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Set(data *e2ap.E2APSubscriptionDeleteFailure) error {
-
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2UnsuccessfulOutcome, C.cRICsubscriptionDeleteFailure})
        e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
+       e2apMsg.msgG = &e2ap.E2APSubscriptionDeleteFailure{}
        C.initSubsDeleteFailure(e2apMsg.msgC)
+}
 
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
 
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
-               return err
+       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(e2apMsg.msgG.FunctionId)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+               return err, nil
        }
-
-       e2apMsg.msgC.ricCause.content = (C.uchar)(data.Cause.Content)
-       e2apMsg.msgC.ricCause.cause = (C.uchar)(data.Cause.CauseVal)
-
+       e2apMsg.msgC.ricCause.content = (C.uchar)(e2apMsg.msgG.Cause.Content)
+       e2apMsg.msgC.ricCause.cause = (C.uchar)(e2apMsg.msgG.Cause.Value)
        e2apMsg.msgC.criticalityDiagnosticsPresent = false
-       if data.CriticalityDiagnostics.Present {
+       if e2apMsg.msgG.CriticalityDiagnostics.Present {
                e2apMsg.msgC.criticalityDiagnosticsPresent = true
-               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&data.CriticalityDiagnostics); err != nil {
-                       return err
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, nil
                }
        }
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Get() (error, *e2ap.E2APSubscriptionDeleteFailure) {
-
-       data := &e2ap.E2APSubscriptionDeleteFailure{}
 
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       errorNro := C.packRICSubscriptionDeleteFailure(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
        }
+       return nil, e2apMsg.packeddata()
+}
 
-       data.Cause.Content = (uint8)(e2apMsg.msgC.ricCause.content)
-       data.Cause.CauseVal = (uint8)(e2apMsg.msgC.ricCause.cause)
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
-               data.CriticalityDiagnostics.Present = true
-               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&data.CriticalityDiagnostics); err != nil {
-                       return err, data
-               }
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil, data
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduPack(logBuf []byte, data *packer.PackedData) error {
-       var buflen uint32 = (uint32)(len(data.Buf))
-       errorNro := C.packRICSubscriptionDeleteFailure((*C.size_t)(unsafe.Pointer(&buflen)), (*C.uchar)(unsafe.Pointer(&data.Buf[0])), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.Buf = data.Buf[0:buflen]
-       return nil
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduUnPack(logBuf []byte, data *packer.PackedData) error {
-
-       e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
-       C.initSubsDeleteFailure(e2apMsg.msgC)
 
-       e2apMsg.e2apMessage.PduUnPack(logBuf, data)
-       if e2apMsg.e2apMessage.messageInfo.messageType != C.cE2UnsuccessfulOutcome || e2apMsg.e2apMessage.messageInfo.messageId != C.cRICsubscriptionDeleteFailure {
-               return fmt.Errorf("unpackE2AP_pdu failed -> %s", e2apMsg.e2apMessage.String())
+       e2apMsg.msgG.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
+       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+               return err, e2apMsg.msgG
        }
-       errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
+       e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.ricCause.content)
+       e2apMsg.msgG.Cause.Value = (uint8)(e2apMsg.msgC.ricCause.cause)
+       if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
+               e2apMsg.msgG.CriticalityDiagnostics.Present = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, e2apMsg.msgG
+               }
        }
-       return nil
-
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Pack(trg *packer.PackedData) (error, *packer.PackedData) {
-       return packer.PduPackerPackAllocTrg(e2apMsg, trg)
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) UnPack(msg *packer.PackedData) error {
-       return packer.PduPackerUnPack(e2apMsg, msg)
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteFailure.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -1193,32 +1126,27 @@ func (e2apMsg *e2apMsgSubscriptionDeleteFailure) String() string {
 type cppasn1E2APPacker struct{}
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
-       return &e2apMsgSubscriptionRequest{}
+       return &e2apMsgPackerSubscriptionRequest{}
 }
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
-       return &e2apMsgSubscriptionResponse{}
+       return &e2apMsgPackerSubscriptionResponse{}
 }
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
-       return &e2apMsgSubscriptionFailure{}
+       return &e2apMsgPackerSubscriptionFailure{}
 }
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
-       return &e2apMsgSubscriptionDeleteRequest{}
+       return &e2apMsgPackerSubscriptionDeleteRequest{}
 }
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
-       return &e2apMsgSubscriptionDeleteResponse{}
+       return &e2apMsgPackerSubscriptionDeleteResponse{}
 }
 
 func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
-       return &e2apMsgSubscriptionDeleteFailure{}
-}
-
-func (*cppasn1E2APPacker) MessageInfo(msg *packer.PackedData) *packer.MessageInfo {
-       e2apMsg := &e2apMessage{}
-       return e2apMsg.UnPack(msg)
+       return &e2apMsgPackerSubscriptionDeleteFailure{}
 }
 
 func NewAsn1E2Packer() e2ap.E2APPackerIf {