libnl
1.1
|
Modules | |
Callbacks/Customization | |
Callbacks and overwriting capabilities are provided to take influence in various control flows inside the library. | |
Messages | |
Netlink Message Construction/Parsing Interface. | |
Socket | |
Handle representing a netlink socket. | |
Data Structures | |
struct | sockaddr_nl |
Netlink socket address. More... | |
Connection Management | |
int | nl_connect (struct nl_handle *handle, int protocol) |
Create and connect netlink socket. More... | |
void | nl_close (struct nl_handle *handle) |
Close/Disconnect netlink socket. More... | |
Send | |
int | nl_sendto (struct nl_handle *handle, void *buf, size_t size) |
Send raw data over netlink socket. More... | |
int | nl_sendmsg (struct nl_handle *handle, struct nl_msg *msg, struct msghdr *hdr) |
Send netlink message with control over sendmsg() message header. More... | |
int | nl_send (struct nl_handle *handle, struct nl_msg *msg) |
Send netlink message. More... | |
int | nl_send_auto_complete (struct nl_handle *handle, struct nl_msg *msg) |
Send netlink message and check & extend header values as needed. More... | |
int | nl_send_simple (struct nl_handle *handle, 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_handle *handle, struct sockaddr_nl *nla, unsigned char **buf, struct ucred **creds) |
Receive data from netlink socket. More... | |
int | nl_recvmsgs (struct nl_handle *handle, struct nl_cb *cb) |
Receive a set of messages from a netlink socket. More... | |
int | nl_recvmsgs_default (struct nl_handle *handle) |
Receive a set of message from a netlink socket using handlers in nl_handle. More... | |
int | nl_wait_for_ack (struct nl_handle *handle) |
Wait for ACK. More... | |
#define | NL_CB_CALL(cb, type, msg) |
#define NL_CB_CALL | ( | cb, | |
type, | |||
msg | |||
) |
int nl_connect | ( | struct nl_handle * | handle, |
int | protocol | ||
) |
handle | Netlink handle. |
protocol | Netlink protocol to use. |
Creates a netlink socket using the specified protocol, binds the socket and issues a connection attempt.
Definition at line 191 of file nl.c.
References nl_set_buffer_size().
Referenced by nfnl_connect(), and nl_cache_mngr_alloc().
void nl_close | ( | struct nl_handle * | handle | ) |
handle | Netlink handle |
Definition at line 247 of file nl.c.
Referenced by nl_cache_mngr_free().
int nl_sendto | ( | struct nl_handle * | handle, |
void * | buf, | ||
size_t | size | ||
) |
int nl_sendmsg | ( | struct nl_handle * | handle, |
struct nl_msg * | msg, | ||
struct msghdr * | hdr | ||
) |
handle | Netlink handle. |
msg | Netlink message to be sent. |
hdr | Sendmsg() message header. |
Definition at line 290 of file nl.c.
References NL_CB_MSG_OUT, NL_OK, nlmsg_hdr(), and nlmsghdr::nlmsg_len.
Referenced by nl_send().
int nl_send | ( | struct nl_handle * | handle, |
struct nl_msg * | msg | ||
) |
handle | Netlink handle |
msg | Netlink message to be sent. |
Definition at line 325 of file nl.c.
References sockaddr_nl::nl_family, and nl_sendmsg().
Referenced by nl_send_auto_complete().
int nl_send_auto_complete | ( | struct nl_handle * | handle, |
struct nl_msg * | msg | ||
) |
handle | Netlink handle. |
msg | Netlink message to be sent. |
Checks the netlink message nlh
for completness and extends it as required before sending it out. Checked fields include pid, sequence nr, and flags.
Definition at line 373 of file nl.c.
References nl_send(), NLM_F_ACK, NLM_F_REQUEST, nlmsghdr::nlmsg_flags, nlmsg_hdr(), nlmsghdr::nlmsg_pid, and nlmsghdr::nlmsg_seq.
Referenced by flnl_lookup(), nl_send_simple(), rtnl_addr_add(), rtnl_addr_delete(), rtnl_class_add(), rtnl_cls_add(), rtnl_cls_change(), rtnl_cls_delete(), rtnl_link_change(), rtnl_neigh_add(), rtnl_neigh_change(), rtnl_neigh_delete(), rtnl_neightbl_change(), rtnl_qdisc_add(), rtnl_qdisc_change(), rtnl_qdisc_delete(), rtnl_rule_add(), and rtnl_rule_delete().
int nl_send_simple | ( | struct nl_handle * | handle, |
int | type, | ||
int | flags, | ||
void * | buf, | ||
size_t | size | ||
) |
handle | Netlink handle. |
type | Netlink message type. |
flags | Netlink message flags. |
buf | Data buffer. |
size | Size of data buffer. |
Builds a netlink message with the specified type and flags and appends the specified data as payload to the message.
Definition at line 410 of file nl.c.
References nl_send_auto_complete(), nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().
Referenced by genl_send_simple(), nfnl_send_simple(), and nl_rtgen_request().
int nl_recv | ( | struct nl_handle * | handle, |
struct sockaddr_nl * | nla, | ||
unsigned char ** | buf, | ||
struct ucred ** | creds | ||
) |
handle | Netlink handle. |
nla | Destination pointer for peer's netlink address. |
buf | Destination pointer for message content. |
creds | Destination pointer for credentials. |
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.
int nl_recvmsgs | ( | struct nl_handle * | handle, |
struct nl_cb * | cb | ||
) |
handle | netlink handle |
cb | set of callbacks to control behaviour. |
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.
Definition at line 767 of file nl.c.
Referenced by nl_recvmsgs_default(), and nl_wait_for_ack().
int nl_recvmsgs_default | ( | struct nl_handle * | handle | ) |
handle | netlink handle |
Calls nl_recvmsgs() with the handlers configured in the netlink handle.
Definition at line 781 of file nl.c.
References nl_recvmsgs().
Referenced by nl_cache_mngr_data_ready().
int nl_wait_for_ack | ( | struct nl_handle * | handle | ) |
handle | netlink handle |
Waits until an ACK is received for the latest not yet acknowledged netlink message.
Definition at line 800 of file nl.c.
References NL_CB_ACK, nl_cb_clone(), NL_CB_CUSTOM, nl_cb_set(), and nl_recvmsgs().
Referenced by rtnl_addr_add(), rtnl_addr_delete(), rtnl_class_add(), rtnl_cls_add(), rtnl_cls_change(), rtnl_cls_delete(), rtnl_link_change(), rtnl_neigh_add(), rtnl_neigh_change(), rtnl_neigh_delete(), rtnl_neightbl_change(), rtnl_qdisc_add(), rtnl_qdisc_change(), rtnl_qdisc_delete(), rtnl_rule_add(), and rtnl_rule_delete().