OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man7 / netlink.7
1 '\" t
2 .\" Don't change the first line, it tells man that tbl is needed.
3 .\" This man page is Copyright (c) 1998 by Andi Kleen. Subject to the GPL.
4 .\" Based on the original comments from Alexey Kuznetsov
5 .\" $Id: netlink.7,v 1.8 2000/06/22 13:23:00 ak Exp $
6 .\"
7 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
8 .\" Translated 1999-12-06 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
9 .\" Updated 2001-04-04 by Yuichi SATO <ysato@h4.dion.ne.jp>, catch up to LDP v1.35
10 .\" Updated 2006-06-23 by Yuichi SATO <ysato444@yahoo.co.jp>, catch up to LDP v2.29
11 .\"
12 .\"WORD         payload         ¥Ú¥¤¥í¡¼¥É
13 .\"WORD         capability      ¸¢¸Â
14 .\"
15 .TH NETLINK  7 2008-11-11 "Linux" "Linux Programmer's Manual"
16 .\"O .SH NAME
17 .SH Ì¾Á°
18 .\"O netlink \- Communication between kernel and userspace (AF_NETLINK)
19 netlink \- ¥«¡¼¥Í¥ë¤È¥æ¡¼¥¶¡¼¶õ´Ö¤ÎÄÌ¿® (AF_NETLINK)
20 .\"O .SH SYNOPSIS
21 .SH ½ñ¼°
22 .nf
23 .B #include <asm/types.h>
24 .B #include <sys/socket.h>
25 .B #include <linux/netlink.h>
26
27 .BI "netlink_socket = socket(AF_NETLINK, " socket_type ", " netlink_family );
28 .fi
29 .\"O .SH DESCRIPTION
30 .SH ÀâÌÀ
31 .\"O Netlink is used to transfer information between kernel and
32 .\"O userspace processes.
33 .\"O It consists of a standard sockets-based interface for userspace
34 .\"O processes and an internal kernel API for kernel modules.
35 .\"O The internal kernel interface is not documented in this manual page.
36 .\"O There is also an obsolete netlink interface
37 .\"O via netlink character devices; this interface is not documented here
38 .\"O and is only provided for backwards compatibility.
39 netlink ¤Ï¥«¡¼¥Í¥ë¥â¥¸¥å¡¼¥ë¤È¥æ¡¼¥¶¡¼¶õ´Ö¤Î¥×¥í¥»¥¹´Ö¤Ç
40 ¾ðÊó¤ò¤ä¤ê¤È¤ê¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
41 netlink ¤Ï¡¢¥æ¡¼¥¶¡¼¥×¥í¥»¥¹¤ËÂФ·¤Æ¤Ï
42 ɸ½àŪ¤Ê¥½¥±¥Ã¥È¥Ù¡¼¥¹¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò¡¢
43 ¥«¡¼¥Í¥ë¥â¥¸¥å¡¼¥ë¤Ë¤Ï¥«¡¼¥Í¥ë¤ÎÆâÉô API ¤òÄ󶡤¹¤ë¡£
44 ¥«¡¼¥Í¥ëÆâÉô¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë¤Ä¤¤¤Æ¤Ï¤³¤Î man ¥Ú¡¼¥¸¤Ç¤Ïµ­½Ò¤·¤Ê¤¤¡£
45 ¤Þ¤¿¡¢netlink ¥­¥ã¥é¥¯¥¿¥Ç¥Ð¥¤¥¹¤òÍѤ¤¤¿
46 obsolete ¤Ê netlink ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤â¤¢¤ë¤¬¡¢¤³¤ì¤â¤³¤Îʸ½ñ¤Ç¤Ï²òÀ⤷¤Ê¤¤¡£
47 ¤³¤ì¤Ïñ¤Ë²áµî¸ß´¹À­¤Î¤¿¤á¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ë¤¹¤®¤Ê¤¤¡£
48
49 .\"O Netlink is a datagram-oriented service.
50 .\"O Both
51 .\"O .B SOCK_RAW
52 .\"O and
53 .\"O .B SOCK_DGRAM
54 .\"O are valid values for
55 .\"O .IR socket_type .
56 .\"O However, the netlink protocol does not distinguish between datagram
57 .\"O and raw sockets.
58 netlink ¤Ï¥Ç¡¼¥¿¥°¥é¥à»Ø¸þ¤Î¥µ¡¼¥Ó¥¹¤Ç¤¢¤ë¡£
59 .I socket_type
60 ¤Ë¤Ï
61 .B SOCK_RAW
62 ¤È
63 .B SOCK_DGRAM
64 ¤ÎξÊý¤È¤â»ØÄê²Äǽ¤Ç¤¢¤ë¡£
65 ¤·¤«¤· netlink ¥×¥í¥È¥³¥ë¤Ï¥Ç¡¼¥¿¥°¥é¥à¤È raw ¥½¥±¥Ã¥È¤Î¶èÊ̤ò¤·¤Ê¤¤¡£
66
67 .\"O .I netlink_family
68 .\"O selects the kernel module or netlink group to communicate with.
69 .\"O The currently assigned netlink families are:
70 .I netlink_family
71 ¤Ï¡¢ÄÌ¿®¤¹¤ë¥«¡¼¥Í¥ë¥â¥¸¥å¡¼¥ë¤ä netlink ¥°¥ë¡¼¥×¤ÎÁªÂò¤ËÍѤ¤¤ë¡£
72 ¸½ºß³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ë netlink ¥Õ¥¡¥ß¥ê¡¼¤Ï°Ê²¼¤ÎÄ̤ꡣ
73 .TP
74 .B NETLINK_ROUTE
75 .\"O Receives routing and link updates and may be used to modify the routing
76 .\"O tables (both IPv4 and IPv6), IP addresses, link parameters,
77 .\"O neighbor setups, queueing disciplines, traffic classes and
78 .\"O packet classifiers (see
79 .\"O .BR rtnetlink (7)).
80 ¥ë¡¼¥Æ¥£¥ó¥°¤È¥ê¥ó¥¯¤Î¹¹¿·¤ò¼õ¿®¤¹¤ë¡£
81 (IPv4 ¤È IPv6 Î¾Êý¤Î) ¥ë¡¼¥Æ¥£¥ó¥°¥Æ¡¼¥Ö¥ë¡¦
82 IP ¥¢¥É¥ì¥¹¡¦¥ê¥ó¥¯¥Ñ¥é¥á¡¼¥¿¡¦¶á˵ÀßÄê (neighbor setup)¡¦
83 ¥­¥å¡¼¥¤¥ó¥°¥ë¡¼¥ë (queueing dicipline)¡¦¥È¥é¥Õ¥£¥Ã¥¯¥¯¥é¥¹¡¦
84 ¥Ñ¥±¥Ã¥È¤Î¥¯¥é¥¹Ê¬Îà¤Î½¤Àµ¤ËÍѤ¤¤ë¤³¤È¤¬¤Ç¤­¤ë¤À¤í¤¦
85 .RB ( rtnetlink (7)
86 ¤ò¸«¤è)¡£
87 .TP
88 .B NETLINK_W1
89 .\"O Messages from 1-wire subsystem.
90 ñÀþ (1-wire) ¤Î¥µ¥Ö¥·¥¹¥Æ¥à¤«¤é¤Î¥á¥Ã¥»¡¼¥¸¡£
91 .TP
92 .B NETLINK_USERSOCK
93 .\"O Reserved for user-mode socket protocols.
94 ¥æ¡¼¥¶¡¼¥â¡¼¥É¥½¥±¥Ã¥È¥×¥í¥È¥³¥ë¤Î¤¿¤á¤ËͽÌ󤵤ì¤Æ¤¤¤ë¡£
95 .TP
96 .B NETLINK_FIREWALL
97 .\"O Transport IPv4 packets from netfilter to userspace.
98 .\"O Used by
99 .\"O .I ip_queue
100 .\"O kernel module.
101 IPv4 ¥Ñ¥±¥Ã¥È¤ò netfilter ¤«¤é¥æ¡¼¥¶¡¼¶õ´Ö¤ØžÁ÷¤¹¤ë¡£
102 .I ip_queue
103 ¥«¡¼¥Í¥ë¥â¥¸¥å¡¼¥ë¤Ç»ÈÍѤµ¤ì¤ë¡£
104 .TP
105 .B NETLINK_INET_DIAG
106 .\" FIXME More details on NETLINK_INET_DIAG needed.
107 .\"O INET socket monitoring.
108 INET ¥½¥±¥Ã¥È¤ò¥â¥Ë¥¿¥ê¥ó¥°¤¹¤ë¡£
109 .TP
110 .B NETLINK_NFLOG
111 Netfilter/iptables ULOG.
112 .TP
113 .B NETLINK_XFRM
114 .\" FIXME More details on NETLINK_XFRM needed.
115 IPsec.
116 .TP
117 .B NETLINK_SELINUX
118 .\"O SELinux event notifications.
119 SELinux ¤Î¥¤¥Ù¥ó¥ÈÄÌÃΡ£
120 .TP
121 .B NETLINK_ISCSI
122 .\" FIXME More details on NETLINK_ISCSI needed.
123 Open-iSCSI.
124 .TP
125 .B NETLINK_AUDIT
126 .\" FIXME More details on NETLINK_AUDIT needed.
127 .\"O Auditing.
128 ´Æºº (audit) ¤ò¹Ô¤¦¡£
129 .TP
130 .B NETLINK_FIB_LOOKUP
131 .\" FIXME More details on NETLINK_FIB_LOOKUP needed.
132 .\"O Access to FIB lookup from userspace.
133 ¥æ¡¼¥¶¡¼¶õ´Ö¤«¤é FIB ¥ë¥Ã¥¯¥¢¥Ã¥×¤Ë¥¢¥¯¥»¥¹¤¹¤ë¡£
134 .TP
135 .B NETLINK_CONNECTOR
136 .\"O Kernel connector.
137 .\"O See
138 .\"O .I Documentation/connector/*
139 .\"O in the kernel source for further information.
140 ¥«¡¼¥Í¥ë¥³¥Í¥¯¥¿¡£
141 ¤è¤ê¾Ü¤·¤¤¾ðÊó¤Ï¥«¡¼¥Í¥ë¥½¡¼¥¹¤Î
142 .I Documentation/connector/*
143 ¤ò»²¾È¤¹¤ë¤³¤È¡£
144 .TP
145 .B NETLINK_NETFILTER
146 .\" FIXME More details on NETLINK_NETFILTER needed.
147 .\"O Netfilter subsystem.
148 netfilter ¥µ¥Ö¥·¥¹¥Æ¥à¡£
149 .TP
150 .B NETLINK_IP6_FW
151 .\"O Transport IPv6 packets from netfilter to userspace.
152 .\"O Used by
153 .\"O .I ip6_queue
154 .\"O kernel module.
155 IPv6 ¥Ñ¥±¥Ã¥È¤ò netfilter ¤«¤é¥æ¡¼¥¶¡¼¶õ´Ö¤ØžÁ÷¤¹¤ë¡£
156 .I ip6_queue
157 ¥«¡¼¥Í¥ë¥â¥¸¥å¡¼¥ë¤Ç»ÈÍѤµ¤ì¤ë¡£
158 .TP
159 .B NETLINK_DNRTMSG
160 .\"O DECnet routing messages.
161 DECnet ¥ë¡¼¥Æ¥£¥ó¥°¥á¥Ã¥»¡¼¥¸¡£
162 .TP
163 .B NETLINK_KOBJECT_UEVENT
164 .\" FIXME More details on NETLINK_KOBJECT_UEVENT needed.
165 .\"O Kernel messages to userspace.
166 ¥æ¡¼¥¶¡¼¶õ´Ö¤Ø¤Î¥«¡¼¥Í¥ë¥á¥Ã¥»¡¼¥¸
167 .TP
168 .B NETLINK_GENERIC
169 .\"O Generic netlink family for simplified netlink usage.
170 netlink ¤ò´Êñ¤Ë»ÈÍѤ¹¤ë¤¿¤á¤Î°ìÈÌŪ¤Ê netlink ¥Õ¥¡¥ß¥ê¡¼¡£
171 .PP
172 .\"O Netlink messages consist of a byte stream with one or multiple
173 .\"O .I nlmsghdr
174 .\"O headers and associated payload.
175 netlink ¥á¥Ã¥»¡¼¥¸¤Ï¥Ð¥¤¥È¥¹¥È¥ê¡¼¥à¤«¤é¤Ê¤ê¡¢
176 °ì¤Ä°Ê¾å¤Î
177 .I nlmsghdr
178 ¥Ø¥Ã¥À¤È¡¢¤½¤ì¤ËÂбþ¤¹¤ë¥Ú¥¤¥í¡¼¥É (payload) ¤¬´Þ¤Þ¤ì¤ë¡£
179 .\"O The byte stream should only be accessed with the standard
180 .\"O .B NLMSG_*
181 .\"O macros.
182 .\"O See
183 .\"O .BR netlink (3)
184 .\"O for further information.
185 ¥Ð¥¤¥È¥¹¥È¥ê¡¼¥à¤Ë¤Ï¡¢É¸½à¤Î
186 .B NLMSG_*
187 ¥Þ¥¯¥í¤Ë¤è¤Ã¤Æ¤Î¤ß¥¢¥¯¥»¥¹¤¹¤Ù¤­¤Ç¤¢¤ë¡£
188 ¤è¤ê¾Ü¤·¤¤¾ðÊó¤Ï
189 .BR netlink (3)
190 ¤ò¸«¤è¡£
191
192 .\"O In multipart messages (multiple
193 .\"O .I nlmsghdr
194 .\"O headers with associated payload in one byte stream) the first and all
195 .\"O following headers have the
196 .\"O .B NLM_F_MULTI
197 .\"O flag set, except for the last header which has the type
198 .\"O .BR NLMSG_DONE .
199 ¥Þ¥ë¥Á¥Ñ¡¼¥È¥á¥Ã¥»¡¼¥¸ (°ì¤Ä°Ê¾å¤Î
200 .I nlmsghdr
201 ¥Ø¥Ã¥À¤È¡¢¤½¤ì¤ËÂбþ¤¹¤ë¥Ú¥¤¥í¡¼¥É¤¬
202 °ì¤Ä¥Ð¥¤¥È¥¹¥È¥ê¡¼¥à¤Ë´Þ¤Þ¤ì¤ë) ¤Ë¤ª¤¤¤Æ¤Ï¡¢
203 ÀèƬ¤Î¥Ø¥Ã¥À¡¦¸å³¤Î¥Ø¥Ã¥À¤Ë¤Ï
204 .B NLM_F_MULTI
205 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤ë¡£¤¿¤À¤·ºÇ¸å¤Î¥Ø¥Ã¥À¤À¤±¤ÏÎã³°¤Ç¡¢
206 .B NLMSG_DONE
207 ¥¿¥¤¥×¤È¤Ê¤ë¡£
208
209 .\"O After each
210 .\"O .I nlmsghdr
211 .\"O the payload follows.
212 ¤½¤ì¤¾¤ì¤Î
213 .B nlmsghdr
214 ¤Î¸å¤Ë¤Ï¥Ú¥¤¥í¡¼¥É¤¬Â³¤¯¡£
215
216 .in +4n
217 .nf
218 struct nlmsghdr {
219 .\"O     __u32 nlmsg_len;    /* Length of message including header. */
220 .\"O     __u16 nlmsg_type;   /* Type of message content. */
221 .\"O     __u16 nlmsg_flags;  /* Additional flags. */
222 .\"O     __u32 nlmsg_seq;    /* Sequence number. */
223 .\"O     __u32 nlmsg_pid;    /* PID of the sending process. */
224     __u32 nlmsg_len;    /* ¥Ø¥Ã¥À¤ò´Þ¤à¥á¥Ã¥»¡¼¥¸¤ÎŤµ */
225     __u16 nlmsg_type;   /* ¥á¥Ã¥»¡¼¥¸¤ÎÆâÍƤΥ¿¥¤¥× */
226     __u16 nlmsg_flags;  /* Äɲåե饰 */
227     __u32 nlmsg_seq;    /* ¥·¡¼¥±¥ó¥¹ÈÖ¹æ */
228     __u32 nlmsg_pid;    /* Á÷¿®¥×¥í¥»¥¹¤Î PID */
229 };
230 .fi
231 .in
232
233 .\"O .I nlmsg_type
234 .\"O can be one of the standard message types:
235 .\"O .B NLMSG_NOOP
236 .\"O message is to be ignored,
237 .\"O .B NLMSG_ERROR
238 .\"O message signals an error and the payload contains an
239 .\"O .I nlmsgerr
240 .\"O structure,
241 .\"O .B NLMSG_DONE
242 .\"O message terminates a multipart message.
243 .I nlmsg_type
244 ¤Ïɸ½à¤Î¥á¥Ã¥»¡¼¥¸¥¿¥¤¥×¤Î¤É¤ì¤«°ì¤Ä¤Ç¤¢¤ë:
245 .B NLMSG_NOOP
246 ¥á¥Ã¥»¡¼¥¸¤Ï̵»ë¤µ¤ì¤ë¡£
247 .B NLMSG_ERROR
248 ¥á¥Ã¥»¡¼¥¸¤Ï¥¨¥é¡¼¤ò¼¨¤·¡¢¥Ú¥¤¥í¡¼¥É¤Ë¤Ï
249 .I nlmsgerr
250 ¹½Â¤ÂΤ¬Æþ¤ë¡£
251 .B NLMSG_DONE
252 ¥á¥Ã¥»¡¼¥¸¤Ï¥Þ¥ë¥Á¥Ñ¡¼¥È¥á¥Ã¥»¡¼¥¸¤Î½ªÎ»¤òÅÁ¤¨¤ë¡£
253
254 .in +4n
255 .nf
256 struct nlmsgerr {
257 .\"O     int error;        /* Negative errno or 0 for acknowledgements */
258 .\"O     struct nlmsghdr msg;  /* Message header that caused the error */
259     int error;        /* Éé¤Þ¤¿¤Ï 0 ¤Î errno ¤Ï±þÅú¤òɽ¤¹ */
260     struct nlmsghdr msg;  /* ¥¨¥é¡¼¤òµ¯¤³¤·¤¿¥á¥Ã¥»¡¼¥¸¤Î¥Ø¥Ã¥À */
261 };
262 .fi
263 .in
264
265 .\"O A netlink family usually specifies more message types, see the
266 .\"O appropriate manual pages for that, for example,
267 .\"O .BR rtnetlink (7)
268 .\"O for
269 .\"O .BR NETLINK_ROUTE .
270 ¤¢¤ë netlink ¥Õ¥¡¥ß¥ê¡¼¤Ç»ØÄê¤Ç¤­¤ë¥á¥Ã¥»¡¼¥¸¥¿¥¤¥×¤Ï¡¢
271 Ä̾ï¤â¤Ã¤È¿¤¤¡£¤³¤ì¤é¤Ë´Ø¤·¤Æ¤ÏŬÀڤʠman ¥Ú¡¼¥¸¤ò¸«¤Æ¤Û¤·¤¤¡£
272 ¤¿¤È¤¨¤Ð
273 .B NETLINK_ROUTE
274 ¤Ë´Ø¤·¤Æ¤Ï
275 .BR rtnetlink (7)
276 ¤Ë½ñ¤¤¤Æ¤¢¤ë¡£
277
278 .\"O Standard flag bits in
279 .\"O .I nlmsg_flags
280 .I nlmsg_flags
281 ¤Îɸ½à¥Õ¥é¥°¥Ó¥Ã¥È
282 .br
283 ---------------------------------
284 .TS
285 tab(:);
286 lB l.
287 .\"O NLM_F_REQUEST:Must be set on all request messages.
288 .\"O NLM_F_MULTI:T{
289 .\"O The message is part of a multipart message terminated by
290 .\"O .BR NLMSG_DONE .
291 .\"O T}
292 .\"O NLM_F_ACK:Request for an acknowledgment on success.
293 .\"O NLM_F_ECHO:Echo this request.
294 NLM_F_REQUEST:Í×µá¥á¥Ã¥»¡¼¥¸Á´¤Æ¤Ç¥»¥Ã¥È¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
295 NLM_F_MULTI:T{
296 ¤³¤Î¥á¥Ã¥»¡¼¥¸¤Ï¥Þ¥ë¥Á¥Ñ¡¼¥È¥á¥Ã¥»¡¼¥¸¤Î°ìÉô¤Ç¤¢¤ë¡£
297 ¥Þ¥ë¥Á¥Ñ¡¼¥È¥á¥Ã¥»¡¼¥¸¤Ï
298 .B NLMSG_DONE
299 ¤Ç½ªÃ¼¤¹¤ë¡£
300 T}
301 NLM_F_ACK:À®¸ù¤·¤¿¾ì¹ç¤Î±þÅú¤òÍ׵᤹¤ë¡£
302 NLM_F_ECHO:¤³¤ÎÍ×µá¤ò¥¨¥³¡¼¤¹¤ë¡£
303 .TE
304
305 .\"O Additional flag bits for GET requests
306 GET Í×µá¤Ë¤ª¤±¤ëÄɲåե饰¥Ó¥Ã¥È
307 .br
308 -------------------------------------
309 .TS
310 tab(:);
311 lB l.
312 .\"O NLM_F_ROOT:Return the complete table instead of a single entry.
313 .\"O NLM_F_MATCH:T{
314 .\"O Return all entries matching criteria passed in message content.
315 .\"O Not implemented yet.
316 .\"O T}
317 .\" FIXME NLM_F_ATOMIC is not used any more?
318 .\"O NLM_F_ATOMIC:Return an atomic snapshot of the table.
319 .\"O NLM_F_DUMP:Convenience macro; equivalent to (NLM_F_ROOT|NLM_F_MATCH).
320 NLM_F_ROOT:ñ°ì¤Î¥¨¥ó¥È¥ê¤Ç¤Ï¤Ê¤¯¥Æ¡¼¥Ö¥ëÁ´ÂΤòÊÖ¤¹¡£
321 NLM_F_MATCH:T{
322 ¥á¥Ã¥»¡¼¥¸¤ÎÆâÍƤÇÅϤµ¤ì¤¿´ð½à (criteria) ¤Ë¥Þ¥Ã¥Á¤¹¤ë
323 Á´¤Æ¤Î¥¨¥ó¥È¥ê¤òÊÖ¤¹¡£
324 ¤Þ¤À¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
325 T}
326 NLM_F_ATOMIC:¥Æ¡¼¥Ö¥ë¤Î¥¢¥È¥ß¥Ã¥¯¤Ê¥¹¥Ê¥Ã¥×¥·¥ç¥Ã¥È¤òÊÖ¤¹¡£
327 NLM_F_DUMP:ÊØÍø¤Ê¥Þ¥¯¥í¡£(NLM_F_ROOT|NLM_F_MATCH) ¤ÈƱ¤¸¡£
328 .TE
329
330 .\"O Note that
331 .\"O .B NLM_F_ATOMIC
332 .\"O requires the
333 .\"O .B CAP_NET_ADMIN
334 .\"O capability or an effective UID of 0.
335 .B NLM_F_ATOMIC
336 ¤ò»È¤¦¾ì¹ç¤Ï¡¢
337 .B CAP_NET_ADMIN
338 ¸¢¸Â¤ò»ý¤Ä¤«¼Â¸ú¥æ¡¼¥¶¡¼ ID ¤¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
339
340 .\"O Additional flag bits for NEW requests
341 NEW Í×µá¤Ë¤ª¤±¤ëÄɲåե饰¥Ó¥Ã¥È
342 .br
343 -------------------------------------
344 .TS
345 tab(:);
346 lB l.
347 .\"O NLM_F_REPLACE:Replace existing matching object.
348 .\"O NLM_F_EXCL:Don't replace if the object already exists.
349 .\"O NLM_F_CREATE:Create object if it doesn't already exist.
350 .\"O NLM_F_APPEND:Add to the end of the object list.
351 NLM_F_REPLACE:¸½Â¸¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÃÖ´¹¤¹¤ë¡£
352 NLM_F_EXCL:¤¹¤Ç¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤¬¤¢¤Ã¤¿¤éÃÖ´¹¤·¤Ê¤¤¡£
353 NLM_F_CREATE:¤Þ¤À¥ª¥Ö¥¸¥§¥¯¥È¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë¡£
354 NLM_F_APPEND:¥ª¥Ö¥¸¥§¥¯¥È¥ê¥¹¥È¤ÎºÇ¸å¤ËÄɲ乤롣
355 .TE
356
357 .\"O .I nlmsg_seq
358 .\"O and
359 .\"O .I nlmsg_pid
360 .\"O are used to track messages.
361 .I nlmsg_seq
362 ¤È
363 .I nlmsg_pid
364 ¤Ï¥á¥Ã¥»¡¼¥¸¤ÎÄÉÀפ˻ÈÍѤµ¤ì¤ë¡£
365 .\"O .I nlmsg_pid
366 .\"O shows the origin of the message.
367 .I nlmsg_pid
368 ¤Ï¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®¸µ¤òɽ¤¹¡£
369 .\"O Note that there isn't a 1:1 relationship between
370 .\"O .I nlmsg_pid
371 .\"O and the PID of the process if the message originated from a netlink
372 .\"O socket.
373 ¥á¥Ã¥»¡¼¥¸¤¬ netlink ¥½¥±¥Ã¥È¤ÇÁ÷¿®¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
374 .I nlmsg_pid
375 ¤È¥×¥í¥»¥¹¤Î PID ¤Ï 1:1 ¤Î´Ø·¸¤Ç¤Ï¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
376 .\"O See the
377 .\"O .B ADDRESS FORMATS
378 .\"O section for further information.
379 ¤è¤ê¾Ü¤·¤¤¾ðÊó¤Ï¡¢
380 .RB ¡Ö ¥¢¥É¥ì¥¹¤Î¥Õ¥©¡¼¥Þ¥Ã¥È ¡×
381 ¤Î¥»¥¯¥·¥ç¥ó¤ò»²¾È¤¹¤ë¤³¤È¡£
382
383 .\"O Both
384 .\"O .I nlmsg_seq
385 .\"O and
386 .\"O .I nlmsg_pid
387 .\"O .\" FIXME Explain more about nlmsg_seq and nlmsg_pid.
388 .\"O are opaque to netlink core.
389 .I nlmsg_seq
390 ¤È
391 .I nlmsg_pid
392 ¤Ï netlink ¤Î¥³¥¢¤Ë¤Ï¸«¤¨¤Ê¤¤ (opaque)¡£
393
394 .\"O Netlink is not a reliable protocol.
395 netlink ¤Ï¿®ÍêÀ­¤Î¹â¤¤¥×¥í¥È¥³¥ë¤Ç¤Ï¤Ê¤¤¡£
396 .\"O It tries its best to deliver a message to its destination(s),
397 .\"O but may drop messages when an out-of-memory condition or
398 .\"O other error occurs.
399 .\"O For reliable transfer the sender can request an
400 .\"O acknowledgement from the receiver by setting the
401 .\"O .B NLM_F_ACK
402 .\"O flag.
403 .\"O An acknowledgment is an
404 .\"O .B NLMSG_ERROR
405 .\"O packet with the error field set to 0.
406 netlink ¤Ï¥á¥Ã¥»¡¼¥¸¤ò¹Ô¤­Àè¤ËÆϤ±¤ë¤¿¤á¤ËºÇÁ±¤ò¿Ô¤¯¤¹¤¬¡¢
407 ¥á¥â¥ê¤¬Â­¤ê¤Ê¤«¤Ã¤¿¤ê¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¤ê¤¹¤ë¤È
408 ¥á¥Ã¥»¡¼¥¸¤ò¼è¤ê¤³¤Ü¤¹¤³¤È¤â¤¢¤ë¡£
409 ¿®ÍêÀ­¤Î¹â¤¤Å¾Á÷¤ò¹Ô¤¤¤¿¤¤¤È¤­¤Ï¡¢
410 Á÷¿®¼Ô¤Ï¼õ¿®¼Ô¤Ë±þÅú¤òÍ׵᤹¤ë¤³¤È¤â¤Ç¤­¤ë¡£
411 ¤³¤ì¤Ë¤Ï
412 .B NLM_F_ACK
413 ¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£
414 ±þÅú¤Ï
415 .B NLMSG_ERROR
416 ¥Ñ¥±¥Ã¥È¤Î¥¨¥é¡¼¥Õ¥£¡¼¥ë¥É¤ò 0 ¤Ë¤·¤¿¤â¤Î¤Ë¤Ê¤ë¡£
417 .\"O The application must generate acknowledgements for
418 .\"O received messages itself.
419 .\"O The kernel tries to send an
420 .\"O .B NLMSG_ERROR
421 .\"O message for every failed packet.
422 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¼«Ê¬¼«¿È¤Î¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¤¿¤È¤­¤Ë¤Ï¡¢
423 ±þÅú¤òÀ¸À®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
424 ¥«¡¼¥Í¥ë¤Ï¼ºÇÔ¤·¤¿¥Ñ¥±¥Ã¥È¤ËÂФ·¤Æ¡¢
425 .B NLMSG_ERROR
426 ¥á¥Ã¥»¡¼¥¸¤òÁ÷¤í¤¦¤È¤¹¤ë¡£
427 .\"O A user process should follow this convention too.
428 ¥æ¡¼¥¶¡¼¥×¥í¥»¥¹¤Ï¤³¤Î´·½¬¤Ë¤â½¾¤¦É¬Íפ¬¤¢¤ë¡£
429
430 .\"O However, reliable transmissions from kernel to user are impossible
431 .\"O in any case.
432 ¤·¤«¤·¡¢¤É¤Î¤è¤¦¤Ê¾ì¹ç¤Ç¤â¥«¡¼¥Í¥ë¤«¤é¥æ¡¼¥¶¡¼¤Ø¤Î
433 ¿®ÍêÀ­¤Î¹â¤¤Å¾Á÷¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
434 .\"O The kernel can't send a netlink message if the socket buffer is full:
435 .\"O the message will be dropped and the kernel and the userspace process will
436 .\"O no longer have the same view of kernel state.
437 ¥½¥±¥Ã¥È¥Ð¥Ã¥Õ¥¡¤¬ËþÇդξì¹ç¡¢¥«¡¼¥Í¥ë¤Ï netlink ¥á¥Ã¥»¡¼¥¸¤òÁ÷¿®¤Ç¤­¤Ê¤¤¡£
438 ¥á¥Ã¥»¡¼¥¸¤Ï¼è¤ê¤³¤Ü¤µ¤ì¤Æ¡¢¥«¡¼¥Í¥ë¤È¥æ¡¼¥¶¡¼¶õ´Ö¥×¥í¥»¥¹¤Ï¡¢
439 ¥«¡¼¥Í¥ë¤Î¾õÂ֤ˤĤ¤¤Æ¤ÎƱ¤¸¥Ó¥å¡¼¤ò»ý¤Ä¤³¤È¤¬¤Ç¤­¤Ê¤¯¤Ê¤ë¡£
440 .\"O It is up to the application to detect when this happens (via the
441 .\"O .B ENOBUFS
442 .\"O error returned by
443 .\"O .BR recvmsg (2))
444 .\"O and resynchronize.
445 ¤³¤ì¤¬µ¯¤³¤Ã¤¿¤³¤È
446 .RB ( recvmsg (2)
447 ¤Ë¤è¤Ã¤Æ
448 .B ENOBUFS
449 ¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë) ¤ò¸¡ÃΤ·¤ÆºÆ¤ÓƱ´ü¤µ¤»¤ë¤Î¤Ï¡¢
450 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÀÕǤ¤Ç¤¢¤ë¡£
451 .\"O .SS Address Formats
452 .SS ¥¢¥É¥ì¥¹¤Î¥Õ¥©¡¼¥Þ¥Ã¥È
453 .\"O The
454 .\"O .I sockaddr_nl
455 .\"O structure describes a netlink client in user space or in the kernel.
456 .\"O A
457 .\"O .I sockaddr_nl
458 .\"O can be either unicast (only sent to one peer) or sent to
459 .\"O netlink multicast groups
460 .\"O .RI ( nl_groups
461 .\"O not equal 0).
462 .I sockaddr_nl
463 ¹½Â¤ÂΤϥ桼¥¶¡¼¶õ´Ö¤ä¥«¡¼¥Í¥ë¶õ´Ö¤Ç netlink ¥¯¥é¥¤¥¢¥ó¥È¤òµ­½Ò¤¹¤ë¡£
464 .I sockaddr_nl
465 ¤Ï¥æ¥Ë¥­¥ã¥¹¥È (ñ°ì¤ÎÀܳÀè¤Ë¤À¤±Á÷¤é¤ì¤ë) ¤Ë¤â¤Ç¤­¤ë¤·¡¢
466 netlink ¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×
467 .RI ( nl_groups
468 ¤¬ 0 ¤Ç¤Ê¤¤¾ì¹ç) ¤Ë¤âÁ÷¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
469
470 .in +4n
471 .nf
472 struct sockaddr_nl {
473 .\"O     sa_family_t     nl_family;  /* AF_NETLINK */
474 .\"O     unsigned short  nl_pad;     /* Zero. */
475 .\"O     pid_t           nl_pid;     /* Process ID. */
476 .\"O     __u32           nl_groups;  /* Multicast groups mask. */
477     sa_family_t     nl_family;  /* AF_NETLINK */
478     unsigned short  nl_pad;     /* 0 ¤Ç¤¢¤ë */
479     pid_t           nl_pid;     /* ¥×¥í¥»¥¹ ID */
480     __u32           nl_groups;  /* ¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¥Þ¥¹¥¯ */
481 };
482 .fi
483 .in
484
485 .\"O .I nl_pid
486 .\"O is the unicast address of netlink socket.
487 .\"O It's always 0 if the destination is in the kernel.
488 .I nl_pid
489 ¤Ï netlink ¥½¥±¥Ã¥È¤Î¥æ¥Ë¥­¥ã¥¹¥È¥¢¥É¥ì¥¹¤Ç¤¢¤ë¡£
490 ¹Ô¤­À褬¥«¡¼¥Í¥ë¤Î¾ì¹ç¤Ï¡¢¾ï¤Ë 0 ¤Ç¤¢¤ë¡£
491 .\"O For a userspace process,
492 .\"O .I nl_pid
493 .\"O is usually the PID of the process owning the destination socket.
494 ¥æ¡¼¥¶¡¼¶õ´Ö¥×¥í¥»¥¹¤Î¾ì¹ç¡¢Ä̾ï¤Ï
495 .I nl_pid
496 ¤Ï¹Ô¤­Àè¤Î¥½¥±¥Ã¥È¤ò½êÍ­¤·¤Æ¤¤¤ë¥×¥í¥»¥¹¤Î PID ¤Ç¤¢¤ë¡£
497 .\"O However,
498 .\"O .I nl_pid
499 .\"O identifies a netlink socket, not a process.
500 ¤¿¤À¤·¡¢
501 .I nl_pid
502 ¤Ï¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯ netlink ¥½¥±¥Ã¥È¤òƱÄꤹ¤ë¡£
503 .\"O If a process owns several netlink
504 .\"O sockets, then
505 .\"O .I nl_pid
506 .\"O can only be equal to the process ID for at most one socket.
507 ¥×¥í¥»¥¹¤¬Ê£¿ô¤Î netlink ¥½¥±¥Ã¥È¤ò½êÍ­¤¹¤ë¾ì¹ç¡¢
508 .I nl_pid
509 ¤ÏºÇÂç¤Ç¤â°ì¤Ä¤Î¥½¥±¥Ã¥È¤Î¥×¥í¥»¥¹ ID ¤È¤·¤«Åù¤·¤¯¤Ê¤é¤Ê¤¤¡£
510 .\"O There are two ways to assign
511 .\"O .I nl_pid
512 .\"O to a netlink socket.
513 .I nl_pid
514 ¤ò netlink ¥½¥±¥Ã¥È¤Ë³ä¤êÅö¤Æ¤ëÊýË¡¤Ï 2 ¤Ä¤¢¤ë¡£
515 .\"O If the application sets
516 .\"O .I nl_pid
517 .\"O before calling
518 .\"O .BR bind (2),
519 .\"O then it is up to the application to make sure that
520 .\"O .I nl_pid
521 .\"O is unique.
522 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬
523 .BR bind (2)
524 ¤ò¸Æ¤ÖÁ°¤Ë
525 .I nl_pid
526 ¤òÀßÄꤹ¤ë¾ì¹ç¡¢
527 .I nl_pid
528 ¤¬°ì°Õ¤Ç¤¢¤ë¤³¤È¤ò³Îǧ¤¹¤ë¤Î¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÀÕǤ¤È¤Ê¤ë¡£
529 .\"O If the application sets it to 0, the kernel takes care of assigning it.
530 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬
531 .I nl_pid
532 ¤ò 0 ¤ËÀßÄꤷ¤¿¾ì¹ç¡¢¥«¡¼¥Í¥ë¤¬¤³¤ÎÃͤò³ä¤êÅö¤Æ¤ë¡£
533 .\"O The kernel assigns the process ID to the first netlink socket the process
534 .\"O opens and assigns a unique
535 .\"O .I nl_pid
536 .\"O to every netlink socket that the process subsequently creates.
537 ¥«¡¼¥Í¥ë¤Ï¥×¥í¥»¥¹¤¬ºÇ½é¤Ë¥ª¡¼¥×¥ó¤·¤¿
538 netlink ¥½¥±¥Ã¥È¤ËÂФ·¤Æ¥×¥í¥»¥¹ ID ¤ò³ä¤êÅö¤Æ¡¢
539 ¤½¤ì°Ê¹ß¤Ë¥×¥í¥»¥¹¤¬ºîÀ®¤·¤¿Á´¤Æ¤Î netlink ¥½¥±¥Ã¥È¤Ë¤â°ì°Õ¤Ê
540 .I nl_pid
541 ¤ò³ä¤êÅö¤Æ¤ë¡£
542
543 .\"O .I nl_groups
544 .\"O is a bit mask with every bit representing a netlink group number.
545 .I nl_groups
546 ¤Ï¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¡¢¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¤¬ netlink ¥°¥ë¡¼¥×ÈÖ¹æ¤òɽ¤¹¡£
547 .\"O Each netlink family has a set of 32 multicast groups.
548 ¤½¤ì¤¾¤ì¤Î netlink ¥Õ¥¡¥ß¥ê¡¼¤Ï 32 ¤Î¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¤Î¥»¥Ã¥È¤ò»ý¤Ä¡£
549 .\"O When
550 .\"O .BR bind (2)
551 .\"O is called on the socket, the
552 .\"O .I nl_groups
553 .\"O field in the
554 .\"O .I sockaddr_nl
555 .\"O should be set to a bit mask of the groups which it wishes to listen to.
556 ¤½¤ì¤¾¤ì¤Î netlink ¥Õ¥¡¥ß¥ê¡¼¤Ï 32 ¤Î¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¤Î
557 ¥»¥Ã¥È¤ò»ý¤Ä¡£
558 .BR bind (2)
559 ¤¬¥½¥±¥Ã¥È¤ËÂФ·¤Æ¸Æ¤Ð¤ì¤ë¤È¡¢
560 .I sockaddr_nl
561 ¤Î
562 .I nl_groups
563 ¥Õ¥£¡¼¥ë¥É¤Ë¤Ï listen ¤·¤¿¤¤¥°¥ë¡¼¥×¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤¬¥»¥Ã¥È¤µ¤ì¤ë¡£
564 .\"O The default value for this field is zero which means that no multicasts
565 .\"O will be received.
566 .\"O A socket may multicast messages to any of the multicast groups by setting
567 .\"O .I nl_groups
568 .\"O to a bit mask of the groups it wishes to send to when it calls
569 .\"O .BR sendmsg (2)
570 .\"O or does a
571 .\"O .BR connect (2).
572 ¥Ç¥Õ¥©¥ë¥È¤ÎÃͤϠ0 ¤Ç¡¢¥Þ¥ë¥Á¥­¥ã¥¹¥È¤ò°ìÀÚ¼õ¿®¤·¤Ê¤¤¡£
573 .BR sendmsg (2)
574 ¤ä
575 .BR connect (2)
576 ¤Ë¤è¤Ã¤Æ¡¢¤¢¤ë¥½¥±¥Ã¥È¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¥Þ¥ë¥Á¥­¥ã¥¹¥È¤·¤¿¤¤¤È¤­¤Ï¡¢
577 .I nl_groups
578 ¤ËÁ÷¿®¤·¤¿¤¤¥°¥ë¡¼¥×¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤ò¥»¥Ã¥È¤¹¤ì¤Ð¤è¤¤¡£
579 .\"O Only processes with an effective UID of 0 or the
580 .\"O .B CAP_NET_ADMIN
581 .\"O capability may send or listen to a netlink multicast group.
582 ¼Â¸ú¥æ¡¼¥¶¡¼ ID ¤¬ 0 ¤«¡¢
583 .B CAP_NET_ADMIN
584 ¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¡¼¤Î¤ß¤¬ netlink ¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¤Ë
585 Á÷¿®¤·¤¿¤ê¡¢¤³¤ì¤ò listen ¤·¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
586 .\"O Any replies to a message received for a multicast group should be
587 .\"O sent back to the sending PID and the multicast group.
588 ¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¸þ¤±¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤·¤¿¾ì¹ç¡¢¤³¤ìÂФ¹¤ë±þÅú¤Ï
589 Á÷¤ê¼ç¤Î PID ¤È¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¤È¤ËÁ÷¤êÊÖ¤¹¤Ù¤­¤Ç¤¢¤ë¡£
590 .\"O .SH VERSIONS
591 .SH ¥Ð¡¼¥¸¥ç¥ó
592 .\"O The socket interface to netlink is a new feature of Linux 2.2.
593 netlink ¤Ø¤Î¥½¥±¥Ã¥È¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ï Linux 2.2 ¤Î¿·µ¡Ç½¤Ç¤¢¤ë¡£
594
595 .\"O Linux 2.0 supported a more primitive device based netlink interface
596 .\"O (which is still available as a compatibility option).
597 .\"O This obsolete interface is not described here.
598 Linux 2.0 ¤Ï¡¢¤â¤Ã¤È¸¶»ÏŪ¤Ê¥Ç¥Ð¥¤¥¹¥Ù¡¼¥¹¤Î netlink ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò
599 ¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤¿ (¤³¤ì¤â¸ß´¹À­¤Î¤¿¤á¤Ëº£¤Ç¤â»ÈÍѤǤ­¤ë)¡£
600 ¸Å¤¤¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ë´Ø¤·¤Æ¤Ï¤³¤³¤Ç¤Ïµ­½Ò¤·¤Ê¤¤¡£
601
602 .\"O NETLINK_SELINUX appeared in Linux 2.6.4.
603 NETLINK_SELINUX ¤Ï Linux 2.6.4 ¤ÇÅо줷¤¿¡£
604
605 .\"O NETLINK_AUDIT appeared in Linux 2.6.6.
606 NETLINK_AUDIT ¤Ï Linux 2.6.6 ¤ÇÅо줷¤¿¡£
607
608 .\"O NETLINK_KOBJECT_UEVENT appeared in Linux 2.6.10.
609 NETLINK_KOBJECT_UEVENT ¤Ï Linux 2.6.10 ¤ÇÅо줷¤¿¡£
610
611 .\"O NETLINK_W1 and NETLINK_FIB_LOOKUP appeared in Linux 2.6.13.
612 NETLINK_W1, NETLINK_FIB_LOOKUP ¤Ï Linux 2.6.13 ¤ÇÅо줷¤¿¡£
613
614 .\"O NETLINK_INET_DIAG, NETLINK_CONNECTOR and NETLINK_NETFILTER appeared in
615 .\"O Linux 2.6.14.
616 NETLINK_INET_DIAG, NETLINK_CONNECTOR, NETLINK_NETFILTER ¤Ï
617 Linux 2.6.14 ¤ÇÅо줷¤¿¡£
618
619 .\"O NETLINK_GENERIC and NETLINK_ISCSI appeared in Linux 2.6.15.
620 NETLINK_GENERIC, NETLINK_ISCSI ¤Ï Linux 2.6.15 ¤ÇÅо줷¤¿¡£
621 .\"O .SH NOTES
622 .SH Ãí°Õ
623 .\"O It is often better to use netlink via
624 .\"O .I libnetlink
625 .\"O or
626 .\"O .I libnl
627 .\"O than via the low-level kernel interface.
628 Äã¥ì¥Ù¥ë¤Î¥«¡¼¥Í¥ë¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤è¤ê¡¢
629 .I libnetlink
630 ¤Þ¤¿¤Ï
631 .I libnl
632 ¤òÄ̤·¤Æ netlink ¤òÍøÍѤ¹¤ë¤Û¤¦¤¬Îɤ¤¤³¤È¤¬Â¿¤¤¡£
633 .\"O .SH BUGS
634 .\"O This manual page is not complete.
635 .SH ¥Ð¥°
636 ¤³¤Î man ¥Ú¡¼¥¸¤Ï´°À®¤·¤Æ¤¤¤Ê¤¤¡£
637 .\"O .SH EXAMPLE
638 .SH Îã
639 .\"O The following example creates a
640 .\"O .B NETLINK_ROUTE
641 .\"O netlink socket which will listen to the
642 .\"O .B RTMGRP_LINK
643 .\"O (network interface create/delete/up/down events) and
644 .\"O .B RTMGRP_IPV4_IFADDR
645 .\"O (IPv4 addresses add/delete events) multicast groups.
646 °Ê²¼¤ÎÎã¤Ç¤Ï¡¢
647 .B RTMGRP_LINK
648 (¥Í¥Ã¥È¥ï¡¼¥¯¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Î create/delete/up/down ¥¤¥Ù¥ó¥È) ¤È
649 .B RTMGRP_IPV4_IFADDR
650 (IPv4 ¥¢¥É¥ì¥¹¤Î add/delete ¥¤¥Ù¥ó¥È) ¥Þ¥ë¥Á¥­¥ã¥¹¥È¥°¥ë¡¼¥×¤ò listen ¤¹¤ë
651 .B NETLINK_ROUTE
652 netlink ¤òºîÀ®¤·¤Æ¤¤¤ë¡£
653
654 .in +4n
655 .nf
656 struct sockaddr_nl sa;
657
658 memset(&sa, 0, sizeof(sa));
659 sa.nl_family = AF_NETLINK;
660 sa.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
661
662 fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
663 bind(fd, (struct sockaddr *) &sa, sizeof(sa));
664 .fi
665 .in
666
667 .\"O The next example demonstrates how to send a netlink message to the
668 .\"O kernel (pid 0).
669 .\"O Note that application must take care of message sequence numbers
670 .\"O in order to reliably track acknowledgements.
671 ¼¡¤ÎÎã¤Ç¤Ï¡¢netlink ¥á¥Ã¥»¡¼¥¸¤ò¥«¡¼¥Í¥ë (pid 0) ¤ËÁ÷¤ëÊýË¡¤ò¼¨¤·¤Æ¤¤¤ë¡£
672 ±þÅú¤òÄÉÀפ¹¤ëºÝ¤Î¿®ÍêÀ­¤ò¹â¤á¤ë¤¿¤á¤Ë¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬
673 ¥á¥Ã¥»¡¼¥¸¤Î¥·¡¼¥±¥ó¥¹ÈÖ¹æ¤òÀµ¤·¤¯½èÍý¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
674
675 .in +4n
676 .nf
677 .\"O struct nlmsghdr *nh;    /* The nlmsghdr with payload to send. */
678 struct nlmsghdr *nh;    /* Á÷¿®¤¹¤ë nlmsghdr ¤È¥Ú¥¤¥í¡¼¥É */
679 struct sockaddr_nl sa;
680 struct iovec iov = { (void *) nh, nh\->nlmsg_len };
681 struct msghdr msg;
682
683 msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
684 memset(&sa, 0, sizeof(sa));
685 sa.nl_family = AF_NETLINK;
686 nh\->nlmsg_pid = 0;
687 nh\->nlmsg_seq = ++sequence_number;
688 .\"O /* Request an ack from kernel by setting NLM_F_ACK. */
689 /* NLM_F_ACK ¤òÀßÄꤹ¤ë¤³¤È¤Ç¡¢¥«¡¼¥Í¥ë¤Ë±þÅú¤òÍ׵᤹¤ë */
690 nh\->nlmsg_flags |= NLM_F_ACK;
691
692 sendmsg(fd, &msg, 0);
693 .fi
694 .in
695
696 .\"O And the last example is about reading netlink message.
697 ºÇ¸å¤Ï¡¢netlink ¥á¥Ã¥»¡¼¥¸¤ÎÆɤ߹þ¤ß¤ÎÎã¤Ç¤¢¤ë¡£
698
699 .in +4n
700 .nf
701 int len;
702 char buf[4096];
703 struct iovec iov = { buf, sizeof(buf) };
704 struct sockaddr_nl sa;
705 struct msghdr msg;
706 struct nlmsghdr *nh;
707
708 msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
709 len = recvmsg(fd, &msg, 0);
710
711 for (nh = (struct nlmsghdr *) buf; NLMSG_OK (nh, len);
712      nh = NLMSG_NEXT (nh, len)) {
713 .\"O     /* The end of multipart message. */
714     /* ¥Þ¥ë¥Á¥Ñ¡¼¥È¥á¥Ã¥»¡¼¥¸¤Î½ª¤ï¤ê */
715     if (nh\->nlmsg_type == NLMSG_DONE)
716         return;
717
718     if (nh\->nlmsg_type == NLMSG_ERROR)
719 .\"O         /* Do some error handling. */
720         /* ²¿¤é¤«¤Î¥¨¥é¡¼½èÍý¤ò¹Ô¤¦ */
721     ...
722
723 .\"O     /* Continue with parsing payload. */
724     /* ¥Ú¥¤¥í¡¼¥É¤Î²òÀϤò³¤±¤ë */
725     ...
726 }
727 .fi
728 .in
729 .\"O .SH SEE ALSO
730 .SH ´ØÏ¢¹àÌÜ
731 .BR cmsg (3),
732 .BR netlink (3),
733 .BR capabilities (7),
734 .BR rtnetlink (7)
735 .PP
736 .\"O ftp://ftp.inr.ac.ru/ip-routing/iproute2*
737 .\"O for information about libnetlink.
738 libnetlink ¤Ë´Ø¤¹¤ë¾ðÊó¤Ï
739 ftp://ftp.inr.ac.ru/ip-routing/iproute2*
740
741 .\"O http://people.suug.ch/~tgr/libnl/
742 .\"O for information about libnl.
743 libnl ¤Ë´Ø¤¹¤ë¾ðÊó¤Ï
744 http://people.suug.ch/~tgr/libnl/
745
746 RFC 3549 "Linux Netlink as an IP Services Protocol"