Clean packing. Removing packer layer. 22/2422/1
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 5 Feb 2020 12:06:57 +0000 (14:06 +0200)
committerJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 5 Feb 2020 12:07:27 +0000 (14:07 +0200)
Change-Id: I539995dd055f7739d6771334cde133b3feba980f
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
e2ap/pkg/e2ap/e2ap_packerif.go
e2ap/pkg/e2ap/e2ap_tests/msg.go
e2ap/pkg/e2ap/msg_e2ap.go
e2ap/pkg/e2ap_wrapper/packer_e2ap.go
e2ap/pkg/packer/messageinfo.go [deleted file]
e2ap/pkg/packer/packeddata.go [deleted file]
e2ap/pkg/packer/packer.go [deleted file]
pkg/control/e2ap.go
pkg/control/transaction.go
pkg/control/ut_stub_e2term_test.go
pkg/control/ut_stub_xapp_test.go

index 6a9c80d..9a06589 100644 (file)
 
 package e2ap
 
-import (
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
-)
-
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionRequestIf interface {
-       Pack(*E2APSubscriptionRequest) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionRequest)
+       Pack(*E2APSubscriptionRequest) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionRequest)
        String() string
 }
 
@@ -36,8 +32,8 @@ type E2APMsgPackerSubscriptionRequestIf interface {
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionResponseIf interface {
-       Pack(*E2APSubscriptionResponse) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionResponse)
+       Pack(*E2APSubscriptionResponse) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionResponse)
        String() string
 }
 
@@ -45,8 +41,8 @@ type E2APMsgPackerSubscriptionResponseIf interface {
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionFailureIf interface {
-       Pack(*E2APSubscriptionFailure) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionFailure)
+       Pack(*E2APSubscriptionFailure) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionFailure)
        String() string
 }
 
@@ -54,10 +50,8 @@ type E2APMsgPackerSubscriptionFailureIf interface {
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionDeleteRequestIf interface {
-       Pack(*E2APSubscriptionDeleteRequest) (error, *packer.PackedData)
-       Pack21(*E2APSubscriptionDeleteRequest) (error, *packer.PackedData)
-       Pack22(*E2APSubscriptionDeleteRequest) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionDeleteRequest)
+       Pack(*E2APSubscriptionDeleteRequest) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionDeleteRequest)
        String() string
 }
 
@@ -65,8 +59,8 @@ type E2APMsgPackerSubscriptionDeleteRequestIf interface {
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionDeleteResponseIf interface {
-       Pack(*E2APSubscriptionDeleteResponse) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionDeleteResponse)
+       Pack(*E2APSubscriptionDeleteResponse) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionDeleteResponse)
        String() string
 }
 
@@ -74,8 +68,8 @@ type E2APMsgPackerSubscriptionDeleteResponseIf interface {
 //
 //-----------------------------------------------------------------------------
 type E2APMsgPackerSubscriptionDeleteFailureIf interface {
-       Pack(*E2APSubscriptionDeleteFailure) (error, *packer.PackedData)
-       UnPack(msg *packer.PackedData) (error, *E2APSubscriptionDeleteFailure)
+       Pack(*E2APSubscriptionDeleteFailure) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APSubscriptionDeleteFailure)
        String() string
 }
 
@@ -89,6 +83,6 @@ type E2APPackerIf interface {
        NewPackerSubscriptionDeleteRequest() E2APMsgPackerSubscriptionDeleteRequestIf
        NewPackerSubscriptionDeleteResponse() E2APMsgPackerSubscriptionDeleteResponseIf
        NewPackerSubscriptionDeleteFailure() E2APMsgPackerSubscriptionDeleteFailureIf
-       //UnPack(*packer.PackedData) (error, interface{})
-       //Pack(interface{}, *packer.PackedData) (error, *packer.PackedData)
+       //UnPack(*PackedData) (error, interface{})
+       //Pack(interface{}, *PackedData) (error, *PackedData)
 }
