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. |
| 17 | ================================================================================== |
| 18 | */ |
| 19 | /* |
| 20 | Mnemonic: rpe.go |
| 21 | Abstract: Contains RPE (Route Policy Engine) module definitions and generic RPE components |
| 22 | Date: 16 March 2019 |
| 23 | */ |
| 24 | |
| 25 | package rpe |
| 26 | |
| 27 | import ( |
| 28 | "errors" |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 29 | "routing-manager/pkg/rtmgr" |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 30 | "routing-manager/pkg/sbi" |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 31 | "strconv" |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 32 | ) |
| 33 | |
| 34 | var ( |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 35 | SupportedRpes = []*EngineConfig{ |
| 36 | { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 37 | Name: "rmrpush", |
| 38 | Version: "pubsush", |
| 39 | Protocol: "rmruta", |
| 40 | Instance: NewRmrPush(), |
| 41 | IsAvailable: true, |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 42 | }, |
| 43 | } |
| 44 | ) |
| 45 | |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 46 | func GetRpe(rpeName string) (Engine, error) { |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 47 | for _, rpe := range SupportedRpes { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 48 | if rpe.Name == rpeName && rpe.IsAvailable { |
| 49 | return rpe.Instance, nil |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 52 | 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] | 53 | } |
| 54 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 55 | type Rpe struct { |
| 56 | } |
| 57 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 58 | func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint { |
| 59 | for _, ep := range *eps { |
| 60 | if ep.Name == name { |
| 61 | rtmgr.Logger.Debug("name: %s", ep.Name) |
| 62 | rtmgr.Logger.Debug("ep: %v", ep) |
| 63 | return ep |
| 64 | } |
| 65 | } |
| 66 | return nil |
| 67 | } |
| 68 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 69 | func getEndpointByUuid(uuid string) *rtmgr.Endpoint { |
| 70 | endPoints := rtmgr.Eps |
| 71 | for _, ep := range endPoints { |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 72 | if ep.Uuid == uuid { |
| 73 | rtmgr.Logger.Debug("name: %s", ep.Uuid) |
| 74 | rtmgr.Logger.Debug("ep: %v", ep) |
| 75 | return ep |
| 76 | } |
| 77 | } |
| 78 | return nil |
| 79 | } |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 80 | |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 81 | func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32) { |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 82 | txList := rtmgr.EndpointList{*tx} |
| 83 | rxList := []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}} |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 84 | messageId := rtmgr.MessageTypes[messageType] |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 85 | route := rtmgr.RouteTableEntry{ |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 86 | MessageType: messageId, |
| 87 | TxList: txList, |
| 88 | RxGroups: rxList, |
| 89 | SubID: subId} |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 90 | *routeTable = append(*routeTable, route) |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 91 | rtmgr.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId) |
| 92 | rtmgr.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 93 | } |
| 94 | |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 95 | func (r *Rpe) generateXappRoutes(xAppEp *rtmgr.Endpoint, e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 96 | rtmgr.Logger.Debug("rpe.generateXappRoutes invoked") |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 97 | rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", xAppEp.Name, xAppEp.XAppType) |
| 98 | if xAppEp.XAppType != sbi.PlatformType && len(xAppEp.TxMessages) > 0 && len(xAppEp.RxMessages) > 0 { |
| 99 | //xApp -> Subscription Manager |
| 100 | r.addRoute("RIC_SUB_REQ", xAppEp, subManEp, routeTable, -1) |
| 101 | r.addRoute("RIC_SUB_DEL_REQ", xAppEp, subManEp, routeTable, -1) |
| 102 | //xApp -> E2 Termination |
| 103 | r.addRoute("RIC_CONTROL_REQ", xAppEp, e2TermEp, routeTable, -1) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | func (r *Rpe) generateSubscriptionRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
| 108 | rtmgr.Logger.Debug("rpe.addSubscriptionRoutes invoked") |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 109 | subscriptionList := &rtmgr.Subs |
| 110 | for _, subscription := range *subscriptionList { |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 111 | rtmgr.Logger.Debug("Subscription: %v", subscription) |
| 112 | xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port)) |
| 113 | rtmgr.Logger.Debug("xApp UUID: %v", xAppUuid) |
| 114 | xAppEp := getEndpointByUuid(xAppUuid) |
| 115 | //Subscription Manager -> xApp |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 116 | r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID) |
| 117 | r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID) |
| 118 | r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID) |
| 119 | r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 120 | //E2 Termination -> xApp |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 121 | r.addRoute("RIC_INDICATION", e2TermEp, xAppEp, routeTable, subscription.SubID) |
| 122 | r.addRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, subscription.SubID) |
| 123 | r.addRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, subscription.SubID) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
| 127 | func (r *Rpe) generatePlatformRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, e2ManEp *rtmgr.Endpoint, ueManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) { |
| 128 | rtmgr.Logger.Debug("rpe.generatePlatformRoutes invoked") |
| 129 | //Platform Routes --- Subscription Routes |
| 130 | //Subscription Manager -> E2 Termination |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 131 | r.addRoute("RIC_SUB_REQ", subManEp, e2TermEp, routeTable, -1) |
| 132 | r.addRoute("RIC_SUB_DEL_REQ", subManEp, e2TermEp, routeTable, -1) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 133 | //E2 Termination -> Subscription Manager |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 134 | r.addRoute("RIC_SUB_RESP", e2TermEp, subManEp, routeTable, -1) |
| 135 | r.addRoute("RIC_SUB_DEL_RESP", e2TermEp, subManEp, routeTable, -1) |
| 136 | r.addRoute("RIC_SUB_FAILURE", e2TermEp, subManEp, routeTable, -1) |
| 137 | r.addRoute("RIC_SUB_DEL_FAILURE", e2TermEp, subManEp, routeTable, -1) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 138 | //TODO: UE Man Routes removed (since it is not existing) |
| 139 | //UE Manager -> Subscription Manager |
| 140 | //r.addRoute("RIC_SUB_REQ", ueManEp, subManEp, routeTable) |
| 141 | //r.addRoute("RIC_SUB_DEL_REQ", ueManEp, subManEp, routeTable) |
| 142 | ////UE Manager -> E2 Termination |
| 143 | //r.addRoute("RIC_CONTROL_REQ", ueManEp, e2TermEp, routeTable) |
| 144 | |
| 145 | //Platform Routes --- X2 Routes |
| 146 | //E2 Manager -> E2 Termination |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 147 | r.addRoute("RIC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable, -1) |
| 148 | r.addRoute("RIC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable, -1) |
| 149 | r.addRoute("RIC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable, -1) |
| 150 | r.addRoute("RIC_X2_RESET_RESP", e2ManEp, e2TermEp, routeTable, -1) |
| 151 | r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable, -1) |
| 152 | r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable, -1) |
| 153 | r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable, -1) |
zkoczka | 4d0e07a | 2019-10-15 15:05:57 +0200 | [diff] [blame^] | 154 | r.addRoute("RIC_SCTP_CLEAR_ALL", e2ManEp, e2TermEp, routeTable, -1) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 155 | //E2 Termination -> E2 Manager |
zkoczka | 4d0e07a | 2019-10-15 15:05:57 +0200 | [diff] [blame^] | 156 | r.addRoute("E2_TERM_INIT", e2TermEp, e2ManEp, routeTable, -1) |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 157 | r.addRoute("RIC_X2_SETUP_REQ", e2TermEp, e2ManEp, routeTable, -1) |
| 158 | r.addRoute("RIC_X2_SETUP_RESP", e2TermEp, e2ManEp, routeTable, -1) |
| 159 | r.addRoute("RIC_X2_RESET", e2TermEp, e2ManEp, routeTable, -1) |
| 160 | r.addRoute("RIC_X2_RESOURCE_STATUS_RESPONSE", e2TermEp, e2ManEp, routeTable, -1) |
| 161 | r.addRoute("RIC_X2_RESET_RESP", e2TermEp, e2ManEp, routeTable, -1) |
| 162 | r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable, -1) |
| 163 | r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable, -1) |
| 164 | r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable, -1) |
zkoczka | 4d0e07a | 2019-10-15 15:05:57 +0200 | [diff] [blame^] | 165 | r.addRoute("RIC_SCTP_CONNECTION_FAILURE", e2TermEp, e2ManEp, routeTable, -1) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable { |
| 169 | rtmgr.Logger.Debug("rpe.generateRouteTable invoked") |
| 170 | rtmgr.Logger.Debug("Endpoint List: %v", endPointList) |
| 171 | routeTable := &rtmgr.RouteTable{} |
| 172 | e2TermEp := getEndpointByName(&endPointList, "E2TERM") |
| 173 | if e2TermEp == nil { |
| 174 | rtmgr.Logger.Error("Platform component not found: %v", "E2 Termination") |
| 175 | rtmgr.Logger.Debug("Endpoints: %v", endPointList) |
| 176 | } |
| 177 | subManEp := getEndpointByName(&endPointList, "SUBMAN") |
| 178 | if subManEp == nil { |
| 179 | rtmgr.Logger.Error("Platform component not found: %v", "Subscription Manager") |
| 180 | rtmgr.Logger.Debug("Endpoints: %v", endPointList) |
| 181 | } |
| 182 | e2ManEp := getEndpointByName(&endPointList, "E2MAN") |
| 183 | if e2ManEp == nil { |
| 184 | rtmgr.Logger.Error("Platform component not found: %v", "E2 Manager") |
| 185 | rtmgr.Logger.Debug("Endpoints: %v", endPointList) |
| 186 | } |
| 187 | ueManEp := getEndpointByName(&endPointList, "UEMAN") |
| 188 | if ueManEp == nil { |
| 189 | rtmgr.Logger.Error("Platform component not found: %v", "UE Manger") |
| 190 | rtmgr.Logger.Debug("Endpoints: %v", endPointList) |
| 191 | } |
| 192 | r.generatePlatformRoutes(e2TermEp, subManEp, e2ManEp, ueManEp, routeTable) |
| 193 | |
| 194 | for _, endPoint := range endPointList { |
| 195 | rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType) |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 196 | if endPoint.XAppType != sbi.PlatformType && len(endPoint.TxMessages) > 0 && len(endPoint.RxMessages) > 0 { |
| 197 | r.generateXappRoutes(endPoint, e2TermEp, subManEp, routeTable) |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 198 | r.generateSubscriptionRoutes(e2TermEp, subManEp, routeTable) |
| 199 | } |
| 200 | } |
| 201 | return routeTable |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 202 | } |