0ffe458f66989bb0a5f9a40956fcc96b83892d18
[ric-plt/e2mgr.git] / E2Manager / models / ric_service_update_message.go
1 //
2 // Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 //  platform project (RICP).
18
19 package models
20
21 import (
22         "encoding/xml"
23
24         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
25 )
26
27 type RANfunctionsItemProtocolIESingleContainer struct {
28         Text        string `xml:",chardata"`
29         Id          string `xml:"id"`
30         Criticality struct {
31                 Text   string `xml:",chardata"`
32                 Ignore string `xml:"ignore"`
33         } `xml:"criticality"`
34         Value struct {
35                 Text            string `xml:",chardata"`
36                 RANfunctionItem struct {
37                         Text                  string `xml:",chardata"`
38                         RanFunctionID         uint32 `xml:"ranFunctionID"`
39                         RanFunctionDefinition string `xml:"ranFunctionDefinition"`
40                         RanFunctionRevision   uint32 `xml:"ranFunctionRevision"`
41                         RanFunctionOID        string `xml:"ranFunctionOID"`
42                 } `xml:"RANfunction-Item"`
43         } `xml:"value"`
44 }
45
46 type RANfunctionsItemIDProtocolIESingleContainer struct {
47         Text        string `xml:",chardata"`
48         Id          string `xml:"id"`
49         Criticality struct {
50                 Text   string `xml:",chardata"`
51                 Ignore string `xml:"ignore"`
52         } `xml:"criticality"`
53         Value struct {
54                 Text              string `xml:",chardata"`
55                 RANfunctionIDItem struct {
56                         Text                string `xml:",chardata"`
57                         RanFunctionID       uint32 `xml:"ranFunctionID"`
58                         RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
59                 } `xml:"RANfunctionID-Item"`
60         } `xml:"value"`
61 }
62
63 type RICServiceUpdateIEs struct {
64         Text        string `xml:",chardata"`
65         ID          int    `xml:"id"`
66         Criticality struct {
67                 Text   string `xml:",chardata"`
68                 Reject string `xml:"reject"`
69         } `xml:"criticality"`
70         Value struct {
71                 Text             string `xml:",chardata"`
72                 RANfunctionsList struct {
73                         Text                                      string                                      `xml:",chardata"`
74                         RANfunctionsItemProtocolIESingleContainer []RANfunctionsItemProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
75                 } `xml:"RANfunctions-List"`
76                 RANfunctionsIDList struct {
77                         Text                                        string                                        `xml:",chardata"`
78                         RANfunctionsItemIDProtocolIESingleContainer []RANfunctionsItemIDProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
79                 } `xml:"RANfunctionsID-List"`
80         } `xml:"value"`
81 }
82
83 type RICServiceUpdateInitiatingMessage struct {
84         Text          string `xml:",chardata"`
85         ProcedureCode string `xml:"procedureCode"`
86         Criticality   struct {
87                 Text   string `xml:",chardata"`
88                 Reject string `xml:"reject"`
89         } `xml:"criticality"`
90         Value struct {
91                 Text             string `xml:",chardata"`
92                 RICServiceUpdate struct {
93                         Text        string `xml:",chardata"`
94                         ProtocolIEs struct {
95                                 Text                string                `xml:",chardata"`
96                                 RICServiceUpdateIEs []RICServiceUpdateIEs `xml:"RICserviceUpdate-IEs"`
97                         } `xml:"protocolIEs"`
98                 } `xml:"RICserviceUpdate"`
99         } `xml:"value"`
100 }
101
102 type RICServiceUpdateE2APPDU struct {
103         XMLName           xml.Name                          `xml:"E2AP-PDU"`
104         Text              string                            `xml:",chardata"`
105         InitiatingMessage RICServiceUpdateInitiatingMessage `xml:"initiatingMessage"`
106 }
107
108 type RICServiceUpdateMessage struct {
109         XMLName xml.Name                `xml:"RICserviceUpdateMessage"`
110         Text    string                  `xml:",chardata"`
111         E2APPDU RICServiceUpdateE2APPDU `xml:"E2AP-PDU"`
112 }
113
114 func (m *RICServiceUpdateE2APPDU) ExtractRanFunctionsList() []*entities.RanFunction {
115         serviceUpdateRequestIes := m.InitiatingMessage.Value.RICServiceUpdate.ProtocolIEs.RICServiceUpdateIEs
116         if len(serviceUpdateRequestIes) < 2 {
117                 return nil
118         }
119
120         ranFunctionsListContainer := serviceUpdateRequestIes[1].Value.RANfunctionsList.RANfunctionsItemProtocolIESingleContainer
121         funcs := make([]*entities.RanFunction, len(ranFunctionsListContainer))
122         for i := 0; i < len(funcs); i++ {
123                 ranFunctionItem := ranFunctionsListContainer[i].Value.RANfunctionItem
124
125                 funcs[i] = &entities.RanFunction{
126                         RanFunctionId:         ranFunctionItem.RanFunctionID,
127                         RanFunctionDefinition: ranFunctionItem.RanFunctionDefinition,
128                         RanFunctionRevision:   ranFunctionItem.RanFunctionRevision,
129                         RanFunctionOid:        ranFunctionItem.RanFunctionOID,
130                 }
131         }
132         return funcs
133 }