ADS.NetId (yaads v0.1.0)

Copy Markdown View Source

AMS NetIds: six numbers from 0 to 255, written with dots like an IP address with two more parts, and sent as six bytes in that order.

iex> ADS.NetId.parse("172.16.17.10.1.1")
{:ok, <<172, 16, 17, 10, 1, 1>>}
iex> ADS.NetId.to_string(<<5, 36, 69, 176, 1, 1>>)
"5.36.69.176.1.1"
iex> ADS.NetId.parse("10.0.0.5")
:error

A NetId is configured on each system, and is often its IP address with .1.1 added, which from_ip/1 makes.

Summary

Types

t()

A NetId as sent: six bytes.

Functions

The NetId made from an IPv4 address by adding .1.1.

Parses a NetId written with dots.

Parses a NetId, raising ArgumentError for one that isn't.

A NetId written with dots.

Types

t()

@type t() :: <<_::48>>

A NetId as sent: six bytes.

Functions

from_ip(arg)

@spec from_ip(:inet.ip4_address()) :: t()

The NetId made from an IPv4 address by adding .1.1.

iex> ADS.NetId.from_ip({10, 0, 0, 5})
<<10, 0, 0, 5, 1, 1>>

parse(string)

@spec parse(String.t()) :: {:ok, t()} | :error

Parses a NetId written with dots.

parse!(string)

@spec parse!(String.t()) :: t()

Parses a NetId, raising ArgumentError for one that isn't.

to_string(net_id)

@spec to_string(t()) :: String.t()

A NetId written with dots.