Re: How can I tell if DHCP is active
Re: How can I tell if DHCP is active
- Subject: Re: How can I tell if DHCP is active
- From: Quinn <email@hidden>
- Date: Mon, 22 Sep 2003 09:43:41 +0100
At 17:18 -0400 20/9/03, Matt Mashyna wrote:
Is there an easy way to tell if DHCP is active with the current
configuration ? I need to know on OS 9 and OS X. It seems like it
ought to be easy enough to ask SCF for it on OS X but I haven't been
able to figure it out.
For traditional Mac OS, you can read the active network configuration
and see whether TCP/IP is configured to use DHCP. Start with the
MoreNetworkSetup sample code.
<
http://developer.apple.com/samplecode/Sample_Code/Archive/Networking/MoreNetworkSetup.htm>
Call NSHGetConfigurationList to get the list of current TCP/IP
configurations, search that list for the active configuration, then
call NSHGetConfiguration to get the digest for that configuration.
Within that digest, look for the fConfigMethod being set to
kOTCfgDHCPConfig.
That only tells you whether the system is configured to use DHCP. To
determine whether it actually got a DHCP address, you'll need to call
OTInetGetInterfaceInfo and check that the address isn't in the
self-assigned range (169.254.x.x).
* * *
For Mac OS X, you can do this using the SCF dynamic store APIs.
Start with the MoreSCF sample code.
<
http://developer.apple.com/samplecode/Sample_Code/Networking/MoreSCF.htm>
There's a function in MoreSCFHelpers called
MoreSCCreateActiveDHCPServicesArray that returns an array of all the
current services that are using DHCP. It gets this array from the
SCF dynamic store.
S+E
--
Quinn "The Eskimo!" <
http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.