Search in sources :

Example 26 with Ipv6MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.

the class Ipv6NdTargetEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Ipv6Address ipv6NdTarget = new Ipv6Address("2001:db8::");
    final Match ipv6NdTargetMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6NdTarget(ipv6NdTarget).build()).build();
    assertMatch(ipv6NdTargetMatch, false, (out) -> {
        byte[] addressBytes = new byte[16];
        out.readBytes(addressBytes);
        assertArrayEquals(addressBytes, IetfInetUtil.INSTANCE.ipv6AddressBytes(ipv6NdTarget));
    });
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 27 with Ipv6MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.

the class Ipv6SourceEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Ipv6Prefix ipv6Address = new Ipv6Prefix("2001:db8::/32");
    final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Source(ipv6Address).build()).build();
    assertMatch(ipv6abmMatch, true, (out) -> {
        byte[] address = new byte[16];
        out.readBytes(address);
        assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(ipv6Address)));
        byte[] mask = new byte[16];
        out.readBytes(mask);
        assertArrayEquals(mask, IpConversionUtil.convertIpv6PrefixToByteArray(IpConversionUtil.extractIpv6Prefix(ipv6Address)));
    });
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 28 with Ipv6MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.

the class Ipv6SourceEntrySerializerTest method testSerializeWithoutMask.

@Test
public void testSerializeWithoutMask() throws Exception {
    final Ipv6Prefix ipv6Address = new Ipv6Prefix("2001:db8::123/128");
    final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Source(ipv6Address).build()).build();
    assertMatch(ipv6abmMatch, false, (out) -> {
        byte[] address = new byte[16];
        out.readBytes(address);
        assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(ipv6Address)));
    });
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 29 with Ipv6MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.

the class Ipv6NdTllEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final MacAddress ipv6NdTll = new MacAddress("00:01:02:03:04:05");
    final Match ipv6NdTllMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6NdTll(ipv6NdTll).build()).build();
    assertMatch(ipv6NdTllMatch, false, (out) -> {
        byte[] addressBytes = new byte[6];
        out.readBytes(addressBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), ipv6NdTll.getValue());
    });
}
Also used : MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 30 with Ipv6MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder in project openflowplugin by opendaylight.

the class OfToSalIpv6DstCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = data.getIpv6MatchArbitraryBitMaskBuilder();
    Ipv6Dst ipv6Dst = source.getIpv6Dst();
    if (ipv6Dst != null) {
        byte[] mask = ipv6Dst.getMask();
        if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
            if (ipv6MatchBuilder.getIpv6Source() != null) {
                Ipv6Prefix ipv6PrefixSourceAddress = ipv6MatchBuilder.getIpv6Source();
                Ipv6Address ipv6SrcAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixSourceAddress);
                Ipv6ArbitraryMask srcIpv6Arbitrary = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.extractIpv6AddressMask(ipv6PrefixSourceAddress));
                setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, srcIpv6Arbitrary, IpConversionUtil.compressedIpv6AddressFormat(ipv6SrcAddress));
            }
            Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, dstIpv6ArbitraryMask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6SourceAddressNoMask() != null) {
            /*
                         TODO Change comments
                        Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
                        source which of type ipv6Match needs to be converted to ipv6MatchArbitraryBitMask.
                        We convert 1::/32 to 1::/FFFF:FFFF::
                        example:-
                        <ipv6-destination>1::/32</ipv6-destination>
                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
                        after conversion output example:-
                        <ipv6-destination-address-no-mask>1::</ipv6-destination-address-no-mask>
                        <ipv6-destination-arbitrary-bitmask>FFFF:FFFF::</ipv6-destination-arbitrary-bitmask>
                        <ipv6-source-address-no-mask>1::1</ipv6-source-address-no-mask>
                        <ipv6-source-arbitrary-bitmask>FFFF::0001</ipv6-source-arbitrary-bitmask>
                        */
            Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, dstIpv6ArbitraryMask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else {
            Ipv6Address stringIpv6DstAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Dst.getIpv6Address());
            setIpv6MatchBuilderFields(ipv6MatchBuilder, mask, stringIpv6DstAddress);
            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
        }
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6Dst(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6Dst) Ipv6ArbitraryMask(org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask) Ipv6MatchArbitraryBitMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Aggregations

Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)32 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)23 Test (org.junit.Test)13 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)12 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)9 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 Ipv6ExtHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder)8 Ipv6FlowLabel (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel)7 Ipv6LabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder)7 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)7 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)6 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)6 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)6 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)6 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)6 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)5 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)5 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)5 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)5