Reputation: 511
I have to find nearby wireless networks along with their IP and MAC addresses. I am using the following piece of code to scan the networks, but I didn't find any way to get the IP addresses of the available networks.
CWInterface* wifi = [[CWWiFiClient sharedWiFiClient] interface];
NSError *err = nil;
NSSet *networksSet = [wifi scanForNetworksWithName:nil error:&err];
NSArray *allNetworks = [networksSet allObjects];
for (CWNetwork *network in allNetworks) {
NSLog(@"SSID : %@",network.ssid);
NSLog(@"BSSID : %@",network.bssid);
}
This can be done using the CoreWLAN.framework provided by Apple, but how can I get the details of other wireless networks?
Upvotes: 1
Views: 3537
Reputation: 3717
The MAC address as you are probably aware is the same thing as the network's BSSID
. Regarding IP addresses I think you are out of luck, and probably should not be thinking of a network as having an IP address. Devices on the network has IP addresses, including routers, DHCP servers etc., and the access point might have one or more IP addresses on any networks it's part of, but the network itself does not necessarily have an IP address.
Assuming that it is a router IP address you are looking for I would suspect you have to connect to each network before being able to retrieve it. The WLAN also does not as far as I know advertise any IP addresses outside of the network, as that is simply of no use to devices outside of the network. It's only once a client connects to the WLAN that the IP address of a router or DHCP server has any meaning. I would suspect it is also technically possible to have a WLAN without any devices connected at all.
Upvotes: 2