Created
April 9, 2009 17:19
-
-
Save libin/92604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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