netlink.rt.addrModule
Interface address listing.
A netlink.session specialization over theNETLINK_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;
niland"ESRCH"if no task has that pid, or the task has exited.Raises
EOPNOTSUPPon 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 (defaultAF_UNSPEC, every family). (optional)
Returns
-
table
list of address tables, each with
family,prefixlen,scope,ifindex,address,peerandlabel;addressis the interface’s own address andpeer, 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. - opts
table
list options:
- 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