2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
21 Abstract: Contains RPE (Route Policy Engine) module definitions and generic RPE components
29 "routing-manager/pkg/rtmgr"
30 "routing-manager/pkg/sbi"
35 SupportedRpes = []*RpeEngineConfig{
40 Instance: NewRmrPush(),
46 func GetRpe(rpeName string) (RpeEngine, error) {
47 for _, rpe := range SupportedRpes {
48 if rpe.Name == rpeName && rpe.IsAvailable {
49 return rpe.Instance, nil
52 return nil, errors.New("SBI:" + rpeName + " is not supported or still not a available")
58 func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint {
59 for _, ep := range *eps {
61 rtmgr.Logger.Debug("name: %s", ep.Name)
62 rtmgr.Logger.Debug("ep: %v", ep)
69 func getEndpointByUuid(uuid string) *rtmgr.Endpoint {
70 endPoints := rtmgr.Eps
71 for _, ep := range endPoints {
73 rtmgr.Logger.Debug("name: %s", ep.Uuid)
74 rtmgr.Logger.Debug("ep: %v", ep)
81 func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
82 txList := rtmgr.EndpointList{*tx}
83 rxList := []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
84 messageId := rtmgr.MESSAGETYPES[messageType]
85 route := rtmgr.RouteTableEntry{
90 *routeTable = append(*routeTable, route)
91 rtmgr.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: -1", messageId, txList, rxList)
94 func (r *Rpe) addSubscriptionRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32) {
95 txList := rtmgr.EndpointList{*tx}
96 rxList := []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
97 messageId := rtmgr.MESSAGETYPES[messageType]
98 route := rtmgr.RouteTableEntry{
104 *routeTable = append(*routeTable, route)
105 rtmgr.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, txList, rxList, subId)
108 func (r *Rpe) generateXappRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
109 rtmgr.Logger.Debug("rpe.generateXappRoutes invoked")
110 endPointList := rtmgr.Eps
111 for _, endPoint := range endPointList {
112 rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType)
113 if endPoint.XAppType != sbi.PLATFORMTYPE && len(endPoint.TxMessages) > 0 && len(endPoint.RxMessages) > 0 {
114 //xApp -> Subscription Manager
115 r.addRoute("RIC_SUB_REQ", endPoint, subManEp, routeTable)
116 r.addRoute("RIC_SUB_DEL_REQ", endPoint, subManEp, routeTable)
117 //xApp -> E2 Termination
118 r.addRoute("RIC_CONTROL_REQ", endPoint, e2TermEp, routeTable)
123 func (r *Rpe) generateSubscriptionRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
124 rtmgr.Logger.Debug("rpe.addSubscriptionRoutes invoked")
125 subscriptionList := rtmgr.Subs
126 for _, subscription := range subscriptionList {
127 rtmgr.Logger.Debug("Subscription: %v", subscription)
128 xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port))
129 rtmgr.Logger.Debug("xApp UUID: %v", xAppUuid)
130 xAppEp := getEndpointByUuid(xAppUuid)
131 //Subscription Manager -> xApp
132 r.addSubscriptionRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID)
133 r.addSubscriptionRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID)
134 r.addSubscriptionRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID)
135 r.addSubscriptionRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID)
136 //E2 Termination -> xApp
137 r.addSubscriptionRoute("RIC_INDICATION", e2TermEp, xAppEp, routeTable, subscription.SubID)
138 r.addSubscriptionRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, subscription.SubID)
139 r.addSubscriptionRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, subscription.SubID)
143 func (r *Rpe) generatePlatformRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, e2ManEp *rtmgr.Endpoint, ueManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
144 rtmgr.Logger.Debug("rpe.generatePlatformRoutes invoked")
145 //Platform Routes --- Subscription Routes
146 //Subscription Manager -> E2 Termination
147 r.addRoute("RIC_SUB_REQ", subManEp, e2TermEp, routeTable)
148 r.addRoute("RIC_SUB_DEL_REQ", subManEp, e2TermEp, routeTable)
149 //E2 Termination -> Subscription Manager
150 r.addRoute("RIC_SUB_RESP", e2TermEp, subManEp, routeTable)
151 r.addRoute("RIC_SUB_DEL_RESP", e2TermEp, subManEp, routeTable)
152 r.addRoute("RIC_SUB_FAILURE", e2TermEp, subManEp, routeTable)
153 r.addRoute("RIC_SUB_DEL_FAILURE", e2TermEp, subManEp, routeTable)
154 //TODO: UE Man Routes removed (since it is not existing)
155 //UE Manager -> Subscription Manager
156 //r.addRoute("RIC_SUB_REQ", ueManEp, subManEp, routeTable)
157 //r.addRoute("RIC_SUB_DEL_REQ", ueManEp, subManEp, routeTable)
158 ////UE Manager -> E2 Termination
159 //r.addRoute("RIC_CONTROL_REQ", ueManEp, e2TermEp, routeTable)
161 //Platform Routes --- X2 Routes
162 //E2 Manager -> E2 Termination
163 r.addRoute("RIC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
164 r.addRoute("RIC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
165 r.addRoute("RIC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
166 r.addRoute("RIC_X2_RESET_RESP", e2ManEp, e2TermEp, routeTable)
167 r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
168 r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
169 r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
170 //E2 Termination -> E2 Manager
171 r.addRoute("RIC_X2_SETUP_REQ", e2TermEp, e2ManEp, routeTable)
172 r.addRoute("RIC_X2_SETUP_RESP", e2TermEp, e2ManEp, routeTable)
173 r.addRoute("RIC_X2_RESET", e2TermEp, e2ManEp, routeTable)
174 r.addRoute("RIC_X2_RESOURCE_STATUS_RESPONSE", e2TermEp, e2ManEp, routeTable)
175 r.addRoute("RIC_X2_RESET_RESP", e2TermEp, e2ManEp, routeTable)
176 r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
177 r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
178 r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
181 func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable {
182 rtmgr.Logger.Debug("rpe.generateRouteTable invoked")
183 rtmgr.Logger.Debug("Endpoint List: %v", endPointList)
184 routeTable := &rtmgr.RouteTable{}
185 e2TermEp := getEndpointByName(&endPointList, "E2TERM")
187 rtmgr.Logger.Error("Platform component not found: %v", "E2 Termination")
188 rtmgr.Logger.Debug("Endpoints: %v", endPointList)
190 subManEp := getEndpointByName(&endPointList, "SUBMAN")
192 rtmgr.Logger.Error("Platform component not found: %v", "Subscription Manager")
193 rtmgr.Logger.Debug("Endpoints: %v", endPointList)
195 e2ManEp := getEndpointByName(&endPointList, "E2MAN")
197 rtmgr.Logger.Error("Platform component not found: %v", "E2 Manager")
198 rtmgr.Logger.Debug("Endpoints: %v", endPointList)
200 ueManEp := getEndpointByName(&endPointList, "UEMAN")
202 rtmgr.Logger.Error("Platform component not found: %v", "UE Manger")
203 rtmgr.Logger.Debug("Endpoints: %v", endPointList)
205 r.generatePlatformRoutes(e2TermEp, subManEp, e2ManEp, ueManEp, routeTable)
207 for _, endPoint := range endPointList {
208 rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType)
209 if endPoint.XAppType != sbi.PLATFORMTYPE && len(endPoint.TxMessages) > 0 && len(endPoint.RxMessages) > 0 {
210 r.generateXappRoutes(e2TermEp, subManEp, routeTable)
211 r.generateSubscriptionRoutes(e2TermEp, subManEp, routeTable)