l2

package
v0.0.0-...-b5aedff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EDDYSTONE16    = []byte{0xAA, 0xFE}
	CH_PROXY_WRITE = []byte{0xDD, 0x2A}
	CH_PROXY_NOTIF = []byte{0xDE, 0x2A}
)
View Source
var (
	AlreadyConnected = errors.New("Already connected")
)

Functions

func DhcpServer

func DhcpServer(dhcpIf string) error

Start a DHCP server on an interface.

This is at L2 because it is used to allow local devices to communicate on the same network. Android expects an IPv4 address to establish P2P connections.

func Schedule

func Schedule(ctx context.Context, p time.Duration,
	o time.Duration, f func(time.Time))

Schedule calls function `f` with a period `p` offsetted by `o`. Aligned with the duration (fixed)

func ScheduleBeacon

func ScheduleBeacon(nanc *wifi.Nan)

func Uint64

func Uint64(b net.HardwareAddr) uint64

Types

type BLE

type BLE struct {
	// contains filtered or unexported fields
}

BLE provides L2 connectivity with other nodes supporting BLE. This uses an extension of EddyStone beacon - advertising the DMesh ID. The extension consists on using the proxy characteristics (from BLE Mesh service) to also allow packet exchange.

Has a matching Android implementation as well as ESP32. When running on Android, the BLE is implemented by the Android process using the core libraries - this is used on linux hosts.

func (*BLE) CleanOlder

func (b *BLE) CleanOlder(d time.Duration)

func (*BLE) Scan

func (b *BLE) Scan(d time.Duration) error

Discover BLE devices of the right type. If found, attempt to connect to create mesh links. TODO: select strongest signal, limit the numbers.

type BLENode

type BLENode struct {
	msgs.MsgConnection

	Addr ble.Addr
	Name string

	Last time.Time
	// contains filtered or unexported fields
}

Tracks a BLE peer.

func (*BLENode) String

func (b *BLENode) String() string

type DHCPHandler

type DHCPHandler struct {
	// contains filtered or unexported fields
}

func (*DHCPHandler) ServeDHCP

func (h *DHCPHandler) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType, options dhcp.Options) (d dhcp.Packet)

type L2

type L2 struct {
	// contains filtered or unexported fields
}

func NewL2

func NewL2(mux *msgs.Mux) *L2

func (*L2) InitBLE

func (l2 *L2) InitBLE() (*BLE, error)

Requires capabilities on the binary or root Uses a AF_BLUETOOTH socket and HCI.

Creates a 'serial' connection over BLE.

func (*L2) InitMon

func (l2 *L2) InitMon(iface *wifi.Interface) error

func (*L2) InitWifi

func (l2 *L2) InitWifi() error

Low level Wifi, using monitor interfaces and netlink. Supports a subset of WifiAware, as well as extensions to handle the lack of low-level support.

func (*L2) NewWPA

func (l2 *L2) NewWPA(baseDir string, refresh int, ap string) (*WPA, error)

baseDir defaults to /var/run/wpa_supplicant

type WPA

type WPA struct {
	// P2P and normal interface are separated.
	// Multiple wifi interfaces supported.
	// TODO: ESP32 or equivalent modems connected via serial or BLE, supporting
	// other frequencies.
	Interfaces map[string]*WifiInterface
	// contains filtered or unexported fields
}

func (*WPA) HandleMessage

func (c *WPA) HandleMessage(ctx context.Context, cmd string, meta map[string]string, data []byte)

Messages on "wifi" topic, for this node.

scan disc con ssid psk p2p wpa - low level wpa command, "i" and "c" params

type WPANetwork

type WPANetwork struct {
	Id    int
	SSID  string
	ESSID string
	Flags string // [CURRENT]
}

Wifi network info - list of networks registered. See wifiManager.getConfiguredNetworks(), plus get current wifi.

type WifiInterface

type WifiInterface struct {

	// Primary interface name.
	Interface string

	// Last scan results (raw). Includes known and DIRECT networks.
	LastScan *mesh.L2NetStatus
	ScanTime time.Time

	// Keep track of discovered P2P devices.
	P2PByMAC  map[string]*mesh.MeshDevice
	P2PBySSID map[string]*mesh.MeshDevice
	// contains filtered or unexported fields
}

