2 ==================================================================================
3 Copyright (c) 2021 Nokia
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================================
24 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
33 SUB_DEL_FAILURE int = 6
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 var origPackerif e2ap.E2APPackerIf = NewAsn1E2Packer()
42 var allowAction = map[int]bool{
48 SUB_DEL_FAILURE: true,
51 func AllowE2apToProcess(mtype int, actionFail bool) {
52 fmt.Printf("INFO: AllowE2apToProcess setting %d : %t -> %t", mtype, allowAction[mtype], actionFail)
53 allowAction[mtype] = actionFail
56 type utMsgPackerSubscriptionRequest struct {
57 e2apMsgPackerSubscriptionRequest
60 func (e2apMsg *utMsgPackerSubscriptionRequest) init() {
63 func (e2apMsg *utMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
64 if allowAction[SUB_REQ] {
65 e2sub := origPackerif.NewPackerSubscriptionRequest()
66 return e2sub.Pack(data)
68 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_REQ]), nil
71 func (e2apMsg *utMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
72 if allowAction[SUB_REQ] {
73 e2sub := origPackerif.NewPackerSubscriptionRequest()
74 return e2sub.UnPack(msg)
76 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_REQ]), nil
79 func (e2apMsg *utMsgPackerSubscriptionRequest) String() string {
80 return "utMsgPackerSubscriptionRequest"
83 //-----------------------------------------------------------------------------
85 //-----------------------------------------------------------------------------
86 type utMsgPackerSubscriptionResponse struct {
87 e2apMsgPackerSubscriptionResponse
90 func (e2apMsg *utMsgPackerSubscriptionResponse) init() {
93 func (e2apMsg *utMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
94 if allowAction[SUB_RESP] {
95 e2sub := origPackerif.NewPackerSubscriptionResponse()
96 return e2sub.Pack(data)
98 return fmt.Errorf("Error: Set to be fail by UT"), nil
101 func (e2apMsg *utMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
102 if allowAction[SUB_RESP] {
103 e2sub := origPackerif.NewPackerSubscriptionResponse()
104 return e2sub.UnPack(msg)
106 return fmt.Errorf("Error: Set to be fail by UT"), nil
109 func (e2apMsg *utMsgPackerSubscriptionResponse) String() string {
110 return "utMsgPackerSubscriptionResponse"
113 //-----------------------------------------------------------------------------
115 //-----------------------------------------------------------------------------
116 type utMsgPackerSubscriptionFailure struct {
117 e2apMsgPackerSubscriptionFailure
120 func (e2apMsg *utMsgPackerSubscriptionFailure) init() {
123 func (e2apMsg *utMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
124 if allowAction[SUB_FAILURE] {
125 e2sub := origPackerif.NewPackerSubscriptionFailure()
126 return e2sub.Pack(data)
128 return fmt.Errorf("Error: Set to be fail by UT"), nil
131 func (e2apMsg *utMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
132 if allowAction[SUB_FAILURE] {
133 e2sub := origPackerif.NewPackerSubscriptionFailure()
134 return e2sub.UnPack(msg)
136 return fmt.Errorf("Error: Set to be fail by UT"), nil
139 func (e2apMsg *utMsgPackerSubscriptionFailure) String() string {
140 return "utMsgPackerSubscriptionFailure"
143 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
146 type utMsgPackerSubscriptionDeleteRequest struct {
147 e2apMsgPackerSubscriptionDeleteRequest
150 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) init() {
153 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
154 if allowAction[SUB_DEL_REQ] {
155 e2sub := origPackerif.NewPackerSubscriptionDeleteRequest()
156 return e2sub.Pack(data)
158 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_DEL_REQ]), nil
161 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
162 if allowAction[SUB_DEL_REQ] {
163 e2sub := origPackerif.NewPackerSubscriptionDeleteRequest()
164 return e2sub.UnPack(msg)
166 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_DEL_REQ]), nil
169 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) String() string {
170 return "utMsgPackerSubscriptionDeleteRequest"
173 //-----------------------------------------------------------------------------
175 //-----------------------------------------------------------------------------
176 type utMsgPackerSubscriptionDeleteResponse struct {
177 e2apMsgPackerSubscriptionDeleteResponse
180 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) init() {
184 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
185 if allowAction[SUB_DEL_RESP] {
186 e2sub := origPackerif.NewPackerSubscriptionDeleteResponse()
187 return e2sub.Pack(data)
189 return fmt.Errorf("Error: Set to be fail by UT"), nil
192 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
193 if allowAction[SUB_DEL_RESP] {
194 e2sub := origPackerif.NewPackerSubscriptionDeleteResponse()
195 return e2sub.UnPack(msg)
197 return fmt.Errorf("Error: Set to be fail by UT"), nil
200 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) String() string {
201 return "utMsgPackerSubscriptionDeleteResponse"
204 //-----------------------------------------------------------------------------
206 //-----------------------------------------------------------------------------
207 type utMsgPackerSubscriptionDeleteFailure struct {
208 e2apMsgPackerSubscriptionDeleteFailure
211 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) init() {
214 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
215 if allowAction[SUB_DEL_FAILURE] {
216 e2sub := origPackerif.NewPackerSubscriptionDeleteFailure()
217 return e2sub.Pack(data)
219 return fmt.Errorf("Error: Set to be fail by UT"), nil
222 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
223 if allowAction[SUB_DEL_FAILURE] {
224 e2sub := origPackerif.NewPackerSubscriptionDeleteFailure()
225 return e2sub.UnPack(msg)
227 return fmt.Errorf("Error: Set to be fail by UT"), nil
230 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) String() string {
231 return "utMsgPackerSubscriptionDeleteFailure"
234 //-----------------------------------------------------------------------------
235 // Public E2AP packer creators
236 //-----------------------------------------------------------------------------
238 type utAsn1E2APPacker struct{}
240 func (*utAsn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
241 return &utMsgPackerSubscriptionRequest{}
244 func (*utAsn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
245 return &utMsgPackerSubscriptionResponse{}
248 func (*utAsn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
249 return &utMsgPackerSubscriptionFailure{}
252 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
253 return &utMsgPackerSubscriptionDeleteRequest{}
256 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
257 return &utMsgPackerSubscriptionDeleteResponse{}
260 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
261 return &utMsgPackerSubscriptionDeleteFailure{}
264 func NewUtAsn1E2APPacker() e2ap.E2APPackerIf {
265 return &utAsn1E2APPacker{}