LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2011, 05:56 AM   #1
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Rep: Reputation: 0
get physical media type of ethernet adapter using c++ on linux


I am using this code to get some info about ethernet adapters.

Code:
for(i = 0; i < nInterfaces; i++)
    {
        struct ifreq *item = &ifr[i];

        if(ioctl(sck, SIOCGIFFLAGS, &ifr[i]) >= 0)
        {
            if (!(ifr[i].ifr_flags & IFF_LOOPBACK))
            {
                printf("Name : %s\n", item->ifr_name);
                printf("Media : %s\n", (ifr->ifr_flags)&IFF_UP ? "Up" : "Down");
                printf("Bandwidth : %d\n", item->ifr_bandwidth);
            }
        }
    }
How do I determine the media type of adatper? For example wireless, bluetooth, ethernet(802.3) etc.?

Another one which is based on getifaddrs is here:
http://www.kernel.org/doc/man-pages/...ifaddrs.3.html

If it's easier to get media type using getifaddrs then I would use this method.

Prashant
 
Old 05-04-2011, 04:29 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,243

Rep: Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527
by reading up on the Operating System basics maybe .
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://rute.2038bug.com/rute.html.gz
and so on


try
Code:
lspci
or for usb
Code:
lsusb
 
  


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
Virtual Ethernet Adapter for Linux? tfm1 Linux - Software 1 01-24-2007 01:45 PM
ethernet card SiS 900-Based PCI Fast Ethernet Adapter Not Detected pathan_azhar Linux - Networking 0 08-13-2006 05:15 AM
Cannot Configure Ethernet Adapter With SUSE Linux databox Linux - Hardware 7 05-18-2006 02:03 AM
rename linux ethernet adapter samills70 Linux - Newbie 2 06-09-2004 04:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:16 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration