netlink

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: BSD-3-Clause Imports: 3 Imported by: 3

README

Table of Contents

Netlinker

TinyGo's network device driver model comprises two Go interfaces: Netdever and Netlinker. This README covers Netlinker.

The Netlinker interface describes an L2 network interface. A netlink is a concrete implementation of a Netlinker. See Netdev for the L4/L3 network interface.

A netlink can:

  • Connect/disconnect device to/from network
  • Notify of network events (e.g. link UP/DOWN)
  • Send and receive Ethernet packets
  • Get/set device's hardware address (MAC address)

Documentation

Index

Constants

View Source
const (
	ConnectModeSTA = iota // Connect as Wifi station (default)
	ConnectModeAP         // Connect as Wifi Access Point
)

Connect modes

View Source
const (
	AuthTypeWPA2      = iota // WPA2 authorization (default)
	AuthTypeOpen             // No authorization required (open)
	AuthTypeWPA              // WPA authorization
	AuthTypeWPA2Mixed        // WPA2/WPA mixed authorization
)

Wifi authorization types. Used when setting up an access point, or connecting to an access point

View Source
const DefaultConnectTimeout = 10 * time.Second

Variables

View Source
var (
	ErrConnected         = errors.New("Already connected")
	ErrConnectFailed     = errors.New("Connect failed")
	ErrConnectTimeout    = errors.New("Connect timed out")
	ErrMissingSSID       = errors.New("Missing WiFi SSID")
	ErrShortPassphrase   = errors.New("Invalid Wifi Passphrase < 8 chars")
	ErrAuthFailure       = errors.New("Wifi authentication failure")
	ErrAuthTypeNoGood    = errors.New("Wifi authorization type not supported")
	ErrConnectModeNoGood = errors.New("Connect mode not supported")
	ErrNotSupported      = errors.New("Not supported")
)

Functions

This section is empty.

Types

type AuthType

type AuthType int

type ConnectMode

type ConnectMode int

type ConnectParams

type ConnectParams struct {

	// Connect mode
	ConnectMode

	// SSID of Wifi AP
	Ssid string

	// Passphrase of Wifi AP
	Passphrase string

	// Wifi authorization type
	AuthType

	// Wifi country code as two-char string.  E.g. "XX" for world-wide,
	// "US" for USA, etc.
	Country string

	// Retries is how many attempts to connect before returning with a
	// "Connect failed" error.  Zero means infinite retries.
	Retries int

	// Timeout duration for each connection attempt.  The default zero
	// value means 10sec.
	ConnectTimeout time.Duration

	// Watchdog ticker duration.  On tick, the watchdog will check for
	// downed connection or hardware fault and try to recover the
	// connection.  Set to zero to disable watchodog.
	WatchdogTimeout time.Duration
}

type Event

type Event int
const (
	// The device's network connection is now UP
	EventNetUp Event = iota
	// The device's network connection is now DOWN
	EventNetDown
)

Network events

type Netlinker

type Netlinker interface {

	// Connect device to network
	NetConnect(params *ConnectParams) error

	// Disconnect device from network
	NetDisconnect()

	// Notify to register callback for network events
	NetNotify(cb func(Event))

	// GetHardwareAddr returns device MAC address
	GetHardwareAddr() (net.HardwareAddr, error)
}

Jump to

Keyboard shortcuts

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