Raw packets

Sep 19, 2003 6 Replies

Well next step in this project after I have got UDP alive is to receive and send raw packets too. My first impression was that this should be even simpler by just changing a couple of parameters in the socket but it just doesn't work. I have just taken my functional UDP code and modified a few lines. It executes with no errors until "sento" that always claims to have an invalid argument.



Am I missing something or are the raw packets not as simple as this in Linux? (In windows they are a pain and here I am using PWinCap)



Thanks,



Jens.


int sendRAW(void) { struct sockaddr_in si_other; int s, i, slen=sizeof(si_other); char buf[BUFLEN];



if ((s=socket(PF_PACKET, SOCK_DGRAM, htons((short)ETH_P_ALL)))==-1) diep("socket");



memset((char *) &si_other, sizeof(si_other), 0); si_other.sin_family = PF_PACKET;



for (i=0; i


Hi Jens,

you should open the socket with other arguments like here

ethInterface->devDescr = socket( PF_INET, SOCK_PACKET, htons( ETH_P_ALL ) ); ethInterface->sa.sa_family = AF_INET; strncpy( (char*) &ethInterface->sa.sa_data, "eth0", sizeof( ethInterface->sa.sa_data ) ); bind( ethInterface->devDescr, &ethInterface->sa, sizeof(ethInterface->sa) );

Bye,

Markus Pietrek (Remove _nospam from email address before replying)

Thanks,

But would this give me the real raw packets? As far as I can see, this gives me the IP header too?

Jens.

Hi Jens,

From my point of view a raw (ethernet) packet is a packet with all header information, untouched by the OS.

Bye,

Markus Pietrek (Remove _nospam from email address before replying)

To get raw ethernet packets, you have to put the ethernet controller into the promiscuous mode. I have no idea if current controllers still support the promiscuous mode.

Paul

Don't you need to bind to a local port first? Also this is UDP not raw ethernet.

and

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required