"sync"
"time"
"os"
+ "fmt"
)
var m sync.Mutex
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"]:
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}
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
}
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)