views:

40

answers:

1

I am trying to send out an ARP request with python, working with dpkt, and I found some sample code that uses:

socket.socket(socket.PF_PACKET, socket.SOCK_RAW)

I understand that you need to use raw sockets to send this, but it says that socket.PF_PACKET doesn't exist. And there is nothing in the python docs about it that I have seen. So, where would this person have gotten PF_PACKET from, what would it do, and how can I get it?

+1  A: 

Edited my reply:

PF_PACKET was introduced in Linux versions 2.0 and above. Python only wraps the socket interface of the operating system. AaronMcSmooth comment verifies that it is available on Linux. It is not available on mac though.

Also it looks like AF_PACKET may get preferred in 3.2

pyfunc
this isn't right. I have it on 2.6. But i'm on linux ;) At any rate, it does seem to be undocumented (in python) AFAIK.
aaronasterling
@AaronMcSmooth : I have edited my reply, I guess at the same time as your comment. You are right. Python only wraps the socket interface of the operating system and It is available only on Linux
pyfunc
Ah that makes sense. I'm on a mac, so thats why it's not there I guess.
The.Anti.9