dc6d315ca35311da063da99839e637775a0f6202
[ric-plt/e2mgr.git] / E2Manager / models / ric_service_query_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         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
24 )
25
26 type RanFunctionIdItem struct {
27         Text                  string `xml:",chardata"`
28         RanFunctionId         uint32 `xml:"ranFunctionID"`
29         RanFunctionRevision   uint32 `xml:"ranFunctionRevision"`
30 }
31
32 type RicServiceQueryProtocolIESingleContainer struct {
33         Text        string `xml:",chardata"`
34         Id          string `xml:"id"`
35         Criticality struct {
36                 Text   string `xml:",chardata"`
37                 Reject string `xml:"reject"`
38         } `xml:"criticality"`
39         Value struct {
40                 Text               string          `xml:",chardata"`
41                 RanFunctionIdItem  RanFunctionIdItem `xml:"RANfunctionID-Item"`
42         } `xml:"value"`
43 }
44
45 type RICServiceQueryIEs struct {
46         Text        string `xml:",chardata"`
47         Id          string `xml:"id"`
48         Criticality struct {
49                 Text   string `xml:",chardata"`
50                 Reject string `xml:"reject"`
51         } `xml:"criticality"`
52         Value struct {
53                 Text   string `xml:",chardata"`
54                 RANFunctionIdList struct {
55                         Text string `xml:",chardata"`
56                         ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
57                 } `xml:"RANfunctionsID-List"`
58         } `xml:"value"`
59 }
60
61 type RICServiceQuery struct {
62         Text    string   `xml:",chardata"`
63         ProtocolIEs struct {
64                 Text              string `xml:",chardata"`
65                 RICServiceQueryIEs []RICServiceQueryIEs `xml:"RICserviceQuery-IEs"`
66         } `xml:"protocolIEs"`
67 }
68
69 type InitiatingMessage struct {
70         Text          string `xml:",chardata"`
71         ProcedureCode string `xml:"procedureCode"`
72         Criticality   struct {
73                 Text   string `xml:",chardata"`
74                 Ignore string `xml:"ignore"`
75         } `xml:"criticality"`
76         Value struct {
77                 Text           string         `xml:",chardata"`
78                 RICServiceQuery RICServiceQuery `xml:"RICserviceQuery"`
79         } `xml:"value"`
80 }
81
82 type RicServiceQueryE2APPDU struct {
83         XMLName xml.Name `xml:"E2AP-PDU"`
84         Text              string `xml:",chardata"`
85         InitiatingMessage InitiatingMessage `xml:"initiatingMessage"`
86 }
87
88
89 type RICServiceQueryMessage struct{
90         XMLName xml.Name `xml:"RICserviceQueryMessage"`
91         Text    string   `xml:",chardata"`
92         E2APPDU RicServiceQueryE2APPDU  `xml:"E2AP-PDU"`
93 }
94
95 func NewRicServiceQueryMessage(ranFunctions []*entities.RanFunction) RICServiceQueryMessage {
96         initiatingMessage := InitiatingMessage{}
97         initiatingMessage.ProcedureCode = "6"
98         initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs = make([]RICServiceQueryIEs,1)
99         initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Id = "9"
100         protocolIESingleContainer := make([]RicServiceQueryProtocolIESingleContainer,len(ranFunctions))
101         for i := 0; i < len(ranFunctions); i++ {
102                 protocolIESingleContainer[i].Id = "6"
103                 protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionId = ranFunctions[i].RanFunctionId
104                 protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionRevision = ranFunctions[i].RanFunctionRevision
105         }
106         initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Value.RANFunctionIdList.ProtocolIESingleContainer = protocolIESingleContainer
107
108         return RICServiceQueryMessage{E2APPDU:RicServiceQueryE2APPDU{InitiatingMessage:initiatingMessage}}
109 }
110
111