List / Scan for available WiFis iPhone

泪湿孤枕 提交于 2019-11-27 14:12:46

问题


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.


回答1:


For a usage sample of iphone wireless, you can check following post,

http://blog.guvenergokce.com/iphone-wireless-scanner-ios5/

There you'll also find a sample project developed with XCode 4.2.

As you have mentioned, this is only for research or private projects, we can not distribute.

Good luck,

Guvener




回答2:


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

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

to:

/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfifuration



回答3:


Check this out. I have created a Repository in GitHub for that.



来源:https://stackoverflow.com/questions/4735426/list-scan-for-available-wifis-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!