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]) >= ...
- 05-04-2011 #1Just 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.
How do I determine the media type of adatper? For example wireless, bluetooth, ethernet(802.3) etc.?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); } } }
Prashant
- 05-05-2011 #2Just 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?


Reply With Quote