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).
26 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 Text string `xml:",chardata"`
32 Text string `xml:",chardata"`
33 PlmnID string `xml:"plmn-id"`
35 Text string `xml:",chardata"`
36 GnbID string `xml:"gnb-ID"`
38 } `xml:"global-gNB-ID"`
42 Text string `xml:",chardata"`
44 Text string `xml:",chardata"`
45 PlmnID string `xml:"pLMN-Identity"`
47 Text string `xml:",chardata"`
48 GnbID string `xml:"gNB-ID"`
50 } `xml:"global-gNB-ID"`
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"`
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"`
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"`
78 Text string `xml:",chardata"`
80 Text string `xml:",chardata"`
81 PlmnID string `xml:"pLMN-Identity"`
82 EnbID EnbId `xml:"eNB-ID"`
83 } `xml:"global-eNB-ID"`
86 type GlobalE2NodeId struct {
87 Text string `xml:",chardata"`
89 EnGNB EnGnb `xml:"en-gNB"`
90 NgENB NgEnb `xml:"ng-eNB"`
94 type E2SetupRequest struct {
95 Text string `xml:",chardata"`
97 Text string `xml:",chardata"`
98 E2setupRequestIEs []struct {
99 Text string `xml:",chardata"`
102 Text string `xml:",chardata"`
103 Reject string `xml:"reject"`
104 } `xml:"criticality"`
106 Text string `xml:",chardata"`
107 GlobalE2nodeID GlobalE2NodeId `xml:"GlobalE2node-ID"`
108 RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
110 } `xml:"E2setupRequestIEs"`
111 } `xml:"protocolIEs"`
114 type E2SetupRequestMessage struct {
115 XMLName xml.Name `xml:"E2SetupRequestMessage"`
116 Text string `xml:",chardata"`
118 Text string `xml:",chardata"`
119 InitiatingMessage struct {
120 Text string `xml:",chardata"`
121 ProcedureCode string `xml:"procedureCode"`
123 Text string `xml:",chardata"`
124 Reject string `xml:"reject"`
125 } `xml:"criticality"`
127 Text string `xml:",chardata"`
128 E2setupRequest E2SetupRequest `xml:"E2setupRequest"`
130 } `xml:"initiatingMessage"`
134 type RanFunctionItem struct {
135 Text string `xml:",chardata"`
136 RanFunctionID uint32 `xml:"ranFunctionID"`
137 RanFunctionDefinition string `xml:"ranFunctionDefinition"`
138 RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
139 RanFunctionOID string `xml:"ranFunctionOID"`
142 type RANfunctionsList struct {
143 Text string `xml:",chardata"`
144 ProtocolIESingleContainer []struct {
145 Text string `xml:",chardata"`
148 Text string `xml:",chardata"`
149 Reject string `xml:"reject"`
150 } `xml:"criticality"`
152 Text string `xml:",chardata"`
153 RANfunctionItem RanFunctionItem `xml:"RANfunction-Item"`
155 } `xml:"ProtocolIE-SingleContainer"`
158 func (m *E2SetupRequestMessage) ExtractRanFunctionsList() []*entities.RanFunction {
159 // TODO: verify e2SetupRequestIEs structure with Adi
160 e2SetupRequestIes := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs
161 if len(e2SetupRequestIes) < 2 {
165 ranFunctionsListContainer := e2SetupRequestIes[1].Value.RANfunctionsList.ProtocolIESingleContainer
166 funcs := make([]*entities.RanFunction, len(ranFunctionsListContainer))
167 for i := 0; i < len(funcs); i++ {
168 ranFunctionItem := ranFunctionsListContainer[i].Value.RANfunctionItem
170 funcs[i] = &entities.RanFunction{
171 RanFunctionId: ranFunctionItem.RanFunctionID,
172 RanFunctionDefinition: ranFunctionItem.RanFunctionDefinition,
173 RanFunctionRevision: ranFunctionItem.RanFunctionRevision,
174 RanFunctionOid: ranFunctionItem.RanFunctionOID,
180 func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
181 return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
184 func (m *E2SetupRequestMessage) GetPlmnId() string {
185 globalE2NodeId := m.getGlobalE2NodeId()
186 if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
187 return m.trimSpaces(id)
189 if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
190 return m.trimSpaces(id)
192 if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
193 return m.trimSpaces(id)
195 if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
196 return m.trimSpaces(id)
201 func (m *E2SetupRequestMessage) getInnerEnbId(enbId EnbId) string {
203 if id := enbId.HomeEnbId; id != "" {
207 if id := enbId.LongMacroEnbId; id != "" {
211 if id := enbId.MacroEnbId; id != "" {
215 if id := enbId.ShortMacroEnbId; id != "" {
222 func (m *E2SetupRequestMessage) getInnerNgEnbId(enbId NgEnbId) string {
223 if id := enbId.EnbIdLongMacro; id != "" {
227 if id := enbId.EnbIdMacro; id != "" {
231 if id := enbId.EnbIdShortMacro; id != "" {
238 func (m *E2SetupRequestMessage) GetNbId() string {
239 globalE2NodeId := m.getGlobalE2NodeId()
241 if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
242 return m.trimSpaces(id)
245 if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
246 return m.trimSpaces(id)
249 if id := m.getInnerEnbId(globalE2NodeId.ENB.GlobalENBID.EnbID); id != "" {
250 return m.trimSpaces(id)
253 if id := m.getInnerNgEnbId(globalE2NodeId.NgENB.GlobalNgENBID.EnbID); id != "" {
254 return m.trimSpaces(id)
260 func (m *E2SetupRequestMessage) trimSpaces(str string) string {
261 return strings.NewReplacer(" ", "", "\n", "").Replace(str)