[VOL-3610] implementing a fake DHCP server within BBSim
Change-Id: If291a0ca7f78909c3713ef0e6831e381304fc2c9
diff --git a/internal/bbsim/packetHandlers/filters.go b/internal/bbsim/packetHandlers/filters.go
index c46f87d..a930b1e 100644
--- a/internal/bbsim/packetHandlers/filters.go
+++ b/internal/bbsim/packetHandlers/filters.go
@@ -44,16 +44,14 @@
return false
}
-// return true if the packet is coming in the OLT from the NNI port
-// it uses the ack to check if the source is the one we assigned to the
-// dhcp server
+// return true if the packet is coming in the OLT from the DHCP Server
+// given that we only check DHCP packets we can use the Operation
+// Request are outgoing (toward the server)
+// Replies are incoming (toward the OLT)
func IsIncomingPacket(packet gopacket.Packet) bool {
- if ipLayer := packet.Layer(layers.LayerTypeIPv4); ipLayer != nil {
-
- ip, _ := ipLayer.(*layers.IPv4)
-
- // FIXME find a better way to filter outgoing packets
- if ip.SrcIP.Equal(net.ParseIP("192.168.254.1")) {
+ layerDHCP := packet.Layer(layers.LayerTypeDHCPv4)
+ if dhcp, ok := layerDHCP.(*layers.DHCPv4); ok {
+ if dhcp.Operation == layers.DHCPOpReply {
return true
}
}