2 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
5 .\" Permission is granted to distribute possibly modified copies
6 .\" of this page provided the header is included verbatim,
7 .\" and in case of nontrivial modification author and date
8 .\" of the modification is added to the header.
11 .\" $Id: netdevice.7,v 1.10 2000/08/17 10:09:54 ak Exp $
13 .\" Modified, 2004-11-25, mtk, formatting and a few wording fixes
15 .\" Modified, 2011-11-02, <bidulock@openss7.org>, added many basic
16 .\" but missing ioctls, such as SIOCGIFADDR.
18 .\"*******************************************************************
20 .\" This file was generated with po4a. Translate the source file.
22 .\"*******************************************************************
24 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
25 .\" Translated Mon 6 Dec 1999 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
26 .\" Updated Wed 14 Feb 2001 by Kentaro Shirakata <argrath@ub32.org>
27 .\" Updated 2009-02-12 by Kentaro Shirakata <argrath@ub32.org>
28 .\" Updated 2012-05-06, Akihiro MOTOKI <amotoki@gmail.com>
29 .\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
31 .TH NETDEVICE 7 2014\-01\-24 Linux "Linux Programmer's Manual"
33 netdevice \- Linux ネットワークデバイスへの低レベルアクセス
35 \fB#include <sys/ioctl.h>\fP
37 \fB#include <net/if.h>\fP
39 この man ページでは、ネットワークデバイスを設定するために 用いるソケットインターフェースについて解説する。
41 Linux はネットワークデバイスを設定するための標準的な ioctl を いくつか備えている。これらはどんなソケットのファイルディスクリプタにも
42 用いることができる。ファミリーやタイプは何でもよい。 これらの ioctl のほとんどは \fIifreq\fP 構造体を渡す。
47 char ifr_name[IFNAMSIZ]; /* Interface name */
49 struct sockaddr ifr_addr;
50 struct sockaddr ifr_dstaddr;
51 struct sockaddr ifr_broadaddr;
52 struct sockaddr ifr_netmask;
53 struct sockaddr ifr_hwaddr;
59 char ifr_slave[IFNAMSIZ];
60 char ifr_newname[IFNAMSIZ];
67 通常、ユーザーによる設定対象デバイスの指定は、 \fIifr_name\fP にインターフェースの名前をセットすることによって行う。
68 他の構造体の全てのメンバは、メモリを共有する。
70 「特権が必要」と記述されている ioctl を実行するには、 実効ユーザー ID が 0 か、 \fBCAP_NET_ADMIN\fP
71 権限が必要である。これが満たされていない場合は \fBEPERM\fP が返される。
74 \fIifr_ifindex\fP を受け取り、インターフェースの名前を \fIifr_name\fP に入れて返す。これは結果を \fIifr_name\fP
78 インターフェースの interface index を取得し、 \fIifr_ifindex\fP に入れて返す。
80 \fBSIOCGIFFLAGS\fP, \fBSIOCSIFFLAGS\fP
81 .\" Do not right adjust text blocks in tables
82 デバイスの active フラグワードを取得または設定する。 \fIifr_flags\fP には以下の値のビットマスクが入る。
90 IFF_BROADCAST:有効なブロードキャストアドレスがセットされている。
92 IFF_LOOPBACK:インターフェースはループバックである。
93 IFF_POINTOPOINT:インターフェースは point\-to\-point リンクである。
94 IFF_RUNNING:リソースが割り当て済み。
96 arp プロトコルがない。 L2 宛先アドレスが設定されていない。
98 IFF_PROMISC:インターフェースは promiscuous モードである。
99 IFF_NOTRAILERS:trailer の利用を避ける。
100 IFF_ALLMULTI:全てのマルチキャストパケットを受信する。
101 IFF_MASTER:負荷分散グループのマスターである。
102 IFF_SLAVE:負荷分散グループのスレーブである。
103 IFF_MULTICAST:マルチキャストをサポートしている。
104 IFF_PORTSEL:ifmap によってメディアタイプを選択できる。
105 IFF_AUTOMEDIA:自動メディア選択が有効になっている。
107 このインターフェースが閉じると、アドレスは失われる。
109 IFF_LOWER_UP:ドライバからの L1 アップの通知 (Linux 2.6.17 以降)
110 IFF_DORMANT:ドライバからの休止状態の通知 (Linux 2.6.17 以降)
111 IFF_ECHO:送られたパケットをエコーする (Linux 2.6.25 以降)
115 active フラグワードの設定は特権が必要な操作である。
116 読み出しはどんなプロセスからも可能である。
118 \fBSIOCGIFPFLAGS\fP, \fBSIOCSIFPFLAGS\fP
119 デバイスの拡張 (プライベート) フラグを取得または設定する。
120 \fIifr_flags\fP には以下の値のビットマスクが入る。
126 IFF_802_1Q_VLAN:インターフェースは 802.1Q VLAN デバイスである。
127 IFF_EBRIDGE:インターフェースは Ethernet ブリッジデバイスである。
128 IFF_SLAVE_INACTIVE:インターフェースは非アクティブな bonding のスレーブである。
129 IFF_MASTER_8023AD:インターフェースは 802.3ad bonding のマスターである。
130 IFF_MASTER_ALB:インターフェースは balanced\-alb bonding のマスターである。
131 IFF_BONDING:インターフェースは bonding のマスターかスレーブである。
132 IFF_SLAVE_NEEDARP:インターフェースは検証に APR が必要である。
133 IFF_ISATAP:インターフェースは RFC4214 ISATAP インターフェースである。
136 拡張 (プライベート) インターフェースフラグの設定には特権が必要である。
138 \fBSIOCGIFADDR\fP, \fBSIOCSIFADDR\fP
139 \fIifr_addr\fP を用いてデバイスのアドレスの設定/取得を行う。
140 インターフェースのアドレスの設定は特権が必要な操作である。
141 互換性確保のため、設定/取得ができるのは \fBAF_INET\fP アドレスだけである。
143 \fBSIOCGIFDSTADDR\fP, \fBSIOCSIFDSTADDR\fP
144 point\-to\-point デバイスの宛先アドレスを \fIifr_dstaddr\fP を用いて
146 設定/取得ができるのは \fBAF_INET\fP アドレスだけである。
147 宛先アドレスの設定は特権が必要な操作である。
149 \fBSIOCGIFBRDADDR\fP, \fBSIOCSIFBRDADDR\fP
150 デバイスのブロードキャストアドレスを \fIifr_brdaddr\fP を用いて
152 設定/取得ができるのは \fBAF_INET\fP アドレスだけである。
153 ブロードキャストアドレスの設定は特権が必要な操作である。
155 \fBSIOCGIFNETMASK\fP, \fBSIOCSIFNETMASK\fP
156 デバイスのネットワークマスクを \fIifr_netmask\fP を用いて
158 設定/取得ができるのは \fBAF_INET\fP アドレスだけである。
159 ネットワークマスクの設定は特権が必要な操作である。
161 \fBSIOCGIFMETRIC\fP, \fBSIOCSIFMETRIC\fP
162 デバイスのメトリックを \fIifr_metric\fP を用いて取得・設定する。 これはまだ実装されていない。読み出そうとすると \fIifr_metric\fP
163 に 0 をセットして返り、設定しようとすると \fBEOPNOTSUPP\fP が返る。
165 \fBSIOCGIFMTU\fP, \fBSIOCSIFMTU\fP
166 デバイスの MTU (Maximum Transfer Unit) を \fIifr_mtu\fP を用いて取得・設定する。 MTU
167 の設定は特権が必要な操作である。 MTU の値を小さくしすぎるとカーネルがクラッシュするかもしれない。
169 \fBSIOCGIFHWADDR\fP, \fBSIOCSIFHWADDR\fP
170 デバイスのハードウェアアドレスを \fIifr_hwaddr\fP を用いて取得・設定する。 ハードウェアアドレスは \fIsockaddr\fP
171 構造体に設定される。 \fIsa_family\fP には ARPHRD_* デバイスタイプが入り、 \fIsa_data\fP にはバイト 0 から始まる L2
172 ハードウェアアドレスが入る。 ハードウェアアドレスの設定は特権が必要な操作である。
174 \fBSIOCSIFHWBROADCAST\fP
175 デバイスのハードウェアブロードキャストアドレスを \fIifr_hwaddr\fP の値に設定する。この操作には特権が必要である。
177 \fBSIOCGIFMAP\fP, \fBSIOCSIFMAP\fP
178 インターフェースのハードウェアのパラメータを \fIifr_map\fP を用いて取得・設定する。 パラメータの設定は特権が必要な操作である。
183 unsigned long mem_start;
184 unsigned long mem_end;
185 unsigned short base_addr;
193 ifmap 構造体の解釈はデバイスドライバとアーキテクチャに依存する。
195 \fBSIOCADDMULTI\fP, \fBSIOCDELMULTI\fP
196 デバイスのリンク層のマルチキャストフィルターから、 \fIifr_hwaddr\fP のアドレスを追加・削除する。これらの操作には特権が必要である。
197 別の方法が \fBpacket\fP(7) で解説されている。
199 \fBSIOCGIFTXQLEN\fP, \fBSIOCSIFTXQLEN\fP
200 デバイスの送信キューの長さを \fIifr_qlen\fP に取得・設定する。送信キューの長さの設定には特権が必要である。
203 \fIifr_name\fP で指定したインターフェースの名前を \fIifr_newname\fP に変更する。この操作には特権が必要である。インターフェースが
207 Return a list of interface (transport layer) addresses. This currently
208 means only addresses of the \fBAF_INET\fP (IPv4) family for compatibility.
209 Unlike the others, this ioctl passes an \fIifconf\fP structure:
214 int ifc_len; /* size of buffer */
216 char *ifc_buf; /* buffer address */
217 struct ifreq *ifc_req; /* array of structures */
223 If \fIifc_req\fP is NULL, \fBSIOCGIFCONF\fP returns the necessary buffer size in
224 bytes for receiving all available addresses in \fIifc_len\fP. Otherwise
225 \fIifc_req\fP contains a pointer to an array of \fIifreq\fP structures to be
226 filled with all currently active L3 interface addresses. \fIifc_len\fP
227 contains the size of the array in bytes. Within each \fIifreq\fP structure,
228 \fIifr_name\fP will receive the interface name, and \fIifr_addr\fP the address.
229 The actual number of bytes transferred is returned in \fIifc_len\fP.
231 If the size specified by \fIifc_len\fP is insufficient to store all the
232 addresses, the kernel will skip the exceeding ones and return success.
233 There is no reliable way of detecting this condition once it has occurred.
234 It is therefore recommended to either determine the necessary buffer size
235 beforehand by calling \fBSIOCGIFCONF\fP with \fIifc_req\fP set to NULL, or to
236 retry the call with a bigger buffer whenever \fIifc_len\fP upon return differs
237 by less than \fIsizeof(struct ifreq)\fP from its original value.
239 .\" Slaving isn't supported in 2.2
242 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
243 .\" Get or set the slave device using
245 .\" Setting the slave device is a privileged operation.
247 .\" FIXME add amateur radio stuff.
248 If an error occurs accessing the \fIifconf\fP or \fIifreq\fP structures, \fBEFAULT\fP
251 ほとんどのプロトコルには、専用のインターフェースオプションを 設定するための独自の ioctl が存在する。 説明は各プロトコルの man
252 ページを見よ。 IP アドレスの設定に関しては \fBip\fP(7) を参照。
254 さらに、デバイスによってはプライベートな ioctl がある。 これらはここでは説明しない。
256 厳密にいうと、 \fBSIOCGIFCONF\fP や、 \fBAF_INET\fP ソケットアドレスだけを
257 引き数に取ったり返したりする他の ioctl は IP 固有であり、 \fBip\fP(7)
260 アドレスがなかったり、 \fBIFF_RUNNING\fP フラグがセットされていないインターフェースの名前は \fI/proc/net/dev\fP
263 ローカル IPV6 IP アドレスは \fI/proc/net\fP か \fBrtnetlink\fP(7) で知ることができる。
265 glibc 2.1 では \fI<net/if.h>\fP に \fIifr_newname\fP マクロがない。
266 とりあえずの対応策として、以下のコードを追加しておくこと。
271 #define ifr_newname ifr_ifru.ifru_slave
276 \fBproc\fP(5), \fBcapabilities\fP(7), \fBip\fP(7), \fBrtnetlink\fP(7)
278 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.64 の一部
279 である。プロジェクトの説明とバグ報告に関する情報は
280 http://www.kernel.org/doc/man\-pages/ に書かれている。