LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to the no of attached ethernet adapters (https://www.linuxquestions.org/questions/linux-networking-3/how-to-the-no-of-attached-ethernet-adapters-296166/)

Bassam 03-01-2005 03:15 AM

How to the no of attached ethernet adapters
 
Hi all,
I am writing a network application for the Red Hat system that requires to know the number of the network cards eth (ethernet adapters) attached to the system where the application is installed.

The way that I am using now to determine the number of NIC cards is by counting the number of the files that their names taking the form ifcfg-eth, where ifcfg-eth0, ifcfg-eth1 and so on are the configuration files for each adapter.

Is there another way by using C language that helps me to determine the number of adapters attached to my Red Hat system??


Regards
Bassam

angrybeaver 03-01-2005 03:40 AM

depending on the kernel you're running, you could just open /proc/pci and match on 'Ethernet Controller' ... or match eth* on /proc/sys/net/ipv4/conf either or, there's a few ways to do it - up to you to decide which is the best..


All times are GMT -5. The time now is 06:39 PM.