link_linux.go 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. package nl
  2. import (
  3. "unsafe"
  4. )
  5. const (
  6. DEFAULT_CHANGE = 0xFFFFFFFF
  7. // doesn't exist in syscall
  8. IFLA_VFINFO_LIST = 0x16
  9. )
  10. const (
  11. IFLA_INFO_UNSPEC = iota
  12. IFLA_INFO_KIND
  13. IFLA_INFO_DATA
  14. IFLA_INFO_XSTATS
  15. IFLA_INFO_MAX = IFLA_INFO_XSTATS
  16. )
  17. const (
  18. IFLA_VLAN_UNSPEC = iota
  19. IFLA_VLAN_ID
  20. IFLA_VLAN_FLAGS
  21. IFLA_VLAN_EGRESS_QOS
  22. IFLA_VLAN_INGRESS_QOS
  23. IFLA_VLAN_PROTOCOL
  24. IFLA_VLAN_MAX = IFLA_VLAN_PROTOCOL
  25. )
  26. const (
  27. VETH_INFO_UNSPEC = iota
  28. VETH_INFO_PEER
  29. VETH_INFO_MAX = VETH_INFO_PEER
  30. )
  31. const (
  32. IFLA_VXLAN_UNSPEC = iota
  33. IFLA_VXLAN_ID
  34. IFLA_VXLAN_GROUP
  35. IFLA_VXLAN_LINK
  36. IFLA_VXLAN_LOCAL
  37. IFLA_VXLAN_TTL
  38. IFLA_VXLAN_TOS
  39. IFLA_VXLAN_LEARNING
  40. IFLA_VXLAN_AGEING
  41. IFLA_VXLAN_LIMIT
  42. IFLA_VXLAN_PORT_RANGE
  43. IFLA_VXLAN_PROXY
  44. IFLA_VXLAN_RSC
  45. IFLA_VXLAN_L2MISS
  46. IFLA_VXLAN_L3MISS
  47. IFLA_VXLAN_PORT
  48. IFLA_VXLAN_GROUP6
  49. IFLA_VXLAN_LOCAL6
  50. IFLA_VXLAN_UDP_CSUM
  51. IFLA_VXLAN_UDP_ZERO_CSUM6_TX
  52. IFLA_VXLAN_UDP_ZERO_CSUM6_RX
  53. IFLA_VXLAN_REMCSUM_TX
  54. IFLA_VXLAN_REMCSUM_RX
  55. IFLA_VXLAN_GBP
  56. IFLA_VXLAN_REMCSUM_NOPARTIAL
  57. IFLA_VXLAN_FLOWBASED
  58. IFLA_VXLAN_MAX = IFLA_VXLAN_FLOWBASED
  59. )
  60. const (
  61. BRIDGE_MODE_UNSPEC = iota
  62. BRIDGE_MODE_HAIRPIN
  63. )
  64. const (
  65. IFLA_BRPORT_UNSPEC = iota
  66. IFLA_BRPORT_STATE
  67. IFLA_BRPORT_PRIORITY
  68. IFLA_BRPORT_COST
  69. IFLA_BRPORT_MODE
  70. IFLA_BRPORT_GUARD
  71. IFLA_BRPORT_PROTECT
  72. IFLA_BRPORT_FAST_LEAVE
  73. IFLA_BRPORT_LEARNING
  74. IFLA_BRPORT_UNICAST_FLOOD
  75. IFLA_BRPORT_MAX = IFLA_BRPORT_UNICAST_FLOOD
  76. )
  77. const (
  78. IFLA_IPVLAN_UNSPEC = iota
  79. IFLA_IPVLAN_MODE
  80. IFLA_IPVLAN_MAX = IFLA_IPVLAN_MODE
  81. )
  82. const (
  83. // not defined in syscall
  84. IFLA_NET_NS_FD = 28
  85. )
  86. const (
  87. IFLA_MACVLAN_UNSPEC = iota
  88. IFLA_MACVLAN_MODE
  89. IFLA_MACVLAN_FLAGS
  90. IFLA_MACVLAN_MAX = IFLA_MACVLAN_FLAGS
  91. )
  92. const (
  93. MACVLAN_MODE_PRIVATE = 1
  94. MACVLAN_MODE_VEPA = 2
  95. MACVLAN_MODE_BRIDGE = 4
  96. MACVLAN_MODE_PASSTHRU = 8
  97. MACVLAN_MODE_SOURCE = 16
  98. )
  99. const (
  100. IFLA_BOND_UNSPEC = iota
  101. IFLA_BOND_MODE
  102. IFLA_BOND_ACTIVE_SLAVE
  103. IFLA_BOND_MIIMON
  104. IFLA_BOND_UPDELAY
  105. IFLA_BOND_DOWNDELAY
  106. IFLA_BOND_USE_CARRIER
  107. IFLA_BOND_ARP_INTERVAL
  108. IFLA_BOND_ARP_IP_TARGET
  109. IFLA_BOND_ARP_VALIDATE
  110. IFLA_BOND_ARP_ALL_TARGETS
  111. IFLA_BOND_PRIMARY
  112. IFLA_BOND_PRIMARY_RESELECT
  113. IFLA_BOND_FAIL_OVER_MAC
  114. IFLA_BOND_XMIT_HASH_POLICY
  115. IFLA_BOND_RESEND_IGMP
  116. IFLA_BOND_NUM_PEER_NOTIF
  117. IFLA_BOND_ALL_SLAVES_ACTIVE
  118. IFLA_BOND_MIN_LINKS
  119. IFLA_BOND_LP_INTERVAL
  120. IFLA_BOND_PACKETS_PER_SLAVE
  121. IFLA_BOND_AD_LACP_RATE
  122. IFLA_BOND_AD_SELECT
  123. IFLA_BOND_AD_INFO
  124. )
  125. const (
  126. IFLA_BOND_AD_INFO_UNSPEC = iota
  127. IFLA_BOND_AD_INFO_AGGREGATOR
  128. IFLA_BOND_AD_INFO_NUM_PORTS
  129. IFLA_BOND_AD_INFO_ACTOR_KEY
  130. IFLA_BOND_AD_INFO_PARTNER_KEY
  131. IFLA_BOND_AD_INFO_PARTNER_MAC
  132. )
  133. const (
  134. IFLA_BOND_SLAVE_UNSPEC = iota
  135. IFLA_BOND_SLAVE_STATE
  136. IFLA_BOND_SLAVE_MII_STATUS
  137. IFLA_BOND_SLAVE_LINK_FAILURE_COUNT
  138. IFLA_BOND_SLAVE_PERM_HWADDR
  139. IFLA_BOND_SLAVE_QUEUE_ID
  140. IFLA_BOND_SLAVE_AD_AGGREGATOR_ID
  141. )
  142. const (
  143. IFLA_GRE_UNSPEC = iota
  144. IFLA_GRE_LINK
  145. IFLA_GRE_IFLAGS
  146. IFLA_GRE_OFLAGS
  147. IFLA_GRE_IKEY
  148. IFLA_GRE_OKEY
  149. IFLA_GRE_LOCAL
  150. IFLA_GRE_REMOTE
  151. IFLA_GRE_TTL
  152. IFLA_GRE_TOS
  153. IFLA_GRE_PMTUDISC
  154. IFLA_GRE_ENCAP_LIMIT
  155. IFLA_GRE_FLOWINFO
  156. IFLA_GRE_FLAGS
  157. IFLA_GRE_ENCAP_TYPE
  158. IFLA_GRE_ENCAP_FLAGS
  159. IFLA_GRE_ENCAP_SPORT
  160. IFLA_GRE_ENCAP_DPORT
  161. IFLA_GRE_COLLECT_METADATA
  162. IFLA_GRE_MAX = IFLA_GRE_COLLECT_METADATA
  163. )
  164. const (
  165. GRE_CSUM = 0x8000
  166. GRE_ROUTING = 0x4000
  167. GRE_KEY = 0x2000
  168. GRE_SEQ = 0x1000
  169. GRE_STRICT = 0x0800
  170. GRE_REC = 0x0700
  171. GRE_FLAGS = 0x00F8
  172. GRE_VERSION = 0x0007
  173. )
  174. const (
  175. IFLA_VF_INFO_UNSPEC = iota
  176. IFLA_VF_INFO
  177. IFLA_VF_INFO_MAX = IFLA_VF_INFO
  178. )
  179. const (
  180. IFLA_VF_UNSPEC = iota
  181. IFLA_VF_MAC /* Hardware queue specific attributes */
  182. IFLA_VF_VLAN
  183. IFLA_VF_TX_RATE /* Max TX Bandwidth Allocation */
  184. IFLA_VF_SPOOFCHK /* Spoof Checking on/off switch */
  185. IFLA_VF_LINK_STATE /* link state enable/disable/auto switch */
  186. IFLA_VF_RATE /* Min and Max TX Bandwidth Allocation */
  187. IFLA_VF_RSS_QUERY_EN /* RSS Redirection Table and Hash Key query
  188. * on/off switch
  189. */
  190. IFLA_VF_STATS /* network device statistics */
  191. IFLA_VF_MAX = IFLA_VF_STATS
  192. )
  193. const (
  194. IFLA_VF_LINK_STATE_AUTO = iota /* link state of the uplink */
  195. IFLA_VF_LINK_STATE_ENABLE /* link always up */
  196. IFLA_VF_LINK_STATE_DISABLE /* link always down */
  197. IFLA_VF_LINK_STATE_MAX = IFLA_VF_LINK_STATE_DISABLE
  198. )
  199. const (
  200. IFLA_VF_STATS_RX_PACKETS = iota
  201. IFLA_VF_STATS_TX_PACKETS
  202. IFLA_VF_STATS_RX_BYTES
  203. IFLA_VF_STATS_TX_BYTES
  204. IFLA_VF_STATS_BROADCAST
  205. IFLA_VF_STATS_MULTICAST
  206. IFLA_VF_STATS_MAX = IFLA_VF_STATS_MULTICAST
  207. )
  208. const (
  209. SizeofVfMac = 0x24
  210. SizeofVfVlan = 0x0c
  211. SizeofVfTxRate = 0x08
  212. SizeofVfRate = 0x0c
  213. SizeofVfSpoofchk = 0x08
  214. SizeofVfLinkState = 0x08
  215. SizeofVfRssQueryEn = 0x08
  216. )
  217. // struct ifla_vf_mac {
  218. // __u32 vf;
  219. // __u8 mac[32]; /* MAX_ADDR_LEN */
  220. // };
  221. type VfMac struct {
  222. Vf uint32
  223. Mac [32]byte
  224. }
  225. func (msg *VfMac) Len() int {
  226. return SizeofVfMac
  227. }
  228. func DeserializeVfMac(b []byte) *VfMac {
  229. return (*VfMac)(unsafe.Pointer(&b[0:SizeofVfMac][0]))
  230. }
  231. func (msg *VfMac) Serialize() []byte {
  232. return (*(*[SizeofVfMac]byte)(unsafe.Pointer(msg)))[:]
  233. }
  234. // struct ifla_vf_vlan {
  235. // __u32 vf;
  236. // __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
  237. // __u32 qos;
  238. // };
  239. type VfVlan struct {
  240. Vf uint32
  241. Vlan uint32
  242. Qos uint32
  243. }
  244. func (msg *VfVlan) Len() int {
  245. return SizeofVfVlan
  246. }
  247. func DeserializeVfVlan(b []byte) *VfVlan {
  248. return (*VfVlan)(unsafe.Pointer(&b[0:SizeofVfVlan][0]))
  249. }
  250. func (msg *VfVlan) Serialize() []byte {
  251. return (*(*[SizeofVfVlan]byte)(unsafe.Pointer(msg)))[:]
  252. }
  253. // struct ifla_vf_tx_rate {
  254. // __u32 vf;
  255. // __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
  256. // };
  257. type VfTxRate struct {
  258. Vf uint32
  259. Rate uint32
  260. }
  261. func (msg *VfTxRate) Len() int {
  262. return SizeofVfTxRate
  263. }
  264. func DeserializeVfTxRate(b []byte) *VfTxRate {
  265. return (*VfTxRate)(unsafe.Pointer(&b[0:SizeofVfTxRate][0]))
  266. }
  267. func (msg *VfTxRate) Serialize() []byte {
  268. return (*(*[SizeofVfTxRate]byte)(unsafe.Pointer(msg)))[:]
  269. }
  270. // struct ifla_vf_rate {
  271. // __u32 vf;
  272. // __u32 min_tx_rate; /* Min Bandwidth in Mbps */
  273. // __u32 max_tx_rate; /* Max Bandwidth in Mbps */
  274. // };
  275. type VfRate struct {
  276. Vf uint32
  277. MinTxRate uint32
  278. MaxTxRate uint32
  279. }
  280. func (msg *VfRate) Len() int {
  281. return SizeofVfRate
  282. }
  283. func DeserializeVfRate(b []byte) *VfRate {
  284. return (*VfRate)(unsafe.Pointer(&b[0:SizeofVfRate][0]))
  285. }
  286. func (msg *VfRate) Serialize() []byte {
  287. return (*(*[SizeofVfRate]byte)(unsafe.Pointer(msg)))[:]
  288. }
  289. // struct ifla_vf_spoofchk {
  290. // __u32 vf;
  291. // __u32 setting;
  292. // };
  293. type VfSpoofchk struct {
  294. Vf uint32
  295. Setting uint32
  296. }
  297. func (msg *VfSpoofchk) Len() int {
  298. return SizeofVfSpoofchk
  299. }
  300. func DeserializeVfSpoofchk(b []byte) *VfSpoofchk {
  301. return (*VfSpoofchk)(unsafe.Pointer(&b[0:SizeofVfSpoofchk][0]))
  302. }
  303. func (msg *VfSpoofchk) Serialize() []byte {
  304. return (*(*[SizeofVfSpoofchk]byte)(unsafe.Pointer(msg)))[:]
  305. }
  306. // struct ifla_vf_link_state {
  307. // __u32 vf;
  308. // __u32 link_state;
  309. // };
  310. type VfLinkState struct {
  311. Vf uint32
  312. LinkState uint32
  313. }
  314. func (msg *VfLinkState) Len() int {
  315. return SizeofVfLinkState
  316. }
  317. func DeserializeVfLinkState(b []byte) *VfLinkState {
  318. return (*VfLinkState)(unsafe.Pointer(&b[0:SizeofVfLinkState][0]))
  319. }
  320. func (msg *VfLinkState) Serialize() []byte {
  321. return (*(*[SizeofVfLinkState]byte)(unsafe.Pointer(msg)))[:]
  322. }
  323. // struct ifla_vf_rss_query_en {
  324. // __u32 vf;
  325. // __u32 setting;
  326. // };
  327. type VfRssQueryEn struct {
  328. Vf uint32
  329. Setting uint32
  330. }
  331. func (msg *VfRssQueryEn) Len() int {
  332. return SizeofVfRssQueryEn
  333. }
  334. func DeserializeVfRssQueryEn(b []byte) *VfRssQueryEn {
  335. return (*VfRssQueryEn)(unsafe.Pointer(&b[0:SizeofVfRssQueryEn][0]))
  336. }
  337. func (msg *VfRssQueryEn) Serialize() []byte {
  338. return (*(*[SizeofVfRssQueryEn]byte)(unsafe.Pointer(msg)))[:]
  339. }