Search in sources :

Example 21 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class IPAddressesAndPrefixesTest method test4.

@Test
public void test4() throws UnknownHostException {
    assertNotNull(new IpPrefix(new Ipv4Prefix("123.123.123.123/32")).getIpv4Prefix());
    assertNotNull(new IpPrefix(new Ipv6Prefix("2001::1/120")).getIpv6Prefix());
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 22 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project bgpcep by opendaylight.

the class IPAddressesAndPrefixesTest method testPrefix6ForBytes.

@Test
public void testPrefix6ForBytes() {
    final byte[] bytes = new byte[] { 0x20, 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02 };
    assertEquals(new Ipv6Prefix("2001:db8:1:2::/64"), Ipv6Util.prefixForBytes(bytes, 64));
    assertArrayEquals(new byte[] { 0x20, (byte) 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40 }, Ipv6Util.bytesForPrefix(new Ipv6Prefix("2001:db8:1:2::/64")));
    assertArrayEquals(new byte[] { 0x20, (byte) 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x80 }, Ipv6Util.bytesForPrefix(new Ipv6Prefix("2001:db8:1:2::/128")));
    try {
        Ipv6Util.prefixForBytes(bytes, 200);
        fail();
    } catch (final IllegalArgumentException exc) {
        assertNull(exc.getMessage());
    }
}
Also used : Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 23 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.

the class MatchNormalizationUtilTest method normalizeIpv6Match.

@Test
public void normalizeIpv6Match() {
    final Ipv6Prefix leftPrefix = new Ipv6Prefix("1E3D:5678:9ABC::/24");
    final Ipv6Prefix rightPrefix = new Ipv6Prefix("1e3d:5600:0:0:0:0:0:0/24");
    final MacAddress leftMac = new MacAddress("01:23:45:AB:CD:EF");
    final MacAddress rightMac = new MacAddress("01:23:45:ab:cd:ef");
    final Ipv6Address leftAddress = new Ipv6Address("1E3D:5678:9ABC::");
    final Ipv6Address rightAddress = new Ipv6Address("1e3d:5678:9abc:0:0:0:0:0");
    final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeIpv6Match(new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6NdSll(leftMac).setIpv6NdTll(leftMac).setIpv6NdTarget(leftAddress).setIpv6Source(leftPrefix).setIpv6Destination(leftPrefix).build()));
    assertEquals(rightMac, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdSll());
    assertEquals(rightMac, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdTll());
    assertEquals(rightPrefix, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6Source());
    assertEquals(rightPrefix, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6Destination());
    assertEquals(rightAddress, Ipv6Match.class.cast(matchBuilder.getLayer3Match()).getIpv6NdTarget());
}
Also used : MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) 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) Test(org.junit.Test)

Example 24 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.

the class OfToSalIpv6SrcCase method setIpv6MatchBuilderFields.

private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder builder, final byte[] mask, final Ipv6Address prefix) {
    Ipv6Prefix ipv6Prefix;
    if (mask != null) {
        ipv6Prefix = IpConversionUtil.createPrefix(prefix, mask);
    } else {
        ipv6Prefix = IpConversionUtil.createPrefix(prefix);
    }
    builder.setIpv6Source(ipv6Prefix);
}
Also used : Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 25 with Ipv6Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.

the class OfToSalIpv6SrcCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    final Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = data.getIpv6MatchArbitraryBitMaskBuilder();
    Ipv6Src ipv6Src = source.getIpv6Src();
    if (ipv6Src != null) {
        byte[] mask = ipv6Src.getMask();
        if (mask != null && IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
            if (ipv6MatchBuilder.getIpv6Destination() != null) {
                Ipv6Prefix ipv6PrefixDestinationAddress = ipv6MatchBuilder.getIpv6Destination();
                Ipv6Address ipv6DstAddress = IpConversionUtil.extractIpv6Address(ipv6PrefixDestinationAddress);
                Ipv6ArbitraryMask dstIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.extractIpv6AddressMask(ipv6PrefixDestinationAddress));
                setDstIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, dstIpv6ArbitraryMask, IpConversionUtil.compressedIpv6AddressFormat(ipv6DstAddress));
            }
            Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6SrcAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Src.getIpv6Address());
            setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, srcIpv6ArbitraryMask, stringIpv6SrcAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else if (ipv6MatchArbitraryBitMaskBuilder.getIpv6DestinationAddressNoMask() != null) {
            /*
                         TODO Change comments
                        Case where destination is of type ipv6MatchArbitraryBitMask already exists in Layer3Match,
                        source which of type ipv6Match needs to be converted to ipv4MatchArbitraryBitMask.
                        We convert 1::/32 to 1::/FFFF:FFFF::
                        example:-
                        <ipv6-source>1::/32</ipv4-source>
                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
                        after conversion output example:-
                        <ipv6-source-address-no-mask>1::</ipv6-source-address-no-mask>
                        <ipv6-source-arbitrary-bitmask>FFFF:FFFF::</ipv6-source-arbitrary-bitmask>
                        <ipv6-destination-address-no-mask>1::1</ipv6-destination-address-no-mask>
                        <ipv6-destination-arbitrary-bitmask>FFFF::0001</ipv6-destination-arbitrary-bitmask>
                        */
            Ipv6ArbitraryMask srcIpv6ArbitraryMask = IpConversionUtil.compressedIpv6MaskFormat(IpConversionUtil.createIpv6ArbitraryBitMask(mask));
            Ipv6Address stringIpv6SrcAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Src.getIpv6Address());
            setSrcIpv6MatchArbitraryBitMaskBuilderFields(ipv6MatchArbitraryBitMaskBuilder, srcIpv6ArbitraryMask, stringIpv6SrcAddress);
            matchBuilder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
        } else {
            Ipv6Address stringIpv6SrcAddress = IpConversionUtil.compressedIpv6AddressFormat(ipv6Src.getIpv6Address());
            setIpv6MatchBuilderFields(ipv6MatchBuilder, mask, stringIpv6SrcAddress);
            matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
        }
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6Src(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6Src) 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

Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)63 Test (org.junit.Test)42 ArrayList (java.util.ArrayList)20 ByteBuf (io.netty.buffer.ByteBuf)16 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)13 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)13 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)12 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)11 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)10 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)8 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)8 InetAddress (java.net.InetAddress)6 AceIpv6Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder)6 SourceIpv6PrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.group.ipv6.flowspec.flowspec.type.SourceIpv6PrefixCaseBuilder)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)6 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)6 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)6 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)5