diff options
author | neiledgar <neil.edgar@btinternet.com> | 2018-07-16 15:02:25 +0100 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-07-16 16:02:25 +0200 |
commit | 7e4d9bd1501f315504808d70ac5e80d77fd7660c (patch) | |
tree | 21e39cde7a8a007a140a9832f9c2394f6fc720de /vendor | |
parent | 9b97f44a704c9c31e45c864c105643e6b197abad (diff) | |
download | prometheus_node_collector-7e4d9bd1501f315504808d70ac5e80d77fd7660c.tar.bz2 prometheus_node_collector-7e4d9bd1501f315504808d70ac5e80d77fd7660c.tar.xz prometheus_node_collector-7e4d9bd1501f315504808d70ac5e80d77fd7660c.zip |
Update wifi stats to support multiple stations (#977) (#980)
Signed-off-by: neiledgar <neil.edgar@btinternet.com>
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/mdlayher/wifi/client.go | 6 | ||||
-rw-r--r-- | vendor/github.com/mdlayher/wifi/client_linux.go | 63 | ||||
-rw-r--r-- | vendor/github.com/mdlayher/wifi/client_others.go | 2 | ||||
-rw-r--r-- | vendor/github.com/mdlayher/wifi/wifi.go | 3 | ||||
-rw-r--r-- | vendor/vendor.json | 6 |
5 files changed, 46 insertions, 34 deletions
diff --git a/vendor/github.com/mdlayher/wifi/client.go b/vendor/github.com/mdlayher/wifi/client.go index 735843d..ff79a54 100644 --- a/vendor/github.com/mdlayher/wifi/client.go +++ b/vendor/github.com/mdlayher/wifi/client.go | |||
@@ -45,8 +45,8 @@ func (c *Client) BSS(ifi *Interface) (*BSS, error) { | |||
45 | return c.c.BSS(ifi) | 45 | return c.c.BSS(ifi) |
46 | } | 46 | } |
47 | 47 | ||
48 | // StationInfo retrieves station statistics about a WiFi interface. | 48 | // StationInfo retrieves all station statistics about a WiFi interface. |
49 | func (c *Client) StationInfo(ifi *Interface) (*StationInfo, error) { | 49 | func (c *Client) StationInfo(ifi *Interface) ([]*StationInfo, error) { |
50 | return c.c.StationInfo(ifi) | 50 | return c.c.StationInfo(ifi) |
51 | } | 51 | } |
52 | 52 | ||
@@ -55,5 +55,5 @@ type osClient interface { | |||
55 | Close() error | 55 | Close() error |
56 | Interfaces() ([]*Interface, error) | 56 | Interfaces() ([]*Interface, error) |
57 | BSS(ifi *Interface) (*BSS, error) | 57 | BSS(ifi *Interface) (*BSS, error) |
58 | StationInfo(ifi *Interface) (*StationInfo, error) | 58 | StationInfo(ifi *Interface) ([]*StationInfo, error) |
59 | } | 59 | } |
diff --git a/vendor/github.com/mdlayher/wifi/client_linux.go b/vendor/github.com/mdlayher/wifi/client_linux.go index 5a4055b..4edb9bc 100644 --- a/vendor/github.com/mdlayher/wifi/client_linux.go +++ b/vendor/github.com/mdlayher/wifi/client_linux.go | |||
@@ -18,7 +18,6 @@ import ( | |||
18 | 18 | ||
19 | // Errors which may occur when interacting with generic netlink. | 19 | // Errors which may occur when interacting with generic netlink. |
20 | var ( | 20 | var ( |
21 | errMultipleMessages = errors.New("expected only one generic netlink message") | ||
22 | errInvalidCommand = errors.New("invalid generic netlink response command") | 21 | errInvalidCommand = errors.New("invalid generic netlink response command") |
23 | errInvalidFamilyVersion = errors.New("invalid generic netlink response family version") | 22 | errInvalidFamilyVersion = errors.New("invalid generic netlink response family version") |
24 | ) | 23 | ) |
@@ -120,9 +119,9 @@ func (c *client) BSS(ifi *Interface) (*BSS, error) { | |||
120 | return parseBSS(msgs) | 119 | return parseBSS(msgs) |
121 | } | 120 | } |
122 | 121 | ||
123 | // StationInfo requests that nl80211 return station info for the specified | 122 | // StationInfo requests that nl80211 return all station info for the specified |
124 | // Interface. | 123 | // Interface. |
125 | func (c *client) StationInfo(ifi *Interface) (*StationInfo, error) { | 124 | func (c *client) StationInfo(ifi *Interface) ([]*StationInfo, error) { |
126 | b, err := netlink.MarshalAttributes(ifi.idAttrs()) | 125 | b, err := netlink.MarshalAttributes(ifi.idAttrs()) |
127 | if err != nil { | 126 | if err != nil { |
128 | return nil, err | 127 | return nil, err |
@@ -147,22 +146,25 @@ func (c *client) StationInfo(ifi *Interface) (*StationInfo, error) { | |||
147 | return nil, err | 146 | return nil, err |
148 | } | 147 | } |
149 | 148 | ||
150 | switch len(msgs) { | 149 | if len(msgs) == 0 { |
151 | case 0: | ||
152 | return nil, os.ErrNotExist | 150 | return nil, os.ErrNotExist |
153 | case 1: | ||
154 | break | ||
155 | default: | ||
156 | return nil, errMultipleMessages | ||
157 | } | 151 | } |
158 | 152 | ||
159 | if err := c.checkMessages(msgs, nl80211.CmdNewStation); err != nil { | 153 | stations := make([]*StationInfo, len(msgs)) |
160 | return nil, err | 154 | for i := range msgs { |
155 | if err := c.checkMessages(msgs, nl80211.CmdNewStation); err != nil { | ||
156 | return nil, err | ||
157 | } | ||
158 | |||
159 | if stations[i], err = parseStationInfo(msgs[i].Data); err != nil { | ||
160 | return nil, err | ||
161 | } | ||
161 | } | 162 | } |
162 | 163 | ||
163 | return parseStationInfo(msgs[0].Data) | 164 | return stations, nil |
164 | } | 165 | } |
165 | 166 | ||
167 | |||
166 | // checkMessages verifies that response messages from generic netlink contain | 168 | // checkMessages verifies that response messages from generic netlink contain |
167 | // the command and family version we expect. | 169 | // the command and family version we expect. |
168 | func (c *client) checkMessages(msgs []genetlink.Message, command uint8) error { | 170 | func (c *client) checkMessages(msgs []genetlink.Message, command uint8) error { |
@@ -323,25 +325,32 @@ func parseStationInfo(b []byte) (*StationInfo, error) { | |||
323 | return nil, err | 325 | return nil, err |
324 | } | 326 | } |
325 | 327 | ||
328 | var info StationInfo | ||
326 | for _, a := range attrs { | 329 | for _, a := range attrs { |
327 | // The other attributes that are returned here appear to indicate the | ||
328 | // interface index and MAC address, which is information we already | ||
329 | // possess. No need to parse them for now. | ||
330 | if a.Type != nl80211.AttrStaInfo { | ||
331 | continue | ||
332 | } | ||
333 | 330 | ||
334 | nattrs, err := netlink.UnmarshalAttributes(a.Data) | 331 | switch a.Type { |
335 | if err != nil { | 332 | case nl80211.AttrMac: |
336 | return nil, err | 333 | info.HardwareAddr = net.HardwareAddr(a.Data) |
337 | } | ||
338 | 334 | ||
339 | var info StationInfo | 335 | case nl80211.AttrStaInfo: |
340 | if err := (&info).parseAttributes(nattrs); err != nil { | 336 | nattrs, err := netlink.UnmarshalAttributes(a.Data) |
341 | return nil, err | 337 | if err != nil { |
342 | } | 338 | return nil, err |
339 | } | ||
343 | 340 | ||
344 | return &info, nil | 341 | if err := (&info).parseAttributes(nattrs); err != nil { |
342 | return nil, err | ||
343 | } | ||
344 | |||
345 | // nl80211.AttrStaInfo is last attibute we are interested in | ||
346 | return &info, nil | ||
347 | |||
348 | default: | ||
349 | // The other attributes that are returned here appear | ||
350 | // nl80211.AttrIfindex, nl80211.AttrGeneration | ||
351 | // No need to parse them for now. | ||
352 | continue | ||
353 | } | ||
345 | } | 354 | } |
346 | 355 | ||
347 | // No station info found | 356 | // No station info found |
diff --git a/vendor/github.com/mdlayher/wifi/client_others.go b/vendor/github.com/mdlayher/wifi/client_others.go index 1848b88..0cbc728 100644 --- a/vendor/github.com/mdlayher/wifi/client_others.go +++ b/vendor/github.com/mdlayher/wifi/client_others.go | |||
@@ -28,6 +28,6 @@ func (c *client) BSS(ifi *Interface) (*BSS, error) { | |||
28 | } | 28 | } |
29 | 29 | ||
30 | // StationInfo always returns an error. | 30 | // StationInfo always returns an error. |
31 | func (c *client) StationInfo(ifi *Interface) (*StationInfo, error) { | 31 | func (c *client) StationInfo(ifi *Interface) ([]*StationInfo, error) { |
32 | return nil, errUnimplemented | 32 | return nil, errUnimplemented |
33 | } | 33 | } |
diff --git a/vendor/github.com/mdlayher/wifi/wifi.go b/vendor/github.com/mdlayher/wifi/wifi.go index e16bcc4..83aed17 100644 --- a/vendor/github.com/mdlayher/wifi/wifi.go +++ b/vendor/github.com/mdlayher/wifi/wifi.go | |||
@@ -128,6 +128,9 @@ type Interface struct { | |||
128 | // StationInfo contains statistics about a WiFi interface operating in | 128 | // StationInfo contains statistics about a WiFi interface operating in |
129 | // station mode. | 129 | // station mode. |
130 | type StationInfo struct { | 130 | type StationInfo struct { |
131 | // The hardware address of the station. | ||
132 | HardwareAddr net.HardwareAddr | ||
133 | |||
131 | // The time since the station last connected. | 134 | // The time since the station last connected. |
132 | Connected time.Duration | 135 | Connected time.Duration |
133 | 136 | ||
diff --git a/vendor/vendor.json b/vendor/vendor.json index 983a378..8dbff89 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json | |||
@@ -103,10 +103,10 @@ | |||
103 | "revisionTime": "2017-12-14T18:12:53Z" | 103 | "revisionTime": "2017-12-14T18:12:53Z" |
104 | }, | 104 | }, |
105 | { | 105 | { |
106 | "checksumSHA1": "6HM95OVqE3M27obRphrlXgXIHNw=", | 106 | "checksumSHA1": "Y7cjrOeOvA/ic+B8WCp2JyLEuvs=", |
107 | "path": "github.com/mdlayher/wifi", | 107 | "path": "github.com/mdlayher/wifi", |
108 | "revision": "ebeb58da4bc660b4882176fedcd10015f44af89c", | 108 | "revision": "9a2549315201616119128afe421d1601ef3506f9", |
109 | "revisionTime": "2018-06-01T12:43:32Z" | 109 | "revisionTime": "2018-06-15T12:49:15Z" |
110 | }, | 110 | }, |
111 | { | 111 | { |
112 | "checksumSHA1": "VzutdH69PUqRqhrDVv6F91ebQd4=", | 112 | "checksumSHA1": "VzutdH69PUqRqhrDVv6F91ebQd4=", |