index 1c3ab2e..7f23b96 100644 (file)
@@ -23,7 +23,6 @@ import (
        "encoding/hex"
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
        "github.com/google/go-cmp/cmp"
        "log"
        "os"
@@ -78,13 +77,13 @@ type E2ApTests struct {
        packerif e2ap.E2APPackerIf
 }
 
-func (testCtxt *E2ApTests) toPackedData(t *testing.T, buffer string) *packer.PackedData {
+func (testCtxt *E2ApTests) toPackedData(t *testing.T, buffer string) *e2ap.PackedData {
        msg, err := hex.DecodeString(buffer)
        if err != nil {
                testCtxt.testError(t, "Hex DecodeString Failed: %s [%s]", err.Error(), buffer)
                return nil
        }
-       packedData := &packer.PackedData{}
+       packedData := &e2ap.PackedData{}
        packedData.Buf = msg
        return packedData
 }
index eecf8b8..7aaad0c 100644 (file)
@@ -172,6 +172,25 @@ const (
        E2AP_ENBIDlongMacroBits21 uint8 = 21
 )
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type PackedData struct {
+       Buf []byte
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type MessageInfo struct {
+       MsgType uint64
+       MsgId   uint64
+}
+
+func (msgInfo *MessageInfo) String() string {
+       return "msginfo(" + strconv.FormatUint((uint64)(msgInfo.MsgType), 10) + string(":") + strconv.FormatUint((uint64)(msgInfo.MsgId), 10) + ")"
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
index a312964..b01baeb 100644 (file)
@@ -51,13 +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
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -424,149 +468,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) String() string {
-       msgInfo := e2apMsg.MessageInfo()
-       if msgInfo == nil {
-               return "N/A"
+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 msgInfo.String()
+       return nil
+}
+
+func (e2apMsg *e2apMessagePacker) messageInfoPdu() *e2ap.MessageInfo {
+       return cMessageInfoToMessageInfo(&e2apMsg.pduMsgInfo)
+}
+
+func (e2apMsg *e2apMessagePacker) messageInfoExpected() *e2ap.MessageInfo {
+       return cMessageInfoToMessageInfo(&e2apMsg.expectedInfo)
+}
+
+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 ret
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
 
-type e2apMsgSubscriptionRequest struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionRequest struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionRequest_t
+       msgG *e2ap.E2APSubscriptionRequest
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionRequest(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionRequest) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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)))
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *packer.PackedData) {
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
 
-       e2apMsg.msgC = &C.RICSubscriptionRequest_t{}
-       C.initSubsRequest(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+       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 {
+       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), nil
+       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 {
+               if err := item.set(&e2apMsg.msgG.ActionSetups[i]); err != nil {
                        return err, nil
                }
        }
 
-       return packer.PduPackerPack(e2apMsg)
+       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()
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
-       data := &e2ap.E2APSubscriptionRequest{}
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
+
+       e2apMsg.init()
+       defer e2apMsg.fini()
+
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
+       }
+       errorNro := C.getRICSubscriptionRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); 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
        }
-       if err := (&e2apEntryEventTrigger{entry: &e2apMsg.msgC.ricSubscription.ricEventTriggerDefinition}).get(&data.EventTriggerDefinition); err != nil {
-               return err, data
+       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
+       return nil, e2apMsg.msgG
 
 }
 
-func (e2apMsg *e2apMsgSubscriptionRequest) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionRequest) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionRequest.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -624,80 +678,75 @@ func (e2apMsg *e2apMsgSubscriptionRequest) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionResponse struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionResponse struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionResponse_t
+       msgG *e2ap.E2APSubscriptionResponse
 }
 
-func (e2apMsg *e2apMsgSubscriptionResponse) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionResponse(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionResponse) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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())
-       }
-       errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionResponse_t{}
-       C.initSubsResponse(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
+       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 := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).set(&data.ActionAdmittedList); err != nil {
+       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 {
+               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
                        return err, nil
                }
        }
-       return packer.PduPackerPack(e2apMsg)
+
+       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()
 }
 
-func (e2apMsg *e2apMsgSubscriptionResponse) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
-       data := &e2ap.E2APSubscriptionResponse{}
+func (e2apMsg *e2apMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
+
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
+       }
+       errorNro := C.getRICSubscriptionResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
 
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); 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
        }
-       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&data.ActionAdmittedList); err != nil {
-               return err, data
+       if err := (&e2apEntryAdmittedList{entry: &e2apMsg.msgC.ricActionAdmittedList}).get(&e2apMsg.msgG.ActionAdmittedList); 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
+               if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); err != nil {
+                       return err, e2apMsg.msgG
                }
        }
-       return nil, data
+       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.")
@@ -730,79 +779,75 @@ func (e2apMsg *e2apMsgSubscriptionResponse) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionFailure struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionFailure struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionFailure_t
+       msgG *e2ap.E2APSubscriptionFailure
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionFailure(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionFailure) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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())
-       }
-       errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       return nil
-
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionFailure_t{}
-       C.initSubsFailure(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
+       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 := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).set(&data.ActionNotAdmittedList); err != nil {
+       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 {
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
                        return err, nil
                }
        }
-       return packer.PduPackerPack(e2apMsg)
+
+       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) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
-       data := &e2ap.E2APSubscriptionFailure{}
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionFailureData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       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
+       }
+       if err := (&e2apEntryNotAdmittedList{entry: &e2apMsg.msgC.ricActionNotAdmittedList}).get(&e2apMsg.msgG.ActionNotAdmittedList); 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
+               e2apMsg.msgG.CriticalityDiagnostics.Present = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, e2apMsg.msgG
                }
        }
-       return nil, data
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionFailure) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionFailure) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionFailure.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -847,74 +892,57 @@ func (e2apMsg *e2apMsgSubscriptionFailure) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteRequest struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteRequest struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteRequest_t
+       msgG *e2ap.E2APSubscriptionDeleteRequest
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionDeleteRequest(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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())
-       }
-       errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
-       C.initSubsDeleteRequest(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
+       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
        }
-       return packer.PduPackerPack(e2apMsg)
-}
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Pack21(data *e2ap.E2APSubscriptionDeleteRequest) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionDeleteRequest_t{}
-       C.initSubsDeleteRequest(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+       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
        }
-       return nil, nil
+       return nil, e2apMsg.packeddata()
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) Pack22(data *e2ap.E2APSubscriptionDeleteRequest) (error, *packer.PackedData) {
-       return packer.PduPackerPack(e2apMsg)
-}
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
-       data := &e2ap.E2APSubscriptionDeleteRequest{}
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionDeleteRequestData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil, 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, e2apMsg.msgG
 
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteRequest) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequest) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteRequest.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -927,59 +955,56 @@ func (e2apMsg *e2apMsgSubscriptionDeleteRequest) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteResponse struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteResponse struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteResponse_t
+       msgG *e2ap.E2APSubscriptionDeleteResponse
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionDeleteResponse(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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())
-       }
-       errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       return nil
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionDeleteResponse_t{}
-       C.initSubsDeleteResponse(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
+       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
        }
-       return packer.PduPackerPack(e2apMsg)
+
+       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
+       }
+       return nil, e2apMsg.packeddata()
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
-       data := &e2ap.E2APSubscriptionDeleteResponse{}
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionDeleteResponseData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
        }
-       return nil, 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, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteResponse) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteResponse) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteResponse.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -992,78 +1017,73 @@ func (e2apMsg *e2apMsgSubscriptionDeleteResponse) String() string {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-type e2apMsgSubscriptionDeleteFailure struct {
-       e2apMessage
+type e2apMsgPackerSubscriptionDeleteFailure struct {
+       e2apMessagePacker
        msgC *C.RICSubscriptionDeleteFailure_t
+       msgG *e2ap.E2APSubscriptionDeleteFailure
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduPack(logBuf []byte) (error, *packer.PackedData) {
-       p := C.malloc(C.size_t(cMsgBufferMaxSize))
-       defer C.free(p)
-       plen := C.size_t(cMsgBufferMaxSize) - cMsgBufferExtra
-       errorNro := C.packRICSubscriptionDeleteFailure(&plen, (*C.uchar)(p), (*C.char)(unsafe.Pointer(&logBuf[0])), e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro))), nil
-       }
-       return nil, &packer.PackedData{C.GoBytes(p, C.int(plen))}
-}
-
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) PduUnPack(logBuf []byte, data *packer.PackedData) 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.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())
-       }
-       errorNro := C.getRICSubscriptionDeleteFailureData(e2apMsg.e2apMessage.pdu, e2apMsg.msgC)
-       if errorNro != C.e2err_OK {
-               return fmt.Errorf("%s", C.GoString(C.getE2ErrorString(errorNro)))
-       }
-       return nil
-
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *packer.PackedData) {
-       e2apMsg.msgC = &C.RICSubscriptionDeleteFailure_t{}
-       C.initSubsDeleteFailure(e2apMsg.msgC)
-       e2apMsg.msgC.ranFunctionID = (C.uint16_t)(data.FunctionId)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).set(&data.RequestId); err != nil {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
+       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
        }
