OSDN Git Service

225500802a5d62c85f15f6af10ac7847b5a2a372
[linuxjm/LDP_man-pages.git] / draft / man7 / packet.7
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: packet.7,v 1.12 2001/06/19 07:07:38 argrath Exp $
7 .\"
8 .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved.
9 .\" Translated 1999-12-06, NAKANO Takeo <nakano@apm.seikei.ac.jp>
10 .\" Updated 2001-02-13, Kentaro Shirakata <argrath@ub32.org>
11 .\" Updated 2005-02-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
12 .\"
13 .\"WORD         physical layer          物理層
14 .\"WORD         link level header(s)    リンクレベルヘッダ
15 .\"WORD         phyxical header(s)      物理ヘッダ
16 .\"WORD         effective user id       実効ユーザー ID
17 .\"WORD         capability              ケーパビリティ
18 .\"WORD         pending error           遅延エラー
19 .\"WORD         promiscuous mode        無差別モード
20 .\"
21 .TH PACKET  7 2008-08-08 "Linux" "Linux Programmer's Manual"
22 .\"O .SH NAME
23 .SH 名前
24 .\"O packet, AF_PACKET \- packet interface on device level.
25 packet, AF_PACKET \- デバイスレベルのパケットインターフェース
26 .\"O .SH SYNOPSIS
27 .SH 書式
28 .nf
29 .B #include <sys/socket.h>
30 .br
31 .B #include <netpacket/packet.h>
32 .br
33 .B #include <net/ethernet.h>     /* the L2 protocols */
34 .sp
35 .BI "packet_socket = socket(AF_PACKET, int " socket_type ", int "protocol );
36 .fi
37 .\"O .SH DESCRIPTION
38 .SH 説明
39 .\"O Packet sockets are used to receive or send raw packets at the device driver
40 .\"O (OSI Layer 2) level.
41 .\"O They allow the user to implement protocol modules in user space
42 .\"O on top of the physical layer.
43 packet ソケットは、デバイスドライバ (OSI レイヤ 2) レベルで
44 生のパケット (raw packet) を送受信するために用いられる。
45 packet ソケットを使うと、ユーザー空間で物理層の上に
46 プロトコルモジュールを実装することができる。
47
48 .\"O The
49 .\"O .I socket_type
50 .\"O is either
51 .\"O .B SOCK_RAW
52 .\"O for raw packets including the link level header or
53 .\"O .B SOCK_DGRAM
54 .\"O for cooked packets with the link level header removed.
55 .\"O The link level
56 .\"O header information is available in a common format in a
57 .\"O .IR sockaddr_ll .
58 .\"O .I protocol
59 .\"O is the IEEE 802.3 protocol number in network order.
60 .\"O See the
61 .\"O .I <linux/if_ether.h>
62 .\"O include file for a list of allowed protocols.
63 .\"O When protocol
64 .\"O is set to
65 .\"O .B htons(ETH_P_ALL)
66 .\"O then all protocols are received.
67 .\"O All incoming packets of that protocol type will be passed to the packet
68 .\"O socket before they are passed to the protocols implemented in the kernel.
69 .I socket_type
70 には
71 .B SOCK_RAW
72
73 .B SOCK_DGRAM
74 のいずれかを指定する。
75 .B SOCK_RAW
76 はリンクレベルヘッダを含む raw パケットを、
77 .B SOCK_DGRAM
78 はリンクレベルヘッダが削除された加工済みパケットを示す。
79 リンクレベルヘッダ情報は
80 .I sockaddr_ll
81 で共通のフォーマットで入手できる。
82 .I protocol
83 には IEEE 802.3 プロトコル番号を
84 ネットワークバイトオーダーで指定する。
85 指定できるプロトコルのリストは、インクルードファイル
86 .I <linux/if_ether.h>
87 を参照。プロトコルを
88 .B htons(ETH_P_ALL)
89 にすると、全てのプロトコルが受信される。
90 外部から来たパケットのうち指定したプロトコルのものは、
91 カーネルに実装されているプロトコルに渡される前の段階で、
92 packet ソケットに渡される。
93
94 .\"O Only processes with effective UID 0 or the
95 .\"O .B CAP_NET_RAW
96 .\"O capability may open packet sockets.
97 packet ソケットをオープンできるのは、
98 実効ユーザーID が 0 のプロセスか、
99 .B CAP_NET_RAW
100 ケーパビリティを持つプロセスだけである。
101
102 .\"O .B SOCK_RAW
103 .\"O packets are passed to and from the device driver without any changes in
104 .\"O the packet data.
105 .\"O When receiving a packet, the address is still parsed and
106 .\"O passed in a standard
107 .\"O .I sockaddr_ll
108 .\"O address structure.
109 .\"O When transmitting a packet, the user supplied buffer
110 .\"O should contain the physical layer header.
111 .\"O That packet is then
112 .\"O queued unmodified to the network driver of the interface defined by the
113 .\"O destination address.
114 .\"O Some device drivers always add other headers.
115 .\"O .B SOCK_RAW
116 .\"O is similar to but not compatible with the obsolete
117 .\"O .B AF_INET/SOCK_PACKET
118 .\"O of Linux 2.0.
119 .B SOCK_RAW
120 パケットでは、パケットをデバイスドライバと受け渡しする際、
121 パケットデータに変更が行われることはない。
122 パケットの受信時には、アドレスの解析だけは行われ、
123 標準的な
124 .I sockaddr_ll
125 アドレス構造体に渡される。パケットの送信時には、ユーザが指定する
126 バッファに物理層のヘッダが含まれている必要がある。
127 パケットはそのまま修正を受けずに、行き先アドレスから決定される
128 インターフェースのネットワークドライバにキューイングされる。
129 デバイスドライバによっては、他のヘッダを常に追加するものもある。
130 .B SOCK_RAW
131 は Linux 2.0 の obosolete な
132 .B AF_INET/SOCK_PACKET
133 と似ているが、互換性があるわけではない。
134
135 .\"O .B SOCK_DGRAM
136 .\"O operates on a slightly higher level.
137 .\"O The physical header is removed before the packet is passed to the user.
138 .\"O Packets sent through a
139 .\"O .B SOCK_DGRAM
140 .\"O packet socket get a suitable physical layer header based on the
141 .\"O information in the
142 .\"O .I sockaddr_ll
143 .\"O destination address before they are queued.
144 .B SOCK_DGRAM
145 はやや高位のレベルで動作する。物理ヘッダは、パケットがユーザーに
146 渡される前に削除される。
147 .B SOCK_DGRAM
148 の packet ソケットを通して送られるパケットは、
149 .I sockaddr_ll
150 の行き先アドレスの情報に基づき、適切な物理層のヘッダが付加されてから、
151 キューに送られる。
152
153 .\"O By default all packets of the specified protocol type
154 .\"O are passed to a packet socket.
155 .\"O To only get packets from a specific interface use
156 .\"O .BR bind (2)
157 .\"O specifying an address in a
158 .\"O .I struct sockaddr_ll
159 .\"O to bind the packet socket to an interface.
160 .\"O Only the
161 .\"O .I sll_protocol
162 .\"O and the
163 .\"O .I sll_ifindex
164 .\"O address fields are used for purposes of binding.
165 デフォルトでは、指定したプロトコル型のパケットはすべて packet
166 ソケットに送られる。特定のインターフェースからのパケットだけを
167 取得したい場合には、
168 .I struct sockaddr_ll
169 にアドレスを指定して
170 .BR bind (2)
171 を呼び、 packet ソケットをそのインターフェースに結び付ける (バインドする)。
172 バインドの際には、アドレスフィールドのうち
173 .I sll_protocol
174
175 .I sll_ifindex
176 だけが用いられる。
177
178 .\"O The
179 .\"O .BR connect (2)
180 .\"O operation is not supported on packet sockets.
181 .BR connect (2)
182 操作は packet ソケットではサポートされていない。
183
184 .\"O When the
185 .\"O .B MSG_TRUNC
186 .\"O flag is passed to
187 .\"O .BR recvmsg (2),
188 .\"O .BR recv (2),
189 .\"O .BR recvfrom (2)
190 .\"O the real length of the packet on the wire is always returned,
191 .\"O even when it is longer than the buffer.
192 .B MSG_TRUNC
193 フラグが
194 .BR recvmsg (2),
195 .BR recv (2),
196 .BR recvfrom (2)
197 に渡されると、 (バッファサイズより大きかったとしても) 常に実際に通信された
198 パケットの長さが返される。
199 .\"O .SS Address Types
200 .SS アドレスのタイプ
201 .\"O The sockaddr_ll is a device independent physical layer address.
202 sockaddr_ll はデバイスに依存しない物理層のアドレスである。
203
204 .in +4n
205 .nf
206 .\"O struct sockaddr_ll {
207 .\"O     unsigned short sll_family;   /* Always AF_PACKET */
208 .\"O     unsigned short sll_protocol; /* Physical layer protocol */
209 .\"O     int            sll_ifindex;  /* Interface number */
210 .\"O     unsigned short sll_hatype;   /* Header type */
211 .\"O     unsigned char  sll_pkttype;  /* Packet type */
212 .\"O     unsigned char  sll_halen;    /* Length of address */
213 .\"O     unsigned char  sll_addr[8];  /* Physical layer address */
214 .\"O };
215 struct sockaddr_ll {
216     unsigned short sll_family;   /* 常に AF_PACKET */
217     unsigned short sll_protocol; /* 物理層のプロトコル */
218     int            sll_ifindex;  /* インターフェース番号 */
219     unsigned short sll_hatype;   /* ヘッダ種別 */
220     unsigned char  sll_pkttype;  /* パケット種別 */
221     unsigned char  sll_halen;    /* アドレスの長さ */
222     unsigned char  sll_addr[8];  /* 物理層のアドレス */
223 };
224 .fi
225 .in
226
227 .\"O .I sll_protocol
228 .\"O is the standard ethernet protocol type in network order as defined
229 .\"O in the
230 .\"O .I <linux/if_ether.h>
231 .\"O include file.
232 .\"O It defaults to the socket's protocol.
233 .I sll_protocol
234 は標準的なイーサネットプロトコルのタイプで、
235 ネットワークバイトオーダーで記述する。
236 インクルードファイル
237 .I <linux/if_ether.h>
238 で定義されている。
239 これがこのソケットのプロトコルのデフォルトとなる。
240
241 .\"O .I sll_ifindex
242 .\"O is the interface index of the interface
243 .\"O (see
244 .\"O .BR netdevice (7));
245 .\"O 0 matches any interface (only permitted for binding).
246 .I sll_ifindex
247 はそのインターフェースの interface index である
248 .RB ( netdevice (7)
249 を参照)。
250 0 は (バインドが許可されている)  任意のインターフェースにマッチする。
251
252 .\"O .I sll_hatype
253 .\"O is a ARP type as defined in the
254 .\"O .I <linux/if_arp.h>
255 .\"O include file.
256 .I sll_hatype
257 は、インクルードファイル
258 .I <linux/if_arp.h>
259 で定義されている ARP 種別である。
260
261 .\"O .I sll_pkttype
262 .\"O contains the packet type.
263 .\"O Valid types are
264 .\"O .B PACKET_HOST
265 .\"O for a packet addressed to the local host,
266 .\"O .B PACKET_BROADCAST
267 .\"O for a physical layer broadcast packet,
268 .\"O .B PACKET_MULTICAST
269 .\"O for a packet sent to a physical layer multicast address,
270 .\"O .B PACKET_OTHERHOST
271 .\"O for a packet to some other host that has been caught by a device driver
272 .\"O in promiscuous mode, and
273 .\"O .B PACKET_OUTGOING
274 .\"O for a packet originated from the local host that is looped back to a packet
275 .\"O socket.
276 .\"O These types make only sense for receiving.
277 .I sll_pkttype
278 はパケット種別である。指定できる種別は以下のいずれかである:
279 .B PACKET_HOST
280 (ローカルホスト向けのパケット)、
281 .B PACKET_BORADCAST
282 (物理層のブロードキャストパケット)、
283 .B PACKET_MULTICAST
284 (物理層のマルチキャストアドレスに送るパケット)、
285 .B PACKET_OTHERHOST
286 (他のホストに向けられたパケットのうち、
287 無差別モード (promiscuous mode: 後述) のデバイスドライバにより補足されたもの)、
288 .B PACKET_OUTGOING
289 (ローカルホストから発信され、
290 packet ソケットにループバックしてきたパケット)。
291 これらの種別が意味を持つのは受信時のみである。
292
293 .\"O .I sll_addr
294 .\"O and
295 .\"O .I sll_halen
296 .\"O contain the physical layer (e.g., IEEE 802.3) address and its length.
297 .\"O The exact interpretation depends on the device.
298 .I sll_addr
299
300 .I sll_halen
301 は、物理層の (つまり IEEE 802.3 の) アドレスとその長さである。
302 厳密な解釈はデバイスに依存する。
303
304 .\"O When you send packets it is enough to specify
305 .\"O .IR sll_family ,
306 .\"O .IR sll_addr ,
307 .\"O .IR sll_halen ,
308 .\"O .IR sll_ifindex .
309 パケットを送る場合は、
310 .IR sll_family ,
311 .IR sll_addr ,
312 .IR sll_halen ,
313 .I sll_ifindex
314 を指定すれば十分である。
315 .\"O The other fields should be 0.
316 その他のフィールドは 0 にしておくべきである。
317 .\"O .I sll_hatype
318 .\"O and
319 .\"O .I sll_pkttype
320 .\"O are set on received packets for your information.
321 .I sll_hatype
322
323 .I sll_pkttype
324 には受信したパケットの情報が設定される。
325 .\"O For bind only
326 .\"O .I sll_protocol
327 .\"O and
328 .\"O .I sll_ifindex
329 .\"O are used.
330 バインドの際には、
331 .I sll_protocol
332
333 .I sll_ifindex
334 だけが使用される。
335 .\"O .SS Socket Options
336 .SS ソケットオプション
337 .\"O Packet sockets can be used to configure physical layer multicasting
338 .\"O and promiscuous mode.
339 .\"O It works by calling
340 .\"O .BR setsockopt (2)
341 .\"O on a packet socket for
342 .\"O .B SOL_PACKET
343 .\"O and one of the options
344 .\"O .B PACKET_ADD_MEMBERSHIP
345 .\"O to add a binding or
346 .\"O .B PACKET_DROP_MEMBERSHIP
347 .\"O to drop it.
348 .\"O They both expect a
349 .\"O .B packet_mreq
350 .\"O structure as argument:
351 packet ソケットは、物理層のマルチキャストや
352 無差別モード (promiscuous mode) を設定して使うことができる。
353 これには
354 .B SOL_PACKET
355 と以下のオプションのいずれかを指定して
356 .BR setsockopt (2)
357 を呼べばよい。
358 バインドを追加する場合は
359 .B PACKET_ADD_MEMBERSHIP
360 であり、取り去る場合は
361 .B PACKET_DROP_MEMBERSHIP
362 である。これらはいずれも
363 .B packet_mreq
364 構造体を引き数に取る。
365
366 .in +4n
367 .nf
368 .\"O struct packet_mreq {
369 .\"O     int            mr_ifindex;    /* interface index */
370 .\"O     unsigned short mr_type;       /* action */
371 .\"O     unsigned short mr_alen;       /* address length */
372 .\"O     unsigned char  mr_address[8]; /* physical layer address */
373 .\"O };
374 struct packet_mreq {
375     int            mr_ifindex;    /* インターフェース番号 */
376     unsigned short mr_type;       /* 動作 */
377     unsigned short mr_alen;       /* アドレスの長さ */
378     unsigned char  mr_address[8]; /* 物理層のアドレス */
379 };
380 .fi
381 .in
382
383 .\"O .B mr_ifindex
384 .\"O contains the interface index for the interface whose status
385 .\"O should be changed.
386 .\"O The
387 .\"O .B mr_type
388 .\"O parameter specifies which action to perform.
389 .\"O .B PACKET_MR_PROMISC
390 .\"O enables receiving all packets on a shared medium (often known as
391 .\"O "promiscuous mode"),
392 .\"O .B PACKET_MR_MULTICAST
393 .\"O binds the socket to the physical layer multicast group specified in
394 .\"O .B mr_address
395 .\"O and
396 .\"O .BR mr_alen ,
397 .\"O and
398 .\"O .B PACKET_MR_ALLMULTI
399 .\"O sets the socket up to receive all multicast packets arriving at
400 .\"O the interface.
401 .I mr_ifindex
402 は、ステータスを変更したいインターフェースの
403 インターフェース番号である。
404 .I mr_type
405 パラメータは実行する動作を指定する:
406 .B PACKET_MR_PROMISC
407 は、共有している媒体からの全てのパケットを受信できるようにする
408 (しばしば "無差別モード (promiscuous mode)" と呼ばれる)。
409 .B PACKET_MR_MULTICAST
410 は、そのソケットを、
411 .I mr_address
412
413 .I mr_alen
414 で指定される物理層のマルチキャストブループにバインドする。
415 .B PACKET_MR_ALLMULTI
416 は socket を up にして、そのインターフェースに到達したすべての
417 マルチキャストパケットを受信できるようにする。
418
419 .\"O In addition the traditional ioctls
420 .\"O .BR SIOCSIFFLAGS ,
421 .\"O .BR SIOCADDMULTI ,
422 .\"O .B SIOCDELMULTI
423 .\"O can be used for the same purpose.
424 昔からある ioctl だけでなく、
425 .BR SIOCSIFFLAGS ,
426 .BR SIOCADDMULTI ,
427 .B SIOCDELMULTI
428 を同じ目的に用いることができる。
429 .\"O .SS Ioctls
430 .SS ioctl
431 .\"O .B SIOCGSTAMP
432 .\"O can be used to receive the timestamp of the last received packet.
433 .\"O Argument is a
434 .\"O .IR "struct timeval" .
435 .B SIOCGSTAMP
436 を用いると、最後に受信したパケットのタイムスタンプを得ることができる。
437 引き数は
438 .I struct timeval
439 である。
440 .\" FIXME Document SIOCGSTAMPNS
441
442 .\"O In addition all standard ioctls defined in
443 .\"O .BR netdevice (7)
444 .\"O and
445 .\"O .BR socket (7)
446 .\"O are valid on packet sockets.
447 さらに、
448 .BR netdevice (7)
449 および
450 .BR socket (7)
451 で定義されている標準の ioctl はいずれも
452 packet ソケットに指定可能である。
453 .\"O .SS Error Handling
454 .SS エラー処理
455 .\"O Packet sockets do no error handling other than errors occurred
456 .\"O while passing the packet to the device driver.
457 .\"O They don't have the concept of a pending error.
458 packet ソケットは、パケットをデバイスドライバに渡すときに
459 起きたエラーしか処理しない。遅延エラー (pending error)
460 に関する概念は持っていない。
461 .\"O .SH ERRORS
462 .SH エラー
463 .TP
464 .B EADDRNOTAVAIL
465 .\"O Unknown multicast group address passed.
466 不明なマルチキャストグループアドレスが渡された。
467 .TP
468 .B EFAULT
469 .\"O User passed invalid memory address.
470 ユーザが渡したメモリアドレスが不正。
471 .TP
472 .B EINVAL
473 .\"O Invalid argument.
474 引き数が不正。
475 .TP
476 .B EMSGSIZE
477 .\"O Packet is bigger than interface MTU.
478 パケットがインターフェースの MTU より大きい。
479 .TP
480 .B ENETDOWN
481 .\"O Interface is not up.
482 インターフェースが up でない。
483 .TP
484 .B ENOBUFS
485 .\"O Not enough memory to allocate the packet.
486 パケットに割り当てるメモリが足りない。
487 .TP
488 .B ENODEV
489 .\"O Unknown device name or interface index specified in interface address.
490 デバイス名が不明。あるいはインターフェースアドレスで指定された
491 インターフェースインデックスが不明。
492 .TP
493 .B ENOENT
494 .\"O No packet received.
495 パケットを一つも受信していない。
496 .TP
497 .B ENOTCONN
498 .\"O No interface address passed.
499 インターフェースアドレスが渡されなかった。
500 .TP
501 .B ENXIO
502 .\"O Interface address contained an invalid interface index.
503 インターフェースアドレスに不正なインターフェースインデックスが含まれている。
504 .TP
505 .B EPERM
506 .\"O User has insufficient privileges to carry out this operation.
507 この操作を行うのに必要な権限をユーザが持っていない。
508
509 .\"O In addition other errors may be generated by the low-level driver.
510 上記以外のエラーが、低レベルのドライバで生成されることがある。
511 .\"O .SH VERSIONS
512 .SH バージョン
513 .\"O .B AF_PACKET
514 .\"O is a new feature in Linux 2.2.
515 .\"O Earlier Linux versions supported only
516 .\"O .BR SOCK_PACKET .
517 .B AF_PACKET
518 は Linux 2.2 の新機能である。これより古いバージョンの Linux では
519 .B SOCK_PACKET
520 のみをサポートしていた。
521 .PP
522 .\"O The include file
523 .\"O .I <netpacket/packet.h>
524 .\"O is present since glibc 2.1.
525 .\"O Older systems need:
526 インクルードファイル
527 .I <netpacket/packet.h>
528 が存在するのは glibc 2.1 以降である。
529 それ以前のシステムでは以下のようにする必要がある:
530 .sp
531 .in +4n
532 .nf
533 #include <asm/types.h>
534 #include <linux/if_packet.h>
535 #include <linux/if_ether.h>  /* The L2 protocols */
536 .fi
537 .in
538 .\"O .SH NOTES
539 .SH 注意
540 .\"O For portable programs it is suggested to use
541 .\"O .B AF_PACKET
542 .\"O via
543 .\"O .BR pcap (3);
544 .\"O although this only covers a subset of the
545 .\"O .B AF_PACKET
546 .\"O features.
547 移植性の必要なプログラムでは、
548 .BR pcap (3)
549 経由で
550 .B AF_PACKET
551 を用いることをお薦めする。ただし、この方法では
552 .B AF_PACKET
553 の機能すべてを利用することはできない。
554
555 .\"O The
556 .\"O .B SOCK_DGRAM
557 .\"O packet sockets make no attempt to create or parse the IEEE 802.2 LLC
558 .\"O header for a IEEE 802.3 frame.
559 .\"O When
560 .\"O .B ETH_P_802_3
561 .\"O is specified as protocol for sending the kernel creates the
562 .\"O 802.3 frame and fills out the length field; the user has to supply the LLC
563 .\"O header to get a fully conforming packet.
564 .\"O Incoming 802.3 packets are not multiplexed on the DSAP/SSAP protocol
565 .\"O fields; instead they are supplied to the user as protocol
566 .\"O .B ETH_P_802_2
567 .\"O with the LLC header prepended.
568 .\"O It is thus not possible to bind to
569 .\"O .BR ETH_P_802_3 ;
570 .\"O bind to
571 .\"O .B ETH_P_802_2
572 .\"O instead and do the protocol multiplex yourself.
573 .\"O The default for sending is the standard Ethernet DIX
574 .\"O encapsulation with the protocol filled in.
575 .B SOCK_DGRAM
576 packet ソケットは、IEEE 802.3 フレームの IEEE 802.2 LLC ヘッダの
577 生成や解析を行おうとしない。
578 .B ETH_P_802_3
579 が送信プロトコルに指定されると、カーネルは 802.3 フレームを
580 生成して length フィールドに書き込む。
581 完全に準拠したパケットを得るためにはユーザーが LLC ヘッダを
582 与える必要がある。到着した 802.3 パケットでは、
583 DSAP/SSAP protocol の各フィールドは多重化 (multiplex) されていない。
584 代わりにこれらは LLC ヘッダが前置された
585 .B ETH_P_802_2
586 プロトコルとして与えられる。したがって、
587 .B ETH_P_802_3
588 にバインドすることはできない。かわりに
589 .B ETH_P_802_2
590 にバインドし、自分自身でプロトコルの多重化を行うこと。
591 送信のデフォルトは、プロトコルフィールドを持つ
592 標準の Ethernet DIX encapsulation である。
593
594 .\"O Packet sockets are not subject to the input or output firewall chains.
595 packet ソケットは入出力の firewall chain に影響をうけない。
596 .\"O .SS Compatibility
597 .SS 移植性
598 .\"O In Linux 2.0, the only way to get a packet socket was by calling
599 .\"O .BI "socket(AF_INET, SOCK_PACKET, " protocol )\fR.
600 .\"O This is still supported but strongly deprecated.
601 .\"O The main difference between the two methods is that
602 .\"O .B SOCK_PACKET
603 .\"O uses the old
604 .\"O .I struct sockaddr_pkt
605 .\"O to specify an interface, which doesn't provide physical layer
606 .\"O independence.
607 Linux 2.0 では、 packet ソケットを得る方法は
608 .BI "socket(AF_INET, SOCK_PACKET, " protocol )\fR
609 を呼ぶやり方しかなかった。この方法はまだサポートされているが、
610 用いないことを強く推奨する。現在の方法との主な違いは、
611 .B SOCK_PACKET
612 ではインターフェースの指定に古い
613 .I struct sockaddr_pkt
614 を用いる点である。これには物理層からの独立性がない。
615
616 .in +4n
617 .nf
618 struct sockaddr_pkt {
619     unsigned short spkt_family;
620     unsigned char  spkt_device[14];
621     unsigned short spkt_protocol;
622 };
623 .fi
624 .in
625
626 .\"O .I spkt_family
627 .\"O contains
628 .\"O the device type,
629 .\"O .I spkt_protocol
630 .\"O is the IEEE 802.3 protocol type as defined in
631 .\"O .I <sys/if_ether.h>
632 .\"O and
633 .\"O .I spkt_device
634 .\"O is the device name as a null-terminated string, for example, eth0.
635 .I spkt_family
636 はデバイスのタイプ、
637 .I spkt_protocol
638
639 .I <sys/if_ether.h>
640 で定義されている IEEE 802.3 プロトコルタイプ、
641 .I spkt_device
642 はデバイスの名前を NULL 終端された文字列で与えたもの (例: eth0) である。
643
644 .\"O This structure is obsolete and should not be used in new code.
645 この構造体は obsolete であり、
646 新しくコードを書く時には用いるべきでない。
647 .\"O .SH BUGS
648 .SH バグ
649 .\"O glibc 2.1 does not have a define for
650 .\"O .BR SOL_PACKET .
651 .\"O The suggested workaround is to use:
652 glibc 2.1 には
653 .B SOL_PACKET
654 の定義がない。回避策としては、以下のようにするとよい。
655 .in +4n
656 .nf
657
658 #ifndef SOL_PACKET
659 #define SOL_PACKET 263
660 #endif
661
662 .fi
663 .in
664 .\"O This is fixed in later glibc versions and also does not occur on
665 .\"O libc5 systems.
666 この問題は新しいバージョンの glibc では修正されている。
667 libc5 のシステムにはこの問題はない。
668
669 .\"O The IEEE 802.2/803.3 LLC handling could be considered as a bug.
670 IEEE 802.2/803.3 の LLC の扱い方は、バグと考えても良いだろう。
671
672 .\"O Socket filters are not documented.
673 ソケットフィルターについて記載されていない。
674
675 .\"O The
676 .\"O .B MSG_TRUNC
677 .\"O .BR recvmsg (2)
678 .\"O extension is an ugly hack and should be replaced by a control message.
679 .\"O There is currently no way to get the original destination address of
680 .\"O packets via
681 .\"O .BR SOCK_DGRAM .
682 .B MSG_TRUNC
683 .BR recvmsg (2)
684 拡張は非常にまずい対処であり、制御メッセージで置き換えるべきである。
685 今のところ
686 .B SOCK_DGRAM
687 経由でパケットについていた宛先アドレスを得る方法がない。
688 .\"O .\" .SH CREDITS
689 .\" .SH 著者
690 .\"O .\" This man page was written by Andi Kleen with help from Matthew Wilcox.
691 .\"O .\" AF_PACKET in Linux 2.2 was implemented
692 .\"O .\" by Alexey Kuznetsov, based on code by Alan Cox and others.
693 .\" この man ページは Matthew Wilcox の助力のもとに Andi Kleen が書いた。
694 .\" Linux 2.2 の AF_PACKET は、
695 .\" Alan Cox たちのコードをもとにして Alexey Kuznetsov が実装した。
696 .\"O .SH SEE ALSO
697 .SH 関連項目
698 .BR socket (2),
699 .BR pcap (3),
700 .BR capabilities (7),
701 .BR ip (7),
702 .BR raw (7),
703 .BR socket (7)
704
705 .\"O RFC\ 894 for the standard IP Ethernet encapsulation.
706 標準 IP Ethernet encapsulation に関する情報は RFC\ 894 にある。
707
708 .\"O RFC\ 1700 for the IEEE 802.3 IP encapsulation.
709 IEEE 802.3 IP encapsulation に関する情報は RFC\ 1700 にある。
710
711 .\"O The
712 .\"O .I <linux/if_ether.h>
713 .\"O include file for physical layer protocols.
714 物理層のプロトコルに関する記述は
715 .I <linux/if_ether.h>
716 インクルードファイルにある。