waseemsmartfissiom / iphone-wireless

Automatically exported from code.google.com/p/iphone-wireless
0 stars 0 forks source link

Apple80211Associate method signature #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I had to associate my iPhone to a given SSID, so I reverse engineered the 
associate function:

int Apple80211Associate(struct Apple80211 *handle, CFDictionaryRef *network, 
CFString *wpa_key);

handle: An open handle from an Apple80211Open call, that has also been bound to 
an interface using 
Apple80211BindToInterface.

network: one of the CFDictionaryRefs returned by the Apple80211Scan function.

wpa_key: NSString containing the WPA PSK.

Hopes that helps,
Renault

Original issue reported on code.google.com by renault....@gmail.com on 9 May 2008 at 9:03

GoogleCodeExporter commented 8 years ago
Hi Renault,

I would like to join a special SSID but do not know how?
Could you explain me how you managed to do so?

I was wondering if there exist Wifi libraries for IPhone that offer functions 
such
Access Point scanning, association....
Actually, I would like to store my credentials (login/password) on the IPhone 
and to
log automatically on an HTML authentication based Access Point. I
I tried to search on the web, especially on apple website but I did not find 
anything...

I really need some help!
Thanks

Original comment by akhalid2...@gmail.com on 13 Jul 2008 at 4:30

GoogleCodeExporter commented 8 years ago
Hi Ranult,
I am also trying to use the same Apple80211Associate using its address(pointer) 
to 
associae to unsecure AP,I am passing the same dictionary as the secone argument 
returned by the scan. But the function fails with error code 9.
Were you able to associte using this function. If YES could you please help me 
outif 
I'm missing anything.

Thanks
Raj

Original comment by bharat.s...@gmail.com on 15 Apr 2009 at 3:39

GoogleCodeExporter commented 8 years ago
can you post the code snippet?

Original comment by renault....@gmail.com on 16 Apr 2009 at 6:49

GoogleCodeExporter commented 8 years ago
Hmm ... I've got everything working *except* associating with a network in 3.0. 
 I'm getting a -101 result--??

Original comment by russ...@gmail.com on 16 Jul 2009 at 12:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Russmcb, you are too nearer the goal.

first confirm that you are passing single network(access point) data as network
parameter and password(if it is WPA/WAP network) in 3rd parameter else nil. 

Original comment by tso...@gmail.com on 28 Aug 2009 at 4:14

GoogleCodeExporter commented 8 years ago
Should've posted some time ago that the 3rd parameter must be nil, not an empty 
string.  Had this working for 
some time.  Thanks, though!

Original comment by russ...@gmail.com on 28 Aug 2009 at 4:31

GoogleCodeExporter commented 8 years ago
Has anyone been able to use Apple80211Associate on 3.1.*?
It doesn't work for me and I'm at a loss as to why. I get all kinds of error 
codes: 
9, -4, -101 but never 0 and I have no indication that it worked at all.
I've tried both with a network without encryption and one with encryption.

Also, is this a blocking call? Or does it trigger an asynchronous task that 
fires a 
notification when done? If so, what notification is raised?

Thanks!

Original comment by cipher.l...@gmail.com on 12 Mar 2010 at 1:58

GoogleCodeExporter commented 8 years ago
Hi, the Apple80211Associate is still working (at least on 3.1.2). Between the 
iPhone OS 2 and 3, the framework has changed name, so you should bind your 
functions as following:

void *airportHandle;
int     (*Apple80211Open)(void *);
int     (*Apple80211BindToInterface)(void *, NSString *);
int     (*Apple80211Close)(void *);
int     (*Apple80211Info)(void *, NSDictionary**);
int     (*Apple80211Associate)(void *, NSDictionary*, void *);
int     (*Apple80211Scan)(void *, NSArray **, void *);

libHandle       = 
dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", 
RTLD_LAZY);
Apple80211Open                          = dlsym(libHandle, "Apple80211Open");
Apple80211BindToInterface       = dlsym(libHandle, "Apple80211BindToInterface");
Apple80211Scan                          = dlsym(libHandle, "Apple80211Scan");
Apple80211Close                         = dlsym(libHandle, "Apple80211Close");
Apple80211Info                          = dlsym(libHandle, 
"Apple80211GetInfoCopy");
Apple80211Associate                     = dlsym(libHandle, 
"Apple80211Associate");

The most significant change from v2 to v3 is SCAN_RSSI_THRESHOLD parameter 
(used for the scan function). It use to take a positive number, far from the 
physical dB it should have been  
and now it takes the dB of the signal. If you make use of it, you can set it to 
-100:

Here is a code snipped (cherry picked from my code, so untested as is):

void *airportHandle;

NSArray *keys = [NSArray arrayWithObjects:@"SCAN_RSSI_THRESHOLD", @"SSID_STR", 
nil];
NSArray *objects = [NSArray arrayWithObjects:[NSNumber numberWithInt:-100], 
ssid, nil];

NSDictionary *params = [NSDictionary dictionaryWithObjects:objects 
forKeys:keys];
NSArray *found;

