Documentation
¶
Index ¶
- Variables
- func NewAttributeFactory[T any](typ uint16) func(T) *Attribute[T]
- func NewNl80211Message(cmd int, lst []AttributeEncoder) (*genetlink.Message, error)
- type Attribute
- func InterfaceIndexAttribute(val uint32) *Attribute[uint32]
- func InterfaceNameAttribute(name string) *Attribute[string]
- func InterfaceTypeAttribute(val uint32) *Attribute[uint32]
- func MacAttribute(val []byte) *Attribute[[]byte]
- func WiphyAttribute(id uint32) *Attribute[uint32]
- func WiphyFrequencyAttribute(val uint32) *Attribute[uint32]
- type AttributeEncoder
- type Client
- func (c *Client) Close() error
- func (c *Client) DeleteInterface(w *WifiInterface) error
- func (c *Client) DumpInterfaces() ([]*WifiInterface, error)
- func (c *Client) InterfaceById(ifindex uint32) (*WifiInterface, error)
- func (c *Client) InterfaceByName(name string) (*WifiInterface, error)
- func (c *Client) NewInterface(w *WifiInterface, ifname string, iftype InterfaceType) error
- func (c *Client) Reset() error
- func (c *Client) SetChannel(w *WifiInterface, channel int) error
- func (c *Client) SetInterfaceType(w *WifiInterface, iftype InterfaceType) error
- type InterfaceType
- type Nl80211Request
- type WifiInterface
Constants ¶
This section is empty.
Variables ¶
var WifiChannel = map[int]uint32{
1: 2412,
2: 2417,
3: 2422,
4: 2427,
5: 2432,
6: 2437,
7: 2442,
8: 2447,
9: 2452,
10: 2457,
11: 2462,
12: 2467,
13: 2472,
14: 2484,
36: 5180,
38: 5190,
40: 5200,
42: 5210,
44: 5220,
46: 5230,
48: 5240,
50: 5250,
52: 5260,
54: 5270,
56: 5280,
58: 5290,
60: 5300,
62: 5310,
64: 5320,
100: 5500,
102: 5510,
104: 5520,
106: 5530,
108: 5540,
110: 5550,
112: 5560,
114: 5570,
116: 5580,
118: 5590,
120: 5600,
122: 5610,
124: 5620,
126: 5630,
128: 5640,
130: 5650,
132: 5660,
134: 5670,
136: 5680,
138: 5690,
140: 5700,
149: 5745,
151: 5755,
153: 5765,
155: 5775,
157: 5785,
159: 5795,
161: 5805,
165: 5825,
}
Functions ¶
func NewAttributeFactory ¶
NewAttributeFactory takes an attribute type as an argument and returns a function which takes an attribute value and returns a pointer to an Attribute object
func NewNl80211Message ¶
func NewNl80211Message(cmd int, lst []AttributeEncoder) (*genetlink.Message, error)
NewNl80211Message takes a command and a list of attributes and returns a generic netlink message containing the encoded attributes.
Types ¶
type Attribute ¶
type Attribute[T any] struct { // contains filtered or unexported fields }
Attributes have a type (ex NL80211_ATTR_IFTYPE) and a value. They are encoded by passing a netlink.AttributeEncoder to their EncodeAttribute method.
func InterfaceIndexAttribute ¶
InterfaceIndexAttribute returns a pointer to an *Attribute[uint32] containing a valid NL80211_ATTR_IFINDEX value
func InterfaceNameAttribute ¶
InterfaceNameAttribute returns a pointer to an *Attribute[string] containing a valid NL80211_ATTR_IFNAME value
func InterfaceTypeAttribute ¶
InterfaceTypeAttribute returns a pointer to an *Attribute[uint32] containing a valid NL80211_ATTR_IFTYPE value
func MacAttribute ¶
MacAttribute returns a pointer to an *Attribute[uint32] containing a valid NL80211_ATTR_MAC value
func WiphyAttribute ¶
WiphyAttribute returns a pointer to an *Attribute[uint32] containing a valid NL80211_ATTR_WIPHY value
func WiphyFrequencyAttribute ¶
WiphyFrequencyAttribute returns a pointer to an *Attribute[uint32] containing a valid NL80211_ATTR_WIPHY_FREQ value
func (*Attribute[T]) EncodeAttribute ¶
func (a *Attribute[T]) EncodeAttribute(ae *netlink.AttributeEncoder)
type AttributeEncoder ¶
type AttributeEncoder interface {
EncodeAttribute(*netlink.AttributeEncoder)
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client objects handle communication with the nl80211 kernel interface.
func (*Client) DeleteInterface ¶
func (c *Client) DeleteInterface(w *WifiInterface) error
DeleteInterface deletes a wireless interface
func (*Client) DumpInterfaces ¶
func (c *Client) DumpInterfaces() ([]*WifiInterface, error)
DumpInterfaces returns a list of all wifi interfaces present on the system.
func (*Client) InterfaceById ¶
func (c *Client) InterfaceById(ifindex uint32) (*WifiInterface, error)
InterfaceById returns the interface that matches the given interface index.
func (*Client) InterfaceByName ¶
func (c *Client) InterfaceByName(name string) (*WifiInterface, error)
InterfaceByName takes an interface name and returns a pointer to the corresponding WifiInterface
func (*Client) NewInterface ¶
func (c *Client) NewInterface(w *WifiInterface, ifname string, iftype InterfaceType) error
NewInterface creates a new wifi interface using the underlying PHY of the provided interface
func (*Client) SetChannel ¶
func (c *Client) SetChannel(w *WifiInterface, channel int) error
SetChannel sets the wifi channel of a given interface
func (*Client) SetInterfaceType ¶
func (c *Client) SetInterfaceType(w *WifiInterface, iftype InterfaceType) error
SetInterfaceType sets the interface type of the given interface
type InterfaceType ¶
type InterfaceType int
An InterfaceType is the operating mode of an Interface.
const ( InterfaceTypeUnspecified InterfaceType = iota InterfaceTypeAdHoc InterfaceTypeStation InterfaceTypeAP InterfaceTypeAPVLAN InterfaceTypeWDS InterfaceTypeMonitor InterfaceTypeMeshPoint InterfaceTypeP2PClient InterfaceTypeP2PGroupOwner InterfaceTypeP2PDevice InterfaceTypeOCB InterfaceTypeNAN )
func (InterfaceType) String ¶
func (t InterfaceType) String() string
String returns the string representation of an InterfaceType.
type Nl80211Request ¶
type Nl80211Request struct { RequestMessage *genetlink.Message Flags netlink.HeaderFlags // contains filtered or unexported fields }
type WifiInterface ¶
type WifiInterface struct { Index uint32 Name string HardwareAddr net.HardwareAddr Phy uint32 Type InterfaceType Device uint64 Frequency uint32 }
func (*WifiInterface) String ¶
func (c *WifiInterface) String() string