Parse numeric ifconfig flags

寵の児 提交于 2019-12-11 03:09:55

问题


The ifconfig command outputs its flags in both textual and numeric format. While I can find a reference here or there to the numeric flags, I cannot find any indication on how to interpret (mask) the number.

qfe2: flags=1100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4> mtu
  1500 index 4
  usesrc vni0
  inet 1.2.3.4 netmask ffffff00 broadcast 1.2.3.255
  ether 0:3:ba:17:4b:e1
vni0: flags=20011100c1<UP,RUNNING,NOARP,NOXMIT,ROUTER,IPv4,VIRTUAL>
  mtu 0 index 5
  srcof qfe2
  inet 3.4.5.6 netmask ffffffff

In the above output, note the following:

flags=1100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4>

The numeric value "1100843" maps to the flags "UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4".

Is there a reference somewhere that I'm simply not seeing that describes how to mask each flag (UP,BROADCAST,etc.) out of the encoded "flags=NNNNNNNN" value?

EDIT: Clarification of exactly which flag I'm interested in masking.


回答1:


The flag values are defined in the header file /usr/include/net/if.h (on Solaris). The value shown is the bitwise-OR of the flags that are set for that interface.



来源:https://stackoverflow.com/questions/1328678/parse-numeric-ifconfig-flags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!