Modules | |
Abstract Address | |
Caching | |
Abstract Data | |
Callbacks/Customization | |
Messages | |
Netlink Message Construction/Parsing Interface. | |
Netlink socket helpers | |
Utilities | |
Connection Management | |
int | nl_connect (struct nl_sock *sk, int protocol) |
Create and connect netlink socket. More... | |
void | nl_close (struct nl_sock *sk) |
Close/Disconnect netlink socket. More... | |
Send | |
int | nl_sendto (struct nl_sock *sk, void *buf, size_t size) |
Send raw data over netlink socket. More... | |
int | nl_sendmsg (struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr) |
Send netlink message with control over sendmsg() message header. More... | |
int | nl_send_iovec (struct nl_sock *sk, struct nl_msg *msg, const struct iovec *iov, unsigned iovlen) |
Send netlink message. More... | |
int | nl_send (struct nl_sock *sk, struct nl_msg *msg) |
Send netlink message. More... | |
void | nl_auto_complete (struct nl_sock *sk, struct nl_msg *msg) |
int | nl_send_auto_complete (struct nl_sock *sk, struct nl_msg *msg) |
Send netlink message and check & extend header values as needed. More... | |
int | nl_send_simple (struct nl_sock *sk, int type, int flags, void *buf, size_t size) |
Send simple netlink message using nl_send_auto_complete() More... | |
Receive | |
int | nl_recv (struct nl_sock *sk, struct sockaddr_nl *nla, unsigned char **buf, struct ucred **creds) |
Receive data from netlink socket. More... | |
int | nl_recvmsgs (struct nl_sock *sk, struct nl_cb *cb) |
Receive a set of messages from a netlink socket. More... | |
int | nl_recvmsgs_default (struct nl_sock *sk) |
Receive a set of message from a netlink socket using handlers in nl_sock. More... | |
int | nl_wait_for_ack (struct nl_sock *sk) |
Wait for ACK. More... | |
#define | NL_CB_CALL(cb, type, msg) |
#define NL_CB_CALL | ( | cb, | |
type, | |||
msg | |||
) |
References NL_NO_AUTO_ACK, sockaddr_nl::nl_pid, nlh, NLM_F_ACK, NLM_F_REQUEST, nlmsghdr::nlmsg_flags, nlmsg_hdr(), nlmsghdr::nlmsg_pid, nlmsghdr::nlmsg_seq, nl_msg::nm_protocol, nl_sock::s_flags, nl_sock::s_local, nl_sock::s_proto, and nl_sock::s_seq_next.
Referenced by nfnl_queue_msg_send_verdict_payload(), and nl_send_auto_complete().
Close/Disconnect netlink socket.
References nl_sock::s_fd, and nl_sock::s_proto.
Referenced by main(), and nl_cache_mngr_free().
Create and connect netlink socket.
Creates a netlink socket using the specified protocol, binds the socket and issues a connection attempt.
References sockaddr_nl::nl_family, NL_SOCK_BUFSIZE_SET, nl_socket_set_buffer_size(), nl_syserr2nlerr(), NLE_AF_NOSUPPORT, NLE_NOADDR, nl_sock::s_fd, nl_sock::s_flags, nl_sock::s_local, and nl_sock::s_proto.
Referenced by genl_connect(), nfnl_connect(), nl_cache_mngr_alloc(), and nl_cli_connect().
int nl_recv | ( | struct nl_sock * | sk, |
struct sockaddr_nl * | nla, | ||
unsigned char ** | buf, | ||
struct ucred ** | creds | ||
) |
Receive data from netlink socket.
Receives a netlink message, allocates a buffer in *buf
and stores the message content. The peer's netlink address is stored in *nla
. The caller is responsible for freeing the buffer allocated in *buf
if a positive value is returned. Interruped system calls are handled by repeating the read. The input buffer size is determined by peeking before the actual read is done.
A non-blocking sockets causes the function to return immediately with a return value of 0 if no data is available.
References flags, MSG_TRUNC, NL_DBG, NL_MSG_PEEK, NL_SOCK_PASSCRED, nl_syserr2nlerr(), NLE_NOADDR, NULL, nl_sock::s_fd, and nl_sock::s_flags.
Receive a set of messages from a netlink socket.
Repeatedly calls nl_recv() or the respective replacement if provided by the application (see nl_cb_overwrite_recv()) and parses the received data as netlink messages. Stops reading if one of the callbacks returns NL_STOP or nl_recv returns either 0 or a negative error code.
A non-blocking sockets causes the function to return immediately if no data is available.
References nl_cb::cb_recvmsgs_ow.
Referenced by __cache_pickup(), nl_recvmsgs_default(), and nl_wait_for_ack().
Receive a set of message from a netlink socket using handlers in nl_sock.
Calls nl_recvmsgs() with the handlers configured in the netlink socket.
References nl_recvmsgs(), and nl_sock::s_cb.
Referenced by main(), and nl_cache_mngr_data_ready().
Send netlink message.
References nl_send_iovec(), nlmsg_hdr(), and nlmsghdr::nlmsg_len.
Referenced by nl_send_auto_complete().
Send netlink message and check & extend header values as needed.
Checks the netlink message nlh
for completness and extends it as required before sending it out. Checked fields include pid, sequence nr, and flags.
References nl_cb::cb_send_ow, nl_auto_complete(), nl_send(), and nl_sock::s_cb.
Referenced by flnl_lookup(), main(), nfnl_ct_add(), nfnl_ct_del(), nfnl_ct_query(), nfnl_nft_chain_add(), nfnl_nft_chain_delete(), nfnl_nft_chain_query(), nfnl_nft_rule_add(), nfnl_nft_rule_delete(), nfnl_nft_rule_query(), nfnl_nft_set_add(), nfnl_nft_set_delete(), nfnl_nft_set_dump_request(), nfnl_nft_set_query(), nfnl_nft_setelem_dump_request(), nfnl_nft_setelem_query(), nfnl_nft_table_add(), nfnl_nft_table_delete(), nfnl_nft_table_query(), nfnl_queue_msg_send_verdict(), nl_send_simple(), rtnl_addr_add(), rtnl_addr_delete(), rtnl_class_add(), rtnl_class_delete(), rtnl_cls_add(), rtnl_cls_change(), rtnl_cls_delete(), rtnl_link_change(), rtnl_neigh_add(), rtnl_neigh_delete(), rtnl_neightbl_change(), rtnl_qdisc_add(), rtnl_qdisc_change(), rtnl_qdisc_delete(), rtnl_route_add(), rtnl_route_delete(), rtnl_rule_add(), and rtnl_rule_delete().
int nl_send_iovec | ( | struct nl_sock * | sk, |
struct nl_msg * | msg, | ||
const struct iovec * | iov, | ||
unsigned | iovlen | ||
) |
Send netlink message.
References buf, sockaddr_nl::nl_family, nl_sendmsg(), nlmsg_get_creds(), nlmsg_get_dst(), NULL, and nl_sock::s_peer.
Referenced by nfnl_queue_msg_send_verdict_payload(), and nl_send().
Send simple netlink message using nl_send_auto_complete()
Builds a netlink message with the specified type and flags and appends the specified data as payload to the message.
References nl_send_auto_complete(), NLE_NOMEM, NLMSG_ALIGNTO, nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().
Referenced by genl_send_simple(), nfnl_send_simple(), and nl_rtgen_request().
Send netlink message with control over sendmsg() message header.
References nl_cb::cb_set, NL_CB_MSG_OUT, NL_DBG, NL_OK, nl_syserr2nlerr(), nlmsg_set_src(), nl_sock::s_cb, nl_sock::s_fd, and nl_sock::s_local.
Referenced by nl_send_iovec().
Send raw data over netlink socket.
References nl_syserr2nlerr(), nl_sock::s_fd, and nl_sock::s_peer.
Wait for ACK.
References NL_CB_ACK, nl_cb_clone(), NL_CB_CUSTOM, nl_cb_put(), nl_cb_set(), nl_recvmsgs(), NLE_NOMEM, NULL, and nl_sock::s_cb.
Referenced by rtnl_cls_add(), rtnl_cls_change(), and rtnl_cls_delete().