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 := e2SubReq.UnPack(packedData)
52 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
54 err, subReq := e2SubReq.Get()
56 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
61 func (c *E2ap) PackSubscriptionRequest(req *e2ap.E2APSubscriptionRequest) (int, *packer.PackedData, error) {
62 e2SubReq := packerif.NewPackerSubscriptionRequest()
63 err := e2SubReq.Set(req)
67 err, packedData := e2SubReq.Pack(nil)
71 return xapp.RIC_SUB_REQ, packedData, nil
74 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
77 func (c *E2ap) UnpackSubscriptionResponse(payload []byte) (*e2ap.E2APSubscriptionResponse, error) {
78 e2SubResp := packerif.NewPackerSubscriptionResponse()
79 packedData := &packer.PackedData{}
80 packedData.Buf = payload
81 err := e2SubResp.UnPack(packedData)
83 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
85 err, subResp := e2SubResp.Get()
87 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
92 func (c *E2ap) PackSubscriptionResponse(req *e2ap.E2APSubscriptionResponse) (int, *packer.PackedData, error) {
93 e2SubResp := packerif.NewPackerSubscriptionResponse()
94 err := e2SubResp.Set(req)
98 err, packedData := e2SubResp.Pack(nil)
102 return xapp.RIC_SUB_RESP, packedData, nil
105 //-----------------------------------------------------------------------------
107 //-----------------------------------------------------------------------------
108 func (c *E2ap) UnpackSubscriptionFailure(payload []byte) (*e2ap.E2APSubscriptionFailure, error) {
109 e2SubFail := packerif.NewPackerSubscriptionFailure()
110 packedData := &packer.PackedData{}
111 packedData.Buf = payload
112 err := e2SubFail.UnPack(packedData)
114 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
116 err, subFail := e2SubFail.Get()
118 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
123 func (c *E2ap) PackSubscriptionFailure(req *e2ap.E2APSubscriptionFailure) (int, *packer.PackedData, error) {
124 e2SubFail := packerif.NewPackerSubscriptionFailure()
125 err := e2SubFail.Set(req)
129 err, packedData := e2SubFail.Pack(nil)
133 return xapp.RIC_SUB_FAILURE, packedData, nil
136 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
139 func (c *E2ap) UnpackSubscriptionDeleteRequest(payload []byte) (*e2ap.E2APSubscriptionDeleteRequest, error) {
140 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
141 packedData := &packer.PackedData{}
142 packedData.Buf = payload
143 err := e2SubDelReq.UnPack(packedData)
145 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
147 err, subDelReq := e2SubDelReq.Get()
149 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
151 return subDelReq, nil
154 func (c *E2ap) PackSubscriptionDeleteRequest(req *e2ap.E2APSubscriptionDeleteRequest) (int, *packer.PackedData, error) {
155 e2SubDelReq := packerif.NewPackerSubscriptionDeleteRequest()
156 err := e2SubDelReq.Set(req)
160 err, packedData := e2SubDelReq.Pack(nil)
164 return xapp.RIC_SUB_DEL_REQ, packedData, nil
167 //-----------------------------------------------------------------------------
169 //-----------------------------------------------------------------------------
170 func (c *E2ap) UnpackSubscriptionDeleteResponse(payload []byte) (*e2ap.E2APSubscriptionDeleteResponse, error) {
171 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
172 packedData := &packer.PackedData{}
173 packedData.Buf = payload
174 err := e2SubDelResp.UnPack(packedData)
176 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
178 err, subDelResp := e2SubDelResp.Get()
180 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
182 return subDelResp, nil
185 func (c *E2ap) PackSubscriptionDeleteResponse(req *e2ap.E2APSubscriptionDeleteResponse) (int, *packer.PackedData, error) {
186 e2SubDelResp := packerif.NewPackerSubscriptionDeleteResponse()
187 err := e2SubDelResp.Set(req)
191 err, packedData := e2SubDelResp.Pack(nil)
195 return xapp.RIC_SUB_DEL_RESP, packedData, nil
198 //-----------------------------------------------------------------------------
200 //-----------------------------------------------------------------------------
201 func (c *E2ap) UnpackSubscriptionDeleteFailure(payload []byte) (*e2ap.E2APSubscriptionDeleteFailure, error) {
202 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
203 packedData := &packer.PackedData{}
204 packedData.Buf = payload
205 err := e2SubDelFail.UnPack(packedData)
207 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
209 err, subDelFail := e2SubDelFail.Get()
211 return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
213 return subDelFail, nil
216 func (c *E2ap) PackSubscriptionDeleteFailure(req *e2ap.E2APSubscriptionDeleteFailure) (int, *packer.PackedData, error) {
217 e2SubDelFail := packerif.NewPackerSubscriptionDeleteFailure()
218 err := e2SubDelFail.Set(req)
222 err, packedData := e2SubDelFail.Pack(nil)
226 return xapp.RIC_SUB_DEL_FAILURE, packedData, nil