2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
25 #cgo LDFLAGS: -le2ap_wrapper -le2ap
32 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
33 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
34 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
37 var packerif e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
45 func (c *E2ap) UnpackSubscriptionRequest(payload []byte) (*e2ap.E2APSubscriptionRequest, error) {
46 e2SubReq := packerif.NewPackerSubscriptionRequest()
47 err, subReq := e2SubReq.UnPack(&e2ap.PackedData{payload})
49 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
54 func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *e2ap.PackedData, error) {
55 e2SubReq := packerif.NewPackerSubscriptionRequest()
56 err, packedData := e2SubReq.Pack(req)
60 return xapp.RIC_SUB_REQ, packedData, nil
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
66 func (c *E2ap) UnpackSubscriptionResponse(payload []byte) (*e2ap.E2APSubscriptionResponse, error) {
67 e2SubResp := packerif.NewPackerSubscriptionResponse()
68 err, subResp := e2SubResp.UnPack(&e2ap.PackedData{payload})
70 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
75 func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *e2ap.PackedData, error) {
76 e2SubResp := packerif.NewPackerSubscriptionResponse()
77 err, packedData := e2SubResp.Pack(req)
81 return xapp.RIC_SUB_RESP, packedData, nil
84 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
87 func (c *E2ap) UnpackSubscriptionFailure(payload []byte) (*e2ap.E2APSubscriptionFailure, error) {
88 e2SubFail := packerif.NewPackerSubscriptionFailure()
89 err, subFail := e2SubFail.UnPack(&e2ap.PackedData{payload})
91 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
96 func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *e2ap.PackedData, error) {
97 e2SubFail := packerif.NewPackerSubscriptionFailure()
98 err, packedData := e2SubFail.Pack(req)
102 return xapp.RIC_SUB_FAILURE, packedData, nil
105 //-----------------------------------------------------------------------------
107 //-----------------------------------------------------------------------------
108 func (c *E2ap) UnpackSubscriptionDeleteRequest(payload []byte) (*e2ap.E2APSubscriptionDeleteRequest, error) {
109 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
110 err, subDelReq := e2SubDelReq.UnPack(&e2ap.PackedData{payload})
112 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
114 return subDelReq, nil
117 func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *e2ap.PackedData, error) {
118 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
119 err, packedData := e2SubDelReq.Pack(req)
123 return xapp.RIC_SUB_DEL_REQ, packedData, nil
126 //-----------------------------------------------------------------------------
128 //-----------------------------------------------------------------------------
129 func (c *E2ap) UnpackSubscriptionDeleteResponse(payload []byte) (*e2ap.E2APSubscriptionDeleteResponse, error) {
130 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
131 err, subDelResp := e2SubDelResp.UnPack(&e2ap.PackedData{payload})
133 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
135 return subDelResp, nil
138 func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *e2ap.PackedData, error) {
139 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
140 err, packedData := e2SubDelResp.Pack(req)
144 return xapp.RIC_SUB_DEL_RESP, packedData, nil
147 //-----------------------------------------------------------------------------
149 //-----------------------------------------------------------------------------
150 func (c *E2ap) UnpackSubscriptionDeleteFailure(payload []byte) (*e2ap.E2APSubscriptionDeleteFailure, error) {
151 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
152 err, subDelFail := e2SubDelFail.UnPack(&e2ap.PackedData{payload})
154 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
156 return subDelFail, nil
159 func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *e2ap.PackedData, error) {
160 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
161 err, packedData := e2SubDelFail.Pack(req)
165 return xapp.RIC_SUB_DEL_FAILURE, packedData, nil