Lunatik

netlink.rt.addrModule

Interface address listing.

A netlink.session specialization over the NETLINK_ROUTE protocol: create an instance with netlink.rt.addr() and list the kernel’s interface addresses; the underlying socket is closed by close() (or the to-be-closed __close). All methods block and require a sleepable runtime.

See also

Class addr

addr:__call ([pid]) Opens a session, calling the class: netlink.rt.addr([pid]).
addr:list ([opts]) Lists all interface addresses from the kernel.
addr:new ([o]) Wraps a table in the class, or derives a class from it.

Class addr in detail

addr:__call ([pid])
Opens a session, calling the class: netlink.rt.addr([pid]).

Parameters

  • pid integer a task whose network namespace the session talks to, as socket.new takes it; the initial network namespace when absent. (optional)

Returns

    addr a new addr object; nil and "ESRCH" if no task has that pid, or the task has exited.

Raises

EOPNOTSUPP on a kernel whose sockets cannot hold a namespace of their own.

See also

addr:list ([opts])
Lists all interface addresses from the kernel.

Parameters

  • opts table list options: family, the address family of the records listed (default AF_UNSPEC, every family). (optional)

Returns

    table list of address tables, each with family, prefixlen, scope, ifindex, address, peer and label; address is the interface’s own address and peer, only on an address configured with one, the other end of a point-to-point link, both as bytes in network byte order; a field whose attribute the reply lacks is nil.
addr:new ([o])
Wraps a table in the class, or derives a class from it. It opens no socket: calling the class does, netlink.rt.addr().

Parameters

  • o table an initial object table. (optional)

Returns

    addr the wrapped table or the derived class.

See also