Re: notification of IP stack changes on OS X
Re: notification of IP stack changes on OS X
- Subject: Re: notification of IP stack changes on OS X
- From: Stéphane Sudre <email@hidden>
- Date: Tue, 5 Feb 2002 12:39:20 +0100
On Tuesday, February 5, 2002, at 05:39 AM, email@hidden wrote:
On Monday, February 4, 2002, at 06:46 PM, Rob Newberry wrote:
I believe it's been talked about recently on this list; I apologize for
not paying better attention at the time.
I'd like to find out when the status of the IP stack changes --
primarily,
I need to know when my IP address(es) change(s).
I need this only on Mac OS X, and would prefer a Cocoa-based solution,
though C/C++ or Carbon is fine, too. I _think_ this is the purpose of
the
System Configuration Framework, but I didn't find any API details in
the
documentation on this. Is there anything more, or do I just need to
pay
closer attention to what's there?
As far as I know, the only documentation available on the
SCDynamicStore component of the System Configuration Framework is:
<http://developer.apple.com/techpubs/macosx/Networking/SysConfigOverview926/
index.html>
but it is only an overview (pretty cool tho). The only source of API
info is in the header files of the System Configuration Framework.
There is some good info in:
SCDynamicStore.h
SCDynamicStoreKey.h
SCSchemaDefinitions.h
SCDynamicStoreCopy.h
The dynamic store can notify you when the TCP/IP protocol stack address
changes in the current networking environment (or when just about
anything else changes in the network environment - its really really
cool). If you just want to know when the user changes their network
preferences, then you have to use other facilities. I don't think there
is a Cocoa API (although I'd love to be corrected on this point), but I
don't see any problems making calling the SCDynamicStore Carbon calls
from a Cocoa program.
Another solution can be to use the Kern Event APIs with this key:
vendor_code = KEV_VENDOR_APPLE;
kev_class = KEV_NETWORK_CLASS;
The KernelEventMonitor.bproj project in Darwin shows how to use it.