version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
RTNETLINK |
|
|
2 |
!!!RTNETLINK |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
EXAMPLE |
|
|
7 |
BUGS |
|
|
8 |
SEE ALSO |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
rtnetlink - Macros to manipuate rtnetlink messages |
|
|
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__#include __ |
|
|
18 |
#include __ |
|
|
19 |
#include __ |
|
|
20 |
#include __ |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
__rtnetlink_socket = socket(PF_NETLINK, int__ |
|
|
24 |
''socket_type''__, NETLINK_ROUTE); |
|
|
25 |
int RTA_OK(struct rtattr *rta, int rtabuflen); |
|
|
26 |
void *RTA_DATA(struct rtattr *rta); |
|
|
27 |
unsigned int RTA_PAYLOAD(struct rtattr *rta); |
|
|
28 |
struct rtattr *RTA_NEXT(struct rtattr *rta, unsigned int |
|
|
29 |
rtabuflen); |
|
|
30 |
unsigned int RTA_LENGTH(unsigned int length); |
|
|
31 |
unsigned int RTA_SPACE(unsigned int |
|
|
32 |
length);__ |
|
|
33 |
!!DESCRIPTION |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
All rtnetlink(7) messages consist of a |
|
|
37 |
netlink(7) message header and appended attributes. |
|
|
38 |
The attributes should be only manipulated using the macros |
|
|
39 |
provided here. |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
__RTA_OK(__''rta''__,__ ''attrlen''__)__ |
|
|
43 |
returns true if ''rta'' points to a valid routing |
|
|
44 |
attribute; ''attrlen'' is the running length of the |
|
|
45 |
attribute buffer. When not true then you must assume there |
|
|
46 |
are no more attributes in the message, even if |
|
|
47 |
''attrlen'' is non-zero.__ |
|
|
48 |
RTA_DATA(__''rta''__)__ returns a pointer to the |
|
|
49 |
start of this attribute's data.__ |
|
|
50 |
RTA_PAYLOAD(__''rta''__)__ returns the length of |
|
|
51 |
this attribute's data.__ |
|
|
52 |
RTA_NEXT(__''rta''__,__ ''attrlen''__)__ gets |
|
|
53 |
the next attribute after ''rta''. Calling this macro will |
|
|
54 |
update ''attrlen''. You should use __RTA_OK__ to check |
|
|
55 |
for the validity of the returned pointer.__ |
|
|
56 |
RTA_LENGTH(__''len''__)__ returns the length which |
|
|
57 |
is required for ''len'' bytes of data plus the |
|
|
58 |
header.__ |
|
|
59 |
RTA_SPACE(__''len''__)__ returns the amount of space |
|
|
60 |
which will be needed in the message with ''len'' bytes of |
|
|
61 |
data. |
|
|
62 |
!!EXAMPLE |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
Creating a rtnetlink message to set a MTU of a |
|
|
66 |
device. |
|
|
67 |
|
|
|
68 |
|
|
|
69 |
struct { |
|
|
70 |
struct nlmsghdr nh; |
|
|
71 |
struct ifinfomsg if; |
|
|
72 |
char attrbuf[[512]; |
|
|
73 |
} req; |
|
|
74 |
struct rtattr *rta; |
|
|
75 |
unsigned int mtu = 1000; |
|
|
76 |
int rtnetlink_sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); |
|
|
77 |
memset( |
|
|
78 |
!!BUGS |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
This manual page is lacking and incomplete. |
|
|
82 |
!!SEE ALSO |
|
|
83 |
|
|
|
84 |
|
|
|
85 |
rtnetlink(7), netlink(7), |
|
|
86 |
netlink(3) |
|
|
87 |
---- |