int openResult = Apple80211Open(&airportHandle);
NSLog(@"Openning wifi interface %@", (openResult == 0?@"succeeded":@"failed"));

int bindResult = Apple80211BindToInterface(airportHandle, @IF_NAME);

int scanResult = Apple80211Scan(airportHandle, &found, params);

NSDictionary *network;

// get the first network found
network = [found objectAtIndex:0];
int associateResult = Apple80211Associate(airportHandle, network,NULL);

Apple80211Close(airportHandle);

Hope that's helps,
Renault

Original comment by renault....@gmail.com on 12 Mar 2010 at 2:42

GoogleCodeExporter commented 8 years ago
Hey thanks for the quick and detailed answer Renault.
Got it working now :-)
One extra question: is there a way to know when the association is complete? 
Following the call, the OS pops up 
the Wifi network selection dialog and I'd like to wait until the user has 
dismissed this dialog before attempting to 
connect to a host. Do you know if some notification is raised to signal that?

Thanks a bunch

Original comment by cipher.l...@gmail.com on 23 Mar 2010 at 3:32

GoogleCodeExporter commented 8 years ago
Deal all,

when i try to use the framework, the following error happened, could you please 
tell me what shall i do?
dlopen(/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager, 1): 
image not found

my simulator is OS 3.1.3. thanks a lot.

Original comment by ToLiB...@gmail.com on 29 Mar 2010 at 1:38

GoogleCodeExporter commented 8 years ago
Anyone have an explanation on the return values yet? I can associate with my 
network using the WPA key. But 
sometimes it fails, giving me either a return value of -6 or 16

Original comment by iwha...@gmail.com on 6 Apr 2010 at 3:26

GoogleCodeExporter commented 8 years ago
@ToLiBing: this only works on the actual device, not on the Simulator.

Original comment by guymorei...@gmail.com on 12 Apr 2010 at 8:45

GoogleCodeExporter commented 8 years ago
im curently looking to make an app for the iphone that scans for a particular 
wifi networkk and connects to it. im however not able to make a headstart. 
could anyone help point me in a direction to using the stumbler code in my 
application?

Original comment by keviny...@gmail.com on 8 Jun 2010 at 2:06

GoogleCodeExporter commented 8 years ago
How are things working in OS 4.0?

Original comment by russ...@gmail.com on 30 Jun 2010 at 7:03

GoogleCodeExporter commented 8 years ago
My App still works, so I guess nothing changed since 3.1.3

Original comment by iwha...@gmail.com on 1 Jul 2010 at 11:48

GoogleCodeExporter commented 8 years ago
How can I detect signal strenght and other information of nearby bluetooth 
devices ?
Will applications that use these libraries be allowed on the itunes store ? 

Original comment by peter.go...@gmail.com on 5 Jul 2010 at 7:14

GoogleCodeExporter commented 8 years ago
My app fails over ios4.

Original comment by lertl...@gmail.com on 14 Jul 2010 at 10:47

GoogleCodeExporter commented 8 years ago
I'm sorry, I found that there is a problem if u're running with simulator.

Original comment by lertl...@gmail.com on 14 Jul 2010 at 11:50

GoogleCodeExporter commented 8 years ago
i have problem working on ios4 too.

Original comment by liulin...@gmail.com on 23 Jul 2010 at 3:20

GoogleCodeExporter commented 8 years ago
Yes now I can't use bluetooth over iOS4!!

Original comment by lertl...@gmail.com on 29 Jul 2010 at 9:08

GoogleCodeExporter commented 8 years ago
this still works fine for me on iOS4:
- (id)init
{
    self = [super init];
    NetworksManager = self;
    networks = [[NSMutableDictionary alloc] init];
    types = [NSArray arrayWithObjects:@"80211", @"Bluetooth", @"GSM", nil];
    [types retain];
    autoScanInterval = 5; //seconds
    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");
    return self;
}

- (void)scan
{
    NSLog(@"Scanning...");
    scanning = true;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"startedScanning" object:self];
    NSArray *scan_networks;
    NSDictionary *parameters = [[NSDictionary alloc] init];
    scan(airportHandle, &scan_networks, parameters);
    int i;
    bool changed;
    for (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) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"NetworksUpdated" object:self];
    }
    scanning = false;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"stoppedScanning" object:self];
    NSLog(@"Scan Finished...");
}

Original comment by iwha...@gmail.com on 29 Jul 2010 at 9:16

GoogleCodeExporter commented 8 years ago
Can you connect between two iphones via bluetooth over iOS4? 

Original comment by lertl...@gmail.com on 29 Jul 2010 at 9:19

GoogleCodeExporter commented 8 years ago
I'm not sure if it's possible using this method. BUT Apple allows 
iPhone-to-iPhone communication over bluetooth in the GameKit Framework: 
http://stackoverflow.com/questions/1049393/gamekit-in-iphone-sdk-3-0

Original comment by iwha...@gmail.com on 29 Jul 2010 at 9:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi guys,

I have just started to make a iPhone Wifi scanning app. I have searched a lot 
websites, finally I have the recent code the below. Someone told this is 
working for iPhoneOS4.0 well.

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");

