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 allowAction[mtype] = actionFail
55 type utMsgPackerSubscriptionRequest struct {
56 e2apMsgPackerSubscriptionRequest
59 func (e2apMsg *utMsgPackerSubscriptionRequest) init() {
62 func (e2apMsg *utMsgPackerSubscriptionRequest) Pack(data *e2ap.E2APSubscriptionRequest) (error, *e2ap.PackedData) {
63 if allowAction[SUB_REQ] {
64 e2sub := origPackerif.NewPackerSubscriptionRequest()
65 return e2sub.Pack(data)
67 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_REQ]), nil
70 func (e2apMsg *utMsgPackerSubscriptionRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionRequest) {
71 if allowAction[SUB_REQ] {
72 e2sub := origPackerif.NewPackerSubscriptionRequest()
73 return e2sub.UnPack(msg)
75 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_REQ]), nil
78 func (e2apMsg *utMsgPackerSubscriptionRequest) String() string {
79 return "utMsgPackerSubscriptionRequest"
82 //-----------------------------------------------------------------------------
84 //-----------------------------------------------------------------------------
85 type utMsgPackerSubscriptionResponse struct {
86 e2apMsgPackerSubscriptionResponse
89 func (e2apMsg *utMsgPackerSubscriptionResponse) init() {
92 func (e2apMsg *utMsgPackerSubscriptionResponse) Pack(data *e2ap.E2APSubscriptionResponse) (error, *e2ap.PackedData) {
93 if allowAction[SUB_RESP] {
94 e2sub := origPackerif.NewPackerSubscriptionResponse()
95 return e2sub.Pack(data)
97 return fmt.Errorf("Error: Set to be fail by UT"), nil
100 func (e2apMsg *utMsgPackerSubscriptionResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionResponse) {
101 if allowAction[SUB_RESP] {
102 e2sub := origPackerif.NewPackerSubscriptionResponse()
103 return e2sub.UnPack(msg)
105 return fmt.Errorf("Error: Set to be fail by UT"), nil
108 func (e2apMsg *utMsgPackerSubscriptionResponse) String() string {
109 return "utMsgPackerSubscriptionResponse"
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
115 type utMsgPackerSubscriptionFailure struct {
116 e2apMsgPackerSubscriptionFailure
119 func (e2apMsg *utMsgPackerSubscriptionFailure) init() {
122 func (e2apMsg *utMsgPackerSubscriptionFailure) Pack(data *e2ap.E2APSubscriptionFailure) (error, *e2ap.PackedData) {
123 if allowAction[SUB_FAILURE] {
124 e2sub := origPackerif.NewPackerSubscriptionFailure()
125 return e2sub.Pack(data)
127 return fmt.Errorf("Error: Set to be fail by UT"), nil
130 func (e2apMsg *utMsgPackerSubscriptionFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionFailure) {
131 if allowAction[SUB_FAILURE] {
132 e2sub := origPackerif.NewPackerSubscriptionFailure()
133 return e2sub.UnPack(msg)
135 return fmt.Errorf("Error: Set to be fail by UT"), nil
138 func (e2apMsg *utMsgPackerSubscriptionFailure) String() string {
139 return "utMsgPackerSubscriptionFailure"
142 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
145 type utMsgPackerSubscriptionDeleteRequest struct {
146 e2apMsgPackerSubscriptionDeleteRequest
149 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) init() {
152 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) Pack(data *e2ap.E2APSubscriptionDeleteRequest) (error, *e2ap.PackedData) {
153 if allowAction[SUB_DEL_REQ] {
154 e2sub := origPackerif.NewPackerSubscriptionDeleteRequest()
155 return e2sub.Pack(data)
157 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_DEL_REQ]), nil
160 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteRequest) {
161 if allowAction[SUB_DEL_REQ] {
162 e2sub := origPackerif.NewPackerSubscriptionDeleteRequest()
163 return e2sub.UnPack(msg)
165 return fmt.Errorf("Error: Set to be fail by UT (%v)", allowAction[SUB_DEL_REQ]), nil
168 func (e2apMsg *utMsgPackerSubscriptionDeleteRequest) String() string {
169 return "utMsgPackerSubscriptionDeleteRequest"
172 //-----------------------------------------------------------------------------
174 //-----------------------------------------------------------------------------
175 type utMsgPackerSubscriptionDeleteResponse struct {
176 e2apMsgPackerSubscriptionDeleteResponse
179 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) init() {
183 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) Pack(data *e2ap.E2APSubscriptionDeleteResponse) (error, *e2ap.PackedData) {
184 if allowAction[SUB_DEL_RESP] {
185 e2sub := origPackerif.NewPackerSubscriptionDeleteResponse()
186 return e2sub.Pack(data)
188 return fmt.Errorf("Error: Set to be fail by UT"), nil
191 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteResponse) {
192 if allowAction[SUB_DEL_RESP] {
193 e2sub := origPackerif.NewPackerSubscriptionDeleteResponse()
194 return e2sub.UnPack(msg)
196 return fmt.Errorf("Error: Set to be fail by UT"), nil
199 func (e2apMsg *utMsgPackerSubscriptionDeleteResponse) String() string {
200 return "utMsgPackerSubscriptionDeleteResponse"
203 //-----------------------------------------------------------------------------
205 //-----------------------------------------------------------------------------
206 type utMsgPackerSubscriptionDeleteFailure struct {
207 e2apMsgPackerSubscriptionDeleteFailure
210 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) init() {
213 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) Pack(data *e2ap.E2APSubscriptionDeleteFailure) (error, *e2ap.PackedData) {
214 if allowAction[SUB_DEL_FAILURE] {
215 e2sub := origPackerif.NewPackerSubscriptionDeleteFailure()
216 return e2sub.Pack(data)
218 return fmt.Errorf("Error: Set to be fail by UT"), nil
221 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APSubscriptionDeleteFailure) {
222 if allowAction[SUB_DEL_FAILURE] {
223 e2sub := origPackerif.NewPackerSubscriptionDeleteFailure()
224 return e2sub.UnPack(msg)
226 return fmt.Errorf("Error: Set to be fail by UT"), nil
229 func (e2apMsg *utMsgPackerSubscriptionDeleteFailure) String() string {
230 return "utMsgPackerSubscriptionDeleteFailure"
233 //-----------------------------------------------------------------------------
234 // Public E2AP packer creators
235 //-----------------------------------------------------------------------------
237 type utAsn1E2APPacker struct{}
239 func (*utAsn1E2APPacker) NewPackerSubscriptionRequest() e2ap.E2APMsgPackerSubscriptionRequestIf {
240 return &utMsgPackerSubscriptionRequest{}
243 func (*utAsn1E2APPacker) NewPackerSubscriptionResponse() e2ap.E2APMsgPackerSubscriptionResponseIf {
244 return &utMsgPackerSubscriptionResponse{}
247 func (*utAsn1E2APPacker) NewPackerSubscriptionFailure() e2ap.E2APMsgPackerSubscriptionFailureIf {
248 return &utMsgPackerSubscriptionFailure{}
251 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteRequest() e2ap.E2APMsgPackerSubscriptionDeleteRequestIf {
252 return &utMsgPackerSubscriptionDeleteRequest{}
255 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteResponse() e2ap.E2APMsgPackerSubscriptionDeleteResponseIf {
256 return &utMsgPackerSubscriptionDeleteResponse{}
259 func (*utAsn1E2APPacker) NewPackerSubscriptionDeleteFailure() e2ap.E2APMsgPackerSubscriptionDeleteFailureIf {
260 return &utMsgPackerSubscriptionDeleteFailure{}
263 func NewUtAsn1E2APPacker() e2ap.E2APPackerIf {
264 return &utAsn1E2APPacker{}