OSDN Git Service

2e3f70cb3cfa8ba1b6198bc97575c95e7b162d14
[linuxjm/LDP_man-pages.git] / draft / man7 / raw.7
1 '\" t
2 .\" Don't change the first line, it tells man that we need tbl.
3 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4 .\" Permission is granted to distribute possibly modified copies
5 .\" of this page provided the header is included verbatim,
6 .\" and in case of nontrivial modification author and date
7 .\" of the modification is added to the header.
8 .\" $Id: raw.7,v 1.6 1999/06/05 10:32:08 freitag Exp $
9 .\"
10 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
11 .\" Translated 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>
12 .\" Updated 2007-01-05, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
13 .\"
14 .\"WORD         link level header(s)    リンクレベルヘッダ
15 .\"WORD         effective user ID       実効ユーザー ID
16 .\"WORD         capability              権限
17 .\"WORD         route                   (パケットの) 経路
18 .\"
19 .TH RAW  7 2008-11-20 "Linux" "Linux Programmer's Manual"
20 .\"O .SH NAME
21 .\"O raw, SOCK_RAW \- Linux IPv4 raw sockets
22 .SH 名前
23 raw, SOCK_RAW \- Linux の IPv4 raw ソケット
24 .\"O .SH SYNOPSIS
25 .SH 書式
26 .B #include <sys/socket.h>
27 .br
28 .B #include <netinet/in.h>
29 .br
30 .BI "raw_socket = socket(AF_INET, SOCK_RAW, int " protocol );
31 .\"O .SH DESCRIPTION
32 .SH 説明
33 .\"O Raw sockets allow new IPv4 protocols to be implemented in user space.
34 .\"O A raw socket receives or sends the raw datagram not
35 .\"O including link level headers.
36 raw ソケットを使うと、新しい IPv4 プロトコルをユーザ空間で
37 実装できるようになる。 raw ソケットは、リンクレベルヘッダを
38 含まない raw データグラムの送受信ができる。
39
40 .\"O The IPv4 layer generates an IP header when sending a packet unless the
41 .\"O .B IP_HDRINCL
42 .\"O socket option is enabled on the socket.
43 .\"O When it is enabled, the packet must contain an IP header.
44 .\"O For receiving the IP header is always included in the packet.
45 IPv4 レイヤは、扱っているソケットで
46 .B IP_HDRINCL
47 ソケットオプションが有効になっていなければ、
48 パケットを送信するときに IP ヘッダを生成する。
49 .B IP_HDRINCL
50 オプションが有効になっているときは、パケットには
51 IP ヘッダが含まれていなければならない。
52 受信時には、 IP ヘッダは常にパケットに含まれている。
53
54 .\"O Only processes with an effective user ID of 0 or the
55 .\"O .B CAP_NET_RAW
56 .\"O capability are allowed to open raw sockets.
57 実効ユーザー ID が 0 のプロセスか、
58 .B CAP_NET_RAW
59 権限を持つプロセスだけが raw ソケットをオープンすることができる。
60
61 .\"O All packets or errors matching the
62 .\"O .I protocol
63 .\"O number specified
64 .\"O for the raw socket are passed to this socket.
65 .\"O For a list of the allowed protocols see RFC\ 1700 assigned numbers and
66 .\"O .BR getprotobyname (3).
67 この raw ソケットに指定された
68 .I protocol
69 番号にマッチする全てのパケットとエラーとが、このソケットに渡される。
70 許可されているプロトコルのリストは RFC\ 1700 の割り当て番号と
71 .BR getprotobyname (3)
72 を見よ。
73
74 .\"O A protocol of
75 .\"O .B IPPROTO_RAW
76 .\"O implies enabled
77 .\"O .B IP_HDRINCL
78 .\"O and is able to send any IP protocol that is specified in the passed
79 .\"O header.
80 .\"O Receiving of all IP protocols via
81 .\"O .B IPPROTO_RAW
82 .\"O is not possible using raw sockets.
83 .B IPPROTO_RAW
84 のプロトコルは暗黙のうちに
85 .B IP_HDRINCL
86 を有効にするので、
87 渡されたヘッダで指定された、あらゆる IP プロトコルを送信できる。
88 .B IPPROTO_RAW
89 経由でのあらゆる IP プロトコルの受信は、
90 raw ソケットを用いては行えない。
91 .\"O
92 .TS
93 tab(:) allbox;
94 c s
95 l l.
96 .\"O IP Header fields modified on sending by \fBIP_HDRINCL\fP
97 .\"O IP Checksum:Always filled in.
98 .\"O Source Address:Filled in when zero.
99 .\"O Packet Id:Filled in when zero.
100 .\"O Total Length:Always filled in.
101 IP ヘッダフィールド。 \fBIP_HDRINCL\fP によって送信時に変更される。
102 IP チェックサム:常に変更される。
103 ソースアドレス:元の値が 0 の時に変更される。
104 パケット ID:元の値が 0 の時に変更される。
105 全体の長さ:常に埋められる。
106 .TE
107 .\"O.RE
108 .sp
109 .PP
110 .\"NAKANO Aloways filled in. とは?
111 .\"O If
112 .\"O .B IP_HDRINCL
113 .\"O is specified and the IP header has a nonzero destination address then
114 .\"O the destination address of the socket is used to route the packet.
115 .\"O When
116 .\"O .B MSG_DONTROUTE
117 .\"O is specified, the destination address should refer to a local interface,
118 .\"O otherwise a routing table lookup is done anyway but gatewayed routes
119 .\"O are ignored.
120 .B IP_HERINCL
121 が指定されていて、 IP ヘッダに
122 0 でない送信先アドレスが記入されていた場合は、
123 その送信先アドレスがパケットの経路を決めるのに用いられる。
124 .B MSG_DONTROUTE
125 が指定されている時には、
126 送信先アドレスはローカルなインターフェースを参照するものでなければならない。
127 さもないと、ルーティングテーブルの参照はいずれにせよ行われるが、
128 ゲートウェイが必要な経路は無視される。
129 .\"NAKANO ローカルなネットなのかインターフェースなのか?
130
131 .\"O If
132 .\"O .B IP_HDRINCL
133 .\"O isn't set, then IP header options can be set on raw sockets with
134 .\"O .BR setsockopt (2);
135 .\"O see
136 .\"O .BR ip (7)
137 .\"O for more information.
138 .B IP_HDRINCL
139 がセットされていなければ、
140 raw ソケットの IP ヘッダオプションを
141 .BR setsockopt (2)
142 を用いて設定することができる。詳細な情報は
143 .BR ip (7)
144 を見よ。
145
146 .\"O In Linux 2.2, all IP header fields and options can be set using
147 .\"O IP socket options.
148 .\"O This means raw sockets are usually only needed for new
149 .\"O protocols or protocols with no user interface (like ICMP).
150 Linux 2.2 では、 IP ヘッダの全てのフィールドとオプションとを
151 IP ソケットオプションによって設定できる。したがって
152 raw ソケットが必要になるのは、新しいプロトコルを設計する場合か、
153 ユーザーインターフェースを持たないプロトコル (ICMP など) を扱う場合に
154 限られる。
155
156 .\"O When a packet is received, it is passed to any raw sockets which have
157 .\"O been bound to its protocol before it is passed to other protocol handlers
158 .\"O (e.g., kernel protocol modules).
159 パケットは、受信されるとまずプロトコルにバインドしている
160 raw ソケットに渡され、
161 その後で他のプロトコルハンドラ (カーネルのプロトコルモジュールなど)
162 に渡される。
163 .\"O .SS Address Format
164 .SS アドレスのフォーマット
165 .\"O Raw sockets use the standard
166 .\"O .I sockaddr_in
167 .\"O address structure defined in
168 .\"O .BR ip (7).
169 .\"O The
170 .\"O .I sin_port
171 .\"O field could be used to specify the IP protocol number,
172 .\"O but it is ignored for sending in Linux 2.2 and should be always
173 .\"O set to 0 (see BUGS).
174 .\"O For incoming packets,
175 .\"O .I sin_port
176 .\"O is set to the protocol of the packet.
177 .\"O See the
178 .\"O .I <netinet/in.h>
179 .\"O include file for valid IP protocols.
180 raw ソケットは標準の
181 .I sockaddr_in
182 アドレス構造体を用いる。定義は
183 .BR ip (7)
184 でなされている。
185 .I sin_port
186 フィールドを IP プロトコル番号の指定に用いることができるが、
187 Linux 2.2 ではこれは送信時には無視され、常に 0 にされる
188 (バグ の項を参照)。
189 受信パケットに対しては、
190 .I sin_port
191 はそのパケットのプロトコルにセットされる。
192 用いることのできる IP プロトコルは、インクルードファイル
193 .I <netinet/in.h>
194 を見よ。
195 .\"O .SS Socket Options
196 .SS ソケットオプション
197 .\"O Raw socket options can be set with
198 .\"O .BR setsockopt (2)
199 .\"O and read with
200 .\"O .BR getsockopt (2)
201 .\"O by passing the
202 .\"O .B IPPROTO_RAW
203 .\"O .\" Or SOL_RAW on Linux
204 .\"O family flag.
205 raw ソケットのオプションは、
206 .B IPPROTO_RAW
207 .\" もしくは Linux では .I SOL_RAW
208 ファミリーフラグを与えて
209 .BR setsockopt (2)
210 を呼べば設定でき、
211 .BR getsockopt (2)
212 を呼べば取得できる。
213 .TP
214 .B ICMP_FILTER
215 .\"O Enable a special filter for raw sockets bound to the
216 .\"O .B IPPROTO_ICMP
217 .\"O protocol.
218 .\"O The value has a bit set for each ICMP message type which
219 .\"O should be filtered out.
220 .\"O The default is to filter no ICMP messages.
221 .B IPPROTO_ICMP
222 プロトコルにバインドされた raw ソケットのための特殊なフィルタを有効にする。
223 この値は ICMP メッセージのタイプそれぞれに対して、どれをフィルターアウト
224 するかを表したビットセットである。デフォルトでは
225 ICMP メッセージは全くフィルターしない。
226 .PP
227 .\"O In addition, all
228 .\"O .BR ip (7)
229 .\"O .B IPPROTO_IP
230 .\"O socket options valid for datagram sockets are supported.
231 さらに、データグラムソケットに使える全ての
232 .BR ip (7)
233 .B SOL_IP
234 ソケットオプションがサポートされている。
235 .\"O .SS Error Handling
236 .SS エラー処理
237 .\"O Errors originating from the network are only passed to the user when the
238 .\"O socket is connected or the
239 .\"O .B IP_RECVERR
240 .\"O flag is enabled.
241 .\"O For connected sockets, only
242 .\"O .B EMSGSIZE
243 .\"O and
244 .\"O .B EPROTO
245 .\"O are passed for compatibility.
246 .\"O With
247 .\"O .BR IP_RECVERR ,
248 .\"O all network errors are saved in the error queue.
249 ネットワークで生じたエラーがユーザに渡されるのは、
250 ソケットが接続済みの場合か
251 .B IP_RECVERR
252 フラグが有効になっている場合に限られる。
253 接続済みのソケットに対しては、
254 .B EMSGSIZE
255 および
256 .B EPROTO
257 だけが渡される (互換性のため)。
258 .B IP_RECVERR
259 を設定すると、全てのネットワークエラーがエラーキューに保存される。
260 .\"O .SH ERRORS
261 .SH エラー
262 .TP
263 .B EACCES
264 .\"O User tried to send to a broadcast address without having the
265 .\"O broadcast flag set on the socket.
266 ユーザーが broadcast フラグを設定していないソケットを用いて
267 ブロードキャストアドレスに送信を行おうとした。
268 .TP
269 .B EFAULT
270 .\"O An invalid memory address was supplied.
271 不正なメモリアドレスが与えられた。
272 .TP
273 .B EINVAL
274 .\"O Invalid argument.
275 引数が正しくない。
276 .TP
277 .B EMSGSIZE
278 .\"O Packet too big.
279 .\"O Either Path MTU Discovery is enabled (the
280 .\"O .B IP_MTU_DISCOVER
281 .\"O socket flag) or the packet size exceeds the maximum allowed IPv4
282 .\"O packet size of 64KB.
283 パケットが大きすぎる。 Path MTU Discoverry が有効になっている
284 .RB ( IP_MTU_DISCOVER
285 ソケットフラグ) か、パケットのサイズが IPv4 で許されている
286 パケットサイズの最大値 64KB を越えている。
287 .TP
288 .B EOPNOTSUPP
289 .\"O Invalid flag has been passed to a socket call (like
290 .\"O .BR MSG_OOB ).
291 ソケット呼び出しに不正なフラグ
292 .RB ( MSG_OOB
293 など) が渡された。
294 .TP
295 .B EPERM
296 .\"O The user doesn't have permission to open raw sockets.
297 .\"O Only processes with an effective user ID of 0 or the
298 .\"O .B CAP_NET_RAW
299 .\"O attribute may do that.
300 ユーザーは raw ソケットをオープンする権限を持っていない。
301 実行ユーザー ID が 0 のプロセスか、
302 .B CAP_NET_RAW
303 属性を持つプロセスだけがこれを行うことができる。
304 .TP
305 .B EPROTO
306 .\"O An ICMP error has arrived reporting a parameter problem.
307 パラメータの問題を報告する ICMP エラーを受け取った。
308 .\"O .SH VERSIONS
309 .SH バージョン
310 .\"O .B IP_RECVERR
311 .\"O and
312 .\"O .B ICMP_FILTER
313 .\"O are new in Linux 2.2.
314 .\"O They are Linux extensions and should not be used in portable programs.
315 .B IP_RECVERR
316
317 .B ICMP_FILTER
318 は Linux 2.2 で登場した。これらは Linux での拡張であり、
319 移植性の必要なプログラムでは用いるべきでない。
320
321 .\"O Linux 2.0 enabled some bug-to-bug compatibility with BSD in the
322 .\"O raw socket code when the
323 .\"O .B SO_BSDCOMPAT
324 .\"O socket option was set \(em since Linux 2.2,
325 .\"O this option no longer has that effect.
326 Linux 2.0 では
327 .B SO_BSDCOMPAT
328 ソケットオプションをセットすると、
329 BSD の raw ソケットにあるバグに互換性を取ることができた \(em
330 Linux 2.2 以降では、このオプションはもはや効力を持たない。
331 .\"O .SH NOTES
332 .SH 注意
333 .\"O By default, raw sockets do path MTU (Maximum Transmission Unit) discovery.
334 .\"O This means the kernel
335 .\"O will keep track of the MTU to a specific target IP address and return
336 .\"O .B EMSGSIZE
337 .\"O when a raw packet write exceeds it.
338 .\"O When this happens, the application should decrease the packet size.
339 .\"O Path MTU discovery can be also turned off using the
340 .\"O .B IP_MTU_DISCOVER
341 .\"O socket option or the
342 .\"O .I /proc/sys/net/ipv4/ip_no_pmtu_disc
343 .\"O file, see
344 .\"O .BR ip (7)
345 .\"O for details.
346 .\"O When turned off, raw sockets will fragment outgoing packets
347 .\"O that exceed the interface MTU.
348 .\"O However, disabling it is not recommended
349 .\"O for performance and reliability reasons.
350 デフォルトでは、raw ソケットは Path MTU Discovery を行う。
351 つまり、カーネルは特定の宛先 IP アドレスの MTU (Maximum Transmission Unit;
352 最大転送単位) を記録し、raw パケットの書き込みが MTU を超えた場合
353 .B EMSGSIZE
354 を返す。
355 .B EMSGSIZE
356 を返された場合、アプリケーションはパケットサイズを小さくすべきである。
357 ソケットオプション
358 .B IP_MTU_DISCOVER
359 または
360 .I /proc/sys/net/ipv4/ip_no_pmtu_disc
361 ファイルを使って Path MTU Discovery を無効にすることもできる
362 (詳細は
363 .BR ip (7)
364 を参照)。
365 Path MTU Discovery を無効にした場合は、パケットサイズが
366 インタフェースの MTU よりも大きいと raw ソケットはそのパケットを
367 フラグメント化して送出する。
368 しかしながら、性能と信頼性の理由から Path MTU Discovery を
369 無効にするのは推奨できない。
370
371 .\"O A raw socket can be bound to a specific local address using the
372 .\"O .BR bind (2)
373 .\"O call.
374 .\"O If it isn't bound, all packets with the specified IP protocol are received.
375 .\"O In addition, a RAW socket can be bound to a specific network device using
376 .\"O .BR SO_BINDTODEVICE ;
377 .\"O see
378 .\"O .BR socket (7).
379 .BR bind (2)
380 システムコールを用いると、
381 raw ソケットを
382 特定のローカルアドレスにバインドさせることができる。
383 このバインドがされていない場合は、指定した IP プロトコルの
384 すべてのパケットが受信される。
385 さらに、
386 .B SO_BINDTODEVICE
387 を用いれば raw ソケットを特定のネットワークデバイスに
388 バインドさせることもできる。
389 .BR socket (7)
390 を見よ。
391
392 .\"O An
393 .\"O .B IPPROTO_RAW
394 .\"O socket is send only.
395 .\"O If you really want to receive all IP packets, use a
396 .\"O .BR packet (7)
397 .\"O socket with the
398 .\"O .B ETH_P_IP
399 .\"O protocol.
400 .\"O Note that packet sockets don't reassemble IP fragments,
401 .\"O unlike raw sockets.
402 .B IPPROTO_RAW
403 ソケットは送信専用である。もしどうしてもすべての IP パケットを
404 受信したい場合は、
405 .BR packet (7)
406 ソケットを
407 .B ETH_P_IP
408 プロトコルで用いること。
409 packet ソケットは raw ソケットのように
410 IP フラグメントを再構成しないことに注意。
411
412 .\"O If you want to receive all ICMP packets for a datagram socket,
413 .\"O it is often better to use
414 .\"O .B IP_RECVERR
415 .\"O on that particular socket; see
416 .\"O .BR ip (7).
417 datagram ソケットに対するすべての ICMP パケットを受信したい場合は、
418 特定のソケットに対して
419 .B IP_RECVERR
420 を用いるほうが良い場合が多い。
421 .BR ip (7)
422 を見よ。
423
424 .\"O Raw sockets may tap all IP protocols in Linux, even
425 .\"O protocols like ICMP or TCP which have a protocol module in the kernel.
426 .\"O In this case, the packets are passed to both the kernel module and the raw
427 .\"O socket(s). This should not be relied upon in portable programs, many other BSD
428 .\"O socket implementation have limitations here.
429 raw ソケットは、 Linux のすべての IP プロトコルを受信することができる。
430 ICMP や TCP のように、カーネル内部にプロトコルモジュールを持つような
431 ものも可能である。この場合には、パケットはカーネルモジュールと
432 raw ソケットの両方に渡される (raw ソケットが複数あればそれぞれに渡される)。
433 移植性の必要なプログラムではこの機能に依存するべきではない。
434 他の多くの BSD におけるソケットの実装ではこの点において制限がある。
435
436 .\"O Linux never changes headers passed from the user (except for filling
437 .\"O in some zeroed fields as described for
438 .\"O .BR IP_HDRINCL ).
439 .\"O This differs from many other implementations of raw sockets.
440 Linux はユーザーから渡されたヘッダを決して変更しない (ただし
441 .B IP_HDRINCL
442 の説明にあるように、 0 をいくつか埋める場合を除く)。
443 これは他の多くの raw ソケットの実装では異なる。
444
445 .\"O RAW sockets are generally rather unportable and should be avoided in
446 .\"O programs intended to be portable.
447 一般に raw ソケットは移植性がないことが多いので、
448 移植性が必要なプログラムでは避けるべきである。
449
450 .\"O Sending on raw sockets should take the IP protocol from
451 .\"O .IR sin_port ;
452 .\"O this ability was lost in Linux 2.2.
453 .\"O The workaround is to use
454 .\"O .BR IP_HDRINCL .
455 raw ソケットへの送信では、 IP プロトコルを
456 .I sin_port
457 から取得できなければならない。この機能は Linux 2.2 では使えなくなった。
458 .B IP_HDRINCL
459 を用いれば同様のことが実現できる。
460 .\"O .SH BUGS
461 .SH バグ
462 .\"O Transparent proxy extensions are not described.
463 透過プロクシ (transparent proxy) 拡張については記述していない。
464
465 .\"O When the
466 .\"O .B IP_HDRINCL
467 .\"O option is set, datagrams will not be fragmented and are limited to
468 .\"O the interface MTU.
469 .B IP_HDRINCL
470 オプションがセットされているとデータグラムはフラグメント化されず、
471 インターフェースの MTU の大きさに制限される。
472
473 .\"O Setting the IP protocol for sending in
474 .\"O .I sin_port
475 .\"O got lost in Linux 2.2.
476 .\"O The protocol that socket was bound to or that
477 .\"O was specified in the initial
478 .\"O .BR socket (2)
479 .\"O call is always used.
480 送信用の IP プロトコルの設定を
481 .I sin_port
482 にしておく機能は Linux 2.2 から使えなくなった。
483 ソケットにバインドされているプロトコルか、最初の
484 .BR socket (2)
485 コールによって指定されたプロトコルが常に用いられる。
486 .\"O .\" .SH AUTHORS
487 .\" .SH 著者
488 .\"O .\" This man page was written by Andi Kleen.
489 .\" この man ページは Andi Kleen が書いた。
490 .\"O .SH SEE ALSO
491 .SH 関連項目
492 .BR recvmsg (2),
493 .BR sendmsg (2),
494 .BR capabilities (7),
495 .BR ip (7),
496 .BR socket (7)
497
498 .\"O .B RFC\ 1191
499 .\"O for path MTU discovery.
500 パス MTU 発見に関する情報は
501 .B RFC\ 1191
502 にある
503
504 .\"O .B RFC\ 791
505 .\"O and the
506 .\"O .I <linux/ip.h>
507 .\"O include file for the IP protocol.
508 IP プロトコルに関しては
509 .B RFC\ 791
510 とインクルードファイル
511 .I <linux/ip.h>
512 を参照。