Search in sources :

Example 46 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project openflowplugin by opendaylight.

the class Ipv6NdTargetEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final Ipv6Address address = new Ipv6Address("2001:db8::");
    writeHeader(in, false);
    in.writeBytes(IetfInetUtil.INSTANCE.ipv6AddressBytes(address));
    Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
    assertArrayEquals(IetfInetUtil.INSTANCE.ipv6AddressBytes(address), IetfInetUtil.INSTANCE.ipv6AddressBytes(match.getIpv6NdTarget()));
    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) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 47 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project openflowplugin by opendaylight.

the class MatchConvertorTest method testIpv6MatchArbitraryBitMask.

@Test
public void testIpv6MatchArbitraryBitMask() {
    Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = new Ipv6MatchArbitraryBitMaskBuilder();
    ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
    ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
    ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
    ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
    MatchBuilder builder = new MatchBuilder();
    builder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
    Match match = builder.build();
    Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    List<MatchEntry> entries = entriesOptional.get();
    Assert.assertEquals("Wrong entries size", 2, entries.size());
    MatchEntry entry = entries.get(0);
    checkEntryHeader(entry, Ipv6Src.class, true);
    Assert.assertEquals("wrong Ipv6Adress source", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0", ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
    entry = entries.get(1);
    checkEntryHeader(entry, Ipv6Dst.class, true);
    Assert.assertEquals("wrong Ipv6Adress destination", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0", ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) 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) List(java.util.List) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) 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) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) SctpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) 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.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Example 48 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project cloudstack by apache.

the class Ipv6AddressManagerImpl method setNicIp6Address.

/**
 * Calculate the IPv6 Address the Instance will obtain using SLAAC and IPv6 EUI-64
 *
 * Linux, FreeBSD and Windows all calculate the same IPv6 address when configured properly. (SLAAC)
 *
 * Using Router Advertisements the routers in the network should announce the IPv6 CIDR which is configured
 * for the network.
 *
 * It is up to the network administrator to make sure the IPv6 Routers in the network are sending out Router Advertisements
 * with the correct IPv6 (Prefix, DNS, Lifetime) information.
 *
 * This way the NIC will be populated with a IPv6 address on which the Instance is reachable.
 *
 * This method calculates the IPv6 address the Instance will obtain and updates the Nic object with the correct
 * address information.
 */
@Override
public void setNicIp6Address(final NicProfile nic, final DataCenter dc, final Network network) throws InsufficientAddressCapacityException {
    if (network.getIp6Gateway() != null) {
        if (nic.getIPv6Address() == null) {
            s_logger.debug("Found IPv6 CIDR " + network.getIp6Cidr() + " for Network " + network);
            nic.setIPv6Cidr(network.getIp6Cidr());
            nic.setIPv6Gateway(network.getIp6Gateway());
            setNicPropertiesFromNetwork(nic, network);
            IPv6Address ipv6addr = NetUtils.EUI64Address(network.getIp6Cidr(), nic.getMacAddress());
            s_logger.info("Calculated IPv6 address " + ipv6addr + " using EUI-64 for NIC " + nic.getUuid());
            nic.setIPv6Address(ipv6addr.toString());
            if (nic.getIPv4Address() != null) {
                nic.setFormat(Networks.AddressFormat.DualStack);
            } else {
                nic.setFormat(Networks.AddressFormat.Ip6);
            }
        }
        nic.setIPv6Dns1(dc.getIp6Dns1());
        nic.setIPv6Dns2(dc.getIp6Dns2());
    }
}
Also used : IPv6Address(com.googlecode.ipv6.IPv6Address)

Example 49 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project cloudstack by apache.

the class NetUtils method getIp6FromRange.

// Can cover 127 bits
public static String getIp6FromRange(final String ip6Range) {
    final String[] ips = ip6Range.split("-");
    final String startIp = ips[0];
    final IPv6Address start = IPv6Address.fromString(startIp);
    final BigInteger gap = countIp6InRange(ip6Range);
    BigInteger next = new BigInteger(gap.bitLength(), s_rand);
    while (next.compareTo(gap) >= 0) {
        next = new BigInteger(gap.bitLength(), s_rand);
    }
    InetAddress resultAddr = null;
    final BigInteger startInt = convertIPv6AddressToBigInteger(start);
    if (startInt != null) {
        final BigInteger resultInt = startInt.add(next);
        try {
            resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
        } catch (final UnknownHostException e) {
            return null;
        }
    }
    if (resultAddr != null) {
        final IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
        return ip.toString();
    }
    return null;
}
Also used : UnknownHostException(java.net.UnknownHostException) IPv6Address(com.googlecode.ipv6.IPv6Address) BigInteger(java.math.BigInteger) InetAddress(java.net.InetAddress)

Example 50 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project cloudstack by apache.

the class NetUtils method isIp6RangeOverlap.

public static boolean isIp6RangeOverlap(final String ipRange1, final String ipRange2) {
    String[] ips = ipRange1.split("-");
    final String startIp1 = ips[0];
    String endIp1 = null;
    if (ips.length > 1) {
        endIp1 = ips[1];
    }
    final IPv6Address start1 = IPv6Address.fromString(startIp1);
    final IPv6Address end1 = IPv6Address.fromString(endIp1);
    final IPv6AddressRange range1 = IPv6AddressRange.fromFirstAndLast(start1, end1);
    ips = ipRange2.split("-");
    final String startIp2 = ips[0];
    String endIp2 = null;
    if (ips.length > 1) {
        endIp2 = ips[1];
    }
    final IPv6Address start2 = IPv6Address.fromString(startIp2);
    final IPv6Address end2 = IPv6Address.fromString(endIp2);
    final IPv6AddressRange range2 = IPv6AddressRange.fromFirstAndLast(start2, end2);
    return range1.overlaps(range2);
}
Also used : IPv6AddressRange(com.googlecode.ipv6.IPv6AddressRange) IPv6Address(com.googlecode.ipv6.IPv6Address)

Aggregations

Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)83 Test (org.junit.Test)67 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)23 ByteBuf (io.netty.buffer.ByteBuf)21 ArrayList (java.util.ArrayList)21 IPv6Address (com.googlecode.ipv6.IPv6Address)18 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 BigInteger (java.math.BigInteger)16 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)16 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)15 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)14 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)12 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)12 Ipv6SrcCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder)11 Ipv6SrcBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder)11 Ipv6DstCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder)9 Ipv6DstBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder)9 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)9