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());
}
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());
}
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());
}
}
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;
}
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);
}
Aggregations