title: Get the network interface type in Linux via C program
body: <p>How can I get the type name for a network interface from C program in Linux?</p>
  <p>I tried using <code>getifaddr</code> to access network interfaces, and I got everything I needed, except its type name. Any ideas how it could be done?</p>
  <p>I'm still new to Linux, so any comments on any workarounds or example codes would be appreciated.</p>
  <h2>Edit</h2>
  <p>To elaborate the question. Basically, while doing <code>ifconfig</code> I can get something like this:</p>
  <pre>
  eth0 Link encap:Ethernet HWaddr 00:0C:29:40:93:9C
  inet addr:192.168.154.102 Bcast:192.168.154.255 Mask:255.255.255.0
  inet6 addr: fe80::20c:29ff:fe40:939c/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  RX packets:14785 errors:0 dropped:0 overruns:0 frame:0
  TX packets:429 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:961439 (938.9 KiB) TX bytes:71866 (70.1 KiB)
  Interrupt:67 Base address:0x2000
  </pre>
  <p>Here is what i understood that eth0 is interface name. While there can be several network interfaces (eth0, eth1, eth2) and several virtual interfaces (tap0, tap1, etc) and wireless ones, all of them are Ethernet interfaces.</p>
  <p>The same for loopbacks, being lo as interface name, its interface is Local Loopback.</p>
  <p>So the question is, how can i, using C program, print that eth0,tap0,wlan0 belong to type of Ethernet, and lo -&gt; to Local Loopback type, when i don`t know beforehand what interfaces are used and how many of them are in the machine.</p>
  <p>Hope I could explain this correctly.</p>