Find the answer to your Linux question:
Results 1 to 2 of 2
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]) >= ...
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    5

    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.?


    Prashant

  2. #2
    Just Joined!
    Join Date
    Jan 2010
    Posts
    27
    I guess you could use SIOCGIFHWADDR to get sockaddr.sa_family as it is described here: netdevice - Man Pages

    But by looking at Linux/include/linux/if_arp.h , I don't see any reference to Bluetooth here. Closest matches are probably these:

    ARPHRD_IEEE80211
    ARPHRD_IEEE80211_RADIOTAP
    ARPHRD_ETHER

    Have you considered running ethtool on a BT iface? Does it identify the type correctly?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...