Re: how to get the serviceID belongs to airport
Re: how to get the serviceID belongs to airport
- Subject: Re: how to get the serviceID belongs to airport
- From: Allan Nathanson <email@hidden>
- Date: Wed, 7 Feb 2007 13:47:11 -0500
How about something like :
prefs = SCPreferencesCreate(NULL, CFSTR("your app"), NULL);
set = SCNetworkSetCopyCurrent(prefs);
services = SCNetworkSetCopyServices(set);
for (i = 0; i < CFArrayGetCount(services); i++) {
service = CFArrayGetValueAtIndex(services, i);
interface = SCNetworkServiceGetInterface(service);
interfaceType = SCNetworkInterfaceGetInterfaceType(interface);
if (CFEqual(interfaceType, kSCNetworkInterfaceTypeIEEE80211)) {
serviceID = SCNetworkServiceGetServiceID(service);
CFRetain(serviceID); // release "later"
break;
}
}
CFRelease(services);
CFRelease(set);
CFRelease(prefs);
dict = SCDynamicStoreCopyDHCPInfo(store, serviceID);
CFRelease(serviceID);
... and, of course, you'd add the appropriate error checks :-)
- Allan
On Feb 6, 2007, at 8:46 PM, Cotton Chen wrote:
Hi all,
Recently I'd like to get the dhcp server's ip address who gives
the ip to my airport.
I used the APIs SCDynamicStoreCopyDHCPInfo, and
DHCPInfoGetOptionData to accomplish my purpose.
But, I cand only pass the NULL value as the serviceID to
SCDynamicStoreCopyDHCPInfo because I don't know how to get the
serviceID that belongs to airport.
I also used scutil to get the informations about dhcp, I got the
following of what I want.
with ethernet cable connected:
subKey [47] = State:/Network/Service/0/DHCP
subKey [48] = State:/Network/Service/0/DNS
subKey [49] = State:/Network/Service/0/IPv4
subKey [50] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/DHCP
subKey [51] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/DNS
subKey [52] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/IPv4
without ethernet cable connected:
subKey [50] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/DHCP
subKey [51] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/DNS
subKey [52] = State:/Network/Service/
606C990F-4091-4AC1-807F-86CC64EB7898/IPv4
as I passed the null value as serviceID to
SCDynamicStoreCopyDHCPInfo without ethernet cable connected and turn
on the airport interface, I got the correct dhcp server's ip because
system had no choice to return me the one belongs to airport. But
after I connected the ethernet cable on my computer, I always got
the one that belongs to the ethernet interface.
My question is, how to get the serviceID belongs to airport, for
example the string "606C990F-4091-4AC1-807F-86CC64EB7898" that
listed above.
--
Cotton Chen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden