Search in sources :

Example 1 with NeighborAdvertisePacket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacket in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedNeighborAdvertisementWithValidPayload.

@Test
public void testonPacketReceivedNeighborAdvertisementWithValidPayload() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getNetworkID()).thenReturn(new Uuid("eeec9dba-d831-4ad7-84b9-00d7f65f0555"));
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
    Uint64 mdata = Uint64.valueOf(0x1000000);
    Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
    MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
    byte[] data = ipv6TestUtils.buildPacket(// Destination MAC
    "FA 16 3E F7 69 4E", // Source MAC
    "FA 16 3E A9 38 94", // IPv6
    "86 DD", // Version 6, traffic class 0, no flowlabel
    "60 00 00 00", // Payload length
    "00 20", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "20 01 0D B8 00 00 00 02 00 00 00 00 00 00 11 11", // Destination IP
    "10 01 0D B8 00 00 00 02 F8 16 3E FF FE F7 69 4E", // ICMPv6 neighbor advertisement
    "88", // Code
    "00", // Checksum (valid)
    "C9 9F", // ICMPv6 message body
    "00 00 00 00", // Target
    "20 01 0D B8 00 00 00 02 00 00 00 00 00 00 11 11", // ICMPv6 Option: Target Link Layer Address
    "02", // Length
    "01", // Link Layer Address
    "FA 16 3E A9 38 94");
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(data).setIngress(ncRef).setMatch(matchbuilder.build()).setTableId(new TableId((short) 45)).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    NeighborAdvertisePacket naPdu = new Ipv6NaDecoder(data).decode();
    NeighborAdvertisePacket naPacket = new NeighborAdvertisePacketBuilder(naPdu).addAugmentation(new PacketMetadataBuilder().setOfTableId((long) 45).setMetadata(mdata).setInterface("ddec9dba-d831-4ad7-84b9-00d7f65f052f").build()).build();
    verify(ipv6PktListener).onNaReceived(naPacket);
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) PacketMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadataBuilder) PacketMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadataBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) NeighborAdvertisePacket(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacket) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) NeighborAdvertisePacketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacketBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Ipv6NaDecoder(org.opendaylight.genius.ipv6util.api.decoders.Ipv6NaDecoder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64) Test(org.junit.Test)

Example 2 with NeighborAdvertisePacket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacket in project netvirt by opendaylight.

the class Ipv6NaPacketListener method onNaReceived.

@Override
public void onNaReceived(NeighborAdvertisePacket naPacket) {
    PacketMetadata pktMetadata = naPacket.augmentation(PacketMetadata.class);
    if (pktMetadata == null) {
        return;
    }
    String srcInterface = pktMetadata.getInterface();
    IpAddress srcIP = new IpAddress(naPacket.getSourceIpv6());
    MacAddress srcMac = naPacket.getSourceMac();
    IpAddress targetIP = new IpAddress(naPacket.getTargetAddress());
    Uint64 metadata = pktMetadata.getMetadata();
    LOG.debug("NA notification received from interface {} and IP {} having MAC {}, targetIP={}", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
    validateAndProcessIpLearning(srcInterface, srcIP, srcMac, targetIP, metadata);
}
Also used : PacketMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadata) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)2 Test (org.junit.Test)1 Ipv6NaDecoder (org.opendaylight.genius.ipv6util.api.decoders.Ipv6NaDecoder)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 NeighborAdvertisePacket (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacket)1 NeighborAdvertisePacketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.NeighborAdvertisePacketBuilder)1 PacketMetadata (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadata)1 PacketMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadataBuilder)1 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 Metadata (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata)1 MetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder)1 PacketReceivedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder)1 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder)1 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)1