use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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 = Ipv6Util.getIpv6LinkLocalAddressFromMac(new MacAddress("08:00:27:FE:8F:95"));
ipv6AddrList.add(llAddr);
when(routerIntf.getIpv6Addresses()).thenReturn(ipv6AddrList);
when(pktProcessService.transmitPacket(any())).thenReturn(Mockito.mock(ListenableFuture.class));
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);
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.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel in project bgpcep by opendaylight.
the class FSIpv6FlowLabelHandler method serializeNumericFourByteValue.
private static void serializeNumericFourByteValue(final List<FlowLabel> list, final ByteBuf nlriByteBuf) {
for (final Iterator<FlowLabel> it = list.iterator(); it.hasNext(); ) {
final FlowLabel label = it.next();
final ByteBuf protoBuf = Unpooled.buffer();
Util.writeShortest(label.getValue(), protoBuf);
NumericOneByteOperandParser.INSTANCE.serialize(label.getOp(), protoBuf.readableBytes(), !it.hasNext(), nlriByteBuf);
nlriByteBuf.writeBytes(protoBuf);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel in project bgpcep by opendaylight.
the class FlowspecIpv6NlriParserHelper method createFlowLabels.
private static List<FlowLabel> createFlowLabels(final UnkeyedListNode flowLabelsData) {
final List<FlowLabel> flowLabels = new ArrayList<>();
for (final UnkeyedListEntryNode node : flowLabelsData.body()) {
final FlowLabelBuilder flowLabelsBuilder = new FlowLabelBuilder();
node.findChildByArg(AbstractFlowspecNlriParser.OP_NID).ifPresent(dataContainerChild -> flowLabelsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
node.findChildByArg(AbstractFlowspecNlriParser.VALUE_NID).ifPresent(dataContainerChild -> flowLabelsBuilder.setValue((Uint32) dataContainerChild.body()));
flowLabels.add(flowLabelsBuilder.build());
}
return flowLabels;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabel in project bgpcep by opendaylight.
the class FlowspecIpv6NlriParserHelper method stringFlowLabel.
private static String stringFlowLabel(final List<FlowLabel> list) {
final StringBuilder buffer = new StringBuilder();
boolean isFirst = true;
for (final FlowLabel item : list) {
buffer.append(NumericOneByteOperandParser.INSTANCE.toString(item.getOp(), isFirst));
buffer.append(item.getValue());
buffer.append(' ');
if (isFirst) {
isFirst = false;
}
}
return buffer.toString();
}
Aggregations