LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 02-14-2012, 05:13 AM   #1
turkejd
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Rep: Reputation: Disabled
/sys/class/net files and state of network interfaces


Hi all,

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:
- down
- 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.

Thanks
 
Old 02-14-2012, 04:19 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 1,773

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
You want to read the file operstate. Its possible values are defined in RFC 2863.
 
Old 02-15-2012, 04:25 AM   #3
turkejd
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
You want to read the file operstate. Its possible values are defined in RFC 2863.
Hi, and thanks for the answer.

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:

http://i.imgur.com/WOLv1.png

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.

Cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference for object types for /sys/class/net objects? joeldavis Linux - Networking 1 11-06-2011 12:45 PM
sys/class/net/ethx/type What is it? tank junior Linux - Newbie 1 05-03-2011 09:23 PM
/sys/class/net/ Is this is the correct place for eth info tank junior Linux - Newbie 1 04-14-2011 03:58 AM
Giving user access to files in /sys/class/ subdirectory and /dev/video0 DiBosco Programming 1 12-01-2008 04:11 AM
Blank /sys/power/state file dizzi Slackware 12 11-20-2007 02:17 PM


All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration