Search in sources :

Example 11 with Ipv6ArbitraryMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask in project openflowplugin by opendaylight.

the class IpConversionUtilTest method compressedIpv6MaskFormatTest.

@Test
public void compressedIpv6MaskFormatTest() {
    Ipv6ArbitraryMask compressedIpv6Mask;
    Ipv6ArbitraryMask ipv6IpAddressMask;
    // zero compression
    ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0000:0000:0:0:0:1001:1000");
    compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
    Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::1001:1000");
    // :: present - no compression
    ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF::F000:0:0:1000");
    compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
    Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::f000:0:0:1000");
    // more zero sequences - compress only one
    ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0:0:F000:0000:0:0:1000");
    compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
    Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff:0:0:f000::1000");
}
Also used : Ipv6ArbitraryMask(org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask) Test(org.junit.Test)

Example 12 with Ipv6ArbitraryMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask 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)

Example 13 with Ipv6ArbitraryMask

use of org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask in project openflowplugin by opendaylight.

the class SalToOfIpv6MatchArbitraryBitMaskCase method process.

@Override
public Optional<List<MatchEntry>> process(@Nonnull Ipv6MatchArbitraryBitMask source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
    List<MatchEntry> result = new ArrayList<>();
    if (source.getIpv6SourceAddressNoMask() != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
        Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
        ipv6SrcBuilder.setIpv6Address(source.getIpv6SourceAddressNoMask());
        Ipv6ArbitraryMask sourceArbitrarySubNetMask = source.getIpv6SourceArbitraryBitmask();
        boolean hasMask = false;
        if (sourceArbitrarySubNetMask != null) {
            byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
            if (maskByteArray != null) {
                ipv6SrcBuilder.setMask(maskByteArray);
                hasMask = true;
            }
        }
        matchEntryBuilder.setHasMask(hasMask);
        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
        ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    if (source.getIpv6DestinationAddressNoMask() != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
        Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
        ipv6DstBuilder.setIpv6Address(source.getIpv6DestinationAddressNoMask());
        Ipv6ArbitraryMask destinationArbitrarySubNetMask = source.getIpv6DestinationArbitraryBitmask();
        boolean hasMask = false;
        if (destinationArbitrarySubNetMask != null) {
            byte[] maskByteArray = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(destinationArbitrarySubNetMask);
            if (maskByteArray != null) {
                ipv6DstBuilder.setMask(maskByteArray);
                hasMask = true;
            }
        }
        matchEntryBuilder.setHasMask(hasMask);
        Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    return Optional.of(result);
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) Ipv6ArbitraryMask(org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask) Ipv6SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder) ArrayList(java.util.ArrayList) Ipv6DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder) Ipv6SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder) Ipv6DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder)

Aggregations

Ipv6ArbitraryMask (org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask)13 Test (org.junit.Test)9 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)7 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)6 Ipv6MatchArbitraryBitMaskBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder)6 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)5 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)4 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)2 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)2 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)2 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)2 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)2 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 List (java.util.List)1 Nullable (javax.annotation.Nullable)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1