Blame man/man3/libnetlink.3

Packit Service 3880ab
.TH libnetlink 3
Packit Service 3880ab
.SH NAME
Packit Service 3880ab
libnetlink \- A library for accessing the netlink service
Packit Service 3880ab
.SH SYNOPSIS
Packit Service 3880ab
.nf
Packit Service 3880ab
#include <asm/types.h>
Packit Service 3880ab
.br
Packit Service 3880ab
#include <libnetlink.h>
Packit Service 3880ab
.br
Packit Service 3880ab
#include <linux/netlink.h>
Packit Service 3880ab
.br
Packit Service 3880ab
#include <linux/rtnetlink.h>
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_send(struct rtnl_handle *rth, char *buf, int len)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_dump_filter(struct rtnl_handle *rth,
Packit Service 3880ab
		     int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
Packit Service 3880ab
		     void *arg1,
Packit Service 3880ab
		     int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
Packit Service 3880ab
		     void *arg2)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
Packit Service 3880ab
	      unsigned groups, struct nlmsghdr *answer,
Packit Service 3880ab
.br
Packit Service 3880ab
	      int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
Packit Service 3880ab
.br
Packit Service 3880ab
	      void *jarg)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_listen(struct rtnl_handle *rtnl,
Packit Service 3880ab
	      int (*handler)(struct sockaddr_nl *, struct rtnl_ctrl_data *,
Packit Service 3880ab
			     struct nlmsghdr *n, void *),
Packit Service 3880ab
	      void *jarg)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rtnl_from_file(FILE *rtnl,
Packit Service 3880ab
	      int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
Packit Service 3880ab
	      void *jarg)
Packit Service 3880ab
.sp
Packit Service 3880ab
int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
Packit Service 3880ab
.sp
Packit Service 3880ab
int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
Packit Service 3880ab
.sp
Packit Service 3880ab
int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen)
Packit Service 3880ab
.SH DESCRIPTION
Packit Service 3880ab
libnetlink provides a higher level interface to
Packit Service 3880ab
.BR rtnetlink (7).
Packit Service 3880ab
The read functions return 0 on success and a negative errno on failure.
Packit Service 3880ab
The send functions return the amount of data sent, or -1 on error.
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_open
Packit Service 3880ab
Open a rtnetlink socket and save the state into the
Packit Service 3880ab
.B rth
Packit Service 3880ab
handle. This handle is passed to all subsequent calls.
Packit Service 3880ab
.B subscriptions
Packit Service 3880ab
is a bitmap of the rtnetlink multicast groups the socket will be
Packit Service 3880ab
a member of.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_wilddump_request
Packit Service 3880ab
Request a full dump of the
Packit Service 3880ab
.B type
Packit Service 3880ab
database for
Packit Service 3880ab
.B family
Packit Service 3880ab
addresses.
Packit Service 3880ab
.B type
Packit Service 3880ab
is a rtnetlink message type.
Packit Service 3880ab
.\" XXX
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_dump_request
Packit Service 3880ab
Request a full dump of the
Packit Service 3880ab
.B type
Packit Service 3880ab
data buffer into
Packit Service 3880ab
.B buf
Packit Service 3880ab
with maximum length of
Packit Service 3880ab
.B len.
Packit Service 3880ab
.B type
Packit Service 3880ab
is a rtnetlink message type.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_dump_filter
Packit Service 3880ab
Receive netlink data after a request and filter it.
Packit Service 3880ab
The
Packit Service 3880ab
.B filter
Packit Service 3880ab
callback checks if the received message is wanted. It gets the source
Packit Service 3880ab
address of the message, the message itself and
Packit Service 3880ab
.B arg1
Packit Service 3880ab
as arguments. 0 as return means that the filter passed, a negative
Packit Service 3880ab
value is returned
Packit Service 3880ab
by
Packit Service 3880ab
.I rtnl_dump_filter
Packit Service 3880ab
in case of error. NULL for
Packit Service 3880ab
.I filter
Packit Service 3880ab
means to not use a filter.
Packit Service 3880ab
.B junk
Packit Service 3880ab
is used to filter messages not destined to the local socket.
Packit Service 3880ab
Only one message bundle is received. If there is a message
Packit Service 3880ab
pending, this function does not block.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_listen
Packit Service 3880ab
Receive netlink data after a request and pass it to
Packit Service 3880ab
.I handler.
Packit Service 3880ab
.B handler
Packit Service 3880ab
is a callback that gets the message source address, anscillary data, the message
Packit Service 3880ab
itself, and the
Packit Service 3880ab
.B jarg
Packit Service 3880ab
cookie as arguments. It will get called for all received messages.
Packit Service 3880ab
Only one message bundle is received. If there is a message
Packit Service 3880ab
pending this function does not block.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_from_file
Packit Service 3880ab
Works like
Packit Service 3880ab
.I rtnl_listen,
Packit Service 3880ab
but reads a netlink message bundle from the file
Packit Service 3880ab
.B file
Packit Service 3880ab
and passes the messages to
Packit Service 3880ab
.B handler
Packit Service 3880ab
for parsing. The file should contain raw data as received from a rtnetlink socket.
Packit Service 3880ab
.PP
Packit Service 3880ab
The following functions are useful to construct custom rtnetlink messages. For
Packit Service 3880ab
simple database dumping with filtering it is better to use the higher level
Packit Service 3880ab
functions above. See
Packit Service 3880ab
.BR rtnetlink (3)
Packit Service 3880ab
and
Packit Service 3880ab
.BR netlink (3)
Packit Service 3880ab
on how to generate a rtnetlink message. The following utility functions
Packit Service 3880ab
require a continuous buffer that already contains a netlink message header
Packit Service 3880ab
and a rtnetlink request.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rtnl_send
Packit Service 3880ab
Send the rtnetlink message in
Packit Service 3880ab
.B buf
Packit Service 3880ab
of length
Packit Service 3880ab
.B len
Packit Service 3880ab
to handle
Packit Service 3880ab
.B rth.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
addattr32
Packit Service 3880ab
Add a __u32 attribute of type
Packit Service 3880ab
.B type
Packit Service 3880ab
and with value
Packit Service 3880ab
.B data
Packit Service 3880ab
to netlink message
Packit Service 3880ab
.B n,
Packit Service 3880ab
which is part of a buffer of length
Packit Service 3880ab
.B maxlen.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
addattr_l
Packit Service 3880ab
Add a variable length attribute of type
Packit Service 3880ab
.B type
Packit Service 3880ab
and with value
Packit Service 3880ab
.B data
Packit Service 3880ab
and
Packit Service 3880ab
.B alen
Packit Service 3880ab
length to netlink message
Packit Service 3880ab
.B n,
Packit Service 3880ab
which is part of a buffer of length
Packit Service 3880ab
.B maxlen.
Packit Service 3880ab
.B data
Packit Service 3880ab
is copied.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rta_addattr32
Packit Service 3880ab
Initialize the rtnetlink attribute
Packit Service 3880ab
.B rta
Packit Service 3880ab
with a __u32 data value.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rta_addattr32
Packit Service 3880ab
Initialize the rtnetlink attribute
Packit Service 3880ab
.B rta
Packit Service 3880ab
with a variable length data value.
Packit Service 3880ab
Packit Service 3880ab
.SH BUGS
Packit Service 3880ab
This library is meant for internal use, use libmnl for new programs.
Packit Service 3880ab
Packit Service 3880ab
The functions sometimes use fprintf and exit when a fatal error occurs.
Packit Service 3880ab
This library should be named librtnetlink.
Packit Service 3880ab
Packit Service 3880ab
.SH AUTHORS
Packit Service 3880ab
netlink/rtnetlink was designed and written by Alexey Kuznetsov.
Packit Service 3880ab
Andi Kleen wrote the man page.
Packit Service 3880ab
Packit Service 3880ab
.SH SEE ALSO
Packit Service 3880ab
.BR netlink (7),
Packit Service 3880ab
.BR rtnetlink (7)
Packit Service 3880ab
.br
Packit Service 3880ab
/usr/include/linux/rtnetlink.h