public sockaddr_in() { sin_len((byte)sizeOf()); sin_family(AF_INET); }
public sockaddr_in6() { sin6_len((byte)sizeOf()); sin6_family(AF_INET6); }
protected /*<name>*/SCNetworkReachabilityFlags/*</name>*/ wrap(long value, long mask) { return new /*<name>*/SCNetworkReachabilityFlags/*</name>*/(value, mask); } protected /*<name>*/SCNetworkReachabilityFlags/*</name>*/[] _values() {
public SCNetworkReachabilityContext(@MachineSizedSInt long version, @Pointer long info, FunctionPtr retain, FunctionPtr release, FunctionPtr copyDescription) { this.setVersion(version); this.setInfo(info); this.setRetain(retain); this.setRelease(release); this.setCopyDescription(copyDescription); } /*</constructors>*/
/** * @since Available in iOS 2.0 and later. */ public boolean setCallback(ClientCallback callback) { SCNetworkReachabilityContext context = new SCNetworkReachabilityContext(); context.setInfo(localRefconId); synchronized (callbacks) { callbacks.put(localRefconId, callback); } return setCallback(new FunctionPtr(cbInvoke), context); } /*<methods>*/
/** * @since Available in iOS 2.0 and later. */ public static SCNetworkReachability create(java.net.InetSocketAddress address) { long refconId = SCNetworkReachability.refconId.getAndIncrement(); SCNetworkReachability reachability; java.net.InetAddress addr = address.getAddress(); if (addr instanceof java.net.Inet4Address) { reachability = create(null, new sockaddr_in(address)); } else if (addr instanceof java.net.Inet6Address) { reachability = create(null, new sockaddr_in6(address)); } else { throw new IllegalArgumentException("address is not a valid IPv4 or IPv6 address!"); } reachability.localRefconId = refconId; return reachability; } /**
public InetSocketAddress toInetSocketAddress() { try { Inet6Address address = Inet6Address.getByAddress(null, sin6_addr(), (int)sin6_scope_id()); return new InetSocketAddress(address, sin6_port()); } catch (UnknownHostException e) { e.printStackTrace(); } return null; } }
/** * @since Available in iOS 2.0 and later. */ public SCNetworkReachabilityFlags getFlags() { IntPtr ptr = new IntPtr(); getFlags(ptr); return new SCNetworkReachabilityFlags(ptr.get()); } /**
public static /*<name>*/SCStatusCode/*</name>*/ valueOf(long n) { for (/*<name>*/SCStatusCode/*</name>*/ v : values()) { if (v.n == n) { return v; } } throw new IllegalArgumentException("No constant with value " + n + " found in " + /*<name>*/SCStatusCode/*</name>*/.class.getName()); } }
/** * @since Available in iOS 2.0 and later. */ public static String getStatusDescription(SCStatusCode status) { BytePtr ptr = getStatusDescription0(status); return ptr.toStringZ(); } /*<methods>*/
/** * @since Available in iOS 2.0 and later. */ public static SCNetworkReachability create(String nodename) { long refconId = SCNetworkReachability.refconId.getAndIncrement(); BytePtr ptr = BytePtr.toBytePtrZ(nodename); SCNetworkReachability reachability = create(null, ptr); reachability.localRefconId = refconId; return reachability; } /**
@Callback private static void cbInvoke(SCNetworkReachability target, SCNetworkReachabilityFlags flags, @Pointer long refcon) { ClientCallback callback = null; synchronized (callbacks) { callback = callbacks.get(refcon); } callback.invoke(target, flags); }
public sockaddr_in() { sin_len((byte)sizeOf()); sin_family(AF_INET); }
public sockaddr_in6() { sin6_len((byte)sizeOf()); sin6_family(AF_INET6); }
/** * @since Available in iOS 2.0 and later. */ public static SCNetworkReachability create(java.net.InetSocketAddress localAddress, java.net.InetSocketAddress remoteAddress) { long refconId = SCNetworkReachability.refconId.getAndIncrement(); Struct<?> l; Struct<?> r; if (localAddress.getAddress() instanceof java.net.Inet4Address) { l = new sockaddr_in(localAddress); } else if (localAddress.getAddress() instanceof java.net.Inet6Address) { l = new sockaddr_in6(localAddress); } else { throw new IllegalArgumentException("localAddress is not a valid IPv4 or IPv6 address!"); } if (remoteAddress.getAddress() instanceof java.net.Inet4Address) { r = new sockaddr_in(remoteAddress); } else if (remoteAddress.getAddress() instanceof java.net.Inet6Address) { r = new sockaddr_in6(remoteAddress); } else { throw new IllegalArgumentException("remoteAddress is not a valid IPv4 or IPv6 address!"); } SCNetworkReachability reachability = create(null, l, r); reachability.localRefconId = refconId; return reachability; } /**
public sockaddr_in6(InetSocketAddress address) { this(); sin6_port((short)address.getPort()); InetAddress addr = address.getAddress(); if (!(addr instanceof Inet6Address)) { throw new IllegalArgumentException("address must be a valid IPv6 address!"); } sin6_addr(addr.getAddress()); sin6_scope_id(((Inet6Address)addr).getScopeId()); }
/** * @since Available in iOS 2.0 and later. */ public SCNetworkReachabilityFlags getFlags() { IntPtr ptr = new IntPtr(); getFlags(ptr); return new SCNetworkReachabilityFlags(ptr.get()); } /**
protected /*<name>*/SCNetworkReachabilityFlags/*</name>*/ wrap(long value, long mask) { return new /*<name>*/SCNetworkReachabilityFlags/*</name>*/(value, mask); } protected /*<name>*/SCNetworkReachabilityFlags/*</name>*/[] _values() {