Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Network disconnect/reconnect notification: (10 Items)
   
Network disconnect/reconnect notification  
1) We are writing an application that would like to be notified when the network cable is disconnected or reconnected 
(or link is lost/established).  Is there a way to get this notification?

2) Is there any way to get notification of when the IP address on an interface is assigned or changed?

3) We are also wondering what kind of code we need in our network applications to handle the case where the interface IP
 address is changed?  Either because we get a new DHCP address, or the network cable is unplugged from one network and 
plugged into another.  If we don't need any code is there any explanation of what messages we get from the socket layer 
in such a case.

Thanks,
Jared

Re: Network disconnect/reconnect notification  
On 25/03/10 02:54 PM, Jared Roundy wrote:
> 1) We are writing an application that would like to be notified when the network cable is disconnected or reconnected 
(or link is lost/established).  Is there a way to get this notification?
>
> 2) Is there any way to get notification of when the IP address on an interface is assigned or changed?
>
> 3) We are also wondering what kind of code we need in our network applications to handle the case where the interface 
IP address is changed?  Either because we get a new DHCP address, or the network cable is unplugged from one network and
 plugged into another.  If we don't need any code is there any explanation of what messages we get from the socket layer
 in such a case.
>    

You can use a routing socket. You can see code examples in 'route 
monitor' command or 'if_up'.

HTH,
/P
Re: Network disconnect/reconnect notification  
Thank you.  I will take a look.

Jared
Re: Network disconnect/reconnect notification  
Should ifwatchd work with en0?  
It doesn't seem to be.  We did “Ifwatchd –vi –n no_carrier.sh en0” and then pulled the network cable on the QNX PC 
and a ARM QNX board.  We didn't see our script run (our script just does an echo message).  
Any ideas of if there is a way to get this to work?
I would be a lot nicer then having to poll checking the status as is done in if_up.

Jared
Re: Network disconnect/reconnect notification  
On Fri, Mar 26, 2010 at 11:02:54AM -0400, Jared Roundy wrote:
> Should ifwatchd work with en0?  
> It doesn't seem to be.  We did ???Ifwatchd ???vi ???n no_carrier.sh en0??? and then pulled the network cable on the 
QNX PC and a ARM QNX board.  We didn't see our script run (our script just does an echo message).  
> Any ideas of if there is a way to get this to work?
> I would be a lot nicer then having to poll checking the status as is done in if_up.

Which driver are you running?

-seanb
Re: Network disconnect/reconnect notification  
That was a fast response!

We tried it on a Freescale MCI-MX 25 (arm board) and a BCM 5751 pkfbg (PC).  
If you want more specific driver information can you tell me a quick way to get it.  I had my co-worker do a nicinfo to 
get that.

Thanks,
Jared
Re: Network disconnect/reconnect notification  
On Fri, Mar 26, 2010 at 11:14:04AM -0400, Jared Roundy wrote:
> That was a fast response!
> 
> We tried it on a Freescale MCI-MX 25 (arm board) and a BCM 5751 pkfbg (PC).  
> If you want more specific driver information can you tell me a quick way to get it.  I had my co-worker do a nicinfo 
to get that.

In general io-net drivers won't support this.
Native io-pkt drivers 'should'.

-seanb
RE: Network disconnect/reconnect notification  
> In general io-net drivers won't support this.
> Native io-pkt drivers 'should'.

IIRC it's the if_link_state_change(ifp,LINK_STATE_XXX)
function that needs to be called by the driver?

Someone should create a PR against the shim for
this so that it is known/documented.  It might
actually be possible to fix it in the shim.

--
aboyd
Re: Network disconnect/reconnect notification  
On Fri, Mar 26, 2010 at 11:48:20AM -0400, Andrew Boyd wrote:
> 
> > In general io-net drivers won't support this.
> > Native io-pkt drivers 'should'.
> 
> IIRC it's the if_link_state_change(ifp,LINK_STATE_XXX)
> function that needs to be called by the driver?
> 
> Someone should create a PR against the shim for
> this so that it is known/documented.  It might
> actually be possible to fix it in the shim.

PR 70778.

Regards,

-seanb
Re: Network disconnect/reconnect notification  
This could depend on what driver you're using...