Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 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. |
wahidw | 761934a | 2019-11-27 06:07:26 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 20 | platform project (RICP). |
| 21 | |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 22 | ================================================================================== |
| 23 | */ |
| 24 | /* |
| 25 | Mnemonic: rpe.go |
| 26 | Abstract: Contains RPE (Route Policy Engine) module definitions and generic RPE components |
| 27 | Date: 16 March 2019 |
| 28 | */ |
| 29 | |
| 30 | package rpe |
| 31 | |
| 32 | import ( |
| 33 | "errors" |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 34 | "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 35 | "routing-manager/pkg/models" |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 36 | "routing-manager/pkg/rtmgr" |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 37 | "routing-manager/pkg/sbi" |
prabhukaliswamy | b47d12d | 2019-12-03 15:06:30 +0000 | [diff] [blame] | 38 | "runtime" |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 39 | "strconv" |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 40 | ) |
| 41 | |
| 42 | var ( |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 43 | SupportedRpes = []*EngineConfig{ |
| 44 | { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 45 | Name: "rmrpush", |
| 46 | Version: "pubsush", |
| 47 | Protocol: "rmruta", |
| 48 | Instance: NewRmrPush(), |
| 49 | IsAvailable: true, |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 50 | }, |
| 51 | } |
| 52 | ) |
| 53 | |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 54 | func GetRpe(rpeName string) (Engine, error) { |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 55 | for _, rpe := range SupportedRpes { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 56 | if rpe.Name == rpeName && rpe.IsAvailable { |
| 57 | return rpe.Instance, nil |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 58 | } |
| 59 | } |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 60 | return nil, errors.New("SBI:" + rpeName + " is not supported or still not a available") |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 61 | } |
| 62 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 63 | type Rpe struct { |
| 64 | } |
| 65 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 66 | func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint { |
| 67 | for _, ep := range *eps { |
| 68 | if ep.Name == name { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 69 | xapp.Logger.Debug("name: %s", ep.Name) |
| 70 | xapp.Logger.Debug("ep: %v", ep) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 71 | return ep |
| 72 | } |
| 73 | } |
| 74 | return nil |
| 75 | } |
| 76 | |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 77 | func getEndpointListByName(eps *rtmgr.Endpoints, name string) []rtmgr.Endpoint { |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 78 | var eplist []rtmgr.Endpoint |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 79 | |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 80 | for _, ep := range *eps { |
| 81 | if ep.Name == name { |
| 82 | xapp.Logger.Debug("name: %s", ep.Name) |
| 83 | xapp.Logger.Debug("ep: %v", ep) |
| 84 | eplist = append(eplist, *ep) |
| 85 | } |
| 86 | } |
| 87 | return eplist |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 88 | } |
| 89 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 90 | func getEndpointByUuid(uuid string) *rtmgr.Endpoint { |
| 91 | endPoints := rtmgr.Eps |
| 92 | for _, ep := range endPoints { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 93 | if ep.Uuid == uuid { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 94 | xapp.Logger.Debug("name: %s", ep.Uuid) |
| 95 | xapp.Logger.Debug("ep: %v", ep) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 96 | return ep |
| 97 | } |
| 98 | } |
| 99 | return nil |
| 100 | } |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 101 | |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 102 | func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32, routeType string) { |
| 103 | txList := rtmgr.EndpointList{} |
| 104 | rxList := []rtmgr.EndpointList{} |
| 105 | |
| 106 | if tx == nil && rx == nil { |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 107 | pc, _, _, ok := runtime.Caller(1) |
| 108 | details := runtime.FuncForPC(pc) |
| 109 | if ok && details != nil { |
| 110 | xapp.Logger.Error("Route addition skipped: Either TX or RX endpoint not present. Caller function is %s", details.Name()) |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 111 | } |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 112 | } else { |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 113 | if tx != nil { |
| 114 | txList = rtmgr.EndpointList{*tx} |
| 115 | } |
| 116 | if rx != nil { |
| 117 | rxList = []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}} |
| 118 | } |
wahidw | bce6747 | 2020-06-15 13:52:55 +0000 | [diff] [blame] | 119 | //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType]) |
| 120 | messageId := rtmgr.Mtype[messageType] |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 121 | route := rtmgr.RouteTableEntry{ |
| 122 | MessageType: messageId, |
| 123 | TxList: txList, |
| 124 | RxGroups: rxList, |
| 125 | SubID: subId, |
| 126 | RouteType: routeType} |
| 127 | *routeTable = append(*routeTable, route) |
| 128 | // xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId) |
| 129 | // xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId) |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 130 | } |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 131 | } |
| 132 | |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 133 | func (r *Rpe) addRoute_rx_list(messageType string, tx *rtmgr.Endpoint, rx []rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32, routeType string) { |
| 134 | txList := rtmgr.EndpointList{} |
| 135 | rxList := []rtmgr.EndpointList{} |
| 136 | |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 137 | if tx != nil { |
| 138 | txList = rtmgr.EndpointList{*tx} |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 139 | } |
| 140 | |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 141 | if rx != nil { |
wahidw | 6977ffd | 2020-02-08 19:00:02 +0000 | [diff] [blame] | 142 | for _, item := range rx { |
| 143 | ep := []rtmgr.Endpoint{item} |
| 144 | rxList = append(rxList, ep) |
| 145 | } |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 146 | } |
| 147 | |
wahidw | bce6747 | 2020-06-15 13:52:55 +0000 | [diff] [blame] | 148 | //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType]) |
| 149 | messageId := rtmgr.Mtype[messageType] |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 150 | route := rtmgr.RouteTableEntry{ |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 151 | MessageType: messageId, |
| 152 | TxList: txList, |
| 153 | RxGroups: rxList, |
| 154 | SubID: subId, |
| 155 | RouteType: routeType} |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 156 | *routeTable = append(*routeTable, route) |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 157 | // xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId) |
| 158 | // xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId) |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 159 | } |
| 160 | |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 161 | func (r *Rpe) generateXappRoutes(xAppEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 162 | xapp.Logger.Debug("rpe.generateXappRoutes invoked") |
| 163 | xapp.Logger.Debug("Endpoint: %v, xAppType: %v", xAppEp.Name, xAppEp.XAppType) |
| 164 | if xAppEp.XAppType != sbi.PlatformType && (len(xAppEp.TxMessages) > 0 || len(xAppEp.RxMessages) > 0) { |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 165 | /// TODO --- |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 166 | //xApp -> Subscription Manager |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 167 | r.addRoute("RIC_SUB_REQ", xAppEp, subManEp, routeTable, -1, "") |
| 168 | r.addRoute("RIC_SUB_DEL_REQ", xAppEp, subManEp, routeTable, -1, "") |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 169 | //xApp -> E2 Termination |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 170 | // r.addRoute("RIC_CONTROL_REQ", xAppEp, e2TermEp, routeTable, -1, "") |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 171 | r.addRoute("RIC_CONTROL_REQ", xAppEp, nil, routeTable, -1, "%meid") |
zkoczka | b95b076 | 2019-10-29 13:05:48 +0100 | [diff] [blame] | 172 | //E2 Termination -> xApp |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 173 | /// r.addRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, -1, "") |
| 174 | /// r.addRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, -1, "") |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 175 | r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, -1, "") |
| 176 | r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, -1, "") |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 177 | } |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 178 | //xApp->A1Mediator |
| 179 | if xAppEp.XAppType != sbi.PlatformType && len(xAppEp.Policies) > 0 { |
| 180 | xapp.Logger.Debug("rpe.generateXappRoutes found policies section") |
| 181 | for _, policy := range xAppEp.Policies { |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 182 | r.addRoute("A1_POLICY_REQ", nil, xAppEp, routeTable, policy, "") |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 186 | } |
| 187 | |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 188 | func (r *Rpe) generateXappToXappRoutes(RecvxAppEp *rtmgr.Endpoint, endPointList rtmgr.Endpoints, routeTable *rtmgr.RouteTable) { |
| 189 | xapp.Logger.Debug("rpe.generateXappToXappRoutes invoked") |
| 190 | |
| 191 | for _, rxmsg := range RecvxAppEp.RxMessages { |
| 192 | |
| 193 | var src_present bool |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 194 | identicalMsg := false |
| 195 | var RxGrp []rtmgr.Endpoint |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 196 | xapp.Logger.Debug("RecvxAppEp.RxMessages Endpoint: %v, xAppType: %v and rxmsg: %v ", RecvxAppEp.Name, RecvxAppEp.XAppType, rxmsg) |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 197 | if rxmsg != "RIC_SUB_RESP" && rxmsg != "RIC_SUB_FAILURE" && rxmsg != "RIC_SUB_DEL_RESP" && rxmsg != "RIC_SUB_DEL_FAILURE" && rxmsg != "RIC_INDICATION" && rxmsg != "RIC_CONTROL_ACK" && rxmsg != "RIC_CONTROL_FAILURE" && rxmsg != "A1_POLICY_REQ" { |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 198 | for _, SrcxAppEp := range endPointList { |
| 199 | if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.TxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name { |
| 200 | for _, txmsg := range SrcxAppEp.TxMessages { |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 201 | if rxmsg == txmsg { |
| 202 | r.addRoute(rxmsg, SrcxAppEp, RecvxAppEp, routeTable, -1, "") |
| 203 | src_present = true |
| 204 | break |
| 205 | } |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | } |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 209 | for _, SrcxAppEp := range endPointList { |
| 210 | |
| 211 | if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.RxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name { |
| 212 | for _, newrxmsg := range SrcxAppEp.RxMessages { |
| 213 | if newrxmsg == rxmsg { |
| 214 | RxGrp = append(RxGrp, *SrcxAppEp) |
| 215 | identicalMsg = true |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | if src_present == false && identicalMsg == false { |
| 221 | xapp.Logger.Debug("Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp) |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 222 | r.addRoute(rxmsg, nil, RecvxAppEp, routeTable, -1, "") |
| 223 | } |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 224 | if identicalMsg == true { |
| 225 | xapp.Logger.Debug("Appending Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp) |
| 226 | RxGrp = append(RxGrp, *RecvxAppEp) |
| 227 | r.addRoute_rx_list(rxmsg, nil, RxGrp, routeTable, -1, "") |
wahidw | eac0560 | 2020-11-11 08:43:37 +0000 | [diff] [blame] | 228 | //return |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 229 | } |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 230 | } |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 234 | func (r *Rpe) generateSubscriptionRoutes(selectedxAppEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 235 | xapp.Logger.Debug("rpe.addSubscriptionRoutes invoked") |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 236 | subscriptionList := &rtmgr.Subs |
| 237 | for _, subscription := range *subscriptionList { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 238 | xapp.Logger.Debug("Subscription: %v", subscription) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 239 | xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port)) |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 240 | xapp.Logger.Debug("xApp UUID: %v", xAppUuid) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 241 | xAppEp := getEndpointByUuid(xAppUuid) |
rangajal | d14518e | 2020-04-21 12:33:37 +0000 | [diff] [blame] | 242 | if xAppEp != nil { |
| 243 | if xAppEp.Uuid == selectedxAppEp.Uuid { |
| 244 | xapp.Logger.Debug("xApp UUID is matched for selected xApp.UUID: %v and xApp.Name: %v", selectedxAppEp.Uuid, selectedxAppEp.Name) |
| 245 | /// TODO |
| 246 | //Subscription Manager -> xApp |
| 247 | r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "") |
| 248 | r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "") |
| 249 | r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "") |
| 250 | r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "") |
| 251 | //E2 Termination -> xApp |
| 252 | r.addRoute("RIC_INDICATION", nil, xAppEp, routeTable, subscription.SubID, "") |
| 253 | r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, subscription.SubID, "") |
| 254 | r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, subscription.SubID, "") |
| 255 | } |
| 256 | } else { |
wahidw | bceb7d4 | 2020-10-20 16:21:52 +0000 | [diff] [blame] | 257 | xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid) |
prabhukaliswamy | b47d12d | 2019-12-03 15:06:30 +0000 | [diff] [blame] | 258 | } |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 262 | func (r *Rpe) generatePartialSubscriptionTable(xappSubData *models.XappSubscriptionData, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
| 263 | xapp.Logger.Debug("rpe.addSingleSubscriptionRoutes invoked") |
| 264 | xAppUuid := *xappSubData.Address + ":" + strconv.Itoa(int(*xappSubData.Port)) |
| 265 | xapp.Logger.Debug("xApp UUID: %v", xAppUuid) |
| 266 | xAppEp := getEndpointByUuid(xAppUuid) |
| 267 | if xAppEp != nil { |
| 268 | //Subscription Manager -> xApp |
| 269 | r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 270 | r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 271 | r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 272 | r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 273 | //E2 Termination -> xApp |
| 274 | r.addRoute("RIC_INDICATION", nil, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 275 | r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 276 | r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, *xappSubData.SubscriptionID, "") |
| 277 | } else { |
| 278 | xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid) |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | func (r *Rpe) generatePlatformRoutes(e2TermEp []rtmgr.Endpoint, subManEp *rtmgr.Endpoint, e2ManEp *rtmgr.Endpoint, a1mediatorEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 283 | xapp.Logger.Debug("rpe.generatePlatformRoutes invoked") |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 284 | //Platform Routes --- Subscription Routes |
| 285 | //Subscription Manager -> E2 Termination |
wahidw | 8f7ca65 | 2020-07-08 18:59:53 +0530 | [diff] [blame] | 286 | if rtmgr.PrsCfg == nil { |
| 287 | xapp.Logger.Info("No static routes configuration") |
| 288 | return |
| 289 | } |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 290 | for _, routes := range *rtmgr.PrsCfg { |
| 291 | var sendEp *rtmgr.Endpoint |
| 292 | var Ep *rtmgr.Endpoint |
| 293 | switch routes.SenderEndPoint { |
| 294 | case "SUBMAN": |
| 295 | sendEp = subManEp |
| 296 | case "E2MAN": |
| 297 | sendEp = e2ManEp |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 298 | //case "RSM":, |
| 299 | // sendEp = rsmEp |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 300 | case "A1MEDIATOR": |
| 301 | sendEp = a1mediatorEp |
| 302 | } |
| 303 | switch routes.EndPoint { |
| 304 | case "SUBMAN": |
| 305 | Ep = subManEp |
| 306 | case "E2MAN": |
| 307 | Ep = e2ManEp |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 308 | //case "UEMAN": |
| 309 | // Ep = ueManEp |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 310 | //case "RSM": |
| 311 | // Ep = rsmEp |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 312 | case "A1MEDIATOR": |
| 313 | Ep = a1mediatorEp |
| 314 | } |
rangajal | 6d20904 | 2020-01-08 12:18:39 +0000 | [diff] [blame] | 315 | |
wahidw | da0fd3a | 2020-01-01 04:28:41 +0000 | [diff] [blame] | 316 | r.addRoute(routes.MessageType, sendEp, Ep, routeTable, routes.SubscriptionId, routes.Meid) |
| 317 | } |
rangajal | 6d20904 | 2020-01-08 12:18:39 +0000 | [diff] [blame] | 318 | |
| 319 | if len(e2TermEp) > 0 { |
| 320 | r.addRoute_rx_list("RIC_SCTP_CLEAR_ALL", e2ManEp, e2TermEp, routeTable, -1, "") |
| 321 | r.addRoute_rx_list("E2_TERM_KEEP_ALIVE_REQ", e2ManEp, e2TermEp, routeTable, -1, "") |
wahidw | dd6b056 | 2020-03-31 03:09:45 +0000 | [diff] [blame] | 322 | r.addRoute_rx_list("RIC_E2_SETUP_RESP", e2ManEp, e2TermEp, routeTable, -1, "") |
| 323 | r.addRoute_rx_list("RIC_E2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable, -1, "") |
rangajal | 6d20904 | 2020-01-08 12:18:39 +0000 | [diff] [blame] | 324 | } |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 325 | } |
| 326 | |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 327 | func (r *Rpe) generatePartialRouteTable(endPointList rtmgr.Endpoints, xappSubData *models.XappSubscriptionData, updatetype rtmgr.RMRUpdateType) *rtmgr.RouteTable { |
| 328 | xapp.Logger.Debug("rpe.generatePartialRouteTable invoked") |
| 329 | xapp.Logger.Debug("Endpoint List: %v", endPointList) |
| 330 | routeTable := &rtmgr.RouteTable{} |
| 331 | subManEp := getEndpointByName(&endPointList, "SUBMAN") |
| 332 | if subManEp == nil { |
| 333 | xapp.Logger.Error("Platform component not found: %v", "Subscription Manager") |
| 334 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
| 335 | } |
| 336 | /*e2TermListEp := getEndpointListByName(&endPointList, "E2TERMINST") |
| 337 | if len(e2TermListEp) == 0 { |
| 338 | xapp.Logger.Error("Platform component not found: %v", "E2 Termination List") |
| 339 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
| 340 | } |
| 341 | e2ManEp := getEndpointByName(&endPointList, "E2MAN") |
| 342 | if e2ManEp == nil { |
| 343 | xapp.Logger.Error("Platform component not found: %v", "E2 Manager") |
| 344 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
| 345 | }*/ |
| 346 | |
| 347 | if xappSubData != nil && updatetype == rtmgr.SubsType { |
| 348 | xapp.Logger.Info("Updating partial subscription routes") |
| 349 | r.generatePartialSubscriptionTable(xappSubData, subManEp, routeTable) |
| 350 | } |
| 351 | /*if updatetype == rtmgr.XappType { |
| 352 | xapp.Logger.Info("Updating partial xapp routes") |
| 353 | for _, endPoint := range endPointList { |
| 354 | xapp.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType) |
| 355 | if endPoint.XAppType != sbi.PlatformType && (len(endPoint.TxMessages) > 0 || len(endPoint.RxMessages) > 0) { |
| 356 | r.generateXappRoutes(endPoint, subManEp, routeTable) |
| 357 | r.generateXappToXappRoutes(endPoint, endPointList, routeTable) |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | if updatetype == rtmgr.E2Type { |
| 362 | xapp.Logger.Info("Updating partial E2 routes") |
| 363 | if len(e2TermListEp) > 0 { |
| 364 | r.addRoute_rx_list("RIC_SCTP_CLEAR_ALL", e2ManEp, e2TermListEp, routeTable, -1, "") |
| 365 | r.addRoute_rx_list("E2_TERM_KEEP_ALIVE_REQ", e2ManEp, e2TermListEp, routeTable, -1, "") |
| 366 | r.addRoute_rx_list("RIC_E2_SETUP_RESP", e2ManEp, e2TermListEp, routeTable, -1, "") |
| 367 | r.addRoute_rx_list("RIC_E2_SETUP_FAILURE", e2ManEp, e2TermListEp, routeTable, -1, "") |
| 368 | } |
| 369 | }*/ |
| 370 | |
| 371 | return routeTable |
| 372 | |
| 373 | } |
| 374 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 375 | func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 376 | xapp.Logger.Debug("rpe.generateRouteTable invoked") |
| 377 | xapp.Logger.Debug("Endpoint List: %v", endPointList) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 378 | routeTable := &rtmgr.RouteTable{} |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 379 | /*e2TermEp := getEndpointByName(&endPointList, "E2TERM") |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 380 | if e2TermEp == nil { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 381 | xapp.Logger.Error("Platform component not found: %v", "E2 Termination") |
| 382 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 383 | }*/ |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 384 | subManEp := getEndpointByName(&endPointList, "SUBMAN") |
| 385 | if subManEp == nil { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 386 | xapp.Logger.Error("Platform component not found: %v", "Subscription Manager") |
| 387 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 388 | } |
| 389 | e2ManEp := getEndpointByName(&endPointList, "E2MAN") |
| 390 | if e2ManEp == nil { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 391 | xapp.Logger.Error("Platform component not found: %v", "E2 Manager") |
| 392 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 393 | } |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 394 | /*rsmEp := getEndpointByName(&endPointList, "RSM") |
prabhukaliswamy | be9f268 | 2019-11-22 07:24:09 +0000 | [diff] [blame] | 395 | if rsmEp == nil { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 396 | xapp.Logger.Error("Platform component not found: %v", "Resource Status Manager") |
| 397 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 398 | }*/ |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 399 | A1MediatorEp := getEndpointByName(&endPointList, "A1MEDIATOR") |
| 400 | if A1MediatorEp == nil { |
| 401 | xapp.Logger.Error("Platform component not found: %v", "A1Mediator") |
| 402 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
| 403 | } |
| 404 | |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 405 | e2TermListEp := getEndpointListByName(&endPointList, "E2TERMINST") |
| 406 | if len(e2TermListEp) == 0 { |
| 407 | xapp.Logger.Error("Platform component not found: %v", "E2 Termination List") |
| 408 | xapp.Logger.Debug("Endpoints: %v", endPointList) |
| 409 | } |
wahidw | 505e249 | 2021-05-11 10:53:43 +0000 | [diff] [blame^] | 410 | r.generatePlatformRoutes(e2TermListEp, subManEp, e2ManEp, A1MediatorEp, routeTable) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 411 | |
| 412 | for _, endPoint := range endPointList { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 413 | xapp.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType) |
| 414 | if endPoint.XAppType != sbi.PlatformType && (len(endPoint.TxMessages) > 0 || len(endPoint.RxMessages) > 0) { |
wahidw | cd7867c | 2020-02-05 10:01:12 +0000 | [diff] [blame] | 415 | r.generateXappRoutes(endPoint, subManEp, routeTable) |
| 416 | r.generateSubscriptionRoutes(endPoint, subManEp, routeTable) |
rangajal | 0baa70d | 2020-03-31 12:28:53 +0000 | [diff] [blame] | 417 | r.generateXappToXappRoutes(endPoint, endPointList, routeTable) |
| 418 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 419 | } |
| 420 | } |
| 421 | return routeTable |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 422 | } |