vintage_net v0.2.1 VintageNet
VintageNet
is network configuration library built specifically for Nerves
Project devices. It has the following features:
- Ethernet and WiFi support included. Extendible to other technologies
- Default configurations specified in your Application config
- Runtime updates to configurations are persisted and applied on next boot (can be disabled)
- Simple subscription to network status change events
- Connect to multiple networks at a time and prioritize which interfaces are used (Ethernet over WiFi over cellular)
- Internet connection monitoring and failure detection (currently slow and simplistic)
See github.com/nerves-networking/vintage_net for more information.
Link to this section Summary
Functions
Return a list of all interfaces on the system
Check if this is a valid configuration
Update the settings for the specified interface
Return a list of configured interface
Get the current value of a network property
Get a list of all properties matching the specified prefix
Return the settings for the specified interface
Print the current network status
Run a command on a network interface
Scan wireless interface for other access points
Subscribe to receive property change messages
Stop subscribing to property change messages
Check that the system has the required programs installed
Link to this section Types
ifname()
ifname() :: String.t()
ifname() :: String.t()
A name for the network interface
Names depend on the device drivers and any software that may rename them. Typical names on Nerves are:
- "eth0", "eth1", etc. for wired Ethernet interfaces
- "wlan0", etc. for WiFi interfaces
- "ppp0" for cellular modems
- "usb0" for gadget USB virtual Ethernet interfaces
Link to this section Functions
all_interfaces()
all_interfaces() :: [ifname()]
all_interfaces() :: [ifname()]
Return a list of all interfaces on the system
NOTE: This list is currently updated every 30 seconds rather than on change.
Be patient.
configuration_valid?(ifname, config)
Check if this is a valid configuration
This runs the validation routines for a settings map, but doesn't try to apply them.
configure(ifname, config)
Update the settings for the specified interface
configured_interfaces()
configured_interfaces() :: [ifname()]
configured_interfaces() :: [ifname()]
Return a list of configured interface
get(name, default \\ nil)
Get the current value of a network property
See get_by_prefix/1
to get some or all properties.
get_by_prefix(prefix)
get_by_prefix(VintageNet.PropertyTable.property()) :: [
{VintageNet.PropertyTable.property(), VintageNet.PropertyTable.value()}
]
get_by_prefix(VintageNet.PropertyTable.property()) :: [ {VintageNet.PropertyTable.property(), VintageNet.PropertyTable.value()} ]
Get a list of all properties matching the specified prefix
To get a list of all known properties and their values, call
VintageNet.get_by_prefix([])
get_configuration(ifname)
Return the settings for the specified interface
info()
info() :: :ok
info() :: :ok
Print the current network status
ioctl(ifname, command, args \\ [])
Run a command on a network interface
Commands are mostly network interface-specific. Also see the VintageNet
PropertyTable fo getting status or registering for status changes.
scan(ifname)
scan(ifname()) :: {:ok, [VintageNet.WiFi.AccessPoint.t()]} | {:error, any()}
scan(ifname()) :: {:ok, [VintageNet.WiFi.AccessPoint.t()]} | {:error, any()}
Scan wireless interface for other access points
This is a utility function for calling the :scan
ioctl.
subscribe(name)
subscribe(VintageNet.PropertyTable.property()) :: :ok
subscribe(VintageNet.PropertyTable.property()) :: :ok
Subscribe to receive property change messages
Messages have the form:
{VintageNet, property_name, old_value, new_value, metadata}
unsubscribe(name)
unsubscribe(VintageNet.PropertyTable.property()) :: :ok
unsubscribe(VintageNet.PropertyTable.property()) :: :ok
Stop subscribing to property change messages
verify_system(opts \\ nil)
Check that the system has the required programs installed
NOTE: This isn't completely implemented yet!