use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.
the class BfdSessionCommand method makeSessionConfigPayload.
private IPacket makeSessionConfigPayload(IOFSwitch sw) {
final TransportPort udpPort = TransportPort.of(bfdSession.getUdpPortNumber());
UDP l4 = new UDP().setSourcePort(udpPort).setDestinationPort(udpPort);
InetAddress sourceIpAddress = bfdSession.getTarget().getInetAddress();
InetAddress destIpAddress = bfdSession.getRemote().getInetAddress();
IPacket l3 = new IPv4().setSourceAddress(IPv4Address.of(sourceIpAddress.getAddress())).setDestinationAddress(IPv4Address.of(destIpAddress.getAddress())).setProtocol(IpProtocol.UDP).setPayload(l4);
DatapathId remoteDatapath = DatapathId.of(bfdSession.getRemote().getDatapath().toLong());
return new Ethernet().setEtherType(EthType.IPv4).setSourceMACAddress(convertDpIdToMac(sw.getId())).setDestinationMACAddress(convertDpIdToMac(remoteDatapath)).setPayload(l3);
}
use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.
the class EnableBfdResource method makeSessionConfigPayload.
private IPacket makeSessionConfigPayload(IOFSwitch sw, ISwitchManager switchManager, NoviBfdSession bfdSession) {
final TransportPort udpPort = TransportPort.of(bfdSession.getUdpPortNumber());
UDP l4 = new UDP().setSourcePort(udpPort).setDestinationPort(udpPort);
InetAddress sourceIpAddress = switchManager.getSwitchIpAddress(sw);
InetAddress destIpAddress = bfdSession.getRemote().getInetAddress();
IPacket l3 = new IPv4().setSourceAddress(IPv4Address.of(sourceIpAddress.getAddress())).setDestinationAddress(IPv4Address.of(destIpAddress.getAddress())).setProtocol(IpProtocol.UDP).setPayload(l4);
DatapathId remoteDatapath = DatapathId.of(bfdSession.getRemote().getDatapath().toLong());
return new Ethernet().setEtherType(EthType.IPv4).setSourceMACAddress(convertDpIdToMac(sw.getId())).setDestinationMACAddress(convertDpIdToMac(remoteDatapath)).setPayload(l3);
}
use of net.floodlightcontroller.packet.IPacket 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.IPacket in project open-kilda by telstra.
the class PathVerificationPacketSignTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
final OFPacketOut packetOut = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), true, null);
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();
expect(ofPacketIn.getCookie()).andReturn(PathVerificationService.OF_CATCH_RULE_COOKIE);
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);
}
use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.
the class PathVerificationPacketSignTest method testSignPacketMissedSign.
@Test
public void testSignPacketMissedSign() {
replay(producerService);
OFPacketOut noSignPacket = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), false, null);
IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
pvs.handlePacketIn(new OfInput(sw2, ofPacketIn, context));
verify(producerService);
}
Aggregations