use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.
the class LldpLinkProviderTest method knownPktCtx.
@Test
public void knownPktCtx() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID2));
PacketContext pktCtx = new TestPacketContext(deviceService.getDevice(DID2));
testProcessor.process(pktCtx);
assertTrue("Link not detected", detectedLink(DID1, DID2));
}
use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.
the class NetworkConfigLinksProviderTest method testConfiguredLink.
/**
* Tests discovery of an expected link.
*/
@Test
public void testConfiguredLink() {
LinkKey key = LinkKey.linkKey(src, dst);
configListener.event(new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, key, BasicLinkConfig.class));
PacketContext pktCtx = new TestPacketContext(src, dst);
testProcessor.process(pktCtx);
assertThat(providerService.discoveredLinks().entrySet(), hasSize(1));
DeviceId destination = providerService.discoveredLinks().get(dev1.id());
assertThat(destination, notNullValue());
LinkDescription linkDescription = providerService.discoveredLinkDescriptions().get(key);
assertThat(linkDescription, notNullValue());
assertThat(linkDescription.isExpected(), is(true));
}
use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.
the class Dhcp6IndirectPacketClassifier method match.
@Override
public boolean match(PacketContext packet) {
Ethernet eth = packet.inPacket().parsed();
if (eth.getEtherType() == Ethernet.TYPE_IPV6) {
IPv6 ipv6Packet = (IPv6) eth.getPayload();
if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_UDP) {
UDP udpPacket = (UDP) ipv6Packet.getPayload();
// Indirectly connected host
if (udpPacket.getDestinationPort() == UDP.DHCP_V6_SERVER_PORT && udpPacket.getSourcePort() == UDP.DHCP_V6_SERVER_PORT && Arrays.equals(ipv6Packet.getDestinationAddress(), Ip6Address.valueOf("ff02::1:2").toOctets())) {
DHCP6 relayMessage = (DHCP6) udpPacket.getPayload();
DHCP6 dhcp6 = (DHCP6) relayMessage.getOptions().stream().filter(opt -> opt instanceof Dhcp6RelayOption).map(BasePacket::getPayload).map(pld -> (DHCP6) pld).findFirst().orElse(null);
if (dhcp6.getMsgType() == DHCP6.MsgType.SOLICIT.value()) {
return true;
}
}
}
}
return false;
}
use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.
the class NetworkConfigLinksProviderTest method testNotConfiguredLink.
/**
* Tests discovery of a link that is not expected in the configuration.
*/
@Test
public void testNotConfiguredLink() {
PacketContext pktCtx = new TestPacketContext(src, dst);
testProcessor.process(pktCtx);
assertThat(providerService.discoveredLinks().entrySet(), hasSize(1));
DeviceId destination = providerService.discoveredLinks().get(dev1.id());
assertThat(destination, notNullValue());
LinkKey key = LinkKey.linkKey(src, dst);
LinkDescription linkDescription = providerService.discoveredLinkDescriptions().get(key);
assertThat(linkDescription, notNullValue());
assertThat(linkDescription.isExpected(), is(false));
}
use of org.onosproject.net.packet.PacketContext in project onos by opennetworkinglab.
the class DefaultVirtualPacketProviderTest method virtualizePacket.
/**
* Test the physical packet context is delivered to a proper (physical)
* virtual network and device.
*/
@Test
public void virtualizePacket() {
Ethernet eth = new Ethernet();
eth.setSourceMACAddress(SRC_MAC_ADDR);
eth.setDestinationMACAddress(DST_MAC_ADDR);
eth.setVlanID((short) 1);
eth.setPayload(null);
InboundPacket pInPacket = new DefaultInboundPacket(CP22, eth, ByteBuffer.wrap(eth.serialize()));
PacketContext pContext = new TestPacketContext(System.nanoTime(), pInPacket, null, false);
testPacketService.sendTestPacketContext(pContext);
PacketContext vContext = providerService.getRequestedPacketContext(0);
InboundPacket vInPacket = vContext.inPacket();
assertEquals("the packet should be received from VCP12", VCP12, vInPacket.receivedFrom());
assertEquals("VLAN tag should be excludede", VlanId.UNTAGGED, vInPacket.parsed().getVlanID());
}
Aggregations