Search in sources :

Example 11 with FlowLabel

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());
}
Also used : 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) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) 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) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Uint64(org.opendaylight.yangtools.yang.common.Uint64) Test(org.junit.Test)

Example 12 with FlowLabel

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);
    }
}
Also used : FlowLabel(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) ByteBuf(io.netty.buffer.ByteBuf)

Example 13 with FlowLabel

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;
}
Also used : FlowLabel(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) FlowLabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.group.ipv6.flowspec.flowspec.type.flow.label._case.FlowLabelBuilder) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 14 with FlowLabel

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();
}
Also used : FlowLabel(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)

Aggregations

Test (org.junit.Test)10 PacketReceivedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder)8 PacketMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadataBuilder)7 Metadata (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata)7 MetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder)7 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)7 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder)7 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)7 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)6 ArrayList (java.util.ArrayList)5 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)4 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)4 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)4 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)4 FlowLabel (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)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)3 ByteBuf (io.netty.buffer.ByteBuf)2 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2