Search in sources :

Example 6 with Ethernet

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());
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) Test(org.junit.Test)

Example 7 with Ethernet

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);
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) HashMap(java.util.HashMap) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) DatapathId(org.projectfloodlight.openflow.types.DatapathId) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Match(org.projectfloodlight.openflow.protocol.match.Match) Before(org.junit.Before)

Example 8 with Ethernet

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);
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) AssertionFailedError(junit.framework.AssertionFailedError) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 9 with Ethernet

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);
}
Also used : IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) Command(net.floodlightcontroller.core.IListener.Command) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) IControllerCompletionListener(net.floodlightcontroller.core.IControllerCompletionListener)

Aggregations

Ethernet (net.floodlightcontroller.packet.Ethernet)9 IPacket (net.floodlightcontroller.packet.IPacket)3 IPv4 (net.floodlightcontroller.packet.IPv4)3 LLDPTLV (net.floodlightcontroller.packet.LLDPTLV)3 UDP (net.floodlightcontroller.packet.UDP)3 OFPacketIn (org.projectfloodlight.openflow.protocol.OFPacketIn)3 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)3 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ByteBuffer (java.nio.ByteBuffer)2 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)2 FloodlightModuleException (net.floodlightcontroller.core.module.FloodlightModuleException)2 Test (org.junit.Test)2 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)2 OFPortDescPropEthernet (org.projectfloodlight.openflow.protocol.OFPortDescPropEthernet)2 DatapathId (org.projectfloodlight.openflow.types.DatapathId)2 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1