Fixed function id handling and improved ut fail handling
[ric-plt/submgr.git] / e2ap / pkg / e2ap / msg_e2ap.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
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
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
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 ==================================================================================
18 */
19
20 package e2ap
21
22 import (
23         "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
24         "strconv"
25 )
26
27 //-----------------------------------------------------------------------------
28 //
29 //-----------------------------------------------------------------------------
30 const (
31         E2AP_InitiatingMessage   uint64 = 1
32         E2AP_SuccessfulOutcome   uint64 = 2
33         E2AP_UnsuccessfulOutcome uint64 = 3
34 )
35
36 //-----------------------------------------------------------------------------
37 //
38 //-----------------------------------------------------------------------------
39 // E2AP messages
40 // Initiating message
41 const (
42         E2AP_RICSubscriptionRequest       uint64 = 1
43         E2AP_RICSubscriptionDeleteRequest uint64 = 2
44
45         // E2AP_RICServiceUpdate uint64 = 3
46         // E2AP_RICControlRequest uint64 = 4
47         //
48         // //E2AP_X2SetupRequest uint64 = 5;
49         // E2AP_ENDCX2SetupRequest uint64 = 6
50         // E2AP_ResourceStatusRequest uint64 = 7
51         // E2AP_ENBConfigurationUpdate uint64 = 8
52         // E2AP_ENDCConfigurationUpdate uint64 = 9
53         // E2AP_ResetRequest uint64 = 10
54         // E2AP_RICIndication uint64 = 11
55
56         // E2AP_RICServiceQuery uint64 = 12
57         // E2AP_LoadInformation uint64 = 13
58         // E2AP_GNBStatusIndication uint64 = 14
59         // E2AP_ResourceStatusUpdate uint64 = 15
60         // E2AP_ErrorIndication uint64 = 16
61         //
62 )
63
64 // E2AP messages
65 // Successful outcome
66 const (
67         E2AP_RICSubscriptionResponse       uint64 = 1
68         E2AP_RICSubscriptionDeleteResponse uint64 = 2
69
70         // E2AP_RICserviceUpdateAcknowledge uint64 = 3
71         // E2AP_RICcontrolAcknowledge uint64 = 4
72         //
73         // //E2AP_X2SetupResponse uint64 = 5;
74         // E2AP_ENDCX2SetupResponse uint64 = 6
75         // E2AP_ResourceStatusResponse uint64 = 7
76         // E2AP_ENBConfigurationUpdateAcknowledge uint64 = 8
77         // E2AP_ENDCConfigurationUpdateAcknowledge uint64 = 9
78         // E2AP_ResetResponse uint64 = 10
79         //
80 )
81
82 // E2AP messages
83 // Unsuccessful outcome
84 const (
85         E2AP_RICSubscriptionFailure       uint64 = 1
86         E2AP_RICSubscriptionDeleteFailure uint64 = 2
87
88         // E2AP_RICserviceUpdateFailure uint64 = 3
89         // E2AP_RICcontrolFailure uint64 = 4
90         //
91         // //E2AP_X2SetupFailure uint64 = 5;
92         // E2AP_ENDCX2SetupFailure uint64 = 6
93         // E2AP_ResourceStatusFailure uint64 = 7
94         // E2AP_ENBConfigurationUpdateFailure uint64 = 8
95         // E2AP_ENDCConfigurationUpdateFailure uint64 = 9
96         //
97 )
98
99 //-----------------------------------------------------------------------------
100 //
101 //-----------------------------------------------------------------------------
102 const (
103         E2AP_IndicationTypeReport uint64 = 0
104         E2AP_IndicationTypeInsert uint64 = 1
105 )
106
107 //-----------------------------------------------------------------------------
108 //
109 //-----------------------------------------------------------------------------
110 const (
111         E2AP_ActionTypeReport uint64 = 0
112         E2AP_ActionTypeInsert uint64 = 1
113         E2AP_ActionTypePolicy uint64 = 2
114 )
115
116 //-----------------------------------------------------------------------------
117 //
118 //-----------------------------------------------------------------------------
119 const (
120         E2AP_SubSeqActionTypeContinue uint64 = 0
121         E2AP_SubSeqActionTypeWait     uint64 = 1
122 )
123
124 //-----------------------------------------------------------------------------
125 //
126 //-----------------------------------------------------------------------------
127 const (
128         E2AP_TimeToWaitZero   uint64 = 0
129         E2AP_TimeToWaitW1ms   uint64 = 1
130         E2AP_TimeToWaitW2ms   uint64 = 2
131         E2AP_TimeToWaitW5ms   uint64 = 3
132         E2AP_TimeToWaitW10ms  uint64 = 4
133         E2AP_TimeToWaitW20ms  uint64 = 4
134         E2AP_TimeToWaitW30ms  uint64 = 5
135         E2AP_TimeToWaitW40ms  uint64 = 6
136         E2AP_TimeToWaitW50ms  uint64 = 7
137         E2AP_TimeToWaitW100ms uint64 = 8
138         E2AP_TimeToWaitW200ms uint64 = 9
139         E2AP_TimeToWaitW500ms uint64 = 10
140         E2AP_TimeToWaitW1s    uint64 = 11
141         E2AP_TimeToWaitW2s    uint64 = 12
142         E2AP_TimeToWaitW5s    uint64 = 13
143         E2AP_TimeToWaitW10s   uint64 = 14
144         E2AP_TimeToWaitW20s   uint64 = 15
145         E2AP_TimeToWaitW60    uint64 = 16
146 )
147
148 //-----------------------------------------------------------------------------
149 //
150 //-----------------------------------------------------------------------------
151 const (
152         E2AP_InterfaceDirectionIncoming uint32 = 0
153         E2AP_InterfaceDirectionOutgoing uint32 = 1
154 )
155
156 //-----------------------------------------------------------------------------
157 //
158 //-----------------------------------------------------------------------------
159 const (
160         E2AP_CriticalityReject uint8 = 0
161         E2AP_CriticalityIgnore uint8 = 1
162         E2AP_CriticalityNotify uint8 = 2
163 )
164
165 //-----------------------------------------------------------------------------
166 //
167 //-----------------------------------------------------------------------------
168 const (
169         E2AP_ENBIDMacroPBits20    uint8 = 20
170         E2AP_ENBIDHomeBits28      uint8 = 28
171         E2AP_ENBIDShortMacroits18 uint8 = 18
172         E2AP_ENBIDlongMacroBits21 uint8 = 21
173 )
174
175 //-----------------------------------------------------------------------------
176 //
177 //-----------------------------------------------------------------------------
178 type RequestId struct {
179         Id  uint32
180         Seq uint32
181 }
182
183 func (rid *RequestId) String() string {
184         return strconv.FormatUint((uint64)(rid.Id), 10) + string(":") + strconv.FormatUint((uint64)(rid.Seq), 10)
185 }
186
187 //-----------------------------------------------------------------------------
188 //
189 //-----------------------------------------------------------------------------
190 type FunctionId uint16
191
192 //-----------------------------------------------------------------------------
193 //
194 //-----------------------------------------------------------------------------
195 type NodeId struct {
196         Bits uint8
197         Id   uint32
198 }
199
200 func (nid *NodeId) String() string {
201         return strconv.FormatUint((uint64)(nid.Id), 10)
202 }
203
204 //-----------------------------------------------------------------------------
205 //
206 //-----------------------------------------------------------------------------
207 type GlobalNodeId struct {
208         Present      bool
209         PlmnIdentity conv.PlmnIdentity
210         NodeId       NodeId
211 }
212
213 func (gnid *GlobalNodeId) String() string {
214         return gnid.PlmnIdentity.String() + string(":") + gnid.NodeId.String()
215 }
216
217 //-----------------------------------------------------------------------------
218 //
219 //-----------------------------------------------------------------------------
220 type InterfaceId struct {
221         GlobalEnbId GlobalNodeId
222         GlobalGnbId GlobalNodeId
223 }
224
225 //-----------------------------------------------------------------------------
226 //
227 //-----------------------------------------------------------------------------
228 type EventTriggerDefinition struct {
229         InterfaceId
230         InterfaceDirection uint32
231         ProcedureCode      uint32
232         TypeOfMessage      uint64
233 }
234
235 /*
236 //-----------------------------------------------------------------------------
237 //
238 //-----------------------------------------------------------------------------
239 type CallProcessId struct {
240   CallProcessIDVal uint32
241 }
242 */
243
244 //-----------------------------------------------------------------------------
245 //
246 //-----------------------------------------------------------------------------
247 type ActionDefinition struct {
248         Present bool
249         StyleId uint64
250         ParamId uint32
251         //ParamValue
252 }
253
254 //-----------------------------------------------------------------------------
255 //
256 //-----------------------------------------------------------------------------
257 type SubsequentAction struct {
258         Present    bool
259         Type       uint64
260         TimetoWait uint64
261 }
262
263 //-----------------------------------------------------------------------------
264 //
265 //-----------------------------------------------------------------------------
266 type ActionToBeSetupItem struct {
267         ActionId   uint64
268         ActionType uint64
269         ActionDefinition
270         SubsequentAction
271 }
272
273 //-----------------------------------------------------------------------------
274 //
275 //-----------------------------------------------------------------------------
276 type Cause struct {
277         Content  uint8
278         CauseVal uint8
279 }
280
281 //-----------------------------------------------------------------------------
282 //
283 //-----------------------------------------------------------------------------
284 type ActionAdmittedItem struct {
285         ActionId uint64
286 }
287
288 //-----------------------------------------------------------------------------
289 //
290 //-----------------------------------------------------------------------------
291 type ActionAdmittedList struct {
292         Items []ActionAdmittedItem //16
293 }
294
295 //-----------------------------------------------------------------------------
296 //
297 //-----------------------------------------------------------------------------
298 type ActionNotAdmittedItem struct {
299         ActionId uint64
300         Cause    Cause
301 }
302
303 //-----------------------------------------------------------------------------
304 //
305 //-----------------------------------------------------------------------------
306 type ActionNotAdmittedList struct {
307         Items []ActionNotAdmittedItem //16
308 }
309
310 //-----------------------------------------------------------------------------
311 //
312 //-----------------------------------------------------------------------------
313 type CriticalityDiagnosticsIEListItem struct {
314         IeCriticality uint8 //Crit
315         IeID          uint32
316         TypeOfError   uint8
317 }
318
319 //-----------------------------------------------------------------------------
320 //
321 //-----------------------------------------------------------------------------
322 type CriticalityDiagnosticsIEList struct {
323         Items []CriticalityDiagnosticsIEListItem //256
324 }
325
326 //-----------------------------------------------------------------------------
327 //
328 //-----------------------------------------------------------------------------
329 type CriticalityDiagnostics struct {
330         Present         bool
331         ProcCodePresent bool
332         ProcCode        uint64
333         TrigMsgPresent  bool
334         TrigMsg         uint64
335         ProcCritPresent bool
336         ProcCrit        uint8 //Crit
337         CriticalityDiagnosticsIEList
338 }