Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List / Scan for available WiFis iPhone

I'm searching for a way to present available WiFis in an iPhone App. So far my research resulted in the following:

  • Apps that implement(ed) such a functionality were removed from the AppStore (means you can't deploy the App via AppStore which is fine for me)
  • Apple hides the functionality that is necessary for a scan in a private framework and you can't find any explanations/comments/examples on "how to use"
  • http://code.google.com/p/iphone-wireless seems to be most promising. anyway, i can't figure out how to include the delivered sources in my code so that it runs on a device

Even the adaptions that are mentioned htt ://code.google.com/p/iphone-wireless/issues/detail?id=26 didn't get me the desired results. The most progress was ending up with a

dlopen error: dlopen(/System/Library/SystemConfiguration/Aeropuerto.bundle/Aeropuerto, 1): image not found failed: __Apple80211Associate

message after launching the app on a device (iPhone 3GS; iOS 3.1.3).

Used source code that procudes the error is here:

NSMutableDictionary *networks;
bool scanning;
void *libHandle;
void *airportHandle;
int (*open)(void *);
int (*bind)(void *, NSString *);
int (*close)(void *);
int (*scan)(void *, NSArray **, void *);

networks = [[NSMutableDictionary alloc] init];
// libHandle = dlopen("/System/Library/Frameworks/Preferences.framework/Preferences", RTLD_LAZY);
// libHandle = dlopen("/System/Library/PrivateFrameworks/Apple80211.framework/Preferences", RTLD_LAZY);
libHandle = dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", RTLD_LAZY);

open = dlsym(libHandle, "Apple80211Open");
bind = dlsym(libHandle, "Apple80211BindToInterface");
close = dlsym(libHandle, "Apple80211Close");
scan = dlsym(libHandle, "Apple80211Scan");

open(&airportHandle);
bind(airportHandle, @"en0");

NSLog(@"Scanning...");
scanning = true;
NSArray *scan_networks;
NSDictionary *parameters = [[NSDictionary alloc] init];
scan(airportHandle, &scan_networks, parameters);
bool changed;
for (int i = 0; i < [scan_networks count]; i++) {
    if([networks objectForKey:[[scan_networks objectAtIndex: i] objectForKey:@"BSSID"]] != nil 
       && ![[networks objectForKey:[[scan_networks objectAtIndex: i] objectForKey:@"BSSID"]] isEqualToDictionary:[scan_networks objectAtIndex: i]])
        changed = true;
    [networks setObject:[scan_networks objectAtIndex: i] forKey:[[scan_networks objectAtIndex: i] objectForKey:@"BSSID"]];
}
if(changed) {
    NSLog(@"NetworksUpdated");
}
scanning = false;
NSLog(@"Scan Finished...");
NSLog(@"Found %i networks: %@", [networks count], networks);

Even if trying one of the other commented lines, it doesn't work: program received EXC_BAD_ACCESS and several

warning: check_safe_call: could not restore current frame

warning: Unable to restore previously selected frame.

What i'm searching are hints how to include iphone-wireless in my project and how to modify the given code? An alternative would be a tip on how to scan for WiFis in your environment.

Would be nice if someone could help.

like image 899
m Jae Avatar asked Nov 14 '22 04:11

m Jae


1 Answers

path has changed in 3.X and beyond, from :

/System/Library/SystemConfiguration/Aeropuerto.bundle/Aeropuerto

to:

/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfifuration
like image 117
boo Avatar answered Dec 28 '22 07:12

boo