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/e2ap/pkg/packer"
35 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
38 var packerif e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer()
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
46 func (c *E2ap) UnpackSubscriptionRequest(payload []byte) (*e2ap.E2APSubscriptionRequest, error) {
47 e2SubReq := packerif.NewPackerSubscriptionRequest()
48 packedData := &packer.PackedData{}
49 packedData.Buf = payload
50 err, subReq := e2SubReq.UnPack(packedData)
52 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
57 func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *packer.PackedData, error) {
58 e2SubReq := packerif.NewPackerSubscriptionRequest()
59 err, packedData := e2SubReq.Pack(req)
63 return xapp.RIC_SUB_REQ, packedData, nil
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
69 func (c *E2ap) UnpackSubscriptionResponse(payload []byte) (*e2ap.E2APSubscriptionResponse, error) {
70 e2SubResp := packerif.NewPackerSubscriptionResponse()
71 packedData := &packer.PackedData{}
72 packedData.Buf = payload
73 err, subResp := e2SubResp.UnPack(packedData)
75 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
80 func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *packer.PackedData, error) {
81 e2SubResp := packerif.NewPackerSubscriptionResponse()
82 err, packedData := e2SubResp.Pack(req)
86 return xapp.RIC_SUB_RESP, packedData, nil
89 //-----------------------------------------------------------------------------
91 //-----------------------------------------------------------------------------
92 func (c *E2ap) UnpackSubscriptionFailure(payload []byte) (*e2ap.E2APSubscriptionFailure, error) {
93 e2SubFail := packerif.NewPackerSubscriptionFailure()
94 packedData := &packer.PackedData{}
95 packedData.Buf = payload
96 err, subFail := e2SubFail.UnPack(packedData)
98 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
103 func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *packer.PackedData, error) {
104 e2SubFail := packerif.NewPackerSubscriptionFailure()
105 err, packedData := e2SubFail.Pack(req)
109 return xapp.RIC_SUB_FAILURE, packedData, nil
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
115 func (c *E2ap) UnpackSubscriptionDeleteRequest(payload []byte) (*e2ap.E2APSubscriptionDeleteRequest, error) {
116 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
117 packedData := &packer.PackedData{}
118 packedData.Buf = payload
119 err, subDelReq := e2SubDelReq.UnPack(packedData)
121 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
123 return subDelReq, nil
126 func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *packer.PackedData, error) {
127 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
128 err, packedData := e2SubDelReq.Pack(req)
132 return xapp.RIC_SUB_DEL_REQ, packedData, nil
135 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
138 func (c *E2ap) UnpackSubscriptionDeleteResponse(payload []byte) (*e2ap.E2APSubscriptionDeleteResponse, error) {
139 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
140 packedData := &packer.PackedData{}
141 packedData.Buf = payload
142 err, subDelResp := e2SubDelResp.UnPack(packedData)
144 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
146 return subDelResp, nil
149 func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *packer.PackedData, error) {
150 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
151 err, packedData := e2SubDelResp.Pack(req)
155 return xapp.RIC_SUB_DEL_RESP, packedData, nil
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
161 func (c *E2ap) UnpackSubscriptionDeleteFailure(payload []byte) (*e2ap.E2APSubscriptionDeleteFailure, error) {
162 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
163 packedData := &packer.PackedData{}
164 packedData.Buf = payload
165 err, subDelFail := e2SubDelFail.UnPack(packedData)
167 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
169 return subDelFail, nil
172 func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *packer.PackedData, error) {
173 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
174 err, packedData := e2SubDelFail.Pack(req)
178 return xapp.RIC_SUB_DEL_FAILURE, packedData, nil