Raw IP packets on Linux
Mike Ayers
mike.ayers at tumbleweed.com
Sun Aug 15 03:09:10 EDT 2004
Mike Ayers <mike.ayers <at> tumbleweed.com> writes:
> What am I getting wrong here? What address type does this socket expect?
After further review, I find that AF_PACKET wants addresses that contain the
interface and protocol number. You can also specify an ethernet address, but it
will be ignored (in fact, you can only specify a subset of ethernet addresses,
as the address argument is parsed as 's').
Quick summary: socket( AF_PACKET, SOCK_DGRAM ) is useless.
Workaround: use socket( AF_PACKET, SOCK_RAW ) and create your own ethernet
headers, which (provided you're using true ethernet, which most of us are), is
just the 6 byte ethernet destination address followed by the 6 byte ethernet
source address (.i.e your own), followed by 0x0800 (IP) in two bytes. Really
pretty simple if you're already using raw sockets, eh?
HTH,
/|/|ike
More information about the Python-list
mailing list