OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / rtnetlink.3
1 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
2 .\" Permission is granted to distribute possibly modified copies
3 .\" of this page provided the header is included verbatim,
4 .\" and in case of nontrivial modification author and date
5 .\" of the modification is added to the header.
6 .\" $Id: rtnetlink.3,v 1.3 1999/08/20 04:10:17 nakano Exp $
7 .\"
8 .\" Japanese Version Copyright (c) 1999 Shouichi Saito
9 .\"     all rights reserved.
10 .\" Translated Mon Jul 26 12:18:39 JST 1999
11 .\"     by Shouichi Saito <ss236rx@ymg.urban.ne.jp>
12 .\" Proofed Fri Aug 20 1999 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
13 .\"
14 .\"WORD:        running length  ¼ÂÆ°»þ¤ÎŤµ
15 .\"
16 .TH RTNETLINK 3 2010-01-11 "GNU" "Linux Programmer's Manual"
17 .SH Ì¾Á°
18 .\"O rtnetlink \- macros to manipulate rtnetlink messages
19 rtnetlink \- rtnetlink ¥á¥Ã¥»¡¼¥¸¤òÁàºî¤¹¤ë¥Þ¥¯¥í
20 .\"O .SH SYNOPSIS
21 .SH ½ñ¼°
22 .B #include <asm/types.h>
23 .br
24 .B #include <linux/netlink.h>
25 .br
26 .B #include <linux/rtnetlink.h>
27 .br
28 .B #include <sys/socket.h>
29
30 .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type \
31 ", NETLINK_ROUTE);"
32 .sp
33 .BI "int RTA_OK(struct rtattr *" rta ", int " rtabuflen );
34 .sp
35 .BI "void *RTA_DATA(struct rtattr *" rta );
36 .sp
37 .BI "unsigned int RTA_PAYLOAD(struct rtattr *" rta );
38 .sp
39 .BI "struct rtattr *RTA_NEXT(struct rtattr *" rta \
40 ", unsigned int " rtabuflen );
41 .sp
42 .BI "unsigned int RTA_LENGTH(unsigned int " length );
43 .sp
44 .BI "unsigned int RTA_SPACE(unsigned int "length );
45 .SH ÀâÌÀ
46 .\"O All
47 .\"O .BR rtnetlink (7)
48 .\"O messages consist of a
49 .\"O .BR netlink (7)
50 .\"O message header and appended attributes.
51 .\"O The attributes should be only
52 .\"O manipulated using the macros provided here.
53 Á´¤Æ¤Î
54 .BR rtnetlink (7)
55 ¥á¥Ã¥»¡¼¥¸¤Ï
56 .BR netlink (7)
57 ¥á¥Ã¥»¡¼¥¸¥Ø¥Ã¥À¤ÈÄɲðÀ­¤«¤é¤Ê¤ë¡£
58 °À­¤ÎÁàºî¤Ï¡¢É¬¤º¤³¤³¤Ëµó¤²¤¿¥Þ¥¯¥í¤òÄ̤·¤Æ¹Ô¤¦¤Ù¤­¤Ç¤¢¤ë¡£
59 .PP
60 .\"O .BI RTA_OK( rta ", " attrlen )
61 .\"O returns true if
62 .\"O .I rta
63 .\"O points to a valid routing attribute;
64 .\"O .I attrlen
65 .\"O is the running length of the attribute buffer.
66 .BI RTA_OK( rta ", " attrlen )
67 ¤Ï
68 .I rta
69 ¤¬Í­¸ú¤Ê¥ë¡¼¥Æ¥£¥ó¥°Â°À­¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ì¤Ð¿¿¤òÊÖ¤¹¡£
70 .I attrlen
71 ¤Ï°À­¥Ð¥Ã¥Õ¥¡¤Î¼ÂƯ»þ¤ÎŤµ (running length) ¤Ç¤¢¤ë¡£
72 .\"O When not true then you must assume there are no more attributes in the
73 .\"O message, even if
74 .\"O .I attrlen
75 .\"O is nonzero.
76 ¿¿¤Ç¤Ê¤±¤ì¤Ð¡¢Î㤨
77 .I attrlen
78 ¤¬¥¼¥í¤Ç¤Ê¤¯¤Æ¤â¡¢
79 ¥á¥Ã¥»¡¼¥¸Ãæ¤Ë¤Ï¤â¤¦¤½¤ì°Ê¾å°À­¤Ï̵¤¤¤È¹Í¤¨¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
80 .PP
81 .\"O .BI RTA_DATA( rta )
82 .\"O returns a pointer to the start of this attribute's data.
83 .BI RTA_DATA( rta )
84 ¤Ï¤³¤Î°À­¥Ç¡¼¥¿¤ÎÀèƬ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
85 .PP
86 .\"O .BI RTA_PAYLOAD( rta )
87 .\"O returns the length of this attribute's data.
88 .BI RTA_PAYLOAD( rta )
89 ¤Ï¤³¤Î°À­¥Ç¡¼¥¿¤ÎŤµ¤òÊÖ¤¹¡£
90 .PP
91 .\"O .BI RTA_NEXT( rta ", " attrlen )
92 .\"O gets the next attribute after
93 .\"O .IR rta .
94 .BI RTA_NEXT( rta ", " attrlen )
95 ¤Ï
96 .I rta
97 ¤Î¼¡¤Ë¤¢¤ë°À­¤ò¼èÆÀ¤¹¤ë¡£
98 .\"O Calling this macro will update
99 .\"O .IR attrlen .
100 .\"O You should use
101 .\"O .B RTA_OK
102 .\"O to check the validity of the returned pointer.
103 ¤³¤Î¥Þ¥¯¥í¤ò¸Æ¤Ö¤È
104 .I attrlen
105 ¤¬¹¹¿·¤µ¤ì¤ë¡£
106 .B RTA_OK
107 ¤ò»È¤Ã¤Æ¡¢ÊÖ¤µ¤ì¤¿¥Ý¥¤¥ó¥¿¤¬Àµ¤·¤¤¤«¤ò¥Á¥§¥Ã¥¯¤¹¤Ù¤­¤Ç¤¢¤ë¡£
108 .PP
109 .\"O .BI RTA_LENGTH( len )
110 .\"O returns the length which is required for
111 .\"O .I len
112 .\"O bytes of data plus the header.
113 .BI RTA_LENGTH( len )
114 ¤Ï
115 .I len
116 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿ + ¥Ø¥Ã¥À¤ËɬÍפÊŤµ¤òÊÖ¤¹¡£
117 .PP
118 .\"O .BI RTA_SPACE( len )
119 .\"O returns the amount of space which will be needed in a message with
120 .\"O .I len
121 .\"O bytes of data.
122 .BI RTA_SPACE( len )
123 ¤Ï
124 .I len
125 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤ò»ý¤Ä¥á¥Ã¥»¡¼¥¸¤ËɬÍפȤµ¤ì¤ëÍÆÎ̤òÊÖ¤¹¡£
126 .\"O .SH CONFORMING TO
127 .SH ½àµò
128 .\"O These macros are nonstandard Linux extensions.
129 ¤³¤ì¤é¤Î¥Þ¥¯¥í¤ÏÈóɸ½à¤Ç¡¢Linux ¤Ç¤Î³ÈÄ¥¤Ç¤¢¤ë¡£
130 .SH ¥Ð¥°
131 .\"O This manual page is incomplete.
132 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤Ï´°Á´¤Ç¤Ï¤Ê¤¤¡£
133 .SH Îã
134 .\" FIXME ? would be better to use libnetlink in the EXAMPLE code here
135 .\"O
136 .\"O Creating a rtnetlink message to set the MTU of a device.
137 ¥Ç¥Ð¥¤¥¹¤Î MTU ¤ò¥»¥Ã¥È¤¹¤ë rtnetlink ¥á¥Ã¥»¡¼¥¸¤òÀ¸À®¤¹¤ë
138 .nf
139     #include <linux/rtnetlink.h>
140
141     ...
142
143     struct {
144         struct nlmsghdr  nh;
145         struct ifinfomsg if;
146         char             attrbuf[512];
147     } req;
148
149     struct rtattr *rta;
150     unsigned int mtu = 1000;
151
152     int rtnetlink_sk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
153
154     memset(&req, 0, sizeof(req));
155     req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
156     req.nh.nlmsg_flags = NLM_F_REQUEST;
157     req.nh.nlmsg_type = RTM_NEWLINK;
158     req.if.ifi_family = AF_UNSPEC;
159     req.if.ifi_index = INTERFACE_INDEX;
160     req.if.ifi_change = 0xffffffff; /* ???*/
161     rta = (struct rtattr *)(((char *) &req) +
162                                   NLMSG_ALIGN(req.nh.nlmsg_len));
163     rta\->rta_type = IFLA_MTU;
164     rta\->rta_len = sizeof(unsigned int);
165     req.n.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) +
166                                   RTA_LENGTH(sizeof(mtu));
167     memcpy(RTA_DATA(rta), &mtu, sizeof(mtu));
168     send(rtnetlink_sk, &req, req.nh.nlmsg_len);
169 .fi
170 .SH ´ØÏ¢¹àÌÜ
171 .BR netlink (3),
172 .BR netlink (7),
173 .BR rtnetlink (7)