But, I have the below warnings.

warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0.1/Symbols/usr/lib/libp
cap.A.dylib" (file not found).
warning: Unable to read symbols for 
"/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0.1/Symbols/System/Libra
ry/SystemConfiguration/WiFiManager.bundle/WiFiManager" (file not found).

I am using xcode_3.2.3_and_ios_sdk_4.0.1 and iPhone 3G device that jailbroken, 
unlocked and updated to 4.0.1.

I know, if I use a private API, can not service and get a risks, but I should 
do that. If you any clue about this, please let me know.

Thanks.

Original comment by kikyoung...@gmail.com on 11 Aug 2010 at 1:55

GoogleCodeExporter commented 8 years ago
This code does not work on the simulator, only on the device. Try to run your 
code on the iPhone directly.

Renault

Original comment by renault....@gmail.com on 11 Aug 2010 at 1:57

GoogleCodeExporter commented 8 years ago
I have tried it on he device. but the same. The device is jailbroken, unlocked 
and updated to 4.0.1.

Original comment by kikyoung...@gmail.com on 11 Aug 2010 at 2:06

GoogleCodeExporter commented 8 years ago
What are the errors when you run on the device? because the errors you pasted 
are from the simulator. 

Original comment by iwha...@gmail.com on 11 Aug 2010 at 2:40

GoogleCodeExporter commented 8 years ago
Thank you for your reply, the code is working fine, I can ignore the warning. 
Thanks.
Does anybody know about the error codes of associate? What is the meaning of 
-101 and others?

Original comment by kikyoung...@gmail.com on 16 Aug 2010 at 9:12

GoogleCodeExporter commented 8 years ago
I am having a problem connecting to unsecured networks. My app will connect 
fine to my WEP network, but I get a -3900 error when I try to connect to a 
network without a password. I have tried sending both an empty string and nil 
for the third parameter, but neither worked

Original comment by ughoavg...@gmail.com on 23 Aug 2010 at 8:07

GoogleCodeExporter commented 8 years ago
Does anyone here know how to get the IP Address after associated.

Original comment by kikyoung...@gmail.com on 2 Sep 2010 at 4:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
When I associate to hotspot, it is just associated, not connected to the 
hotspot access point. After associated, how can I make it connected?

After associated, If I open a browser, the browser make it connected. So, I 
think, the browser do something, but I do not know the something. ^^;;;;

Original comment by kikyoung...@gmail.com on 3 Sep 2010 at 3:22

GoogleCodeExporter commented 8 years ago
Hi Renault

Which tools have you used to reverse engineered Apple80211Associate? could you 
describe the process to me please? my email is: jibrilg@gmail.com.

Regards

Original comment by jibr...@gmail.com on 28 Sep 2010 at 6:00

GoogleCodeExporter commented 8 years ago
Hi, Renault,

Do you have any idea how I can detect the signal strenghts of several access 
points? I will need it for an academic test, thanks very much!

Original comment by zhyu...@gmail.com on 30 Sep 2010 at 4:20

GoogleCodeExporter commented 8 years ago
Hi Zhyujjh (is it your name or an acronym?)

You have to use the scan function. If this function call is successful, it will 
return in the variable "CFArrayRef *list" the list of all available networks 
(it is a list of NSDictionary). Iterate over this array and extract the RSSI 
key, from the dictionary.

I hope it helps,
Renault

Original comment by renault....@gmail.com on 30 Sep 2010 at 7:22

GoogleCodeExporter commented 8 years ago
Does anyone know how to toggle the Wifi on an off?  On the desktop library, at 
least, we've got functions like:  WirelessSetPower().  Any ideas?  

Thanks, r

Original comment by russ...@gmail.com on 17 Feb 2011 at 4:22

GoogleCodeExporter commented 8 years ago
hi, i m new to iphone and want to know how can i scan other wifi enabled 
devices. i read the discussion above but not getting where to start from.is 
there any framework that i need to import? any suggestion? thanks.

Shreya

Original comment by shreya.v...@gmail.com on 1 Jun 2011 at 5:55

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Apple has moved the API 
/System/Library/SystemConfiguration/IPConfiguration.bundle  to somewhere else 
in IOS8 ... As this API is not working ... Can Anyone Please tell me the new 
Path .. 

Original comment by mushtaqu...@gmail.com on 12 Sep 2014 at 1:26

GoogleCodeExporter commented 8 years ago
Dear All,
I am currently looking for making an app for iPhone that scans for a particular 
wifi network and connects to it. I will have list of all SSID & passwords. 
Also, I have to upload this application to store. So, I cannot use Private 
frameworks.
Could anyone please help me.

I tried above solutions but its not working. I am not getting where to start 
from.
Any suggestions?

Thanks.

Original comment by rahul.rg...@gmail.com on 20 Feb 2015 at 6:48

GoogleCodeExporter commented 8 years ago
i am not find the list of all scan wifi network device SSID.

Original comment by naveen.g...@dawpl.com on 16 Jul 2015 at 6:19