UT changes and fixes
[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 type PackedData struct {
103         Buf []byte
104 }
105
106 //-----------------------------------------------------------------------------
107 //
108 //-----------------------------------------------------------------------------
109 type MessageInfo struct {
110         MsgType uint64
111         MsgId   uint64
112 }
113
114 func (msgInfo *MessageInfo) String() string {
115         return "msginfo(" + strconv.FormatUint((uint64)(msgInfo.MsgType), 10) + string(":") + strconv.FormatUint((uint64)(msgInfo.MsgId), 10) + ")"
116 }
117
118 //-----------------------------------------------------------------------------
119 //
120 //-----------------------------------------------------------------------------
121 type RequestId struct {
122         Id         uint32 //RequestorId
123         InstanceId uint32 //Same as SubId in many place in the code. Name changed in E2 spec SubId -> InstanceId
124 }
125
126 func (rid *RequestId) String() string {
127         return strconv.FormatUint((uint64)(rid.Id), 10) + string(":") + strconv.FormatUint((uint64)(rid.InstanceId), 10)
128 }
129
130 //-----------------------------------------------------------------------------
131 //
132 //-----------------------------------------------------------------------------
133 type FunctionId uint16
134
135 //-----------------------------------------------------------------------------
136 //
137 //-----------------------------------------------------------------------------
138
139 const (
140         E2AP_ENBIDMacroPBits20    uint8 = 20
141         E2AP_ENBIDHomeBits28      uint8 = 28
142         E2AP_ENBIDShortMacroits18 uint8 = 18
143         E2AP_ENBIDlongMacroBits21 uint8 = 21
144 )
145
146 type NodeId struct {
147         Bits uint8
148         Id   uint32
149 }
150
151 func (nid *NodeId) String() string {
152         return strconv.FormatUint((uint64)(nid.Id), 10)
153 }
154
155 //-----------------------------------------------------------------------------
156 //
157 //-----------------------------------------------------------------------------
158 type GlobalNodeId struct {
159         Present      bool
160         PlmnIdentity conv.PlmnIdentityTbcd
161         NodeId       NodeId
162 }
163
164 func (gnid *GlobalNodeId) String() string {
165         return gnid.PlmnIdentity.String() + string(":") + gnid.NodeId.String()
166 }
167
168 //-----------------------------------------------------------------------------
169 //
170 //-----------------------------------------------------------------------------
171 type InterfaceId struct {
172         GlobalEnbId GlobalNodeId
173         GlobalGnbId GlobalNodeId
174 }
175
176 //-----------------------------------------------------------------------------
177 //
178 //-----------------------------------------------------------------------------
179
180 const (
181         E2AP_InterfaceDirectionIncoming uint32 = 0
182         E2AP_InterfaceDirectionOutgoing uint32 = 1
183 )
184
185 type EventTriggerDefinition struct {
186         Data OctetString
187 }
188
189 /*
190 //-----------------------------------------------------------------------------
191 //
192 //-----------------------------------------------------------------------------
193 type CallProcessId struct {
194   CallProcessIDVal uint32
195 }
196 */
197
198 type ActionDefinitionChoice struct {
199         Data OctetString
200 }
201
202 //-----------------------------------------------------------------------------
203 //
204 //-----------------------------------------------------------------------------
205 type BitString struct {
206         UnusedBits uint8
207         Length     uint64
208         Data       []uint8
209 }
210
211 //-----------------------------------------------------------------------------
212 //
213 //-----------------------------------------------------------------------------
214 type OctetString struct {
215         Length uint64
216         Data   []uint8
217 }
218
219 //-----------------------------------------------------------------------------
220 //
221 //-----------------------------------------------------------------------------
222 const (
223         E2AP_SubSeqActionTypeContinue uint64 = 0
224         E2AP_SubSeqActionTypeWait     uint64 = 1
225 )
226
227 var E2AP_SubSeqActionTypeStrMap = map[string]uint64{
228         "continue": E2AP_SubSeqActionTypeContinue,
229         "wait":     E2AP_SubSeqActionTypeWait,
230 }
231
232 const (
233         E2AP_TimeToWaitZero   uint64 = 0
234         E2AP_TimeToWaitW1ms   uint64 = 1
235         E2AP_TimeToWaitW2ms   uint64 = 2
236         E2AP_TimeToWaitW5ms   uint64 = 3
237         E2AP_TimeToWaitW10ms  uint64 = 4
238         E2AP_TimeToWaitW20ms  uint64 = 4
239         E2AP_TimeToWaitW30ms  uint64 = 5
240         E2AP_TimeToWaitW40ms  uint64 = 6
241         E2AP_TimeToWaitW50ms  uint64 = 7
242         E2AP_TimeToWaitW100ms uint64 = 8
243         E2AP_TimeToWaitW200ms uint64 = 9
244         E2AP_TimeToWaitW500ms uint64 = 10
245         E2AP_TimeToWaitW1s    uint64 = 11
246         E2AP_TimeToWaitW2s    uint64 = 12
247         E2AP_TimeToWaitW5s    uint64 = 13
248         E2AP_TimeToWaitW10s   uint64 = 14
249         E2AP_TimeToWaitW20s   uint64 = 15
250         E2AP_TimeToWaitW60    uint64 = 16
251 )
252
253 var E2AP_TimeToWaitStrMap = map[string]uint64{
254         "zero":   E2AP_TimeToWaitZero,
255         "w1ms":   E2AP_TimeToWaitW1ms,
256         "w2ms":   E2AP_TimeToWaitW2ms,
257         "w5ms":   E2AP_TimeToWaitW5ms,
258         "w10ms":  E2AP_TimeToWaitW10ms,
259         "w20ms":  E2AP_TimeToWaitW20ms,
260         "w30ms":  E2AP_TimeToWaitW30ms,
261         "w40ms":  E2AP_TimeToWaitW40ms,
262         "w50ms":  E2AP_TimeToWaitW50ms,
263         "w100ms": E2AP_TimeToWaitW100ms,
264         "w200ms": E2AP_TimeToWaitW200ms,
265         "w500ms": E2AP_TimeToWaitW500ms,
266         "w1s":    E2AP_TimeToWaitW1s,
267         "w2s":    E2AP_TimeToWaitW2s,
268         "w5s":    E2AP_TimeToWaitW5s,
269         "w10s":   E2AP_TimeToWaitW10s,
270         "w20s":   E2AP_TimeToWaitW20s,
271         "w60s":   E2AP_TimeToWaitW60,
272 }
273
274 type SubsequentAction struct {
275         Present    bool
276         Type       uint64
277         TimetoWait uint64
278 }
279
280 //-----------------------------------------------------------------------------
281 //
282 //-----------------------------------------------------------------------------
283
284 const (
285         E2AP_ActionTypeReport  uint64 = 0
286         E2AP_ActionTypeInsert  uint64 = 1
287         E2AP_ActionTypePolicy  uint64 = 2
288         E2AP_ActionTypeInvalid uint64 = 99 // For RIC internal usage only
289 )
290
291 var E2AP_ActionTypeStrMap = map[string]uint64{
292         "report": E2AP_ActionTypeReport,
293         "insert": E2AP_ActionTypeInsert,
294         "policy": E2AP_ActionTypePolicy,
295 }
296
297 type ActionToBeSetupItem struct {
298         ActionId                   uint64
299         ActionType                 uint64
300         RicActionDefinitionPresent bool
301         ActionDefinitionChoice
302         SubsequentAction
303 }
304
305 //-----------------------------------------------------------------------------
306 //
307 //-----------------------------------------------------------------------------
308
309 const (
310         E2AP_CauseContent_RadioNetwork uint8 = 1
311         E2AP_CauseContent_Transport    uint8 = 2
312         E2AP_CauseContent_Protocol     uint8 = 3
313         E2AP_CauseContent_Misc         uint8 = 4
314         E2AP_CauseContent_Ric          uint8 = 5
315 )
316
317 //const (
318 //      E2AP_CauseValue_RadioNetwork_ uint8 = 0
319 //)
320 //const (
321 //      E2AP_CauseValue_Transport_ uint8 = 0
322 //)
323 //const (
324 //      E2AP_CauseValue_Protocol_ uint8 = 0
325 //)
326 //const (
327 //      E2AP_CauseValue_Misc_ uint8 = 0
328 //)
329
330 const (
331         E2AP_CauseValue_Ric_function_id_Invalid                            uint8 = 0
332         E2AP_CauseValue_Ric_action_not_supported                           uint8 = 1
333         E2AP_CauseValue_Ric_excessive_actions                              uint8 = 2
334         E2AP_CauseValue_Ric_duplicate_action                               uint8 = 3
335         E2AP_CauseValue_Ric_duplicate_event                                uint8 = 4
336         E2AP_CauseValue_Ric_function_resource_limit                        uint8 = 5
337         E2AP_CauseValue_Ric_request_id_unknown                             uint8 = 6
338         E2AP_CauseValue_Ric_inconsistent_action_subsequent_action_sequence uint8 = 7
339         E2AP_CauseValue_Ric_control_message_invalid                        uint8 = 8
340         E2AP_CauseValue_Ric_call_process_id_invalid                        uint8 = 9
341         E2AP_CauseValue_Ric_function_not_required                          uint8 = 10
342         E2AP_CauseValue_Ric_excessive_functions                            uint8 = 11
343         E2AP_CauseValue_Ric_ric_resource_limi                              uint8 = 12
344 )
345
346 type Cause struct {
347         Content uint8
348         Value   uint8
349 }
350
351 //-----------------------------------------------------------------------------
352 //
353 //-----------------------------------------------------------------------------
354 type ActionAdmittedItem struct {
355         ActionId uint64
356 }
357
358 //-----------------------------------------------------------------------------
359 //
360 //-----------------------------------------------------------------------------
361 type ActionAdmittedList struct {
362         Items []ActionAdmittedItem //16
363 }
364
365 //-----------------------------------------------------------------------------
366 //
367 //-----------------------------------------------------------------------------
368 type ActionNotAdmittedItem struct {
369         ActionId uint64
370         Cause    Cause
371 }
372
373 //-----------------------------------------------------------------------------
374 //
375 //-----------------------------------------------------------------------------
376 type ActionNotAdmittedList struct {
377         Items []ActionNotAdmittedItem //16
378 }
379
380 //-----------------------------------------------------------------------------
381 //
382 //-----------------------------------------------------------------------------
383 const (
384         E2AP_CriticalityReject uint8 = 0
385         E2AP_CriticalityIgnore uint8 = 1
386         E2AP_CriticalityNotify uint8 = 2
387 )
388
389 type CriticalityDiagnosticsIEListItem struct {
390         IeCriticality uint8 //Crit
391         IeID          uint32
392         TypeOfError   uint8
393 }
394
395 //-----------------------------------------------------------------------------
396 //
397 //-----------------------------------------------------------------------------
398 type CriticalityDiagnosticsIEList struct {
399         Items []CriticalityDiagnosticsIEListItem //256
400 }
401
402 //-----------------------------------------------------------------------------
403 //
404 //-----------------------------------------------------------------------------
405 type CriticalityDiagnostics struct {
406         Present         bool
407         ProcCodePresent bool
408         ProcCode        uint64
409         TrigMsgPresent  bool
410         TrigMsg         uint64
411         ProcCritPresent bool
412         ProcCrit        uint8 //Crit
413         CriticalityDiagnosticsIEList
414 }