View Source VintageNet.Interface.NameUtilities (vintage_net v0.13.3)

Module for classifying network interfaces

Link to this section Summary

Functions

Extract a number out of an interface name

Classify a network type based on its name

Link to this section Functions

@spec get_instance(VintageNet.ifname()) :: non_neg_integer()

Extract a number out of an interface name

The result is the interface index for most interfaces seen on Nerves (eth0, eth1, ...), and something quite imperfect when using predictable interface naming (enp6s0, enp6s1).

This is currently used to order priorities when there are two interfaces available of the same type that cannot be differentiated by other means. It has the one property of being easy to explain.

Classify a network type based on its name

Examples

iex> NameUtilities.to_type("eth0")
:ethernet

iex> NameUtilities.to_type("wlp5s0")
:wifi

iex> NameUtilities.to_type("wwan0")
:mobile