Skip to content
Snippets Groups Projects
Commit 4f2f9696 authored by Ryan Izard's avatar Ryan Izard
Browse files

VirtualNetworkFilter unit tests complete. Found bug in Entity in devicemanger...

VirtualNetworkFilter unit tests complete. Found bug in Entity in devicemanger package where null doesn't mean no switch or port anymore; DatapathId.NONE and OFPort.ZERO do instead. An object will always be there (not null), but it's contents will specify whether the Entity has a switch port or not.
parent f9e6c237
No related branches found
No related tags found
No related merge requests found
...@@ -98,8 +98,6 @@ public class Entity implements Comparable<Entity> { ...@@ -98,8 +98,6 @@ public class Entity implements Comparable<Entity> {
*/ */
protected Date activeSince; protected Date activeSince;
private int hashCode = 0;
// ************ // ************
// Constructors // Constructors
// ************ // ************
...@@ -157,7 +155,7 @@ public class Entity implements Comparable<Entity> { ...@@ -157,7 +155,7 @@ public class Entity implements Comparable<Entity> {
@JsonIgnore @JsonIgnore
public boolean hasSwitchPort() { public boolean hasSwitchPort() {
return (switchDPID != null && switchPort != null); return (switchDPID != null && !switchDPID.equals(DatapathId.NONE) && switchPort != null && !switchPort.equals(OFPort.ZERO));
} }
public Date getLastSeenTimestamp() { public Date getLastSeenTimestamp() {
......
...@@ -24,6 +24,8 @@ import net.floodlightcontroller.core.IOFSwitch; ...@@ -24,6 +24,8 @@ import net.floodlightcontroller.core.IOFSwitch;
import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFPacketIn; import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketInReason; import org.projectfloodlight.openflow.protocol.OFPacketInReason;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.types.IpProtocol; import org.projectfloodlight.openflow.types.IpProtocol;
import org.projectfloodlight.openflow.types.MacAddress; import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFPort; import org.projectfloodlight.openflow.types.OFPort;
...@@ -53,12 +55,19 @@ public class PacketFactory { ...@@ -53,12 +55,19 @@ public class PacketFactory {
MacAddress hostMac) { MacAddress hostMac) {
byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize(); byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
OFFactory factory = sw.getOFFactory(); OFFactory factory = sw.getOFFactory();
OFPacketIn packetIn = factory.buildPacketIn() OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
.setInPort(OFPort.of(1)) if (factory.getVersion() == OFVersion.OF_10) {
packetInBuilder
.setInPort(OFPort.of(1))
.setData(serializedPacket) .setData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH) .setReason(OFPacketInReason.NO_MATCH);
.build(); } else {
return packetIn; packetInBuilder
.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
.setData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH);
}
return packetInBuilder.build();
} }
/** /**
......
...@@ -90,7 +90,7 @@ public class MockDeviceManager extends DeviceManagerImpl { ...@@ -90,7 +90,7 @@ public class MockDeviceManager extends DeviceManagerImpl {
ipv4Address = null; ipv4Address = null;
if (vlan == null) { if (vlan == null) {
v = VlanVid.ofVlan(-1); v = VlanVid.ofVlan(-1); // TODO @Ryan there is now a ZERO vlan for OF1.3 that should probably be used here.
} else { } else {
v = VlanVid.ofVlan(vlan); v = VlanVid.ofVlan(vlan);
} }
......
...@@ -144,15 +144,17 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase { ...@@ -144,15 +144,17 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
getMockFloodlightProvider().startUp(fmc); getMockFloodlightProvider().startUp(fmc);
vns.startUp(fmc); vns.startUp(fmc);
entityClassifier.startUp(fmc); entityClassifier.startUp(fmc);
expect(topology.isAttachmentPointPort(DatapathId.of(0), OFPort.ZERO)).andReturn(anyBoolean()).anyTimes();
topology.addListener(deviceService); topology.addListener(deviceService);
expectLastCall().times(1); expectLastCall().times(1);
replay(topology); replay(topology);
// Mock switches // Mock switches
//fastWilcards mocked as this constant //fastWilcards mocked as this constant
sw1 = EasyMock.createNiceMock(IOFSwitch.class); sw1 = EasyMock.createNiceMock(IOFSwitch.class);
expect(sw1.getId()).andReturn(DatapathId.of(1L)).anyTimes(); expect(sw1.getId()).andReturn(DatapathId.of(1L)).anyTimes();
expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes(); expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
replay(sw1); replay(sw1);
// Mock packets // Mock packets
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment