I think the only required functions you need are SCNetworkReachabilityCreateWithName() and SCNetworkReachabilityGetFlags(), right? Here's a hacky workaround which will let you do this (not tested, should work in theory):
@Library("SystemConfiguration")
public class Reachability {
static {
Bro.bind();
}
public static class Flags {
public static final int TransientConnection = 1<<0;
public static final int Reachable = 1<<1;
public static final int ConnectionRequired = 1<<2;
public static final int ConnectionOnTraffic = 1<<3;
public static final int InterventionRequired = 1<<4;
public static final int ConnectionOnDemand = 1<<5;
public static final int IsLocalAddress = 1<<16;
public static final int IsDirect = 1<<17;
public static final int IsWWAN = 1<<18;
public static final int ConnectionAutomatic = ConnectionOnTraffic;
}
@Bridge public static native @Pointer long SCNetworkReachabilityCreateWithName(@Pointer long allocator, BytePtr nodename);
@Bridge public static native boolean SCNetworkReachabilityGetFlags(@Pointer long target, IntPtr flags);
}
Use it like this:
long targetRef = Reachability.SCNetworkReachabilityCreateWithName(0, BytePtr.toBytePtrAsciiZ("
www.google.com"));
IntPtr flagsPtr = new IntPtr();
if (Reachability.SCNetworkReachabilityGetFlags(targetRef, flagsPtr)) {
int flags = flagsPtr.get();
if ((flags & Reachability.Flags.Reachable) != 0) {
// Reachable
}
}
Again, it should work in theory. Not tested. Let me know how it goes. Please note that targetRef should be released using CFRelease() in order to not leak memory. I've left that out here but you can bind it similarly but use @Library("CoreFoundation") instead.