I'm getting the information about system network devices through netlink socket. I'm parsing three message types RTM_NEWLINK
, RTM_DELLINK
, RTM_GETLINK
defined in the ifinfomsg
structure.
我通过netlink socket获取有关系统网络设备的信息。我正在解析ifinfomsg结构中定义的三种消息类型RTM_NEWLINK,RTM_DELLINK,RTM_GETLINK。
struct ifinfomsg {
unsigned char ifi_family; /* AF_UNSPEC */
unsigned short ifi_type; /* Device type */
int ifi_index; /* Interface index */
unsigned int ifi_flags; /* Device flags */
unsigned int ifi_change; /* change mask */
};
the definition is from here http://www.kernel.org/doc/man-pages/online/pages/man7/rtnetlink.7.html
定义来自http://www.kernel.org/doc/man-pages/online/pages/man7/rtnetlink.7.html
But there are no description for the device type field ifi_type
, where can I found the constants that describes the possible values?
但是没有设备类型字段ifi_type的描述,在哪里可以找到描述可能值的常量?
there are no description even here http://www.foxprofr.com/rfc/RFC3549-LINUX-NETLINK-AS-AN-IP-SERVICES-PROTOCOL/3549.aspx
这里没有描述http://www.foxprofr.com/rfc/RFC3549-LINUX-NETLINK-AS-AN-IP-SERVICES-PROTOCOL/3549.aspx
Now I know that 1
is ethernet and 772
is loopback, but I'd like to know all possible values. May be the answer is very obvious but google doesn't want to tell me anything usefull.
现在我知道1是以太网,772是环回,但我想知道所有可能的值。可能答案很明显,但谷歌不想告诉我任何有用的东西。
1 个解决方案
#1
3
Take a look at /usr/include/net/if_arp.h
, you will find the constants there as ARPHRD_*
. If you want to make your life somewhat easier, check out libnl if you don't use it already.
看一下/usr/include/net/if_arp.h,你会发现那里的常量为ARPHRD_ *。如果您想让生活更轻松,请查看libnl,如果您还没有使用它。
#1
3
Take a look at /usr/include/net/if_arp.h
, you will find the constants there as ARPHRD_*
. If you want to make your life somewhat easier, check out libnl if you don't use it already.
看一下/usr/include/net/if_arp.h,你会发现那里的常量为ARPHRD_ *。如果您想让生活更轻松,请查看libnl,如果您还没有使用它。