...
1 package netlink
2
3 import (
4 "syscall"
5 "unsafe"
6
7 "golang.org/x/sys/unix"
8 )
9
10
11 const (
12
13 ETHTOOL_GSSET_INFO = 0x00000037
14
15 SIOCETHTOOL = 0x8946
16
17 ETHTOOL_GSTRINGS = 0x0000001b
18
19 ETHTOOL_GSTATS = 0x0000001d
20 )
21
22
23 const (
24
25 ETH_SS_TEST = iota
26
27 ETH_SS_STATS
28
29 ETH_SS_PRIV_FLAGS
30
31 _ETH_SS_NTUPLE_FILTERS
32
33 ETH_SS_FEATURES
34
35 ETH_SS_RSS_HASH_FUNCS
36 )
37
38
39
40 type IfreqSlave struct {
41 Name [unix.IFNAMSIZ]byte
42 Slave [unix.IFNAMSIZ]byte
43 }
44
45
46 type Ifreq struct {
47 Name [unix.IFNAMSIZ]byte
48 Data uintptr
49 }
50
51
52 type ethtoolSset struct {
53 cmd uint32
54 reserved uint32
55 mask uint64
56 data [1]uint32
57 }
58
59 type ethtoolStats struct {
60 cmd uint32
61 nStats uint32
62
63 }
64
65
66
67 func newIocltSlaveReq(slave, master string) *IfreqSlave {
68 ifreq := &IfreqSlave{}
69 copy(ifreq.Name[:unix.IFNAMSIZ-1], master)
70 copy(ifreq.Slave[:unix.IFNAMSIZ-1], slave)
71 return ifreq
72 }
73
74
75 func newIocltStringSetReq(linkName string) (*Ifreq, *ethtoolSset) {
76 e := ðtoolSset{
77 cmd: ETHTOOL_GSSET_INFO,
78 mask: 1 << ETH_SS_STATS,
79 }
80
81 ifreq := &Ifreq{Data: uintptr(unsafe.Pointer(e))}
82 copy(ifreq.Name[:unix.IFNAMSIZ-1], linkName)
83 return ifreq, e
84 }
85
86
87
88 func getSocketUDP() (int, error) {
89 return syscall.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
90 }
91
View as plain text