[3.7] closes bpo-25041: Document AF_PACKET socket address format. (GH… · python/cpython@cadb66e (original) (raw)

`@@ -173,10 +173,25 @@ created. Socket addresses are represented as follows:

`

173

173

``

174

174

` .. versionadded:: 3.7

`

175

175

``

176

``

`` -

``

177

``

`-

support specific representations.

`

178

``

-

179

``

`-

.. XXX document them!

`

``

176

`` +

``

``

177

`+

The packets are represented by the tuple

`

``

178


 ``(ifname, proto[, pkttype[, hatype[, addr]]])`` where:

``

179

+

``

180

`+

`

``

181

`+

`

``

182

`+

protocol number.

`

``

183

`+

`

``

184

+

``

185


 - ``PACKET_HOST`` (the default) - Packet addressed to the local host.

``

186


 - ``PACKET_BROADCAST`` - Physical-layer broadcast packet.

``

187


 - ``PACKET_MULTIHOST`` - Packet sent to a physical-layer multicast address.

``

188


 - ``PACKET_OTHERHOST`` - Packet to some other host that has been caught by

``

189

`+

a device driver in promiscuous mode.

`

``

190


 - ``PACKET_OUTGOING`` - Packet originating from the local host that is

``

191

`+

looped back to a packet socket.

`

``

192

`+

`

``

193

`+

`

``

194

`+

address, whose interpretation depends on the device.

`

180

195

``

181

196

`If you use a hostname in the host portion of IPv4/v6 socket address, the

`

182

197

`program may show a nondeterministic behavior, as Python uses the first address

`

`@@ -376,6 +391,16 @@ Constants

`

376

391

` .. versionadded:: 3.7

`

377

392

``

378

393

``

``

394

`+

.. data:: AF_PACKET

`

``

395

`+

PF_PACKET

`

``

396

`+

PACKET_*

`

``

397

+

``

398

`+

Many constants of these forms, documented in the Linux documentation, are

`

``

399

`+

also defined in the socket module.

`

``

400

+

``

401

`+

Availability: Linux >= 2.2.

`

``

402

+

``

403

+

379

404

`.. data:: AF_RDS

`

380

405

` PF_RDS

`

381

406

` SOL_RDS

`

`` @@ -469,12 +494,12 @@ The following functions all create :ref:socket objects <socket-objects>.

``

469

494

``

470

495

` Create a new socket using the given address family, socket type and protocol

`

471

496

`` number. The address family should be :const:AF_INET (the default),

``

472

``

`` -

:const:AF_INET6, :const:AF_UNIX, :const:AF_CAN or :const:AF_RDS. The

``

473

``

`` -

socket type should be :const:SOCK_STREAM (the default),

``

474

``


:const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other ``SOCK_``

475

``

`-

constants. The protocol number is usually zero and may be omitted or in the

`

476

``

`` -

case where the address family is :const:AF_CAN the protocol should be one

``

477

``

`` -

of :const:CAN_RAW, :const:CAN_BCM or :const:CAN_ISOTP

``

``

497

`` +

:const:AF_INET6, :const:AF_UNIX, :const:AF_CAN, :const:AF_PACKET,

``

``

498

`` +

or :const:AF_RDS. The socket type should be :const:SOCK_STREAM (the

``

``

499

`` +

default), :const:SOCK_DGRAM, :const:SOCK_RAW or perhaps one of the other

``

``

500


``SOCK_`` constants. The protocol number is usually zero and may be omitted

``

501

`` +

or in the case where the address family is :const:AF_CAN the protocol

``

``

502

`` +

should be one of :const:CAN_RAW, :const:CAN_BCM or :const:CAN_ISOTP.

``

478

503

``

479

504

` If fileno is specified, the values for family, type, and proto are

`

480

505

` auto-detected from the specified file descriptor. Auto-detection can be

`