@@ -161,10 +161,25 @@ created. Socket addresses are represented as follows:
161161
162162 .. versionadded :: 3.7
163163
164- - Certain other address families (:const: `AF_PACKET `, :const: `AF_CAN `)
165- support specific representations.
166-
167- .. XXX document them!
164+ - The :const: `AF_PACKET ` address family is a Linux-only packet address protocol
165+ represented by the tuple ``(ifname, proto[, pkttype[, hatype[, addr]]]) ``
166+ where:
167+
168+ - *ifname * - String specifying the device name.
169+ - *proto * - An endian-corrected integer specifying the Ethernet protocol
170+ number.
171+ - *pkttype * - Optional constant integer specifying the packet type:
172+
173+ - ``PACKET_HOST `` (the default) - Packet addressed to the local host.
174+ - ``PACKET_BROADCAST `` - Physical-layer broadcast packet.
175+ - ``PACKET_MULTIHOST `` - Packet sent to a physical-layer multicast address.
176+ - ``PACKET_OTHERHOST `` - Packet to some other host that has been caught by
177+ a device driver in promiscuous mode.
178+ - ``PACKET_OUTGOING `` - Packet originating from the local host that is
179+ looped back to a packet socket.
180+ - *hatype * - Optional integer specifying the ARP hardware address type.
181+ - *addr * - Optional bytes-like object specifying the hardware physical
182+ address, whose interpretation depends on the device.
168183
169184For IPv4 addresses, two special forms are accepted instead of a host address:
170185the empty string represents :const: `INADDR_ANY `, and the string
@@ -363,6 +378,16 @@ Constants
363378 .. versionadded :: 3.7
364379
365380
381+ .. data :: AF_PACKET
382+ PF_PACKET
383+ PACKET_*
384+
385+ Many constants of these forms, documented in the Linux documentation, are
386+ also defined in the socket module.
387+
388+ Availability: Linux >= 2.2.
389+
390+
366391.. data :: AF_RDS
367392 PF_RDS
368393 SOL_RDS
@@ -456,15 +481,16 @@ The following functions all create :ref:`socket objects <socket-objects>`.
456481
457482 Create a new socket using the given address family, socket type and protocol
458483 number. The address family should be :const: `AF_INET ` (the default),
459- :const: `AF_INET6 `, :const: `AF_UNIX `, :const: `AF_CAN ` or :const: `AF_RDS `. The
460- socket type should be :const: `SOCK_STREAM ` (the default),
461- :const: `SOCK_DGRAM `, :const: `SOCK_RAW ` or perhaps one of the other ``SOCK_ ``
462- constants. The protocol number is usually zero and may be omitted or in the
463- case where the address family is :const: `AF_CAN ` the protocol should be one
464- of :const: `CAN_RAW `, :const: `CAN_BCM ` or :const: `CAN_ISOTP `. If *fileno * is specified, the other
465- arguments are ignored, causing the socket with the specified file descriptor
466- to return. Unlike :func: `socket.fromfd `, *fileno * will return the same
467- socket and not a duplicate. This may help close a detached socket using
484+ :const: `AF_INET6 `, :const: `AF_UNIX `, :const: `AF_CAN `, :const: `AF_PACKET `,
485+ or :const: `AF_RDS `. The socket type should be :const: `SOCK_STREAM ` (the
486+ default), :const: `SOCK_DGRAM `, :const: `SOCK_RAW ` or perhaps one of the other
487+ ``SOCK_ `` constants. The protocol number is usually zero and may be omitted
488+ or in the case where the address family is :const: `AF_CAN ` the protocol
489+ should be one of :const: `CAN_RAW `, :const: `CAN_BCM ` or :const: `CAN_ISOTP `.
490+ If *fileno * is specified, the other arguments are ignored, causing the
491+ socket with the specified file descriptor to return. Unlike
492+ :func: `socket.fromfd `, *fileno * will return the same socket and not a
493+ duplicate. This may help close a detached socket using
468494 :meth: `socket.close() `.
469495
470496 The newly created socket is :ref: `non-inheritable <fd_inheritance >`.
0 commit comments