Raw packets

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

Reply to
Jens Munk
Loading thread data ...

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)
Reply to
Markus Pietrek

Thanks,

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

Jens.

Reply to
Jens Munk

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)
Reply to
Markus Pietrek

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

Reply to
Paul Keinanen

Thanks,

Jens.

Reply to
Jens Munk

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

and

Reply to
FLY135

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.