2 // Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
16 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 // platform project (RICP).
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 type RanFunctionIdItem struct {
31 Text string `xml:",chardata"`
32 RanFunctionId uint32 `xml:"ranFunctionID"`
33 RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
36 type RicServiceQueryProtocolIESingleContainer struct {
37 Text string `xml:",chardata"`
40 Text string `xml:",chardata"`
41 Reject string `xml:"reject"`
44 Text string `xml:",chardata"`
45 RanFunctionIdItem RanFunctionIdItem `xml:"RANfunctionID-Item"`
49 type RICServiceQueryIEs struct {
50 Text string `xml:",chardata"`
53 Text string `xml:",chardata"`
54 Reject string `xml:"reject"`
56 Value interface{} `xml:"value"`
59 type RICServiceQueryRANFunctionIdList struct {
60 Text string `xml:",chardata"`
61 RANFunctionIdList struct {
62 Text string `xml:",chardata"`
63 ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
64 } `xml:"RANfunctionsID-List"`
66 type RICServiceQueryTransactionID struct {
67 Text string `xml:",chardata"`
68 TransactionID string `xml:"TransactionID"`
71 type RICServiceQuery struct {
72 Text string `xml:",chardata"`
74 Text string `xml:",chardata"`
75 RICServiceQueryIEs []RICServiceQueryIEs `xml:"RICserviceQuery-IEs"`
79 type InitiatingMessage struct {
80 Text string `xml:",chardata"`
81 ProcedureCode string `xml:"procedureCode"`
83 Text string `xml:",chardata"`
84 Ignore string `xml:"ignore"`
87 Text string `xml:",chardata"`
88 RICServiceQuery RICServiceQuery `xml:"RICserviceQuery"`
92 type RicServiceQueryE2APPDU struct {
93 XMLName xml.Name `xml:"E2AP-PDU"`
94 Text string `xml:",chardata"`
95 InitiatingMessage InitiatingMessage `xml:"initiatingMessage"`
98 type RICServiceQueryMessage struct {
99 XMLName xml.Name `xml:"RICserviceQueryMessage"`
100 Text string `xml:",chardata"`
101 E2APPDU RicServiceQueryE2APPDU `xml:"E2AP-PDU"`
104 func NewRicServiceQueryMessage(ranFunctions []*entities.RanFunction) RICServiceQueryMessage {
105 rand.Seed(time.Now().Unix())
107 txIE := RICServiceQueryIEs{
108 Id: ProtocolIE_ID_id_TransactionID,
109 Value: RICServiceQueryTransactionID{
110 TransactionID: strconv.FormatUint(rand.Uint64(), 10),
114 protocolIESingleContainer := make([]RicServiceQueryProtocolIESingleContainer, len(ranFunctions))
115 for i := 0; i < len(ranFunctions); i++ {
116 protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item
117 protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionId = ranFunctions[i].RanFunctionId
118 protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionRevision = ranFunctions[i].RanFunctionRevision
121 funcListIE := RICServiceQueryIEs{
122 Id: ProtocolIE_ID_id_RANfunctionsAccepted,
123 Value: RICServiceQueryRANFunctionIdList{
124 RANFunctionIdList: struct {
125 Text string `xml:",chardata"`
126 ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
128 ProtocolIESingleContainer: protocolIESingleContainer,
133 initiatingMessage := InitiatingMessage{
134 ProcedureCode: ProcedureCode_id_RICserviceQuery,
136 Text string `xml:",chardata"`
137 RICServiceQuery RICServiceQuery `xml:"RICserviceQuery"`
139 RICServiceQuery: RICServiceQuery{
140 ProtocolIEs: struct {
141 Text string `xml:",chardata"`
142 RICServiceQueryIEs []RICServiceQueryIEs `xml:"RICserviceQuery-IEs"`
144 RICServiceQueryIEs: []RICServiceQueryIEs{txIE, funcListIE},
150 return RICServiceQueryMessage{E2APPDU: RicServiceQueryE2APPDU{InitiatingMessage: initiatingMessage}}