Search in sources :

Example 6 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 parseFlowLabel.

private static List<FlowLabel> parseFlowLabel(final ByteBuf nlri) {
    final List<FlowLabel> labels = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final FlowLabelBuilder builder = new FlowLabelBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        final short length = AbstractOperandParser.parseLength(b);
        builder.setValue(Uint32.valueOf(ByteArray.bytesToLong(ByteArray.readBytes(nlri, length))));
        end = op.getEndOfList();
        labels.add(builder.build());
    }
    return labels;
}
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) NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.NumericOperand) 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)

Example 7 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 Ipv6NeighborSolicitationTest method testTransmitNeighborSolicitation.

/**
 *  Test transmitNeighborSolicitation.
 */
@Test
public void testTransmitNeighborSolicitation() {
    doReturn(RpcResultBuilder.status(true).buildFuture()).when(pktProcessService).transmitPacket(any(TransmitPacketInput.class));
    BigInteger dpnId = BigInteger.valueOf(1);
    String macAddr = "08:00:27:FE:8F:95";
    boolean retValue;
    Ipv6Address srcIpv6Address = new Ipv6Address("2001:db8::1");
    Ipv6Address targetIpv6Address = new Ipv6Address("2001:db8::2");
    InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    NodeConnectorRef nodeRef = new NodeConnectorRef(ncId);
    retValue = instance.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address);
    assertEquals(true, retValue);
    verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
    byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 00 00 00 02", // 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
    "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 01", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF 00 00 02", // ICMPv6 neighbor advertisement.
    "87", // Code
    "00", // Checksum (valid)
    "5E 94", // Flags
    "00 00 00 00", // Target Address
    "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 02", // Type: Source Link-Layer Option
    "01", // Option length
    "01", // Source Link layer address
    "08 00 27 FE 8F 95");
    NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd");
    verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(nodeRef).setIngress(nodeConnectorRef).build());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 8 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 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());
}
Also used : Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 9 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 testonPacketReceivedRouterSolicitationWithSingleSubnet.

@Test
public void testonPacketReceivedRouterSolicitationWithSingleSubnet() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getDpId()).thenReturn(Uint64.valueOf(1));
    when(intf.getIntfUUID()).thenReturn(Uuid.getDefaultInstance("ddec9dba-d831-4ad7-84b9-00d7f65f052f"));
    when(intf.getMacAddress()).thenReturn("fa:16:3e:4e:18:0c");
    when(intf.getMtu()).thenReturn(1400);
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    List<Action> actions = new ArrayList<>();
    actions.add(new ActionNxResubmit(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE).buildAction());
    when(ifMgrInstance.getEgressAction(any())).thenReturn(actions);
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
    when(pktProcessService.transmitPacket(any())).thenReturn(Mockito.mock(ListenableFuture.class));
    IpAddress gwIpAddress = Mockito.mock(IpAddress.class);
    when(gwIpAddress.getIpv4Address()).thenReturn(null);
    when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8::1"));
    VirtualSubnet v6Subnet = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_SLAAC).ipv6RAMode(Ipv6ServiceConstants.IPV6_SLAAC).build();
    VirtualRouter virtualRouter = VirtualRouter.builder().build();
    v6Subnet.setRouter(virtualRouter);
    List<VirtualSubnet> subnetList = new ArrayList<>();
    subnetList.add(v6Subnet);
    when(intf.getSubnets()).thenReturn(subnetList);
    Uint64 dpnId = Uint64.valueOf("1");
    NodeConnectorRef ncRef = MDSALUtil.getDefaultNodeConnRef(dpnId);
    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 00 00 00 02", // Source MAC
    "FA 16 3E 69 2C F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 10", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "B4 47", // ICMPv6 message body
    "00 00 00 00", // ICMPv6 Option: Source Link Layer Address
    "01", // Length
    "01", // Link Layer Address
    "FA 16 3E 69 2C F3")).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
    "FA 16 3E 69 2C F3", // Source MAC
    "FA 16 3E 4E 18 0C", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 40", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 4E 18 0C", // Destination IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // ICMPv6 router advertisement.
    "86", // Code
    "00", // Checksum (valid)
    "11 2F", // Current Hop Limit
    "40", // ICMPv6 RA Flags
    "00", // Router Lifetime
    "11 94", // Reachable time
    "00 01 D4 C0", // Retransmission time.
    "00 00 00 00", // Type: Source Link-Layer Option
    "01", // Option length
    "01", // Source Link layer address
    "FA 16 3E 4E 18 0C", // Type: MTU Option
    "05", // Option length
    "01", // Reserved
    "00 00", // MTU
    "00 00 05 78", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 00 00 00 00 00 00 00 00 00 00 00 00");
    TransmitPacketInput transmitPacketInput = MDSALUtil.getPacketOut(actions, expectedPayload, dpnId);
    verify(pktProcessService).transmitPacket(transmitPacketInput);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) 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) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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 10 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 testonPacketReceivedNeighborAdvertisementWithInvalidPayload.

@Test
public void testonPacketReceivedNeighborAdvertisementWithInvalidPayload() throws Exception {
    // incorrect checksum
    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);
    // incorrect checksum
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(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 (invalid)
    "C9 9A", // 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")).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();
    verify(ipv6PktListener, times(0)).onNaReceived(any(NeighborAdvertisePacket.class));
    // incorrect ICMPv6 type
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(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 solicitation (invalid)
    "87", // 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")).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();
    verify(ipv6PktListener, times(0)).onNaReceived(any(NeighborAdvertisePacket.class));
}
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) 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) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) 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)

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