e61d4983eb1c1ba24f0cd84b66c1307058a7779f
[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 {
267         // TODO: verify e2SetupRequestIEs structure with Adi
268         e2SetupRequestIes := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs
269         if len(e2SetupRequestIes) < 2  {
270                 return nil
271         }
272
273         ranFunctionsListContainer := e2SetupRequestIes[1].Value.RANfunctionsList.ProtocolIESingleContainer
274         funcs := make([]*entities.RanFunction, len(ranFunctionsListContainer))
275         for i := 0; i < len(funcs); i++ {
276                 ranFunctionItem := ranFunctionsListContainer[i].Value.RANfunctionItem
277
278                 funcs[i] = &entities.RanFunction{
279                         RanFunctionId:         &wrappers.UInt32Value{Value: ranFunctionItem.RanFunctionID},
280                         RanFunctionDefinition: m.buildRanFunctionDefinitionProto(&ranFunctionItem.RanFunctionDefinition),
281                         RanFunctionRevision:   &wrappers.UInt32Value{Value: ranFunctionItem.RanFunctionRevision},
282                 }
283         }
284         return funcs
285 }
286
287 func (m *E2SetupRequestMessage) buildRanFunctionDefinitionProto(def *RanFunctionDefinition) *entities.RanFunctionDefinition {
288         return &entities.RanFunctionDefinition{
289                 E2SmGnbNrtRanFunctionDefinition: &entities.E2SmGnbNrtRanFunctionDefinition{
290                         RanFunctionName:       buildRanFunctionNameProto(def),
291                         RicEventTriggerStyles: buildRicEventTriggerStylesProto(def),
292                         RicReportStyles:       buildRicReportStylesProto(def),
293                         RicInsertStyles:       buildRicInsertStylesProto(def),
294                         RicControlStyles:      buildRicControlStylesProto(def),
295                         RicPolicyStyles:       buildRicPolicyStylesProto(def),
296                 },
297         }
298 }
299
300 func buildRanFunctionNameProto(def *RanFunctionDefinition) *entities.RanFunctionName {
301         defRanFunctionName := def.E2smGnbNrtRanFunctionDefinition.RanFunctionName
302         ranFunctionName := &entities.RanFunctionName{
303                 RanFunctionShortName:   &wrappers.StringValue{Value: defRanFunctionName.RanFunctionShortName},
304                 RanFunctionE2SmOid:     &wrappers.StringValue{Value: defRanFunctionName.RanFunctionE2smOid},
305                 RanFunctionDescription: &wrappers.StringValue{Value: defRanFunctionName.RanFunctionDescription},
306         }
307
308         if defRanFunctionName.RanFunctionInstance != nil {
309                 ranFunctionName.OptionalRanFunctionInstance = &entities.RanFunctionName_RanFunctionInstance{
310                         RanFunctionInstance: *defRanFunctionName.RanFunctionInstance,
311                 }
312         }
313
314         return ranFunctionName
315 }
316
317 func buildRicEventTriggerStylesProto(def *RanFunctionDefinition) []*entities.RicEventTriggerStyle {
318         defRicEventTriggerStyleList := def.E2smGnbNrtRanFunctionDefinition.RicEventTriggerStyleList.RicEventTriggerStyleList
319         ricEventTriggerStyles := make([]*entities.RicEventTriggerStyle, len(defRicEventTriggerStyleList))
320
321         for i, v := range defRicEventTriggerStyleList {
322                 ricEventTriggerStyles[i] = &entities.RicEventTriggerStyle{
323                         RicEventTriggerStyleType:  &wrappers.UInt32Value{Value: v.RicEventTriggerStyleType},
324                         RicEventTriggerStyleName:  &wrappers.StringValue{Value: v.RicEventTriggerStyleName},
325                         RicEventTriggerFormatType: &wrappers.UInt32Value{Value: v.RicEventTriggerFormatType},
326                 }
327         }
328
329         return ricEventTriggerStyles
330 }
331
332 func buildRicReportStylesProto(def *RanFunctionDefinition) []*entities.RicReportStyle {
333         defRicReportStyleList := def.E2smGnbNrtRanFunctionDefinition.RicReportStyleList.RicReportStyleList
334         ricReportStyles := make([]*entities.RicReportStyle, len(defRicReportStyleList))
335
336         for i, v := range defRicReportStyleList {
337                 ricReportStyles[i] = &entities.RicReportStyle{
338                         RicReportStyleType:             &wrappers.UInt32Value{Value: v.RicReportStyleType},
339                         RicReportStyleName:             &wrappers.StringValue{Value: v.RicReportStyleName},
340                         RicReportActionFormatType:      &wrappers.UInt32Value{Value: v.RicReportActionFormatType},
341                         RicReportRanParameterDefs:      buildRicReportRanParameterDefsProto(v),
342                         RicIndicationHeaderFormatType:  &wrappers.UInt32Value{Value: v.RicIndicationHeaderFormatType},
343                         RicIndicationMessageFormatType: &wrappers.UInt32Value{Value: v.RicIndicationMessageFormatType},
344                 }
345         }
346
347         return ricReportStyles
348 }
349
350 func buildRicReportRanParameterDefsProto(ricReportStyleList RicReportStyleList) []*entities.RanParameterDef {
351         ricReportRanParameterDefList := ricReportStyleList.RicReportRanParameterDefList.RanParameterDefItem
352         ranParameterDefs := make([]*entities.RanParameterDef, len(ricReportRanParameterDefList))
353
354         for i, v := range ricReportRanParameterDefList {
355                 ranParameterDefs[i] = &entities.RanParameterDef{
356                         RanParameterId:   &wrappers.UInt32Value{Value: v.RanParameterID},
357                         RanParameterName: &wrappers.StringValue{Value: v.RanParameterName},
358                         RanParameterType: getRanParameterTypeEnumValue(v.RanParameterType),
359                 }
360         }
361
362         return ranParameterDefs
363 }
364
365 func getRanParameterTypeEnumValue(ranParameterType RanParameterType) entities.RanParameterType {
366         if ranParameterType.Boolean != nil {
367                 return entities.RanParameterType_BOOLEAN
368         }
369
370         if ranParameterType.BitString != nil {
371                 return entities.RanParameterType_BIT_STRING
372         }
373
374         if ranParameterType.Enumerated != nil {
375                 return entities.RanParameterType_ENUMERATED
376         }
377
378         if ranParameterType.Integer != nil {
379                 return entities.RanParameterType_INTEGER
380         }
381
382         if ranParameterType.OctetString != nil {
383                 return entities.RanParameterType_OCTET_STRING
384         }
385
386         if ranParameterType.PrintableString != nil {
387                 return entities.RanParameterType_PRINTABLE_STRING
388         }
389
390         return entities.RanParameterType_UNKNOWN_RAN_PARAMETER_TYPE
391 }
392
393 func buildRicInsertStylesProto(def *RanFunctionDefinition) []*entities.RicInsertStyle {
394         defRicInsertStyleList := def.E2smGnbNrtRanFunctionDefinition.RicInsertStyleList.RicInsertStyleList
395         ricInsertStyles := make([]*entities.RicInsertStyle, len(defRicInsertStyleList))
396
397         for i, v := range defRicInsertStyleList {
398                 ricInsertStyles[i] = &entities.RicInsertStyle{
399                         RicInsertStyleType:             &wrappers.UInt32Value{Value: v.RicInsertStyleType},
400                         RicInsertStyleName:             &wrappers.StringValue{Value: v.RicInsertStyleName},
401                         RicInsertActionFormatType:      &wrappers.UInt32Value{Value: v.RicInsertActionFormatType},
402                         RicInsertRanParameterDefs:      buildRicInsertRanParameterDefsProto(v),
403                         RicIndicationHeaderFormatType:  &wrappers.UInt32Value{Value: v.RicIndicationHeaderFormatType},
404                         RicIndicationMessageFormatType: &wrappers.UInt32Value{Value: v.RicIndicationMessageFormatType},
405                         RicCallProcessIdFormatType:     &wrappers.UInt32Value{Value: v.RicCallProcessIdFormatType},
406                 }
407         }
408
409         return ricInsertStyles
410 }
411
412 func buildRicInsertRanParameterDefsProto(ricInsertStyleList RicInsertStyleList) []*entities.RanParameterDef {
413         ricInsertRanParameterDefList := ricInsertStyleList.RicInsertRanParameterDefList.RanParameterDefItem
414         ranParameterDefs := make([]*entities.RanParameterDef, len(ricInsertRanParameterDefList))
415
416         for i, v := range ricInsertRanParameterDefList {
417                 ranParameterDefs[i] = &entities.RanParameterDef{
418                         RanParameterId:   &wrappers.UInt32Value{Value: v.RanParameterID},
419                         RanParameterName: &wrappers.StringValue{Value: v.RanParameterName},
420                         RanParameterType: getRanParameterTypeEnumValue(v.RanParameterType),
421                 }
422         }
423
424         return ranParameterDefs
425 }
426
427 func buildRicControlStylesProto(def *RanFunctionDefinition) []*entities.RicControlStyle {
428         defRicControlStyleList := def.E2smGnbNrtRanFunctionDefinition.RicControlStyleList.RicControlStyleList
429         ricControlStyles := make([]*entities.RicControlStyle, len(defRicControlStyleList))
430
431         for i, v := range defRicControlStyleList {
432                 ricControlStyles[i] = &entities.RicControlStyle{
433                         RicControlStyleType:         &wrappers.UInt32Value{Value: v.RicControlStyleType},
434                         RicControlStyleName:         &wrappers.StringValue{Value: v.RicControlStyleName},
435                         RicControlHeaderFormatType:  &wrappers.UInt32Value{Value: v.RicControlHeaderFormatType},
436                         RicControlMessageFormatType: &wrappers.UInt32Value{Value: v.RicControlMessageFormatType},
437                         RicCallProcessIdFormatType:  &wrappers.UInt32Value{Value: v.RicCallProcessIdFormatType},
438                 }
439         }
440
441         return ricControlStyles
442 }
443
444 func buildRicPolicyRanParameterDefsProto(ricPolicyStyleList RicPolicyStyleList) []*entities.RanParameterDef {
445         ricPolicyRanParameterDefList := ricPolicyStyleList.RicPolicyRanParameterDefList.RanParameterDefItem
446         ranParameterDefs := make([]*entities.RanParameterDef, len(ricPolicyRanParameterDefList))
447
448         for i, v := range ricPolicyRanParameterDefList {
449                 ranParameterDefs[i] = &entities.RanParameterDef{
450                         RanParameterId:   &wrappers.UInt32Value{Value: v.RanParameterID},
451                         RanParameterName: &wrappers.StringValue{Value: v.RanParameterName},
452                         RanParameterType: getRanParameterTypeEnumValue(v.RanParameterType),
453                 }
454         }
455
456         return ranParameterDefs
457 }
458
459 func buildRicPolicyStylesProto(def *RanFunctionDefinition) []*entities.RicPolicyStyle {
460         defRicPolicyStyleList := def.E2smGnbNrtRanFunctionDefinition.RicPolicyStyleList.RicPolicyStyleList
461         ricPolicyStyles := make([]*entities.RicPolicyStyle, len(defRicPolicyStyleList))
462
463         for i, v := range defRicPolicyStyleList {
464                 ricPolicyStyles[i] = &entities.RicPolicyStyle{
465                         RicPolicyStyleType:        &wrappers.UInt32Value{Value: v.RicPolicyStyleType},
466                         RicPolicyStyleName:        &wrappers.StringValue{Value: v.RicPolicyStyleName},
467                         RicPolicyActionFormatType: &wrappers.UInt32Value{Value: v.RicPolicyActionFormatType},
468                         RicPolicyRanParameterDefs: buildRicPolicyRanParameterDefsProto(v),
469                 }
470         }
471
472         return ricPolicyStyles
473 }
474
475 func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
476         return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
477 }
478
479 func (m *E2SetupRequestMessage) GetPlmnId() string {
480         globalE2NodeId := m.getGlobalE2NodeId()
481         if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
482                 return m.trimSpaces(id)
483         }
484         if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
485                 return m.trimSpaces(id)
486         }
487         if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
488                 return m.trimSpaces(id)
489         }
490         if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
491                 return m.trimSpaces(id)
492         }
493         return ""
494 }
495
496 func (m *E2SetupRequestMessage) getInnerEnbId(enbId EnbId) string {
497
498         if id := enbId.HomeEnbId; id != "" {
499                 return id
500         }
501
502         if id := enbId.LongMacroEnbId; id != "" {
503                 return id
504         }
505
506         if id := enbId.MacroEnbId; id != "" {
507                 return id
508         }
509
510         if id := enbId.ShortMacroEnbId; id != "" {
511                 return id
512         }
513
514         return ""
515 }
516
517 func (m *E2SetupRequestMessage) getInnerNgEnbId(enbId NgEnbId) string {
518         if id := enbId.EnbIdLongMacro; id != "" {
519                 return id
520         }
521
522         if id := enbId.EnbIdMacro; id != "" {
523                 return id
524         }
525
526         if id := enbId.EnbIdShortMacro; id != "" {
527                 return id
528         }
529
530         return ""
531 }
532
533 func (m *E2SetupRequestMessage) GetNbId() string {
534         globalE2NodeId := m.getGlobalE2NodeId()
535
536         if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
537                 return m.trimSpaces(id)
538         }
539
540         if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
541                 return m.trimSpaces(id)
542         }
543
544         if id := m.getInnerEnbId(globalE2NodeId.ENB.GlobalENBID.EnbID); id != "" {
545                 return m.trimSpaces(id)
546         }
547
548         if id := m.getInnerNgEnbId(globalE2NodeId.NgENB.GlobalNgENBID.EnbID); id != "" {
549                 return m.trimSpaces(id)
550         }
551
552         return ""
553 }
554
555 func (m *E2SetupRequestMessage) trimSpaces(str string) string {
556         return strings.NewReplacer(" ", "", "\n", "").Replace(str)
557 }