Skip to content

Instantly share code, notes, and snippets.

@libin
Created April 9, 2009 17:19
Show Gist options
  • Save libin/92604 to your computer and use it in GitHub Desktop.
Save libin/92604 to your computer and use it in GitHub Desktop.
BOOL IsWIFIConnection
{
BOOL ret = YES;
struct ifaddrs * first_ifaddr, * current_ifaddr;
NSMutableArray* activeInterfaceNames = [[NSMutableArray alloc] init];
getifaddrs( &first_ifaddr );
current_ifaddr = first_ifaddr;
while( current_ifaddr!=NULL )
{
if( current_ifaddr->ifa_addr->sa_family==0x02 )
{
[activeInterfaceNames addObject:[NSString stringWithFormat:@"%s", current_ifaddr->ifa_name]];
}
current_ifaddr = current_ifaddr->ifa_next;
}
ret = [activeInterfaceNames containsObject:@"en0"] || [activeInterfaceNames containsObject:@"en1"];
[activeInterfaceNames release];
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment