use of net.floodlightcontroller.packet.Ethernet in project open-kilda by telstra.
the class PathVerificationPacketInTest method testDeserialize.
@Test
public void testDeserialize() {
Ethernet ethernet = (Ethernet) new Ethernet().deserialize(pkt, 0, pkt.length);
assertArrayEquals(pkt, ethernet.serialize());
IPacket expected = getPacket();
assertArrayEquals(expected.serialize(), ethernet.serialize());
}
use of net.floodlightcontroller.packet.Ethernet in project open-kilda by telstra.
the class PathVerificationPacketSignTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
OFPacketOut packetOut = pvs.generateVerificationPacket(sw1, OFPort.of(1));
ofPacketIn = EasyMock.createMock(OFPacketIn.class);
context = new FloodlightContext();
expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
Match match = EasyMock.createMock(Match.class);
expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
replay(match);
expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
replay(ofPacketIn);
IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
switches.put(sw1.getId(), sw1);
switches.put(sw2.getId(), sw2);
mockSwitchManager.setSwitches(switches);
reset(producer);
pvs.setKafkaProducer(producer);
}
use of net.floodlightcontroller.packet.Ethernet in project open-kilda by telstra.
the class PathVerificationPacketSignTest method testSignPacketMissedSign.
@Test
public void testSignPacketMissedSign() throws PacketParsingException, FloodlightModuleException {
OFPacketOut noSignPacket = pvs.generateVerificationPacket(sw1, OFPort.of(1), null, false);
IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
expect(producer.send(anyObject())).andThrow(new AssertionFailedError()).anyTimes();
replay(producer);
assertEquals(Command.STOP, pvs.receive(sw2, ofPacketIn, context));
verify(producer);
}
use of net.floodlightcontroller.packet.Ethernet in project open-kilda by telstra.
the class MockFloodlightProvider method dispatchMessage.
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
if (theListeners != null) {
Command result = Command.CONTINUE;
Iterator<IOFMessageListener> it = theListeners.iterator();
if (OFType.PACKET_IN.equals(msg.getType())) {
OFPacketIn pi = (OFPacketIn) msg;
Ethernet eth = new Ethernet();
eth.deserialize(pi.getData(), 0, pi.getData().length);
IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth);
}
while (it.hasNext() && !Command.STOP.equals(result)) {
result = it.next().receive(sw, msg, bc);
}
}
// paag
for (IControllerCompletionListener listener : completionListeners) listener.onMessageConsumed(sw, msg, bc);
}
Aggregations