use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithValidPayload.
@Test
public void testonPacketReceivedNeighborSolicitationWithValidPayload() 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);
VirtualPort routerIntf = Mockito.mock(VirtualPort.class);
when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(routerIntf);
List<Ipv6Address> ipv6AddrList = new ArrayList<>();
when(routerIntf.getMacAddress()).thenReturn("08:00:27:FE:8F:95");
Ipv6Address llAddr = Ipv6ServiceUtils.getIpv6LinkLocalAddressFromMac(new MacAddress("08:00:27:FE:8F:95"));
ipv6AddrList.add(llAddr);
when(routerIntf.getIpv6Addresses()).thenReturn(ipv6AddrList);
InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF FE 8F 95", // Source MAC
"08 00 27 D4 10 BB", // 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
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF FE 8F 95", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (valid)
"A9 57", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // ICMPv6 Option: Source Link Layer Address
"01", // Length
"01", // Link Layer Address
"08 00 27 D4 10 BB")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
"08 00 27 D4 10 BB", // Source MAC
"08 00 27 FE 8F 95", // Ethertype - 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
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Destination IP
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE D4 10 BB", // ICMPv6 neighbor advertisement.
"88", // Code
"00", // Checksum (valid)
"17 D6", // Flags
"E0 00 00 00", // Target Address
"FE 80 00 00 00 00 00 00 0A 00 27 FF FE FE 8F 95", // Type: Target Link-Layer Option
"02", // Option length
"01", // Target Link layer address
"08 00 27 FE 8F 95");
verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(ncRef).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel in project openflowplugin by opendaylight.
the class Ipv6FlabelEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final int flowLabel = 10;
final int flowLabelMask = 8;
writeHeader(in, false);
in.writeInt(flowLabel);
Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
assertEquals(flowLabel, match.getIpv6Label().getIpv6Flabel().getValue().intValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeInt(flowLabel);
in.writeInt(flowLabelMask);
match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
assertEquals(flowLabel, match.getIpv6Label().getIpv6Flabel().getValue().intValue());
assertEquals(flowLabelMask, match.getIpv6Label().getFlabelMask().getValue().intValue());
assertEquals(0, in.readableBytes());
}
Aggregations