vintage_net v0.5.1 VintageNet.Technology behaviour View Source

Technologies define how network interface types work

VintageNet comes with several built-in technologies, but more can be added or existing ones modified by implementing the Technology behaviour.

Link to this section Summary

Callbacks

Check that the system has all of the required programs for this technology

Handle an ioctl that has been requested on the network interface

Normalize a configuration

Convert a technology-specific configuration to one for VintageNet

Link to this section Callbacks

Link to this callback

check_system(opts)

View Source
check_system(opts :: keyword()) :: :ok | {:error, String.t()}

Check that the system has all of the required programs for this technology

This is intended to help identify missing programs without configuring a network.

Link to this callback

ioctl(arg1, command, args)

View Source
ioctl(VintageNet.ifname(), command :: atom(), args :: list()) ::
  :ok | {:ok, any()} | {:error, any()}

Handle an ioctl that has been requested on the network interface

The function runs isolated in its own process and only one ioctl is guaranteed to be running at a time. VintageNet will handle crashes and hangs and unceremoniously kill the ioctl if the user changes their mind and reconfigures the network interface.

Ioctl support is optional. Examples of ioctls include:

  • :scan - scan for WiFi networks
  • :statistics - return a map of network statistics
Link to this callback

normalize(config)

View Source
normalize(config :: map()) :: {:ok, map()} | {:error, any()}

Normalize a configuration

Technologies can use this to update provided configurations so that same configurations that could be specified in multiple ways have a single representation.

Link to this callback

to_raw_config(arg1, config, opts)

View Source
to_raw_config(VintageNet.ifname(), config :: map(), opts :: keyword()) ::
  {:ok, VintageNet.Interface.RawConfig.t()} | {:error, any()}

Convert a technology-specific configuration to one for VintageNet