Thread: Ethernet device info

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    7

    Ethernet device info

    Hi!

    I would like to write a routine to find out if the user has an ethernet card in his system.

    If the card is present and it's ready for use, I need to fetch the following info.:

    - name of the device in Linux (e.g: eth0)
    - Hardware manufacturer's name
    - Currently assigned IP address
    - maybe PCI ID.

    Are there any standard functions or a library in C for this purpose? Where should I begin?

    P.S: I guess this could be accomplished via programs such as scanpci, lspci, or ifconfig, but these provide a lot of unnecessary details as well. So this something I would like to avoid.

    I would appreciate any help!

    Thank you in advance!

  2. #2
    Registered User PotitKing's Avatar
    Join Date
    Dec 2001
    Posts
    28
    You may want to look into the /proc , and the proc() syscalls. I've not done this myself, but something similar, and I think you should look at some manpages, maybe linux sourcecode.
    % gcc -v
    Configured with: FreeBSD/i386 system compiler
    Thread model: posix
    gcc version 3.3.3 [FreeBSD] 20031106

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    7
    Hi

    Thanks for the answer. I checked out the /proc files, some related man pages, and the libc docs, and that's what I found:

    The file /proc/pci stores info about all the PCI devices (it's generated by the kernel). Since none of the new motherboards have ISA slots, this would be enough, however some of the details are missing.:

    I can't find the device names or MAC addresses (eth0 etc) in /proc/pci.

    I can fetch the name of the correctly cinfigured devices using the if_nameindex structure and other routines in net/if.h. But this struct has only two members: index and name. No other info is available!

    Without the MAC address or a name, I can't indentify the card. I've got two Realteks. Now which one is eth0? -

    Finally, the device names (including the currently inactive ones) can also be found in /proc/net/dev.
    The rest of the file doesn't seem to be interesting.

    I will check the kernel source as well tomorrow, but I hope there is an easier way. -

    Any more ideas? Please guys post your thoughts!

    Thanks again!
    Last edited by Karl; 01-22-2004 at 01:46 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about getting an info class from another Form
    By Joelito in forum C# Programming
    Replies: 0
    Last Post: 10-16-2006, 01:02 PM
  2. Device Driver: sysfs confusion
    By filker0 in forum Linux Programming
    Replies: 0
    Last Post: 12-02-2005, 11:36 AM
  3. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM
  4. Replies: 4
    Last Post: 06-30-2004, 03:11 PM
  5. Device problem
    By John22 in forum C Programming
    Replies: 0
    Last Post: 12-19-2002, 12:02 PM