-       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.CauseVal)
        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 {
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
                        return err, nil
                }
        }
 
-       return packer.PduPackerPack(e2apMsg)
+       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()
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) UnPack(msg *packer.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
-       data := &e2ap.E2APSubscriptionDeleteFailure{}
-       if err := packer.PduPackerUnPack(e2apMsg, msg); err != nil {
-               return err, data
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
        }
-       data.FunctionId = (e2ap.FunctionId)(e2apMsg.msgC.ranFunctionID)
-       if err := (&e2apEntryRequestID{entry: &e2apMsg.msgC.ricRequestID}).get(&data.RequestId); err != nil {
-               return err, data
+       errorNro := C.getRICSubscriptionDeleteFailureData(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
        }
-       data.Cause.Content = (uint8)(e2apMsg.msgC.ricCause.content)
-       data.Cause.CauseVal = (uint8)(e2apMsg.msgC.ricCause.cause)
+       e2apMsg.msgG.Cause.Content = (uint8)(e2apMsg.msgC.ricCause.content)
+       e2apMsg.msgG.Cause.CauseVal = (uint8)(e2apMsg.msgC.ricCause.cause)
        if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
-               data.CriticalityDiagnostics.Present = true
-               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&data.CriticalityDiagnostics); err != nil {
-                       return err, data
+               e2apMsg.msgG.CriticalityDiagnostics.Present = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, e2apMsg.msgG
                }
        }
-       return nil, data
+       return nil, e2apMsg.msgG
 }
 
