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 $
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>
14 .\"WORD: running length ¼ÂÆ°»þ¤ÎŤµ
16 .TH RTNETLINK 3 2010-01-11 "GNU" "Linux Programmer's Manual"
18 rtnetlink \- rtnetlink ¥á¥Ã¥»¡¼¥¸¤òÁàºî¤¹¤ë¥Þ¥¯¥í
20 .B #include <asm/types.h>
22 .B #include <linux/netlink.h>
24 .B #include <linux/rtnetlink.h>
26 .B #include <sys/socket.h>
28 .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type \
31 .BI "int RTA_OK(struct rtattr *" rta ", int " rtabuflen );
33 .BI "void *RTA_DATA(struct rtattr *" rta );
35 .BI "unsigned int RTA_PAYLOAD(struct rtattr *" rta );
37 .BI "struct rtattr *RTA_NEXT(struct rtattr *" rta \
38 ", unsigned int " rtabuflen );
40 .BI "unsigned int RTA_LENGTH(unsigned int " length );
42 .BI "unsigned int RTA_SPACE(unsigned int "length );
48 ¥á¥Ã¥»¡¼¥¸¥Ø¥Ã¥À¤ÈÄɲðÀ¤«¤é¤Ê¤ë¡£
49 °À¤ÎÁàºî¤Ï¡¢É¬¤º¤³¤³¤Ëµó¤²¤¿¥Þ¥¯¥í¤òÄ̤·¤Æ¹Ô¤¦¤Ù¤¤Ç¤¢¤ë¡£
51 .BI RTA_OK( rta ", " attrlen )
54 ¤¬Í¸ú¤Ê¥ë¡¼¥Æ¥£¥ó¥°Â°À¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ì¤Ð¿¿¤òÊÖ¤¹¡£
56 ¤Ï°À¥Ð¥Ã¥Õ¥¡¤Î¼ÂƯ»þ¤ÎŤµ (running length) ¤Ç¤¢¤ë¡£
60 ¥á¥Ã¥»¡¼¥¸Ãæ¤Ë¤Ï¤â¤¦¤½¤ì°Ê¾å°À¤Ï̵¤¤¤È¹Í¤¨¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
63 ¤Ï¤³¤Î°À¥Ç¡¼¥¿¤ÎÀèƬ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
65 .BI RTA_PAYLOAD( rta )
66 ¤Ï¤³¤Î°À¥Ç¡¼¥¿¤ÎŤµ¤òÊÖ¤¹¡£
68 .BI RTA_NEXT( rta ", " attrlen )
71 ¤Î¼¡¤Ë¤¢¤ë°À¤ò¼èÆÀ¤¹¤ë¡£
76 ¤ò»È¤Ã¤Æ¡¢ÊÖ¤µ¤ì¤¿¥Ý¥¤¥ó¥¿¤¬Àµ¤·¤¤¤«¤ò¥Á¥§¥Ã¥¯¤¹¤Ù¤¤Ç¤¢¤ë¡£
81 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿ + ¥Ø¥Ã¥À¤ËɬÍפÊŤµ¤òÊÖ¤¹¡£
86 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤ò»ý¤Ä¥á¥Ã¥»¡¼¥¸¤ËɬÍפȤµ¤ì¤ëÍÆÎ̤òÊÖ¤¹¡£
88 ¤³¤ì¤é¤Î¥Þ¥¯¥í¤ÏÈóɸ½à¤Ç¡¢Linux ¤Ç¤Î³ÈÄ¥¤Ç¤¢¤ë¡£
90 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤Ï´°Á´¤Ç¤Ï¤Ê¤¤¡£
92 .\" FIXME ? would be better to use libnetlink in the EXAMPLE code here
93 ¥Ç¥Ð¥¤¥¹¤Î MTU ¤ò¥»¥Ã¥È¤¹¤ë rtnetlink ¥á¥Ã¥»¡¼¥¸¤òÀ¸À®¤¹¤ë
95 #include <linux/rtnetlink.h>
106 unsigned int mtu = 1000;
108 int rtnetlink_sk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
110 memset(&req, 0, sizeof(req));
111 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
112 req.nh.nlmsg_flags = NLM_F_REQUEST;
113 req.nh.nlmsg_type = RTM_NEWLINK;
114 req.if.ifi_family = AF_UNSPEC;
115 req.if.ifi_index = INTERFACE_INDEX;
116 req.if.ifi_change = 0xffffffff; /* ???*/
117 rta = (struct rtattr *)(((char *) &req) +
118 NLMSG_ALIGN(req.nh.nlmsg_len));
119 rta\->rta_type = IFLA_MTU;
120 rta\->rta_len = sizeof(unsigned int);
121 req.n.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) +
122 RTA_LENGTH(sizeof(mtu));
123 memcpy(RTA_DATA(rta), &mtu, sizeof(mtu));
124 send(rtnetlink_sk, &req, req.nh.nlmsg_len);