/sys/class/net files and state of network interfaces
I am writing a little C program that need to know the state of network interfaces.
I saw that in /sys/class/net directory and subdirectories there are a lot of useful files concerning network interfaces.
The problem is that I can't find the related documentation and sometimes I don't know what a file does represent (i.e. the file carrier).
What I need to know is the state of every network interface at a certain moment. I assume that there are three possible (big) states:
- up but not connected
- up and connected
Can you help find a way to retrieve those informations?
I also appreciate simply some documentation or explanation on /sys/class/net files.
You want to read the file operstate. Its possible values are defined in RFC 2863.
I had a look at that RFC, but it concerns SNMP and I didn't found anything about the file operstate.
I, instead, found somethin about ifOperStatus, but it does not seem the same exact thing.
I run a few tests and I came up with this result:
As you see, the operstate value could be used to see if an interface is connected (and ready to work) or not, except for the "eth0: up + cable + NOT connected" case.
I'd like to know if exists something that tell me universally if an interface is ready to use or not.
|All times are GMT -5. The time now is 07:58 PM.|