Mike writes:
> I'm unable to find out how I can detect the network interface carrier bit 
> state. I'd like to poll this to determine if there is an active attached 
> network device. If there is a way to do this with an interrupt of some kind 
> it would also work. I need to find out this from within a C++ thread so C 
> code or an external command would be nice.

If you're using IP, and you actually care about the IP interface
(rather than or in addition to the underlying network interface), then
looking at the IFF_RUNNING bit is probably the best answer.  That bit
will be turned off when the hardware reports link-down, and back on
when it reports link-up.  IP will generate routing socket messages for
the flag changes.

If you really want to mess about with the underlying network interface
for some reason, then there are basically two ways to go about it:

  - Use DLPI and the Solaris-proprietary DL_NOTIFY_REQ extension to
    get the link up/down notifications directly.  Your application
    will need special privileges to open the device nodes.

  - Poll the kstats for the driver's "link_up" value.  This is a
    KSTAT_DATA_CHAR (ick) that will be '1' if the link is up, and '0'
    if it's down.

One issue that you may need to deal with here is that not all drivers
actually report link up/down events correctly.

-- 
James Carlson, Solaris Networking              <[EMAIL PROTECTED]>
Sun Microsystems / 1 Network Drive         71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to