+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("Route addition skipped: 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: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
+ // xapp.Logger.Trace("Route added: MessageTyp: %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: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
+ // xapp.Logger.Trace("Route added: MessageTyp: %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")
+
+ for _, rxmsg := range RecvxAppEp.RxMessages {
+
+ var src_present bool
+ identicalMsg := false
+ var RxGrp []rtmgr.Endpoint
+ xapp.Logger.Debug("RecvxAppEp.RxMessages Endpoint: %v, xAppType: %v and rxmsg: %v ", RecvxAppEp.Name, RecvxAppEp.XAppType, rxmsg)
+ 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" {
+ for _, SrcxAppEp := range endPointList {
+ if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.TxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name {
+ for _, txmsg := range SrcxAppEp.TxMessages {
+ if rxmsg == txmsg {
+ r.addRoute(rxmsg, SrcxAppEp, RecvxAppEp, routeTable, -1, "")
+ src_present = true
+ break
+ }
+ }
+ }
+ }
+ for _, SrcxAppEp := range endPointList {
+
+ if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.RxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name {
+ for _, newrxmsg := range SrcxAppEp.RxMessages {
+ if newrxmsg == rxmsg {
+ RxGrp = append(RxGrp, *SrcxAppEp)
+ identicalMsg = true
+ }
+ }
+ }
+ }
+ if src_present == false && identicalMsg == false {
+ xapp.Logger.Debug("Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp)
+ r.addRoute(rxmsg, nil, RecvxAppEp, routeTable, -1, "")
+ }
+ if identicalMsg == true {
+ xapp.Logger.Debug("Appending Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp)
+ RxGrp = append(RxGrp, *RecvxAppEp)
+ r.addRoute_rx_list(rxmsg, nil, RxGrp, routeTable, -1, "")
+ //return
+ }
+ }
+ }
+}
+
+func (r *Rpe) generateSubscriptionRoutes(selectedxAppEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+ xapp.Logger.Debug("rpe.addSubscriptionRoutes invoked")
+ subscriptionList := &rtmgr.Subs
+ for _, subscription := range *subscriptionList {
+ xapp.Logger.Debug("Subscription: %v", subscription)
+ xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port))
+ xapp.Logger.Debug("xApp UUID: %v", xAppUuid)
+ xAppEp := getEndpointByUuid(xAppUuid)
+ if xAppEp != nil {
+ if xAppEp.Uuid == selectedxAppEp.Uuid {
+ xapp.Logger.Debug("xApp UUID is matched for selected xApp.UUID: %v and xApp.Name: %v", selectedxAppEp.Uuid, selectedxAppEp.Name)
+ /// TODO
+ //Subscription Manager -> xApp
+ r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
+ r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
+ r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
+ r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
+ //E2 Termination -> xApp
+ r.addRoute("RIC_INDICATION", nil, xAppEp, routeTable, subscription.SubID, "")
+ r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, subscription.SubID, "")
+ r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, subscription.SubID, "")
+ }
+ } else {
+ xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid)