Clean packing. Removing packer layer.
[ric-plt/submgr.git] / pkg / control / e2ap.go
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 {