I also searched for this answer. I found an interesting piece of code in the opened Gitorious . Apparently, they use the following code snippet to get the interface type:
get_iface_type () { local IF=$1 TYPE test -n "$IF" || return 1 test -d /sys/class/net/$IF || return 2 case "'cat /sys/class/net/$IF/type'" in 1) TYPE=eth
I still need to find the official documentation to confirm what the value in / sys / class / net / $ IF / type means, but this function already explains a lot.
EDIT: ok, I read a little more about sysfs, and finding it to be a pain in the ass. I did not find the proper documentation.
As you may know, this information is taken from the kernel for presentation in user space. So I ended up looking at the sysfs sources and the kernel to understand what the type attribute is. I believe that part of the answer should be found in net-sysfs.c as well as in linux / device.h. I just canβt understand how all this is connected. I stopped when I saw that I needed to understand all these macros ...
source share