libnetlink provides a higher level interface to rtnetlink(7). The
read functions return 0 on success and a negative errno on failure.
The send functions return the amount of data sent, or -1 on error.
Open a rtnetlink socket and save the state into the rth
handle. This handle is passed to all subsequent calls.
subscriptions is a bitmap of the rtnetlink multicast groups
the socket will be a member of.
Request a full dump of the type database for family addresses.
type is a rtnetlink message type.
Request a full dump of the type data buffer into buf with
maximum length of len. type is a rtnetlink message type.
Receive netlink data after a request and filter it. The
filter callback checks if the received message is wanted. It
gets the source address of the message, the message itself and
arg1 as arguments. 0 as return means that the filter passed, a
negative value is returned by rtnl_dump_filter in case of
error. NULL for filter means to not use a filter. junk is
used to filter messages not destined to the local socket.
Only one message bundle is received. If there is a message
pending, this function does not block.
Receive netlink data after a request and pass it to handler.handler is a callback that gets the message source address,
anscillary data, the message itself, and the jarg cookie as
arguments. It will get called for all received messages. Only
one message bundle is received. If there is a message pending
this function does not block.
Works like rtnl_listen, but reads a netlink message bundle
from the file file and passes the messages to handler for
parsing. The file should contain raw data as received from a
The following functions are useful to construct custom rtnetlink
messages. For simple database dumping with filtering it is better to
use the higher level functions above. See rtnetlink(3) and netlink(3)
on how to generate a rtnetlink message. The following utility
functions require a continuous buffer that already contains a netlink
message header and a rtnetlink request.
Send the rtnetlink message in buf of length len to handle rth.
Add a __u32 attribute of type type and with value data to
netlink message n, which is part of a buffer of length maxlen.
Add a variable length attribute of type type and with value
data and alen length to netlink message n, which is part of a
buffer of length maxlen. data is copied.
Initialize the rtnetlink attribute rta with a __u32 data
Initialize the rtnetlink attribute rta with a variable length
This page is part of the iproute2 (utilities for controlling TCP/IP
networking and traffic) project. Information about the project can
be found at
If you have a bug report for this manual page, send it to
email@example.com, firstname.lastname@example.org. This page was obtained
from the project's upstream Git repository
on 2017-03-13. If you discover any rendering problems in this HTML
version of the page, or you believe there is a better or more up-to-
date source for the page, or you have corrections or improvements to
the information in this COLOPHON (which is not part of the original
manual page), send a mail to email@example.com