forked from mdlayher/wifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
59 lines (49 loc) · 1.35 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package wifi
import (
"fmt"
"runtime"
)
var (
// errUnimplemented is returned by all functions on platforms that
// do not have package wifi implemented.
errUnimplemented = fmt.Errorf("package wifi not implemented on %s/%s",
runtime.GOOS, runtime.GOARCH)
)
// A Client is a type which can access WiFi device actions and statistics
// using operating system-specific operations.
type Client struct {
c osClient
}
// New creates a new Client.
func New() (*Client, error) {
c, err := newClient()
if err != nil {
return nil, err
}
return &Client{
c: c,
}, nil
}
// Close releases resources used by a Client.
func (c *Client) Close() error {
return c.c.Close()
}
// Interfaces returns a list of the system's WiFi network interfaces.
func (c *Client) Interfaces() ([]*Interface, error) {
return c.c.Interfaces()
}
// BSS retrieves the BSS associated with a WiFi interface.
func (c *Client) BSS(ifi *Interface) (*BSS, error) {
return c.c.BSS(ifi)
}
// StationInfo retrieves all station statistics about a WiFi interface.
func (c *Client) StationInfo(ifi *Interface) ([]*StationInfo, error) {
return c.c.StationInfo(ifi)
}
// An osClient is the operating system-specific implementation of Client.
type osClient interface {
Close() error
Interfaces() ([]*Interface, error)
BSS(ifi *Interface) (*BSS, error)
StationInfo(ifi *Interface) ([]*StationInfo, error)
}