2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 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.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
24 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
29 Text string `xml:",chardata"`
31 Text string `xml:",chardata"`
32 PlmnID string `xml:"plmn-id"`
34 Text string `xml:",chardata"`
35 GnbID string `xml:"gnb-ID"`
37 } `xml:"global-gNB-ID"`
41 Text string `xml:",chardata"`
43 Text string `xml:",chardata"`
44 PlmnID string `xml:"pLMN-Identity"`
46 Text string `xml:",chardata"`
47 GnbID string `xml:"gNB-ID"`
49 } `xml:"global-gNB-ID"`
53 Text string `xml:",chardata"`
54 EnbIdMacro string `xml:"enb-ID-macro"`
55 EnbIdShortMacro string `xml:"enb-ID-shortmacro"`
56 EnbIdLongMacro string `xml:"enb-ID-longmacro"`
60 Text string `xml:",chardata"`
61 GlobalNgENBID struct {
62 Text string `xml:",chardata"`
63 PlmnID string `xml:"plmn-id"`
64 EnbID NgEnbId `xml:"enb-id"`
65 } `xml:"global-ng-eNB-ID"`
69 Text string `xml:",chardata"`
70 MacroEnbId string `xml:"macro-eNB-ID"`
71 HomeEnbId string `xml:"home-eNB-ID"`
72 ShortMacroEnbId string `xml:"short-Macro-eNB-ID"`
73 LongMacroEnbId string `xml:"long-Macro-eNB-ID"`
77 Text string `xml:",chardata"`
79 Text string `xml:",chardata"`
80 PlmnID string `xml:"pLMN-Identity"`
81 EnbID EnbId `xml:"eNB-ID"`
82 } `xml:"global-eNB-ID"`
85 type GlobalE2NodeId struct {
86 Text string `xml:",chardata"`
88 EnGNB EnGnb `xml:"en-gNB"`
89 NgENB NgEnb `xml:"ng-eNB"`
93 type E2SetupRequest struct {
94 Text string `xml:",chardata"`
96 Text string `xml:",chardata"`
97 E2setupRequestIEs []struct {
98 Text string `xml:",chardata"`
101 Text string `xml:",chardata"`
102 Reject string `xml:"reject"`
103 } `xml:"criticality"`
105 Text string `xml:",chardata"`
106 GlobalE2nodeID GlobalE2NodeId `xml:"GlobalE2node-ID"`
107 RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
109 } `xml:"E2setupRequestIEs"`
110 } `xml:"protocolIEs"`
113 type E2SetupRequestMessage struct {
114 XMLName xml.Name `xml:"E2SetupRequestMessage"`
115 Text string `xml:",chardata"`
117 Text string `xml:",chardata"`
118 InitiatingMessage struct {
119 Text string `xml:",chardata"`
120 ProcedureCode string `xml:"procedureCode"`
122 Text string `xml:",chardata"`
123 Reject string `xml:"reject"`
124 } `xml:"criticality"`
126 Text string `xml:",chardata"`
127 E2setupRequest E2SetupRequest `xml:"E2setupRequest"`
129 } `xml:"initiatingMessage"`
133 type RanFunctionItem struct {
134 Text string `xml:",chardata"`
135 RanFunctionID uint32 `xml:"ranFunctionID"`
136 RanFunctionDefinition string `xml:"ranFunctionDefinition"`
137 RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
140 type RANfunctionsList struct {
141 Text string `xml:",chardata"`
142 ProtocolIESingleContainer []struct {
143 Text string `xml:",chardata"`
146 Text string `xml:",chardata"`
147 Reject string `xml:"reject"`
148 } `xml:"criticality"`
150 Text string `xml:",chardata"`
151 RANfunctionItem RanFunctionItem `xml:"RANfunction-Item"`
153 } `xml:"ProtocolIE-SingleContainer"`
156 func (m *E2SetupRequestMessage) ExtractRanFunctionsList() []*entities.RanFunction {
157 // TODO: verify e2SetupRequestIEs structure with Adi
158 e2SetupRequestIes := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs
159 if len(e2SetupRequestIes) < 2 {
163 ranFunctionsListContainer := e2SetupRequestIes[1].Value.RANfunctionsList.ProtocolIESingleContainer
164 funcs := make([]*entities.RanFunction, len(ranFunctionsListContainer))
165 for i := 0; i < len(funcs); i++ {
166 ranFunctionItem := ranFunctionsListContainer[i].Value.RANfunctionItem
168 funcs[i] = &entities.RanFunction{
169 RanFunctionId: ranFunctionItem.RanFunctionID,
170 RanFunctionDefinition: ranFunctionItem.RanFunctionDefinition,
171 RanFunctionRevision: ranFunctionItem.RanFunctionRevision,
177 func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
178 return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
181 func (m *E2SetupRequestMessage) GetPlmnId() string {
182 globalE2NodeId := m.getGlobalE2NodeId()
183 if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
184 return m.trimSpaces(id)
186 if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
187 return m.trimSpaces(id)
189 if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
190 return m.trimSpaces(id)
192 if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
193 return m.trimSpaces(id)
198 func (m *E2SetupRequestMessage) getInnerEnbId(enbId EnbId) string {
200 if id := enbId.HomeEnbId; id != "" {
204 if id := enbId.LongMacroEnbId; id != "" {
208 if id := enbId.MacroEnbId; id != "" {
212 if id := enbId.ShortMacroEnbId; id != "" {
219 func (m *E2SetupRequestMessage) getInnerNgEnbId(enbId NgEnbId) string {
220 if id := enbId.EnbIdLongMacro; id != "" {
224 if id := enbId.EnbIdMacro; id != "" {
228 if id := enbId.EnbIdShortMacro; id != "" {
235 func (m *E2SetupRequestMessage) GetNbId() string {
236 globalE2NodeId := m.getGlobalE2NodeId()
238 if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
239 return m.trimSpaces(id)
242 if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
243 return m.trimSpaces(id)
246 if id := m.getInnerEnbId(globalE2NodeId.ENB.GlobalENBID.EnbID); id != "" {
247 return m.trimSpaces(id)
250 if id := m.getInnerNgEnbId(globalE2NodeId.NgENB.GlobalNgENBID.EnbID); id != "" {
251 return m.trimSpaces(id)
257 func (m *E2SetupRequestMessage) trimSpaces(str string) string {
258 return strings.NewReplacer(" ", "", "\n", "").Replace(str)