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: Matt Mashyna <email@hidden>
- Date: Mon, 22 Sep 2003 08:39:06 -0400
Thanks for the clues. I did go back to these to make it work. What
was really the hardest part was getting used to the CF calls to
unravel the xml properties. I still don't fully understand how to use
it like I should.
OS 9 was pretty easy.
Thanks again,
Matt
At 9:43 AM +0100 9/22/03, Quinn wrote:
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
--
----------------------------------------------------------------
Matt Mashyna
email@hidden
The Frodis Co
_______________________________________________
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.