Add intid to GetOnuByID
Change-Id: Ibe18e674dd228aa6c8851fcff89d4ceadb2e427e
diff --git a/core/core_server.go b/core/core_server.go
index 50a2224..ce55024 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -214,7 +214,7 @@
}
func (s *Server) updateOnuIntState (intfid uint32, onuid uint32, state device.DeviceState) error {
- onu, err := s.GetOnuByID(onuid) //TODO: IntfID should be included ?
+ onu, err := s.GetOnuByID(onuid, intfid)
if err != nil {
return err
}
@@ -458,7 +458,7 @@
continue
}
- onu, err := s.GetOnuByID(onuid)
+ onu, err := s.GetOnuByID(onuid, intfid)
if err != nil {
logger.Error("Failed to GetOnuByID:%d", onuid)
continue
@@ -496,10 +496,11 @@
continue
}
onuid := nnipkt.Info.onuid
- onu, _ := s.GetOnuByID(onuid)
+ intfid := nnipkt.Info.intfid
+ onu, _ := s.GetOnuByID(onuid, intfid)
utils.LoggerWithOnu(onu).Info("Received packet from NNI in grpc Server.")
- intfid := nnipkt.Info.intfid
+
pkt := nnipkt.Pkt
data = &openolt.Indication_PktInd{PktInd: &openolt.PacketIndication{IntfType: "nni", IntfId: intfid, Pkt: pkt.Data()}}
if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
@@ -517,7 +518,7 @@
func (s *Server) onuPacketOut(intfid uint32, onuid uint32, rawpkt gopacket.Packet) error {
layerEth := rawpkt.Layer(layers.LayerTypeEthernet)
- onu, _ := s.GetOnuByID(onuid)
+ onu, _ := s.GetOnuByID(onuid, intfid)
if layerEth != nil {
pkt, _ := layerEth.(*layers.Ethernet)
@@ -599,7 +600,7 @@
if err != nil {
logger.Warn("Failed to getGemPortID from OMCI lib: %s", err)
}
- onu, err := s.GetOnuByID(onuid)
+ onu, err := s.GetOnuByID(onuid, intfid)
if err != nil {
logger.Error("Failed to getGemPortID: %s", err)
return 0, err
@@ -621,16 +622,14 @@
return nil, err
}
-func (s *Server) GetOnuByID(onuid uint32) (*device.Onu, error) {
- return getOnuByID(s.Onumap, onuid)
+func (s *Server) GetOnuByID(onuid uint32, intfid uint32) (*device.Onu, error) {
+ return getOnuByID(s.Onumap, onuid, intfid)
}
-func getOnuByID(onumap map[uint32][]*device.Onu, onuid uint32) (*device.Onu, error) {
- for _, onus := range onumap {
- for _, onu := range onus {
- if onu.OnuID == onuid {
- return onu, nil
- }
+func getOnuByID(onumap map[uint32][]*device.Onu, onuid uint32, intfid uint32) (*device.Onu, error) {
+ for _, onu := range onumap[intfid] {
+ if onu.OnuID == onuid {
+ return onu, nil
}
}
err := errors.New("No matched OnuID is found ")
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 7a66fc0..bc92483 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -120,7 +120,7 @@
}
func (s *Server) OnuPacketOut(c context.Context, packet *openolt.OnuPacket) (*openolt.Empty, error) {
- onu, _ := s.GetOnuByID(packet.OnuId)
+ onu, _ := s.GetOnuByID(packet.OnuId, packet.IntfId)
utils.LoggerWithOnu(onu).Debugf("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId)
onuid := packet.OnuId
intfid := packet.IntfId
@@ -143,7 +143,7 @@
func (s *Server) FlowAdd(c context.Context, flow *openolt.Flow) (*openolt.Empty, error) {
logger.Debug("OLT %d receives FlowAdd() IntfID:%d OnuID:%d EType:%x GemPortID:%d", s.Olt.ID, flow.AccessIntfId, flow.OnuId, flow.Classifier.EthType, flow.GemportId)
- onu, err := s.GetOnuByID(uint32(flow.OnuId))
+ onu, err := s.GetOnuByID(uint32(flow.OnuId), uint32(flow.AccessIntfId))
if err == nil {
intfid := onu.IntfID
@@ -167,7 +167,7 @@
}
func (s *Server) FlowRemove(c context.Context, flow *openolt.Flow) (*openolt.Empty, error) {
- onu, _ := s.GetOnuByID(uint32(flow.OnuId))
+ onu, _ := s.GetOnuByID(uint32(flow.OnuId), uint32(flow.AccessIntfId))
utils.LoggerWithOnu(onu).WithFields(log.Fields{
"olt": s.Olt.ID,