+func getEndpointListByName(eps *rtmgr.Endpoints, name string) []rtmgr.Endpoint {
+ var eplist []rtmgr.Endpoint
+
+ for _, ep := range *eps {
+ if ep.Name == name {
+ xapp.Logger.Debug("name: %s", ep.Name)
+ xapp.Logger.Debug("ep: %v", ep)
+ eplist = append(eplist, *ep)
+ }
+ }
+ return eplist
+}
+
+func getEndpointByUuid(uuid string) *rtmgr.Endpoint {
+ endPoints := rtmgr.Eps
+ for _, ep := range endPoints {
+ if ep.Uuid == uuid {
+ xapp.Logger.Debug("name: %s", ep.Uuid)
+ xapp.Logger.Debug("ep: %v", ep)
+ return ep
+ }
+ }
+ return nil
+}
+
+func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32, routeType string) {
+ txList := rtmgr.EndpointList{}
+ rxList := []rtmgr.EndpointList{}
+
+ if tx == nil && rx == nil {
+ pc, _, _, ok := runtime.Caller(1)
+ details := runtime.FuncForPC(pc)
+ if ok && details != nil {
+ xapp.Logger.Error("Addition of route skipped due to either TX or RX endpoint not present. Caller function is %s", details.Name())
+ }
+ } else {
+ if tx != nil {
+ txList = rtmgr.EndpointList{*tx}
+ }
+ if rx != nil {
+ rxList = []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
+ }
+ //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+ messageId := rtmgr.Mtype[messageType]
+ route := rtmgr.RouteTableEntry{
+ MessageType: messageId,
+ TxList: txList,
+ RxGroups: rxList,
+ SubID: subId,
+ RouteType: routeType}
+ *routeTable = append(*routeTable, route)
+ // xapp.Logger.Debug("Route added: MessageType: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
+ // xapp.Logger.Trace("Route added: MessageType: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId)
+ }
+}
+
+func (r *Rpe) addRoute_rx_list(messageType string, tx *rtmgr.Endpoint, rx []rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32, routeType string) {
+ txList := rtmgr.EndpointList{}
+ rxList := []rtmgr.EndpointList{}
+
+ if tx != nil {
+ txList = rtmgr.EndpointList{*tx}
+ }
+
+ if rx != nil {
+ for _, item := range rx {
+ ep := []rtmgr.Endpoint{item}
+ rxList = append(rxList, ep)
+ }
+ }
+
+ //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+ messageId := rtmgr.Mtype[messageType]
+ route := rtmgr.RouteTableEntry{
+ MessageType: messageId,
+ TxList: txList,
+ RxGroups: rxList,
+ SubID: subId,
+ RouteType: routeType}
+ *routeTable = append(*routeTable, route)
+ // xapp.Logger.Debug("Route added: MessageType: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, SubId)
+ // xapp.Logger.Trace("Route added: MessageType: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, SubId)
+}
+
+func (r *Rpe) generateXappRoutes(xAppEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+ xapp.Logger.Debug("rpe.generateXappRoutes invoked")
+ xapp.Logger.Debug("Endpoint: %v, xAppType: %v", xAppEp.Name, xAppEp.XAppType)
+ if xAppEp.XAppType != sbi.PlatformType && (len(xAppEp.TxMessages) > 0 || len(xAppEp.RxMessages) > 0) {
+ /// TODO ---
+ //xApp -> Subscription Manager
+ r.addRoute("RIC_SUB_REQ", xAppEp, subManEp, routeTable, -1, "")
+ r.addRoute("RIC_SUB_DEL_REQ", xAppEp, subManEp, routeTable, -1, "")
+ //xApp -> E2 Termination
+ // r.addRoute("RIC_CONTROL_REQ", xAppEp, e2TermEp, routeTable, -1, "")
+ r.addRoute("RIC_CONTROL_REQ", xAppEp, nil, routeTable, -1, "%meid")
+ //E2 Termination -> xApp
+ /// r.addRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, -1, "")
+ /// r.addRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, -1, "")
+ r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, -1, "")
+ r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, -1, "")
+ }
+ //xApp->A1Mediator
+ if xAppEp.XAppType != sbi.PlatformType && len(xAppEp.Policies) > 0 {
+ xapp.Logger.Debug("rpe.generateXappRoutes found policies section")
+ for _, policy := range xAppEp.Policies {
+ r.addRoute("A1_POLICY_REQ", nil, xAppEp, routeTable, policy, "")
+ }
+ }
+
+}
+
+func (r *Rpe) generateXappToXappRoutes(RecvxAppEp *rtmgr.Endpoint, endPointList rtmgr.Endpoints, routeTable *rtmgr.RouteTable) {
+ xapp.Logger.Debug("rpe.generateXappToXappRoutes invoked")