use of java.net.Inet6Address in project android_frameworks_base by AOSPA.
the class IPv6TetheringCoordinator method getIPv6OnlyLinkProperties.
private static LinkProperties getIPv6OnlyLinkProperties(LinkProperties lp) {
final LinkProperties v6only = new LinkProperties();
if (lp == null) {
return v6only;
}
// NOTE: At this time we don't copy over any information about any
// stacked links. No current stacked link configuration has IPv6.
v6only.setInterfaceName(lp.getInterfaceName());
v6only.setMtu(lp.getMtu());
for (LinkAddress linkAddr : lp.getLinkAddresses()) {
if (linkAddr.isGlobalPreferred() && linkAddr.getPrefixLength() == 64) {
v6only.addLinkAddress(linkAddr);
}
}
for (RouteInfo routeInfo : lp.getRoutes()) {
final IpPrefix destination = routeInfo.getDestination();
if ((destination.getAddress() instanceof Inet6Address) && (destination.getPrefixLength() <= 64)) {
v6only.addRoute(routeInfo);
}
}
for (InetAddress dnsServer : lp.getDnsServers()) {
if (isIPv6GlobalAddress(dnsServer)) {
// For now we include ULAs.
v6only.addDnsServer(dnsServer);
}
}
v6only.setDomains(lp.getDomains());
return v6only;
}
use of java.net.Inet6Address in project android_frameworks_base by AOSPA.
the class IPv6TetheringInterfaceServices method updateUpstreamIPv6LinkProperties.
// IPv6TetheringCoordinator sends updates with carefully curated IPv6-only
// LinkProperties. These have extraneous data filtered out and only the
// necessary prefixes included (per its prefix distribution policy).
//
// TODO: Evaluate using a data structure than is more directly suited to
// communicating only the relevant information.
public void updateUpstreamIPv6LinkProperties(LinkProperties v6only) {
if (mRaDaemon == null)
return;
// Avoid unnecessary work on spurious updates.
if (Objects.equals(mLastIPv6LinkProperties, v6only)) {
return;
}
RaParams params = null;
if (v6only != null) {
params = new RaParams();
params.mtu = v6only.getMtu();
params.hasDefaultRoute = v6only.hasIPv6DefaultRoute();
for (LinkAddress linkAddr : v6only.getLinkAddresses()) {
if (linkAddr.getPrefixLength() != RFC7421_IP_PREFIX_LENGTH)
continue;
final IpPrefix prefix = new IpPrefix(linkAddr.getAddress(), linkAddr.getPrefixLength());
params.prefixes.add(prefix);
final Inet6Address dnsServer = getLocalDnsIpFor(prefix);
if (dnsServer != null) {
params.dnses.add(dnsServer);
}
}
}
// If v6only is null, we pass in null to setRaParams(), which handles
// deprecation of any existing RA data.
setRaParams(params);
mLastIPv6LinkProperties = v6only;
}
use of java.net.Inet6Address in project Lucee by lucee.
the class IPRange method add.
private void add(String ip) throws IOException {
ip = ip.trim();
// no wildcard defined
if (ip.indexOf('*') == -1) {
add(new Range(toShortArray(toInetAddress(ip))));
return;
}
if ("*".equals(ip)) {
add("*.*.*.*");
add("*:*:*:*:*:*:*:*");
return;
}
String from = ip.replace('*', '0');
String to;
InetAddress addr1 = toInetAddress(from);
if (addr1 instanceof Inet6Address)
to = StringUtil.replace(ip, "*", "ffff", false);
else
to = StringUtil.replace(ip, "*", "255", false);
add(new Range(toShortArray(addr1), toShortArray(toInetAddress(to))));
}
use of java.net.Inet6Address in project JGroups by belaban.
the class Configurator method setupProtocolStack.
/**
* The configuration string has a number of entries, separated by a ':' (colon).
* Each entry consists of the name of the protocol, followed by an optional configuration
* of that protocol. The configuration is enclosed in parentheses, and contains entries
* which are name/value pairs connected with an assignment sign (=) and separated by
* a semicolon.
* <pre>UDP(in_port=5555;out_port=4445):FRAG(frag_size=1024)</pre><p>
* The <em>first</em> entry defines the <em>bottommost</em> layer, the string is parsed
* left to right and the protocol stack constructed bottom up. Example: the string
* "UDP(in_port=5555):FRAG(frag_size=32000):DEBUG" results is the following stack:<pre>
*
* -----------------------
* | DEBUG |
* |-----------------------|
* | FRAG frag_size=32000 |
* |-----------------------|
* | UDP in_port=32000 |
* -----------------------
* </pre>
*/
public static Protocol setupProtocolStack(List<ProtocolConfiguration> protocol_configs, ProtocolStack st) throws Exception {
List<Protocol> protocols = createProtocols(protocol_configs, st);
if (protocols == null)
return null;
// check InetAddress related features of stack
Map<String, Map<String, InetAddressInfo>> inetAddressMap = createInetAddressMap(protocol_configs, protocols);
Collection<InetAddress> addrs = getAddresses(inetAddressMap);
// 0 = n/a, 4 = IPv4, 6 = IPv6
StackType ip_version = Util.getIpStackType();
if (!addrs.isEmpty()) {
for (InetAddress addr : addrs) {
if (addr instanceof Inet6Address && ip_version == StackType.IPv4)
throw new IllegalArgumentException("found IPv6 address " + addr + " in an IPv4 stack");
if (addr instanceof Inet4Address && addr.isMulticastAddress() && ip_version == StackType.IPv6)
throw new Exception("found IPv4 multicast address " + addr + " in an IPv6 stack");
}
}
// process default values
setDefaultValues(protocol_configs, protocols, ip_version);
ensureValidBindAddresses(protocols);
// Fixes NPE with concurrent channel creation when using a shared stack (https://issues.jboss.org/browse/JGRP-1488)
Protocol top_protocol = protocols.get(protocols.size() - 1);
top_protocol.setUpProtocol(st);
return connectProtocols(protocols);
}
use of java.net.Inet6Address in project JGroups by belaban.
the class Configurator method setDefaultValues.
public static void setDefaultValues(List<Protocol> protocols) throws Exception {
if (protocols == null)
return;
// check InetAddress related features of stack
Collection<InetAddress> addrs = getInetAddresses(protocols);
// 0 = n/a, 4 = IPv4, 6 = IPv6
StackType ip_version = Util.getIpStackType();
if (!addrs.isEmpty()) {
for (InetAddress addr : addrs) {
if (addr instanceof Inet6Address && ip_version == StackType.IPv4)
throw new IllegalArgumentException("found IPv6 address " + addr + " in an IPv4 stack");
if (addr instanceof Inet4Address && addr.isMulticastAddress() && ip_version == StackType.IPv6)
throw new Exception("found IPv4 multicast address " + addr + " in an IPv6 stack");
}
}
// process default values
setDefaultValues(protocols, ip_version);
}
Aggregations