-func (e2apMsg *e2apMsgSubscriptionDeleteFailure) String() string {
+func (e2apMsg *e2apMsgPackerSubscriptionDeleteFailure) String() string {
        var b bytes.Buffer
        fmt.Fprintln(&b, "ricSubscriptionDeleteFailure.")
        fmt.Fprintln(&b, "  ricRequestID.")
@@ -1102,27 +1122,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{}
+       return &e2apMsgPackerSubscriptionDeleteFailure{}
 }
 
 func NewAsn1E2Packer() e2ap.E2APPackerIf {
diff --git a/e2ap/pkg/packer/messageinfo.go b/e2ap/pkg/packer/messageinfo.go
deleted file mode 100644 (file)
index 3da270f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-==================================================================================
-  Copyright (c) 2019 AT&T Intellectual Property.
-  Copyright (c) 2019 Nokia
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-
-package packer
-
-import (
-       "bytes"
-       "fmt"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type MessageInfo struct {
-       MsgType uint64
-       MsgId   uint64
-}
-
-func (msgInfo *MessageInfo) String() string {
-       var b bytes.Buffer
-       fmt.Fprintf(&b, "MsgType: %d, MsgId: %d", msgInfo.MsgType, msgInfo.MsgId)
-       return b.String()
-}
diff --git a/e2ap/pkg/packer/packeddata.go b/e2ap/pkg/packer/packeddata.go
deleted file mode 100644 (file)
index 24fcaf0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-==================================================================================
-  Copyright (c) 2019 AT&T Intellectual Property.
-  Copyright (c) 2019 Nokia
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-
-package packer
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type PackedData struct {
-       Buf []byte
-}
diff --git a/e2ap/pkg/packer/packer.go b/e2ap/pkg/packer/packer.go
deleted file mode 100644 (file)
index 9eeefaf..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-==================================================================================
-  Copyright (c) 2019 AT&T Intellectual Property.
-  Copyright (c) 2019 Nokia
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-
-package packer
-
-import (
-       "fmt"
-       "strings"
-)
-
-const cLogBufferMaxSize = 40960
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-
-type PduLoggerBuf struct {
-       logBuffer []byte
-}
-
-func (lb *PduLoggerBuf) String() string {
-       return "logbuffer(" + string(lb.logBuffer[:strings.Index(string(lb.logBuffer[:]), "\000")]) + ")"
-}
-
-func NewPduLoggerBuf() *PduLoggerBuf {
-       lb := &PduLoggerBuf{}
-       lb.logBuffer = make([]byte, cLogBufferMaxSize)
-       lb.logBuffer[0] = 0
-       return lb
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type PduPackerIf interface {
-       PduPack(logBuf []byte) (error, *PackedData)
-}
-
-func PduPackerPack(entry PduPackerIf) (error, *PackedData) {
-       lb := NewPduLoggerBuf()
-       err, buf := entry.PduPack(lb.logBuffer)
-       if err == nil {
-               return nil, buf
-       }
-       return fmt.Errorf("Pack failed: err(%s), %s", err.Error(), lb.String()), nil
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-
-type PduUnPackerIf interface {
-       PduUnPack(logBuf []byte, data *PackedData) error
-}
-
-func PduPackerUnPack(entry PduUnPackerIf, data *PackedData) error {
-       if data == nil {
-               return fmt.Errorf("Unpack failed: data is nil")
-       }
-       lb := NewPduLoggerBuf()
-       err := entry.PduUnPack(lb.logBuffer, data)
-       if err == nil {
-               return nil
-       }
-       return fmt.Errorf("Unpack failed: err(%s), %s", err.Error(), lb.String())
-}
index f0b3381..ed2f690 100644 (file)
@@ -31,7 +31,6 @@ import (
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 )
 
@@ -45,16 +44,14 @@ type E2ap struct {
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionRequest(payload []byte) (*e2ap.E2APSubscriptionRequest, error) {
        e2SubReq := packerif.NewPackerSubscriptionRequest()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subReq := e2SubReq.UnPack(packedData)
+       err, subReq := e2SubReq.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subReq, nil
 }
 
-func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *e2ap.PackedData, error) {
        e2SubReq := packerif.NewPackerSubscriptionRequest()
        err, packedData := e2SubReq.Pack(req)
        if err != nil {
@@ -68,16 +65,14 @@ func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int,
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionResponse(payload []byte) (*e2ap.E2APSubscriptionResponse, error) {
        e2SubResp := packerif.NewPackerSubscriptionResponse()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subResp := e2SubResp.UnPack(packedData)
+       err, subResp := e2SubResp.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subResp, nil
 }
 
-func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *e2ap.PackedData, error) {
        e2SubResp := packerif.NewPackerSubscriptionResponse()
        err, packedData := e2SubResp.Pack(req)
        if err != nil {
@@ -91,16 +86,14 @@ func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionFailure(payload []byte) (*e2ap.E2APSubscriptionFailure, error) {
        e2SubFail := packerif.NewPackerSubscriptionFailure()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subFail := e2SubFail.UnPack(packedData)
+       err, subFail := e2SubFail.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subFail, nil
 }
 
-func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *e2ap.PackedData, error) {
        e2SubFail := packerif.NewPackerSubscriptionFailure()
        err, packedData := e2SubFail.Pack(req)
        if err != nil {
@@ -114,16 +107,14 @@ func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int,
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionDeleteRequest(payload []byte) (*e2ap.E2APSubscriptionDeleteRequest, error) {
        e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subDelReq := e2SubDelReq.UnPack(packedData)
+       err, subDelReq := e2SubDelReq.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subDelReq, nil
 }
 
-func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *e2ap.PackedData, error) {
        e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
        err, packedData := e2SubDelReq.Pack(req)
        if err != nil {
@@ -137,16 +128,14 @@ func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteReq
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionDeleteResponse(payload []byte) (*e2ap.E2APSubscriptionDeleteResponse, error) {
        e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subDelResp := e2SubDelResp.UnPack(packedData)
+       err, subDelResp := e2SubDelResp.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subDelResp, nil
 }
 
-func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *e2ap.PackedData, error) {
        e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
        err, packedData := e2SubDelResp.Pack(req)
        if err != nil {
@@ -160,16 +149,14 @@ func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteRe
 //-----------------------------------------------------------------------------
 func (c *E2ap) UnpackSubscriptionDeleteFailure(payload []byte) (*e2ap.E2APSubscriptionDeleteFailure, error) {
        e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
-       packedData := &packer.PackedData{}
-       packedData.Buf = payload
-       err, subDelFail := e2SubDelFail.UnPack(packedData)
+       err, subDelFail := e2SubDelFail.UnPack(&e2ap.PackedData{payload})
        if err != nil {
                return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
        }
        return subDelFail, nil
 }
 
-func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *packer.PackedData, error) {
+func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *e2ap.PackedData, error) {
        e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
        err, packedData := e2SubDelFail.Pack(req)
        if err != nil {
index b2b838b..df4d7db 100644 (file)
@@ -20,7 +20,7 @@
 package control
 
 import (
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "strconv"
        "sync"
@@ -42,13 +42,13 @@ type TransactionIf interface {
 //-----------------------------------------------------------------------------
 
 type Transaction struct {
-       mutex     sync.Mutex         //
-       Seq       uint64             //transaction sequence
-       tracker   *Tracker           //tracker instance
-       Meid      *xapp.RMRMeid      //meid transaction related
-       ReqId     RequestId          //
-       Mtype     int                //Encoded message type to be send
-       Payload   *packer.PackedData //Encoded message to be send
+       mutex     sync.Mutex       //
+       Seq       uint64           //transaction sequence
+       tracker   *Tracker         //tracker instance
+       Meid      *xapp.RMRMeid    //meid transaction related
+       ReqId     RequestId        //
+       Mtype     int              //Encoded message type to be send
+       Payload   *e2ap.PackedData //Encoded message to be send
        EventChan chan interface{}
 }
 
@@ -104,7 +104,7 @@ func (t *Transaction) GetMeid() *xapp.RMRMeid {
        return nil
 }
 
-func (t *Transaction) GetPayload() *packer.PackedData {
+func (t *Transaction) GetPayload() *e2ap.PackedData {
        t.mutex.Lock()
        defer t.mutex.Unlock()
        return t.Payload
index 840c98e..f2392b9 100644 (file)
@@ -22,7 +22,6 @@ package control
 import (
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "testing"
        "time"
@@ -85,7 +84,7 @@ func (e2termConn *testingE2termStub) handle_e2term_subs_req(t *testing.T) (*e2ap
                        testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.GetDesc(), "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
                } else {
                        xapp.Logger.Info("(%s) Recv Subs Req", e2termConn.GetDesc())
-                       packedData := &packer.PackedData{}
+                       packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        unpackerr, req := e2SubsReq.UnPack(packedData)
                        if unpackerr != nil {
@@ -230,7 +229,7 @@ func (e2termConn *testingE2termStub) handle_e2term_subs_del_req(t *testing.T) (*
                } else {
                        xapp.Logger.Info("(%s) Recv Subs Del Req", e2termConn.GetDesc())
 
-                       packedData := &packer.PackedData{}
+                       packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        unpackerr, req := e2SubsDelReq.UnPack(packedData)
                        if unpackerr != nil {
index c9c297d..ccd1eb6 100644 (file)
@@ -22,7 +22,6 @@ package control
 import (
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/packer"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "strconv"
        "strings"
@@ -206,7 +205,7 @@ func (xappConn *testingXappStub) handle_xapp_subs_resp(t *testing.T, trans *xapp
                        testError(t, "(%s) Received RIC_SUB_RESP wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
                        return 0
                } else {
-                       packedData := &packer.PackedData{}
+                       packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        if msg.SubId > 0 {
                                e2SubsId = uint32(msg.SubId)
@@ -248,7 +247,7 @@ func (xappConn *testingXappStub) handle_xapp_subs_fail(t *testing.T, trans *xapp
                        testError(t, "(%s) Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
                        return 0
                } else {
-                       packedData := &packer.PackedData{}
+                       packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        if msg.SubId > 0 {
                                e2SubsId = uint32(msg.SubId)
@@ -335,7 +334,7 @@ func (xappConn *testingXappStub) handle_xapp_subs_del_resp(t *testing.T, trans *
                        testError(t, "(%s) Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", xappConn.GetDesc(), trans.xid, msg.Xid)
                        return
                } else {
-                       packedData := &packer.PackedData{}
+                       packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        unpackerr, resp := e2SubsDelResp.UnPack(packedData)
                        if unpackerr != nil {