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;
}
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);
}
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);
}
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();
}
Aggregations