This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: incomplete support for AF_PACKET in socketmodule.c
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, gustavo
Priority: normal Keywords: patch

Created on 2004-11-19 19:00 by gustavo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-af_packet.diff gustavo, 2004-11-19 19:00 patch, fix AF_PACKET address parsing
Messages (4)
msg47308 - (view) Author: Gustavo J. A. M. Carneiro (gustavo) * Date: 2004-11-19 19:00
A comment in the source documents the AF_PACKET address
format:
- an AF_PACKET socket address is a tuple containing a
string
  specifying the ethernet interface and an integer
specifying
  the Ethernet protocol number to be received. For example:
  ("eth0",0x1234).  Optional 3rd,4th,5th elements in
the tuple
  specify packet-type and ha-type/addr -- these are
ignored by
  networking code, but accepted since they are returned
by the
  getsockname() method.

The part that says "these are ignored by networking
code," is clearly innacurate when comparing with the
packet(7) man page:
    "(...)Packets sent  through a  SOCK_DGRAM  packet
socket get a suitable physical layer header based on
the information in the sockaddr_ll destination address
 before  they are queued.(...)"

Attached patch copies the passed in addr into the
sockaddr structure.  It is against Python 2.3.4.
msg47309 - (view) Author: Gustavo J. A. M. Carneiro (gustavo) * Date: 2004-11-19 19:19
Logged In: YES 
user_id=908

And just now I actually tested this patch.  It works!  While
before the ethernet frame was sent with broadcast
destination address, now it goes with a correct destination
address.  This should go into python 2.3.x as well.
msg47310 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-03-03 15:23
Logged In: YES 
user_id=1188172

From the patch:

+		addr->sll_halen = hatype;
+		addr->sll_halen = halen;

This doesn't seem to make sense, so the upper line can be
removed.

Also, you are mixing tabs and spaces. 
msg47311 - (view) Author: Gustavo J. A. M. Carneiro (gustavo) * Date: 2005-03-26 12:54
Logged In: YES 
user_id=908

Oh, I just noticed this patch (fixed) was committed to CVS
before 2.4/2.5 branching!
Thanks!
Guess this can be closed now...
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41198
2004-11-19 19:00:19gustavocreate