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