View Source VintageNet.Route (vintage_net v0.13.3)

Types for handling routing tables

Link to this section Summary

Types

A default route entry

A list of routing table entries

A routing table entry

A local route entry

Metric (priority) for a routing table entry

Compute a route metric value from information about the interface

An IP route rule

Linux routing table index

Link to this section Types

@type default_route() ::
  {:default_route, VintageNet.ifname(), :inet.ip_address(), metric(),
   table_index()}

A default route entry

The IP address is the default gateway

@type entries() :: [entry()]

A list of routing table entries

@type entry() :: rule() | default_route() | local_route()

A routing table entry

This can be turned into real Linux IP routing table entry.

@type local_route() ::
  {:local_route, VintageNet.ifname(), :inet.ip_address(), metric(),
   table_index()}

A local route entry

This is for routing packets to the LAN

@type metric() :: 0..32767

Metric (priority) for a routing table entry

@type route_metric_fun() ::
  (VintageNet.ifname(), VintageNet.Route.InterfaceInfo.t() -> metric())

Compute a route metric value from information about the interface

See VintageNet.Route.DefaultMetric.compute_metric/2 for an example. This can be set using the :route_metric_fun application environment key.

@type rule() :: {:rule, table_index(), :inet.ip_address()}

An IP route rule

If the source address matches the 3rd element, then use the routing table specified by the 2nd element.

@type table_index() :: 0..255 | :main | :local | :default

Linux routing table index

:main is table 254, :local is table 255. :default is normally the same as :main.