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> {
*/
protected Date activeSince;
private int hashCode = 0;
// ************
// Constructors
// ************
......@@ -157,7 +155,7 @@ public class Entity implements Comparable<Entity> {
@JsonIgnore
public boolean hasSwitchPort() {
return (switchDPID != null && switchPort != null);
return (switchDPID != null && !switchDPID.equals(DatapathId.NONE) && switchPort != null && !switchPort.equals(OFPort.ZERO));
}
public Date getLastSeenTimestamp() {
......
......@@ -24,6 +24,8 @@ import net.floodlightcontroller.core.IOFSwitch;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
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.MacAddress;
import org.projectfloodlight.openflow.types.OFPort;
......@@ -53,12 +55,19 @@ public class PacketFactory {
MacAddress hostMac) {
byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
OFFactory factory = sw.getOFFactory();
OFPacketIn packetIn = factory.buildPacketIn()
.setInPort(OFPort.of(1))
OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
if (factory.getVersion() == OFVersion.OF_10) {
packetInBuilder
.setInPort(OFPort.of(1))
.setData(serializedPacket)
.setReason(OFPacketInReason.NO_MATCH)
.build();
return packetIn;
.setReason(OFPacketInReason.NO_MATCH);
} else {
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 {
ipv4Address = 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 {
v = VlanVid.ofVlan(vlan);
}
......
......@@ -144,15 +144,17 @@ public class VirtualNetworkFilterTest extends FloodlightTestCase {
getMockFloodlightProvider().startUp(fmc);
vns.startUp(fmc);
entityClassifier.startUp(fmc);
expect(topology.isAttachmentPointPort(DatapathId.of(0), OFPort.ZERO)).andReturn(anyBoolean()).anyTimes();
topology.addListener(deviceService);
expectLastCall().times(1);
replay(topology);
// Mock switches
//fastWilcards mocked as this constant
sw1 = EasyMock.createNiceMock(IOFSwitch.class);
expect(sw1.getId()).andReturn(DatapathId.of(1L)).anyTimes();
expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
replay(sw1);
// 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