Module netlink.session
Netlink request/response session.
A session owns an AF_NETLINK socket and
the transaction discipline on it: talk and dump send one request and
drain its complete reply, raising on a kernel error reply (NLMSG_ERROR).
Protocol modules (rtnetlink, generic netlink) derive from this class.
All methods block and require a sleepable runtime.
See also:
Class session
| session:__call () | Creates a session backed by an AF_NETLINK socket of the class's proto. |
| session:close () | Closes the underlying socket. |
| session:dump (mtype, payload) | Sends a dump request and drains the multipart reply until NLMSG_DONE. |
| session:new ([o]) | Creates a new session object. |
| session:request (mtype, flags, payload) | Sends one request (NLM_F_REQUEST plus flags) with a fresh sequence number, without waiting for a reply. |
| session:talk (mtype[, flags=0], payload) | Sends a request with NLM_F_ACK and drains the reply up to the kernel
acknowledgment, keeping the socket in sync. |
Class session
Base class for netlink sessions.
- session:__call ()
-
Creates a session backed by an
AF_NETLINKsocket of the class'sproto.Returns:
-
session
a new session object.
- session:close ()
- Closes the underlying socket.
- session:dump (mtype, payload)
-
Sends a dump request and drains the multipart reply until
NLMSG_DONE.Parameters:
- mtype integer message type.
- payload string the family header and attributes.
Returns:
-
table
the parsed reply messages (the trailing
NLMSG_DONEincluded; see netlink.message.parse).Raises:
on a netlink error reply. - session:new ([o])
-
Creates a new session object.
Parameters:
- o table an initial object table. (optional)
Returns:
-
session
the new session object.
See also:
- session:request (mtype, flags, payload)
-
Sends one request (
NLM_F_REQUESTplusflags) with a fresh sequence number, without waiting for a reply.Parameters:
- mtype integer message type.
- flags integer additional NLMF* flags.
- payload string the family header and attributes.
- session:talk (mtype[, flags=0], payload)
-
Sends a request with
NLM_F_ACKand drains the reply up to the kernel acknowledgment, keeping the socket in sync.Parameters:
- mtype integer message type.
- flags integer extra NLMF* flags. (default 0)
- payload string the family header and attributes.
Returns:
-
table
the parsed reply messages (the trailing ack included).
Raises:
on a netlink error reply.