X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fnbi%2Fcontrol.go;h=0ab3f069e3a055033ee10d536fb23ee93c8b52d5;hb=refs%2Fchanges%2F35%2F4535%2F1;hp=5483abac38609a3c15e29ea20009fc24b9c62256;hpb=2c131acf0418c45d9045a6a81baf3e7d047fcb38;p=ric-plt%2Frtmgr.git diff --git a/pkg/nbi/control.go b/pkg/nbi/control.go index 5483aba..0ab3f06 100644 --- a/pkg/nbi/control.go +++ b/pkg/nbi/control.go @@ -35,6 +35,7 @@ import ( "sync" "time" "os" + "fmt" ) var m sync.Mutex @@ -87,6 +88,8 @@ func initRtmgr() (nbiEngine Engine, sbiEngine sbi.Engine, sdlEngine sdl.Engine, func (c *Control) controlLoop() { for { msg := <-c.rcChan + c.recievermr(msg) + /* xapp_msg := sbi.RMRParams{msg} switch msg.Mtype { case xapp.RICMessageTypes["RMRRM_REQ_TABLE"]: @@ -103,10 +106,29 @@ func (c *Control) controlLoop() { err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded") xapp.Logger.Error("Unknown message type: %v", err) } - xapp.Rmr.Free(msg.Mbuf) + xapp.Rmr.Free(msg.Mbuf)*/ } } +func (c *Control) recievermr(msg *xapp.RMRParams) { + xapp_msg := sbi.RMRParams{msg} + switch msg.Mtype { + case xapp.RICMessageTypes["RMRRM_REQ_TABLE"]: + if rtmgr.Rtmgr_ready == false { + xapp.Logger.Info("Update Route Table Request(RMR to RM), message discarded as routing manager is not ready") + } else { + xapp.Logger.Info("Update Route Table Request(RMR to RM)") + go c.handleUpdateToRoutingManagerRequest(msg) + } + case xapp.RICMessageTypes["RMRRM_TABLE_STATE"]: + xapp.Logger.Info("state of table to route mgr %s,payload %s", xapp_msg.String(), msg.Payload) + default: + err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded") + xapp.Logger.Error("Unknown message type: %v", err) + } + xapp.Rmr.Free(msg.Mbuf) +} + func (c *Control) handleUpdateToRoutingManagerRequest(params *xapp.RMRParams) { msg := sbi.RMRParams{params} @@ -114,16 +136,16 @@ func (c *Control) handleUpdateToRoutingManagerRequest(params *xapp.RMRParams) { xapp.Logger.Info("Update Route Table Request, msg.String() : %s", msg.String()) xapp.Logger.Info("Update Route Table Request, params.Payload : %s", string(params.Payload)) - m.Lock() + /*m.Lock() data, err := sdlEngine.ReadAll(xapp.Config.GetString("rtfile")) m.Unlock() if err != nil || data == nil { xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) return - } + }*/ - ep := sbiEngine.CreateEndpoint(string(params.Payload)) - if ep == nil { + sbiEngine.CreateEndpoint(string(params.Payload),msg.String()) + /*if ep == nil { xapp.Logger.Error("Update Routing Table Request can't handle due to end point %s is not avail in complete ep list: ", string(params.Payload)) return } @@ -133,17 +155,21 @@ func (c *Control) handleUpdateToRoutingManagerRequest(params *xapp.RMRParams) { if err != nil { xapp.Logger.Error("Routing table cannot be published due to: " + err.Error()) return - } + }*/ } func sendRoutesToAll() (err error) { m.Lock() data, err := sdlEngine.ReadAll(xapp.Config.GetString("rtfile")) + fmt.Printf("data = %v,%v,%v",data,sdlEngine,sbiEngine) m.Unlock() if err != nil || data == nil { return errors.New("Cannot get data from sdl interface due to: " + err.Error()) } + if sbiEngine == nil { + fmt.Printf("SBI is nil") + } sbiEngine.UpdateEndpoints(data) policies := rpeEngine.GeneratePolicies(rtmgr.Eps, data) err = sbiEngine.DistributeAll(policies)