]> git.pld-linux.org Git - packages/iproute2.git/blame - libnetlink.3
- adjusted pl after desc update; mention tc too
[packages/iproute2.git] / libnetlink.3
CommitLineData
de7a528b
ER
1.TH libnetlink 3
2.SH NAME
3libnetlink \- A library for accessing the netlink service
4.SH SYNOPSIS
5.nf
6#include <asm/types.h>
7.br
8#include <libnetlink.h>
9.br
10#include <linux/netlink.h>
11.br
12#include <linux/rtnetlink.h>
13.sp
14int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
15.sp
16int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
17.sp
18int rtnl_send(struct rtnl_handle *rth, char *buf, int len)
19.sp
20int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
21.sp
22int rtnl_dump_filter(struct rtnl_handle *rth,
23 int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
24 void *arg1,
25 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
26 void *arg2)
27.sp
28int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
29 unsigned groups, struct nlmsghdr *answer,
30.br
31 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
32.br
33 void *jarg)
34.sp
35int rtnl_listen(struct rtnl_handle *rtnl,
36 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
37 void *jarg)
38.sp
39int rtnl_from_file(FILE *rtnl,
40 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
41 void *jarg)
42.sp
43int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
44.sp
45int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
46.sp
47int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
48.sp
49int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen)
50.SH DESCRIPTION
51libnetlink provides a higher level interface to
52.BR rtnetlink(7).
53The read functions return 0 on success and a negative errno on failure.
54The send functions return the amount of data sent, or -1 on error.
55.TP
56rtnl_open
57Open a rtnetlink socket and save the state into the
58.B rth
59handle. This handle is passed to all subsequent calls.
60.B subscriptions
61is a bitmap of the rtnetlink multicast groups the socket will be
62a member of.
63
64.TP
65rtnl_wilddump_request
66Request a full dump of the
67.B type
68database for
69.B family
70addresses.
71.B type
72is a rtnetlink message type.
73.\" XXX
74
75.TP
76rtnl_dump_request
77Request a full dump of the
78.B type
79data buffer into
80.B buf
81with maximum length of
82.B len.
83.B type
84is a rtnetlink message type.
85
86.TP
87rtnl_dump_filter
88Receive netlink data after a request and filter it.
89The
90.B filter
91callback checks if the received message is wanted. It gets the source
92address of the message, the message itself and
93.B arg1
94as arguments. 0 as return means that the filter passed, a negative
95value is returned
96by
97.I rtnl_dump_filter
98in case of error. NULL for
99.I filter
100means to not use a filter.
101.B junk
102is used to filter messages not destined to the local socket.
103Only one message bundle is received. Unless there is no message
104pending, this function does not block.
105
106.TP
107rtnl_listen
108Receive netlink data after a request and pass it to
109.I handler.
110.B handler
111is a callback that gets the message source address, the message itself,
112and the
113.B jarg
114cookie as arguments. It will get called for all received messages.
115Only one message bundle is received. Unless there is no message
116pending this function does not block.
117
118.TP
119rtnl_from_file
120Works like
121.I rtnl_listen,
122but reads a netlink message bundle from the file
123.B file
124and passes the messages to
125.B handler
126for parsing. The file contains raw data as received from a rtnetlink socket.
127.PP
128The following functions are useful to construct custom rtnetlink messages. For
129simple database dumping with filtering it is better to use the higher level
130functions above. See
131.BR rtnetlink(3)
132and
133.BR netlink(3)
134on how to generate a rtnetlink message. The following utility functions
135require a continuous buffer that already contains a netlink message header
136and a rtnetlink request.
137
138.TP
139rtnl_send
140Send the rtnetlink message in
141.B buf
142of length
143.B len
144to handle
145.B rth.
146
147.TP
148addattr32
149Add a __u32 attribute of type
150.B type
151and with value
152.B data
153to netlink message
154.B n,
155which is part of a buffer of length
156.B maxlen.
157
158.TP
159addattr_l
160Add a variable length attribute of type
161.B type
162and with value
163.B data
164and
165.B alen
166length to netlink message
167.B n,
168which is part of a buffer of length
169.B maxlen.
170.B data
171is copied.
172
173.TP
174rta_addattr32
175Initialize the rtnetlink attribute
176.B rta
177with a __u32 data value.
178
179.TP
180rta_addattr32
181Initialize the rtnetlink attribute
182.B rta
183with a variable length data value.
184
185.SH BUGS
186The functions sometimes use fprintf and exit when a fatal error occurs.
187This library should be named librtnetlink.
188
189.SH AUTHORS
190netlink/rtnetlink was designed and writen by Alexey Kuznetsov.
191Andi Kleen wrote the man page.
192
193.SH SEE ALSO
194.BR netlink(7),
195.BR rtnetlink(7)
196.br
197/usr/include/linux/rtnetlink.h
This page took 0.082028 seconds and 4 git commands to generate.