[RIC-384] Unmarshal Ran Functions and populate proto
[ric-plt/e2mgr.git] / E2Manager / models / e2_setup_request_message.go
1 //
2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
4 //
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
8 //
9 //      http://www.apache.org/licenses/LICENSE-2.0
10 //
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
17 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 //  platform project (RICP).
19
20 package models
21
22 import (
23         "encoding/xml"
24         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
25         "github.com/golang/protobuf/ptypes/wrappers"
26         "strings"
27 )
28
29 type Gnb struct {
30         Text        string `xml:",chardata"`
31         GlobalGNBID struct {
32                 Text   string `xml:",chardata"`
33                 PlmnID string `xml:"plmn-id"`
34                 GnbID  struct {
35                         Text  string `xml:",chardata"`
36                         GnbID string `xml:"gnb-ID"`
37                 } `xml:"gnb-id"`
38         } `xml:"global-gNB-ID"`
39 }
40
41 type EnGnb struct {
42         Text        string `xml:",chardata"`
43         GlobalGNBID struct {
44                 Text   string `xml:",chardata"`
45                 PlmnID string `xml:"pLMN-Identity"`
46                 GnbID  struct {
47                         Text  string `xml:",chardata"`
48                         GnbID string `xml:"gNB-ID"`
49                 } `xml:"gNB-ID"`
50         } `xml:"global-gNB-ID"`
51 }
52
53 type NgEnbId struct {
54         Text            string `xml:",chardata"`
55         EnbIdMacro      string `xml:"enb-ID-macro"`
56         EnbIdShortMacro string `xml:"enb-ID-shortmacro"`
57         EnbIdLongMacro  string `xml:"enb-ID-longmacro"`
58 }
59
60 type NgEnb struct {
61         Text          string `xml:",chardata"`
62         GlobalNgENBID struct {
63                 Text   string  `xml:",chardata"`
64                 PlmnID string  `xml:"plmn-id"`
65                 EnbID  NgEnbId `xml:"enb-id"`
66         } `xml:"global-ng-eNB-ID"`
67 }
68
69 type EnbId struct {
70         Text            string `xml:",chardata"`
71         MacroEnbId      string `xml:"macro-eNB-ID"`
72         HomeEnbId       string `xml:"home-eNB-ID"`
73         ShortMacroEnbId string `xml:"short-Macro-eNB-ID"`
74         LongMacroEnbId  string `xml:"long-Macro-eNB-ID"`
75 }
76
77 type Enb struct {
78         Text        string `xml:",chardata"`
79         GlobalENBID struct {
80                 Text   string `xml:",chardata"`
81                 PlmnID string `xml:"pLMN-Identity"`
82                 EnbID  EnbId  `xml:"eNB-ID"`
83         } `xml:"global-eNB-ID"`
84 }
85
86 type GlobalE2NodeId struct {
87         Text  string `xml:",chardata"`
88         GNB   Gnb    `xml:"gNB"`
89         EnGNB EnGnb  `xml:"en-gNB"`
90         NgENB NgEnb  `xml:"ng-eNB"`
91         ENB   Enb    `xml:"eNB"`
92 }
93
94 type E2SetupRequest struct {
95         Text        string `xml:",chardata"`
96         ProtocolIEs struct {
97                 Text              string `xml:",chardata"`
98                 E2setupRequestIEs []struct {
99                         Text        string `xml:",chardata"`
100                         ID          string `xml:"id"`
101                         Criticality struct {
102                                 Text   string `xml:",chardata"`
103                                 Reject string `xml:"reject"`
104                         } `xml:"criticality"`
105                         Value struct {
106                                 Text             string           `xml:",chardata"`
107                                 GlobalE2nodeID   GlobalE2NodeId   `xml:"GlobalE2node-ID"`
108                                 RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
109                         } `xml:"value"`
110                 } `xml:"E2setupRequestIEs"`
111         } `xml:"protocolIEs"`
112 }
113
114 type E2SetupRequestMessage struct {
115         XMLName xml.Name `xml:"E2SetupRequestMessage"`
116         Text    string   `xml:",chardata"`
117         E2APPDU struct {
118                 Text              string `xml:",chardata"`
119                 InitiatingMessage struct {
120                         Text          string `xml:",chardata"`
121                         ProcedureCode string `xml:"procedureCode"`
122                         Criticality   struct {
123                                 Text   string `xml:",chardata"`
124                                 Reject string `xml:"reject"`
125                         } `xml:"criticality"`
126                         Value struct {
127                                 Text           string         `xml:",chardata"`
128                                 E2setupRequest E2SetupRequest `xml:"E2setupRequest"`
129                         } `xml:"value"`
130                 } `xml:"initiatingMessage"`
131         } `xml:"E2AP-PDU"`
132 }
133
134 type RanFunctionItem struct {
135         Text                  string                `xml:",chardata"`
136         RanFunctionID         uint32                `xml:"ranFunctionID"`
137         RanFunctionDefinition RanFunctionDefinition `xml:"ranFunctionDefinition"`
138         RanFunctionRevision   uint32                `xml:"ranFunctionRevision"`
139 }
140
141 type RanFunctionDefinition struct {
142         Text                            string                          `xml:",chardata"`
143         E2smGnbNrtRanFunctionDefinition E2smGnbNrtRanFunctionDefinition `xml:"E2SM-gNB-NRT-RANfunction-Definition"`
144 }
145
146 type RanFunctionName struct {
147         Text                   string  `xml:",chardata"`
148         RanFunctionShortName   string  `xml:"ranFunction-ShortName"`
149         RanFunctionE2smOid     string  `xml:"ranFunction-E2SM-OID"`
150         RanFunctionDescription string  `xml:"ranFunction-Description"`
151         RanFunctionInstance    *uint32 `xml:"ranFunction-Instance"`
152 }
153
154 type RicEventTriggerStyleList struct {
155         Text                      string `xml:",chardata"`
156         RicEventTriggerStyleType  uint32 `xml:"ric-EventTriggerStyle-Type"`
157         RicEventTriggerStyleName  string `xml:"ric-EventTriggerStyle-Name"`
158         RicEventTriggerFormatType uint32 `xml:"ric-EventTriggerFormat-Type"`
159 }
160
161 type RanParameterDefItem struct {
162         Text             string           `xml:",chardata"`
163         RanParameterID   uint32           `xml:"ranParameter-ID"`
164         RanParameterName string           `xml:"ranParameter-Name"`
165         RanParameterType RanParameterType `xml:"ranParameter-Type"`
166 }
167
168 type RanParameterType struct {
169         Text            string    `xml:",chardata"`
170         Boolean         *struct{} `xml:"boolean,omitempty"`
171         Integer         *struct{} `xml:"integer,omitempty"`
172         Enumerated      *struct{} `xml:"enumerated,omitempty"`
173         BitString       *struct{} `xml:"bit-string,omitempty"`
174         OctetString     *struct{} `xml:"octet-string,omitempty"`
175         PrintableString *struct{} `xml:"printable-string,omitempty"`
176 }
177
178 type RicReportStyleList struct {
179         Text                         string `xml:",chardata"`
180         RicReportStyleType           uint32 `xml:"ric-ReportStyle-Type"`
181         RicReportStyleName           string `xml:"ric-ReportStyle-Name"`
182         RicReportActionFormatType    uint32 `xml:"ric-ReportActionFormat-Type"`
183         RicReportRanParameterDefList struct {
184                 Text                string                `xml:",chardata"`
185                 RanParameterDefItem []RanParameterDefItem `xml:"RANparameterDef-Item"`
186         } `xml:"ric-ReportRanParameterDef-List"`
187         RicIndicationHeaderFormatType  uint32 `xml:"ric-IndicationHeaderFormat-Type"`
188         RicIndicationMessageFormatType uint32 `xml:"ric-IndicationMessageFormat-Type"`
189 }
190
191 type RicInsertStyleList struct {
192         Text                         string `xml:",chardata"`
193         RicInsertStyleType           uint32 `xml:"ric-InsertStyle-Type"`
194         RicInsertStyleName           string `xml:"ric-InsertStyle-Name"`
195         RicInsertActionFormatType    uint32 `xml:"ric-InsertActionFormat-Type"`
196         RicInsertRanParameterDefList struct {
197                 Text                string                `xml:",chardata"`
198                 RanParameterDefItem []RanParameterDefItem `xml:"RANparameterDef-Item"`
199         } `xml:"ric-InsertRanParameterDef-List"`
200         RicIndicationHeaderFormatType  uint32 `xml:"ric-IndicationHeaderFormat-Type"`
201         RicIndicationMessageFormatType uint32 `xml:"ric-IndicationMessageFormat-Type"`
202         RicCallProcessIdFormatType     uint32 `xml:"ric-CallProcessIDFormat-Type"`
203 }
204
205 type RicControlStyleList struct {
206         Text                        string `xml:",chardata"`
207         RicControlStyleType         uint32 `xml:"ric-ControlStyle-Type"`
208         RicControlStyleName         string `xml:"ric-ControlStyle-Name"`
209         RicControlHeaderFormatType  uint32 `xml:"ric-ControlHeaderFormat-Type"`
210         RicControlMessageFormatType uint32 `xml:"ric-ControlMessageFormat-Type"`
211         RicCallProcessIdFormatType  uint32 `xml:"ric-CallProcessIDFormat-Type"`
212 }
213
214 type RicPolicyStyleList struct {
215         Text                         string `xml:",chardata"`
216         RicPolicyStyleType           uint32 `xml:"ric-PolicyStyle-Type"`
217         RicPolicyStyleName           string `xml:"ric-PolicyStyle-Name"`
218         RicPolicyActionFormatType    uint32 `xml:"ric-PolicyActionFormat-Type"`
219         RicPolicyRanParameterDefList struct {
220                 Text                string                `xml:",chardata"`
221                 RanParameterDefItem []RanParameterDefItem `xml:"RANparameterDef-Item"`
222         } `xml:"ric-PolicyRanParameterDef-List"`
223 }
224
225 type E2smGnbNrtRanFunctionDefinition struct {
226         Text                     string          `xml:",chardata"`
227         RanFunctionName          RanFunctionName `xml:"ranFunction-Name"`
228         RicEventTriggerStyleList struct {
229                 Text                     string                     `xml:",chardata"`
230                 RicEventTriggerStyleList []RicEventTriggerStyleList `xml:"RIC-EventTriggerStyle-List"`
231         } `xml:"ric-EventTriggerStyle-List"`
232         RicReportStyleList struct {
233                 Text               string               `xml:",chardata"`
234                 RicReportStyleList []RicReportStyleList `xml:"RIC-ReportStyle-List"`
235         } `xml:"ric-ReportStyle-List"`
236         RicInsertStyleList struct {
237                 Text               string               `xml:",chardata"`
238                 RicInsertStyleList []RicInsertStyleList `xml:"RIC-InsertStyle-List"`
239         } `xml:"ric-InsertStyle-List"`
240         RicControlStyleList struct {
241                 Text                string                `xml:",chardata"`
242                 RicControlStyleList []RicControlStyleList `xml:"RIC-ControlStyle-List"`
243         } `xml:"ric-ControlStyle-List"`
244         RicPolicyStyleList struct {
245                 Text               string               `xml:",chardata"`
246                 RicPolicyStyleList []RicPolicyStyleList `xml:"RIC-PolicyStyle-List"`
247         } `xml:"ric-PolicyStyle-List"`
248 }
249
250 type RANfunctionsList struct {
251         Text                      string `xml:",chardata"`
252         ProtocolIESingleContainer []struct {
253                 Text        string `xml:",chardata"`
254                 ID          string `xml:"id"`
255                 Criticality struct {
256                         Text   string `xml:",chardata"`
257                         Reject string `xml:"reject"`
258                 } `xml:"criticality"`
259                 Value struct {
260                         Text            string          `xml:",chardata"`
261                         RANfunctionItem RanFunctionItem `xml:"RANfunction-Item"`
262                 } `xml:"value"`
263         } `xml:"ProtocolIE-SingleContainer"`
264 }
265
266 func (m *E2SetupRequestMessage) ExtractRanFunctionsList() ([]*entities.RanFunction, error) {
267         list := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList.ProtocolIESingleContainer
268         funcs := make([]*entities.RanFunction, len(list))
269         for i := 0; i < len(funcs); i++ {
270                 funcs[i] = &entities.RanFunction{}
271                 funcs[i].RanFunctionId = &wrappers.UInt32Value{Value: list[i].Value.RANfunctionItem.RanFunctionID}
272                 def, _ := m.buildRanFunctionDefinitionProto(&list[i].Value.RANfunctionItem.RanFunctionDefinition)
273                 funcs[i].RanFunctionDefinition = def
274                 funcs[i].RanFunctionRevision = &wrappers.UInt32Value{Value: list[i].Value.RANfunctionItem.RanFunctionRevision}
275         }
276         return funcs, nil
277 }
278
279 func (m *E2SetupRequestMessage) buildRanFunctionDefinitionProto(def *RanFunctionDefinition) (*entities.RanFunctionDefinition, error) {
280         defProto := &entities.RanFunctionDefinition{
281                 E2SmGnbNrtRanFunctionDefinition: &entities.E2SmGnbNrtRanFunctionDefinition{
282                         RanFunctionName:       buildRanFunctionNameProto(def),
283                         RicEventTriggerStyles: buildRicEventTriggerStylesProto(def),
284                         RicReportStyles:       buildRicReportStylesProto(def),
285                         RicInsertStyles:       buildRicInsertStylesProto(def),
286                         RicControlStyles:      buildRicControlStylesProto(def),
287                         RicPolicyStyles:       buildRicPolicyStylesProto(def),
288                 },
289         }
290
291         return defProto, nil
292 }
293
294 func buildRanFunctionNameProto(def *RanFunctionDefinition) *entities.RanFunctionName {
295         defRanFunctionName := def.E2smGnbNrtRanFunctionDefinition.RanFunctionName
296         ranFunctionName := &entities.RanFunctionName{
297                 RanFunctionShortName:   &wrappers.StringValue{Value: defRanFunctionName.RanFunctionShortName},
298                 RanFunctionE2SmOid:     &wrappers.StringValue{Value: defRanFunctionName.RanFunctionE2smOid},
299                 RanFunctionDescription: &wrappers.StringValue{Value: defRanFunctionName.RanFunctionDescription},
300         }
301
302         if defRanFunctionName.RanFunctionInstance != nil {
303                 ranFunctionName.OptionalRanFunctionInstance = &entities.RanFunctionName_RanFunctionInstance{
304                         RanFunctionInstance: *defRanFunctionName.RanFunctionInstance,
305                 }
306         }
307
308         return ranFunctionName
309 }
310
311 func buildRicEventTriggerStylesProto(def *RanFunctionDefinition) []*entities.RicEventTriggerStyle {
312         defRicEventTriggerStyleList := def.E2smGnbNrtRanFunctionDefinition.RicEventTriggerStyleList.RicEventTriggerStyleList
313         ricEventTriggerStyles := make([]*entities.RicEventTriggerStyle, len(defRicEventTriggerStyleList))
314
315         for i, v := range defRicEventTriggerStyleList {
316                 ricEventTriggerStyles[i] = &entities.RicEventTriggerStyle{}
317                 ricEventTriggerStyles[i].RicEventTriggerStyleType = &wrappers.UInt32Value{Value: v.RicEventTriggerStyleType}
318                 ricEventTriggerStyles[i].RicEventTriggerStyleName = &wrappers.StringValue{Value: v.RicEventTriggerStyleName}
319                 ricEventTriggerStyles[i].RicEventTriggerFormatType = &wrappers.UInt32Value{Value: v.RicEventTriggerFormatType}
320         }
321
322         return ricEventTriggerStyles
323 }
324
325 func buildRicReportStylesProto(def *RanFunctionDefinition) []*entities.RicReportStyle {
326         defRicReportStyleList := def.E2smGnbNrtRanFunctionDefinition.RicReportStyleList.RicReportStyleList
327         ricReportStyles := make([]*entities.RicReportStyle, len(defRicReportStyleList))
328
329         for i, v := range defRicReportStyleList {
330                 ricReportStyles[i] = &entities.RicReportStyle{}
331                 ricReportStyles[i].RicReportStyleType = &wrappers.UInt32Value{Value: v.RicReportStyleType}
332                 ricReportStyles[i].RicReportStyleName = &wrappers.StringValue{Value: v.RicReportStyleName}
333                 ricReportStyles[i].RicReportActionFormatType = &wrappers.UInt32Value{Value: v.RicReportActionFormatType}
334                 ricReportStyles[i].RicReportRanParameterDefs = buildRicReportRanParameterDefsProto(v)
335                 ricReportStyles[i].RicIndicationHeaderFormatType = &wrappers.UInt32Value{Value: v.RicIndicationHeaderFormatType}
336                 ricReportStyles[i].RicIndicationMessageFormatType = &wrappers.UInt32Value{Value: v.RicIndicationMessageFormatType}
337         }
338
339         return ricReportStyles
340 }
341
342 func buildRicReportRanParameterDefsProto(ricReportStyleList RicReportStyleList) []*entities.RanParameterDef {
343         ricReportRanParameterDefList := ricReportStyleList.RicReportRanParameterDefList.RanParameterDefItem
344         ranParameterDefs := make([]*entities.RanParameterDef, len(ricReportRanParameterDefList))
345
346         for i, v := range ricReportRanParameterDefList {
347                 ranParameterDefs[i] = &entities.RanParameterDef{}
348                 ranParameterDefs[i].RanParameterId = &wrappers.UInt32Value{Value: v.RanParameterID}
349                 ranParameterDefs[i].RanParameterName = &wrappers.StringValue{Value: v.RanParameterName}
350                 ranParameterDefs[i].RanParameterType = getRanParameterTypeEnumValue(v.RanParameterType)
351         }
352
353         return ranParameterDefs
354 }
355
356 func getRanParameterTypeEnumValue(ranParameterType RanParameterType) entities.RanParameterType {
357         if ranParameterType.Boolean != nil {
358                 return entities.RanParameterType_BOOLEAN
359         }
360
361         if ranParameterType.BitString != nil {
362                 return entities.RanParameterType_BIT_STRING
363         }
364
365         if ranParameterType.Enumerated != nil {
366                 return entities.RanParameterType_ENUMERATED
367         }
368
369         if ranParameterType.Integer != nil {
370                 return entities.RanParameterType_INTEGER
371         }
372
373         if ranParameterType.OctetString != nil {
374                 return entities.RanParameterType_OCTET_STRING
375         }
376
377         if ranParameterType.PrintableString != nil {
378                 return entities.RanParameterType_PRINTABLE_STRING
379         }
380
381         return entities.RanParameterType_UNKNOWN_RAN_PARAMETER_TYPE
382 }
383
384 func buildRicInsertStylesProto(def *RanFunctionDefinition) []*entities.RicInsertStyle {
385         defRicInsertStyleList := def.E2smGnbNrtRanFunctionDefinition.RicInsertStyleList.RicInsertStyleList
386         ricInsertStyles := make([]*entities.RicInsertStyle, len(defRicInsertStyleList))
387
388         for i, v := range defRicInsertStyleList {
389                 ricInsertStyles[i] = &entities.RicInsertStyle{}
390                 ricInsertStyles[i].RicInsertStyleType = &wrappers.UInt32Value{Value: v.RicInsertStyleType}
391                 ricInsertStyles[i].RicInsertStyleName = &wrappers.StringValue{Value: v.RicInsertStyleName}
392                 ricInsertStyles[i].RicInsertActionFormatType = &wrappers.UInt32Value{Value: v.RicInsertActionFormatType}
393                 ricInsertStyles[i].RicInsertRanParameterDefs = buildRicInsertRanParameterDefsProto(v)
394                 ricInsertStyles[i].RicIndicationHeaderFormatType = &wrappers.UInt32Value{Value: v.RicIndicationHeaderFormatType}
395                 ricInsertStyles[i].RicIndicationMessageFormatType = &wrappers.UInt32Value{Value: v.RicIndicationMessageFormatType}
396                 ricInsertStyles[i].RicCallProcessIdFormatType = &wrappers.UInt32Value{Value: v.RicCallProcessIdFormatType}
397         }
398
399         return ricInsertStyles
400 }
401
402 func buildRicInsertRanParameterDefsProto(ricInsertStyleList RicInsertStyleList) []*entities.RanParameterDef {
403         ricInsertRanParameterDefList := ricInsertStyleList.RicInsertRanParameterDefList.RanParameterDefItem
404         ranParameterDefs := make([]*entities.RanParameterDef, len(ricInsertRanParameterDefList))
405
406         for i, v := range ricInsertRanParameterDefList {
407                 ranParameterDefs[i] = &entities.RanParameterDef{}
408                 ranParameterDefs[i].RanParameterId = &wrappers.UInt32Value{Value: v.RanParameterID}
409                 ranParameterDefs[i].RanParameterName = &wrappers.StringValue{Value: v.RanParameterName}
410                 ranParameterDefs[i].RanParameterType = getRanParameterTypeEnumValue(v.RanParameterType)
411         }
412
413         return ranParameterDefs
414 }
415
416 func buildRicControlStylesProto(def *RanFunctionDefinition) []*entities.RicControlStyle {
417         defRicControlStyleList := def.E2smGnbNrtRanFunctionDefinition.RicControlStyleList.RicControlStyleList
418         ricControlStyles := make([]*entities.RicControlStyle, len(defRicControlStyleList))
419
420         for i, v := range defRicControlStyleList {
421                 ricControlStyles[i] = &entities.RicControlStyle{}
422                 ricControlStyles[i].RicControlStyleType = &wrappers.UInt32Value{Value: v.RicControlStyleType}
423                 ricControlStyles[i].RicControlStyleName = &wrappers.StringValue{Value: v.RicControlStyleName}
424                 ricControlStyles[i].RicControlHeaderFormatType = &wrappers.UInt32Value{Value: v.RicControlHeaderFormatType}
425                 ricControlStyles[i].RicControlMessageFormatType = &wrappers.UInt32Value{Value: v.RicControlMessageFormatType}
426                 ricControlStyles[i].RicCallProcessIdFormatType = &wrappers.UInt32Value{Value: v.RicCallProcessIdFormatType}
427         }
428
429         return ricControlStyles
430 }
431
432 func buildRicPolicyRanParameterDefsProto(ricPolicyStyleList RicPolicyStyleList) []*entities.RanParameterDef {
433         ricPolicyRanParameterDefList := ricPolicyStyleList.RicPolicyRanParameterDefList.RanParameterDefItem
434         ranParameterDefs := make([]*entities.RanParameterDef, len(ricPolicyRanParameterDefList))
435
436         for i, v := range ricPolicyRanParameterDefList {
437                 ranParameterDefs[i] = &entities.RanParameterDef{}
438                 ranParameterDefs[i].RanParameterId = &wrappers.UInt32Value{Value: v.RanParameterID}
439                 ranParameterDefs[i].RanParameterName = &wrappers.StringValue{Value: v.RanParameterName}
440                 ranParameterDefs[i].RanParameterType = getRanParameterTypeEnumValue(v.RanParameterType)
441         }
442
443         return ranParameterDefs
444 }
445
446 func buildRicPolicyStylesProto(def *RanFunctionDefinition) []*entities.RicPolicyStyle {
447         defRicPolicyStyleList := def.E2smGnbNrtRanFunctionDefinition.RicPolicyStyleList.RicPolicyStyleList
448         ricPolicyStyles := make([]*entities.RicPolicyStyle, len(defRicPolicyStyleList))
449
450         for i, v := range defRicPolicyStyleList {
451                 ricPolicyStyles[i] = &entities.RicPolicyStyle{}
452                 ricPolicyStyles[i].RicPolicyStyleType = &wrappers.UInt32Value{Value: v.RicPolicyStyleType}
453                 ricPolicyStyles[i].RicPolicyStyleName = &wrappers.StringValue{Value: v.RicPolicyStyleName}
454                 ricPolicyStyles[i].RicPolicyActionFormatType = &wrappers.UInt32Value{Value: v.RicPolicyActionFormatType}
455                 ricPolicyStyles[i].RicPolicyRanParameterDefs = buildRicPolicyRanParameterDefsProto(v)
456         }
457
458         return ricPolicyStyles
459 }
460
461 func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
462         return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
463 }
464
465 func (m *E2SetupRequestMessage) GetPlmnId() string {
466         globalE2NodeId := m.getGlobalE2NodeId()
467         if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
468                 return m.trimSpaces(id)
469         }
470         if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
471                 return m.trimSpaces(id)
472         }
473         if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
474                 return m.trimSpaces(id)
475         }
476         if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
477                 return m.trimSpaces(id)
478         }
479         return ""
480 }
481
482 func (m *E2SetupRequestMessage) getInnerEnbId(enbId EnbId) string {
483
484         if id := enbId.HomeEnbId; id != "" {
485                 return id
486         }
487
488         if id := enbId.LongMacroEnbId; id != "" {
489                 return id
490         }
491
492         if id := enbId.MacroEnbId; id != "" {
493                 return id
494         }
495
496         if id := enbId.ShortMacroEnbId; id != "" {
497                 return id
498         }
499
500         return ""
501 }
502
503 func (m *E2SetupRequestMessage) getInnerNgEnbId(enbId NgEnbId) string {
504         if id := enbId.EnbIdLongMacro; id != "" {
505                 return id
506         }
507
508         if id := enbId.EnbIdMacro; id != "" {
509                 return id
510         }
511
512         if id := enbId.EnbIdShortMacro; id != "" {
513                 return id
514         }
515
516         return ""
517 }
518
519 func (m *E2SetupRequestMessage) GetNbId() string {
520         globalE2NodeId := m.getGlobalE2NodeId()
521
522         if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
523                 return m.trimSpaces(id)
524         }
525
526         if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
527                 return m.trimSpaces(id)
528         }
529
530         if id := m.getInnerEnbId(globalE2NodeId.ENB.GlobalENBID.EnbID); id != "" {
531                 return m.trimSpaces(id)
532         }
533
534         if id := m.getInnerNgEnbId(globalE2NodeId.NgENB.GlobalNgENBID.EnbID); id != "" {
535                 return m.trimSpaces(id)
536         }
537
538         return ""
539 }
540
541 func (m *E2SetupRequestMessage) trimSpaces(str string) string {
542         return strings.NewReplacer(" ", "", "\n", "").Replace(str)
543 }