Replace deprecated SDL APIs
[ric-plt/rtmgr.git] / pkg / rtmgr / types.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17
18    This source code is part of the near-RT RIC (RAN Intelligent Controller)
19    platform project (RICP).
20
21 ==================================================================================
22 */
23 /*
24   Mnemonic:     rtmgr/types.go
25   Abstract:     Contains RTMGR (Routing Manager) specific types
26   Date:         12 March 2019
27 */
28
29 package rtmgr
30
31 type RMRUpdateType int
32
33 const (
34         XappType = iota
35         SubsType
36         E2Type
37 )
38
39 type XApps struct {
40         XAppList []XApp
41 }
42
43 type RouteTable []RouteTableEntry
44 type EndpointList []Endpoint
45
46 type Endpoints map[string]*Endpoint
47
48 type SubscriptionList []Subscription
49
50 type MessageTypeList map[string]string
51
52 type ProcessMultipleRMR map[string]int
53
54 //TODO: uuid is not a real UUID but a string of "ip:port"
55 // this should be changed to real UUID later on which should come from xApp Manager // petszila
56 type Endpoint struct {
57         Uuid       string
58         Name       string
59         XAppType   string
60         Ip         string
61         Port       uint16
62         TxMessages []string
63         RxMessages []string
64         Policies   []int32
65         Socket     interface{}
66         IsReady    bool
67         Keepalive  bool
68         Whid       int
69 }
70
71 type RouteTableEntry struct {
72         MessageType string
73         TxList      EndpointList
74         RxGroups    []EndpointList
75         SubID       int32
76         RouteType   string
77 }
78
79 type XApp struct {
80         Name      string         `json:"name"`
81         Status    string         `json:"status"`
82         Version   string         `json:"version"`
83         Instances []XAppInstance `json:"instances"`
84 }
85
86 type XAppInstance struct {
87         Name       string   `json:"name"`
88         Status     string   `json:"status"`
89         Ip         string   `json:"ip"`
90         Port       uint16   `json:"port"`
91         TxMessages []string `json:"txMessages"`
92         RxMessages []string `json:"rxMessages"`
93         Policies   []int32  `json:"policies"`
94 }
95
96 type PlatformComponents []struct {
97         Name string `json:"name"`
98         Fqdn string `json:"fqdn"`
99         Port uint16 `json:"port"`
100 }
101
102 type E2TInstance struct {
103         Name    string   `json:"name"`
104         Fqdn    string   `json:"fqdn"`
105         Ranlist []string `json:"ranlist"`
106 }
107
108 type E2tIdentity struct {
109         E2taddress string   `json:"e2tAddress"`
110         Rannames   []string `json:"ranNames"`
111 }
112
113 type ConfigRtmgr struct {
114         Pcs PlatformComponents `json:"PlatformComponents"`
115 }
116
117 type MessageTypeIdentifier struct {
118         Mit []string `json:"messagetypes"`
119 }
120
121 type RicComponents struct {
122         XApps   []XApp
123         E2Ts    map[string]E2TInstance
124         MeidMap []string
125         Pcs     PlatformComponents
126 }
127
128 type Subscription struct {
129         SubID int32
130         Fqdn  string
131         Port  uint16
132 }
133
134 type PlatformRoutes []struct {
135         MessageType    string `json:"messagetype"`
136         SenderEndPoint string `json:"senderendpoint"`
137         SubscriptionId int32  `json:"subscriptionid"`
138         EndPoint       string `json:"endpoint"`
139         Meid           string `json:"meid"`
140 }
141
142 type RtmgrRoutes struct {
143         Prs PlatformRoutes `json:"PlatformRoutes"`
144 }
145
146 type FqDn struct {
147         Address *string
148         Port    *uint16
149 }
150
151 type XappList struct {
152         SubscriptionID uint16
153         FqdnList       []FqDn
154 }
155
156 var (
157         Rtmgr_ready bool
158 )
159
160 //To encapsulate routing-manager's keys under their own namespace in a DB
161 const RTMGR_SDL_NS string = "rtmgr"