+
+/*
+Adds specific static routes to the route table
+which cannot be calculated with endpoint tx/rx message types.
+*/
+func (r *Rpe) addStaticRoutes(eps rtmgr.Endpoints, rt *rtmgr.RouteTable) {
+ var uemanep, submanep *rtmgr.Endpoint
+ for _, ep := range eps {
+ if ep.Name == "UEMAN" {
+ uemanep = ep
+ }
+ if ep.Name == "SUBMAN" {
+ submanep = ep
+ }
+ }
+
+ if uemanep != nil && submanep != nil {
+ txlist := rtmgr.EndpointList{*uemanep}
+ rxlist := []rtmgr.EndpointList{[]rtmgr.Endpoint{*submanep}}
+ rte1 := rtmgr.RouteTableEntry{
+ rtmgr.MESSAGETYPES["RIC_SUB_REQ"],
+ txlist,
+ rxlist,
+ -1,
+ }
+ rte2 := rtmgr.RouteTableEntry{
+ rtmgr.MESSAGETYPES["RIC_SUB_DEL_REQ"],
+ txlist,
+ rxlist,
+ -1,
+ }
+ *rt = append(*rt, rte1)
+ *rt = append(*rt, rte2)
+ } else {
+ rtmgr.Logger.Warn("Cannot get the static route details of the platform components UEMAN/SUBMAN")
+ }
+}
+
+func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint {
+ for _, ep := range *eps {
+ if ep.Name == name {
+ rtmgr.Logger.Debug("name: %s", ep.Name)
+ rtmgr.Logger.Debug("ep: %v", ep)
+ return ep
+ }
+ }
+ return nil
+}
+
+func getEndpointByUuid(eps *rtmgr.Endpoints, uuid string) *rtmgr.Endpoint {
+ for _, ep := range *eps {
+ if ep.Uuid == uuid {
+ rtmgr.Logger.Debug("name: %s", ep.Uuid)
+ rtmgr.Logger.Debug("ep: %v", ep)
+ return ep
+ }
+ }
+ return nil
+}
+func (r *Rpe) addSubscriptionRoutes(eps rtmgr.Endpoints, rt *rtmgr.RouteTable, subs *rtmgr.SubscriptionList) {
+ rtmgr.Logger.Debug("rpe.addSubscriptionRoutes invoked")
+ rtmgr.Logger.Debug("params: %v", eps)
+ var e2termep, submanep, xappEp *rtmgr.Endpoint
+ var xappName string
+ e2termep = getEndpointByName(&eps, "E2TERM")
+ submanep = getEndpointByName(&eps, "SUBMAN")
+ if e2termep != nil && submanep != nil {
+ // looping through the subscription list, add routes one by one
+ for _, sub := range *subs {
+ // SubMan -> XApp
+ xappName = sub.Fqdn + ":" + strconv.Itoa(int(sub.Port))
+ xappEp = getEndpointByUuid(&eps, xappName)
+ if xappEp == nil {
+ rtmgr.Logger.Error("XApp not found: %s", xappName)
+ rtmgr.Logger.Debug("Endpoints: %v", eps)
+ } else {
+ txlist := rtmgr.EndpointList{*submanep}
+ rxlist := []rtmgr.EndpointList{[]rtmgr.Endpoint{*xappEp}}
+ subManMsgs := []string{"RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}
+ for _, entry := range subManMsgs {
+ rte := rtmgr.RouteTableEntry{
+ rtmgr.MESSAGETYPES[entry],
+ txlist,
+ rxlist,
+ sub.SubID,
+ }
+ *rt = append(*rt, rte)
+ }
+ // E2Term -> XApp
+ txlist = rtmgr.EndpointList{*e2termep}
+ rxlist = []rtmgr.EndpointList{[]rtmgr.Endpoint{*xappEp}}
+ e2apMsgs := []string{"RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE", "RIC_INDICATION"}
+ for _, entry := range e2apMsgs {
+ rte := rtmgr.RouteTableEntry{
+ rtmgr.MESSAGETYPES[entry],
+ txlist,
+ rxlist,
+ sub.SubID,
+ }
+ *rt = append(*rt, rte)
+ }
+ }
+ }
+ rtmgr.Logger.Debug("addSubscriptionRoutes eps: %v", eps)
+ } else {
+ rtmgr.Logger.Warn("Subscription route update failure: Cannot get the static route details of the platform components E2TERM/SUBMAN")
+ }
+
+}