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 ==================================================================================
23 #cgo LDFLAGS: -le2ap_wrapper -le2ap
30 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
31 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
32 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
35 var packerif e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
43 func (c *E2ap) UnpackSubscriptionRequest(payload []byte) (*e2ap.E2APSubscriptionRequest, error) {
44 e2SubReq := packerif.NewPackerSubscriptionRequest()
45 err, subReq := e2SubReq.UnPack(&e2ap.PackedData{payload})
47 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
52 func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *e2ap.PackedData, error) {
53 e2SubReq := packerif.NewPackerSubscriptionRequest()
54 err, packedData := e2SubReq.Pack(req)
58 return xapp.RIC_SUB_REQ, packedData, nil
61 //-----------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------
64 func (c *E2ap) UnpackSubscriptionResponse(payload []byte) (*e2ap.E2APSubscriptionResponse, error) {
65 e2SubResp := packerif.NewPackerSubscriptionResponse()
66 err, subResp := e2SubResp.UnPack(&e2ap.PackedData{payload})
68 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
73 func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *e2ap.PackedData, error) {
74 e2SubResp := packerif.NewPackerSubscriptionResponse()
75 err, packedData := e2SubResp.Pack(req)
79 return xapp.RIC_SUB_RESP, packedData, nil
82 //-----------------------------------------------------------------------------
84 //-----------------------------------------------------------------------------
85 func (c *E2ap) UnpackSubscriptionFailure(payload []byte) (*e2ap.E2APSubscriptionFailure, error) {
86 e2SubFail := packerif.NewPackerSubscriptionFailure()
87 err, subFail := e2SubFail.UnPack(&e2ap.PackedData{payload})
89 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
94 func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *e2ap.PackedData, error) {
95 e2SubFail := packerif.NewPackerSubscriptionFailure()
96 err, packedData := e2SubFail.Pack(req)
100 return xapp.RIC_SUB_FAILURE, packedData, nil
103 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
106 func (c *E2ap) UnpackSubscriptionDeleteRequest(payload []byte) (*e2ap.E2APSubscriptionDeleteRequest, error) {
107 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
108 err, subDelReq := e2SubDelReq.UnPack(&e2ap.PackedData{payload})
110 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
112 return subDelReq, nil
115 func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *e2ap.PackedData, error) {
116 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
117 err, packedData := e2SubDelReq.Pack(req)
121 return xapp.RIC_SUB_DEL_REQ, packedData, nil
124 //-----------------------------------------------------------------------------
126 //-----------------------------------------------------------------------------
127 func (c *E2ap) UnpackSubscriptionDeleteResponse(payload []byte) (*e2ap.E2APSubscriptionDeleteResponse, error) {
128 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
129 err, subDelResp := e2SubDelResp.UnPack(&e2ap.PackedData{payload})
131 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
133 return subDelResp, nil
136 func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *e2ap.PackedData, error) {
137 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
138 err, packedData := e2SubDelResp.Pack(req)
142 return xapp.RIC_SUB_DEL_RESP, packedData, nil
145 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
148 func (c *E2ap) UnpackSubscriptionDeleteFailure(payload []byte) (*e2ap.E2APSubscriptionDeleteFailure, error) {
149 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
150 err, subDelFail := e2SubDelFail.UnPack(&e2ap.PackedData{payload})
152 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
154 return subDelFail, nil
157 func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *e2ap.PackedData, error) {
158 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
159 err, packedData := e2SubDelFail.Pack(req)
163 return xapp.RIC_SUB_DEL_FAILURE, packedData, nil