Network Interface Status
The ifconfig command somehow knows which interfaces are up and which are down. I'm writing a daemon that needs to know if a particular interface is up or down. What functions are used to determine if an interface is up or down?
|
There is a special file in /proc/net called dev. Its contents show the active interfaces and some statistics for each iface. Reading and parsing that file sounds like the easiest route to me.
Gary |
I've looked at this file, but it appears to contain any interface that's ever been up on the system.
|
There are several ioctls for getting the interfaces and its status. I would search for SIOCGIFCONF and ioctl. There's a structure that has a flag which you can query for IFF_UP. I can't remember it on top of my head, but that should be enough to point you to the right direction.
|
interface status
i have one doubt regarding using /proc/net/dev file.interface are up then cont of transmitted packets,transmitted bytes,received packets and recived bytes is incremented.if one interface is down that suddenly file shows some count value.how will i decide from count wheter interface is up or down.the structure that writes the data to the /proc/net/dev available in which file.is there any information regarding structure please respond.
|
Quote:
|
All times are GMT -5. The time now is 02:37 AM. |