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 $
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
14 .\"WORD link level header(s) リンクレベルヘッダ
15 .\"WORD effective user ID 実効ユーザー ID
17 .\"WORD route (パケットの) 経路
19 .TH RAW 7 2008-11-20 "Linux" "Linux Programmer's Manual"
21 .\"O raw, SOCK_RAW \- Linux IPv4 raw sockets
23 raw, SOCK_RAW \- Linux の IPv4 raw ソケット
26 .B #include <sys/socket.h>
28 .B #include <netinet/in.h>
30 .BI "raw_socket = socket(AF_INET, SOCK_RAW, int " protocol );
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 データグラムの送受信ができる。
40 .\"O The IPv4 layer generates an IP header when sending a packet unless the
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.
47 ソケットオプションが有効になっていなければ、
48 パケットを送信するときに IP ヘッダを生成する。
50 オプションが有効になっているときは、パケットには
52 受信時には、 IP ヘッダは常にパケットに含まれている。
54 .\"O Only processes with an effective user ID of 0 or the
56 .\"O capability are allowed to open raw sockets.
59 権限を持つプロセスだけが raw ソケットをオープンすることができる。
61 .\"O All packets or errors matching the
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).
69 番号にマッチする全てのパケットとエラーとが、このソケットに渡される。
70 許可されているプロトコルのリストは RFC\ 1700 の割り当て番号と
71 .BR getprotobyname (3)
78 .\"O and is able to send any IP protocol that is specified in the passed
80 .\"O Receiving of all IP protocols via
82 .\"O is not possible using raw sockets.
87 渡されたヘッダで指定された、あらゆる IP プロトコルを送信できる。
89 経由でのあらゆる IP プロトコルの受信は、
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 によって送信時に変更される。
103 ソースアドレス:元の値が 0 の時に変更される。
104 パケット ID:元の値が 0 の時に変更される。
110 .\"NAKANO Aloways filled in. とは?
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.
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
122 0 でない送信先アドレスが記入されていた場合は、
123 その送信先アドレスがパケットの経路を決めるのに用いられる。
126 送信先アドレスはローカルなインターフェースを参照するものでなければならない。
127 さもないと、ルーティングテーブルの参照はいずれにせよ行われるが、
129 .\"NAKANO ローカルなネットなのかインターフェースなのか?
133 .\"O isn't set, then IP header options can be set on raw sockets with
134 .\"O .BR setsockopt (2);
137 .\"O for more information.
140 raw ソケットの IP ヘッダオプションを
142 を用いて設定することができる。詳細な情報は
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 など) を扱う場合に
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 パケットは、受信されるとまずプロトコルにバインドしている
161 その後で他のプロトコルハンドラ (カーネルのプロトコルモジュールなど)
163 .\"O .SS Address Format
165 .\"O Raw sockets use the standard
167 .\"O address structure defined in
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,
176 .\"O is set to the protocol of the packet.
178 .\"O .I <netinet/in.h>
179 .\"O include file for valid IP protocols.
186 フィールドを IP プロトコル番号の指定に用いることができるが、
187 Linux 2.2 ではこれは送信時には無視され、常に 0 にされる
191 はそのパケットのプロトコルにセットされる。
192 用いることのできる IP プロトコルは、インクルードファイル
195 .\"O .SS Socket Options
197 .\"O Raw socket options can be set with
198 .\"O .BR setsockopt (2)
200 .\"O .BR getsockopt (2)
203 .\"O .\" Or SOL_RAW on Linux
207 .\" もしくは Linux では .I SOL_RAW
215 .\"O Enable a special filter for raw sockets bound to the
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.
222 プロトコルにバインドされた raw ソケットのための特殊なフィルタを有効にする。
223 この値は ICMP メッセージのタイプそれぞれに対して、どれをフィルターアウト
224 するかを表したビットセットである。デフォルトでは
225 ICMP メッセージは全くフィルターしない。
227 .\"O In addition, all
230 .\"O socket options valid for datagram sockets are supported.
231 さらに、データグラムソケットに使える全ての
235 .\"O .SS Error Handling
237 .\"O Errors originating from the network are only passed to the user when the
238 .\"O socket is connected or the
240 .\"O flag is enabled.
241 .\"O For connected sockets, only
245 .\"O are passed for compatibility.
247 .\"O .BR IP_RECVERR ,
248 .\"O all network errors are saved in the error queue.
249 ネットワークで生じたエラーがユーザに渡されるのは、
259 を設定すると、全てのネットワークエラーがエラーキューに保存される。
264 .\"O User tried to send to a broadcast address without having the
265 .\"O broadcast flag set on the socket.
266 ユーザーが broadcast フラグを設定していないソケットを用いて
267 ブロードキャストアドレスに送信を行おうとした。
270 .\"O An invalid memory address was supplied.
274 .\"O Invalid argument.
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 を越えている。
289 .\"O Invalid flag has been passed to a socket call (like
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
299 .\"O attribute may do that.
300 ユーザーは raw ソケットをオープンする権限を持っていない。
301 実行ユーザー ID が 0 のプロセスか、
303 属性を持つプロセスだけがこれを行うことができる。
306 .\"O An ICMP error has arrived reporting a parameter problem.
307 パラメータの問題を報告する ICMP エラーを受け取った。
313 .\"O are new in Linux 2.2.
314 .\"O They are Linux extensions and should not be used in portable programs.
318 は Linux 2.2 で登場した。これらは Linux での拡張であり、
319 移植性の必要なプログラムでは用いるべきでない。
321 .\"O Linux 2.0 enabled some bug-to-bug compatibility with BSD in the
322 .\"O raw socket code when the
324 .\"O socket option was set \(em since Linux 2.2,
325 .\"O this option no longer has that effect.
329 BSD の raw ソケットにあるバグに互換性を取ることができた \(em
330 Linux 2.2 以降では、このオプションはもはや効力を持たない。
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
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
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 を超えた場合
356 を返された場合、アプリケーションはパケットサイズを小さくすべきである。
360 .I /proc/sys/net/ipv4/ip_no_pmtu_disc
361 ファイルを使って Path MTU Discovery を無効にすることもできる
365 Path MTU Discovery を無効にした場合は、パケットサイズが
366 インタフェースの MTU よりも大きいと raw ソケットはそのパケットを
368 しかしながら、性能と信頼性の理由から Path MTU Discovery を
371 .\"O A raw socket can be bound to a specific local address using the
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 ;
382 特定のローカルアドレスにバインドさせることができる。
383 このバインドがされていない場合は、指定した IP プロトコルの
387 を用いれば raw ソケットを特定のネットワークデバイスに
394 .\"O socket is send only.
395 .\"O If you really want to receive all IP packets, use a
400 .\"O Note that packet sockets don't reassemble IP fragments,
401 .\"O unlike raw sockets.
403 ソケットは送信専用である。もしどうしてもすべての IP パケットを
409 packet ソケットは raw ソケットのように
410 IP フラグメントを再構成しないことに注意。
412 .\"O If you want to receive all ICMP packets for a datagram socket,
413 .\"O it is often better to use
415 .\"O on that particular socket; see
417 datagram ソケットに対するすべての ICMP パケットを受信したい場合は、
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 におけるソケットの実装ではこの点において制限がある。
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 はユーザーから渡されたヘッダを決して変更しない (ただし
442 の説明にあるように、 0 をいくつか埋める場合を除く)。
443 これは他の多くの raw ソケットの実装では異なる。
445 .\"O RAW sockets are generally rather unportable and should be avoided in
446 .\"O programs intended to be portable.
447 一般に raw ソケットは移植性がないことが多いので、
448 移植性が必要なプログラムでは避けるべきである。
450 .\"O Sending on raw sockets should take the IP protocol from
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 プロトコルを
457 から取得できなければならない。この機能は Linux 2.2 では使えなくなった。
462 .\"O Transparent proxy extensions are not described.
463 透過プロクシ (transparent proxy) 拡張については記述していない。
467 .\"O option is set, datagrams will not be fragmented and are limited to
468 .\"O the interface MTU.
470 オプションがセットされているとデータグラムはフラグメント化されず、
471 インターフェースの MTU の大きさに制限される。
473 .\"O Setting the IP protocol for sending in
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
479 .\"O call is always used.
482 にしておく機能は Linux 2.2 から使えなくなった。
483 ソケットにバインドされているプロトコルか、最初の
485 コールによって指定されたプロトコルが常に用いられる。
488 .\"O .\" This man page was written by Andi Kleen.
489 .\" この man ページは Andi Kleen が書いた。
494 .BR capabilities (7),
499 .\"O for path MTU discovery.
507 .\"O include file for the IP protocol.