func DialWPA

func DialWPA(wpap *WPA, base, ifname string, refreshSeconds int, ap string) (*WifiInterface, error)

DialWPA connects to a real interface. Requires root or NET_ADMIN

func (*WifiInterface) APStart

func (c *WifiInterface) APStart()

Attempt to start P2P AP, using channel 6 if possible so NAN can work

func (*WifiInterface) APStop

func (c *WifiInterface) APStop()

func (*WifiInterface) AddNetwork

func (c *WifiInterface) AddNetwork() (int, error)

func (*WifiInterface) Connect

func (c *WifiInterface) Connect(meta map[string]string, ssid, pass string) error

func (*WifiInterface) DisableNetwork

func (c *WifiInterface) DisableNetwork(networkId int) error

func (*WifiInterface) EnableNetwork

func (c *WifiInterface) EnableNetwork(networkId int) error

func (*WifiInterface) GetNetworkSetting

func (c *WifiInterface) GetNetworkSetting(networkId int, variable string) (string, error)

func (*WifiInterface) ListNetworks

func (c *WifiInterface) ListNetworks() ([]*WPANetwork, error)

func (*WifiInterface) OnP2PGroupStart

func (c *WifiInterface) OnP2PGroupStart(parts []string)

Called as result of ...

P2P-GROUP-STARTED p2p-wlp2s0-0 GO ssid="DIRECT-JF" freq=2437 passphrase="DKAcUzpO" go_dev_addr=38:ba:f8:49:d3:c0

func (*WifiInterface) OnP2PGroupStop

func (c *WifiInterface) OnP2PGroupStop(parts []string)

<3>P2P-GROUP-REMOVED p2p-wlp2s0-4 GO reason=REQUESTED

func (*WifiInterface) P2PDiscover

func (c *WifiInterface) P2PDiscover()

start peer discovery with DNSSD. Events will be sent, discovery will auto-terminate Uses a hard-coded time of 6 seconds ( TODO: and override )

func (*WifiInterface) Redial

func (i *WifiInterface) Redial() error

func (*WifiInterface) ReloadConfiguration

func (c *WifiInterface) ReloadConfiguration() error

func (*WifiInterface) RemoveNetwork

func (c *WifiInterface) RemoveNetwork(networkId int) error

func (*WifiInterface) SaveConfiguration

func (c *WifiInterface) SaveConfiguration() error

func (*WifiInterface) Scan

func (c *WifiInterface) Scan()

func (*WifiInterface) SelectNetwork

func (c *WifiInterface) SelectNetwork(networkId int) error

func (*WifiInterface) SendCommand

func (c *WifiInterface) SendCommand(command string) (string, error)

PING STATUS: address, p2p_device_address RECONNECT,REASSOCIATE p2p_group_add OK <3>P2P-GROUP-STARTED p2p-wlp2s0-0 GO ssid="DIRECT-OF" freq=2437 passphrase="5BqiXAgj" go_dev_addr=cc:2f:71:c8:f3:99 <3>P2P-SERV-DISC-REQ 2437 da:50:e6:91:5b:cb 0 22 02000117 P2P_SERV_DISC_EXTERNAL 1 -> 0 means to reject disc req, 1 to respond with ...

func (*WifiInterface) SendCommandBool

func (c *WifiInterface) SendCommandBool(command string) error

func (*WifiInterface) SendCommandInt

func (c *WifiInterface) SendCommandInt(command string) (int, error)

func (*WifiInterface) SendCommandP2P

func (c *WifiInterface) SendCommandP2P(command string) (string, error)

func (*WifiInterface) SetNetworkSettingRaw

func (c *WifiInterface) SetNetworkSettingRaw(networkId int, variable string, value string) error

func (*WifiInterface) SetNetworkSettingString

func (c *WifiInterface) SetNetworkSettingString(networkId int, variable string, value string) error

func (*WifiInterface) Status

func (c *WifiInterface) Status() map[string]string

func (*WifiInterface) UpdateLoop

func (c *WifiInterface) UpdateLoop(refresh int)

Directories

Path Synopsis
Package nl80211 is an auto-generated package which contains constants and types used to access nl80211 information using generic netlink.
Package nl80211 is an auto-generated package which contains constants and types used to access nl80211 information using generic netlink.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL