use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEid.
public static Eid toEid(Ipv6Address address, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv6Afi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress((Address) new Ipv6Builder().setIpv6(address).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromIpAddress_Ipv6Binary.
/**
* Tests {@link LispAddressUtil#binaryAddressFromIpAddress(IpAddress)} and {@link
* LispAddressUtil#binaryAddressTypeFromIpAddress(IpAddress)}
* methods with Ipv6Binary address.
*/
@Test
public void binaryAddressFromIpAddress_Ipv6Binary() {
final IpAddress ipv6Address = new IpAddress(new Ipv6Address(IPV6_ADDRESS_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromIpAddress(ipv6Address);
assertEquals(Ipv6BinaryAfi.class, addressClass);
final Address address = LispAddressUtil.binaryAddressFromIpAddress(ipv6Address);
assertEquals(IPV6_BINARY, address);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toRloc.
/**
* Tests:
* - {@link LispAddressUtil#toRloc(InetAddress)}
* - {@link LispAddressUtil#toRloc(Ipv4Address)}
* - {@link LispAddressUtil#toRloc(Ipv6Address)}
* - {@link LispAddressUtil#toRloc(SimpleAddress)}
* methods.
*/
@Test
public void toRloc() throws UnknownHostException {
InetAddress ipv4AddressInet = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
final Rloc rlocFromInetAddress = LispAddressUtil.toRloc(ipv4AddressInet);
assertEquals(Ipv4BinaryAfi.class, rlocFromInetAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromInetAddress.getAddress()).getIpv4Binary());
final Rloc rlocFromIpv4Address = LispAddressUtil.toRloc(IPV4_ADDRESS_TEST);
assertEquals(Ipv4Afi.class, rlocFromIpv4Address.getAddressType());
assertEquals(IPV4_ADDRESS_VALUE_TEST, ((Ipv4) rlocFromIpv4Address.getAddress()).getIpv4().getValue());
final Rloc rlocFromIpv6Address = LispAddressUtil.toRloc(IPV6_ADDRESS_TEST);
assertEquals(Ipv6Afi.class, rlocFromIpv6Address.getAddressType());
assertEquals(IPV6_ADDRESS_VALUE_TEST, ((Ipv6) rlocFromIpv6Address.getAddress()).getIpv6().getValue());
final Rloc rlocFromSimpleAddress = LispAddressUtil.toRloc(SIMPLE_ADDRESS_IPV4_TEST);
assertEquals(Ipv4BinaryAfi.class, rlocFromSimpleAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromSimpleAddress.getAddress()).getIpv4Binary());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project cosmic by MissionCriticalCloud.
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);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project cosmic by MissionCriticalCloud.
the class NetUtils method getNextIp6InRange.
public static String getNextIp6InRange(final String currentIp, final String ipRange) {
final String[] ips = ipRange.split("-");
final String startIp = ips[0];
String endIp = null;
if (ips.length > 1) {
endIp = ips[1];
}
final IPv6Address start = IPv6Address.fromString(startIp);
final IPv6Address end = IPv6Address.fromString(endIp);
final IPv6Address current = IPv6Address.fromString(currentIp);
IPv6Address result = null;
if (current.equals(end)) {
result = start;
} else {
result = current.add(1);
}
String resultIp = null;
if (result != null) {
resultIp = result.toString();
}
return resultIp;
}
Aggregations