# `VintageNet.Route`
[🔗](https://github.com/nerves-networking/vintage_net/blob/v0.13.9/lib/vintage_net/route.ex#L5)

Types for handling routing tables

# `default_route`

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

A default route entry

The IP address is the default gateway

# `entries`

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

A list of routing table entries

# `entry`

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

A routing table entry

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

# `local_route`

```elixir
@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

# `metric`

```elixir
@type metric() :: 0..32767
```

Metric (priority) for a routing table entry

# `route_metric_fun`

```elixir
@type route_metric_fun() :: (VintageNet.ifname(),
                       VintageNet.Route.InterfaceInfo.t() -&gt;
                         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.

# `rule`

```elixir
@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.

# `table_index`

```elixir
@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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
