Search in sources :

Example 1 with OFPacketIn

use of org.projectfloodlight.openflow.protocol.OFPacketIn in project open-kilda by telstra.

the class FloodlightTestCase method parseAndAnnotate.

public static FloodlightContext parseAndAnnotate(FloodlightContext bc, OFMessage m) {
    if (OFType.PACKET_IN.equals(m.getType())) {
        OFPacketIn pi = (OFPacketIn) m;
        Ethernet eth = new Ethernet();
        eth.deserialize(pi.getData(), 0, pi.getData().length);
        IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth);
    }
    return bc;
}
Also used : Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn)

Example 2 with OFPacketIn

use of org.projectfloodlight.openflow.protocol.OFPacketIn 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 3 with OFPacketIn

use of org.projectfloodlight.openflow.protocol.OFPacketIn 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)

Example 4 with OFPacketIn

use of org.projectfloodlight.openflow.protocol.OFPacketIn in project open-kilda by telstra.

the class PacketFactory method DhcpDiscoveryRequestOFPacketIn.

/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw, MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder.setInPort(OFPort.of(1)).setData(serializedPacket).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();
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn)

Aggregations

OFPacketIn (org.projectfloodlight.openflow.protocol.OFPacketIn)4 Ethernet (net.floodlightcontroller.packet.Ethernet)3 HashMap (java.util.HashMap)1 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IControllerCompletionListener (net.floodlightcontroller.core.IControllerCompletionListener)1 Command (net.floodlightcontroller.core.IListener.Command)1 IOFMessageListener (net.floodlightcontroller.core.IOFMessageListener)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 IPacket (net.floodlightcontroller.packet.IPacket)1 Before (org.junit.Before)1 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)1 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)1 Match (org.projectfloodlight.openflow.protocol.match.Match)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1