views:

26

answers:

1

I'm awaiting the arrival of "Linux Network Programming" but in the meantime I thought I'd ask my brothers (and sisters) here for some info. If I have constructed a raw packet structure containing the ethernet header, ip header and tcp/udp/icmp header. What do I actually have to fill in when using the option IP_HDRINCL? At first I thought that I had to do everything but now I understand that the src and dest mac addresses of the ethernet header could be handled by the kernel. But what is required that I fill in and what values should the other fields have for the kernel to understand that it should fill those in?

Thanx in advance boys (and girls)!

A: 

You start with the IP header. But set all members of the IP and TCP/UDP frames correctly.

Your assumptions is correct. Don't include the Ethernet header when you send raw IP frames. Usually Ethernet is used as a low level communication, but there are others.

harper
I have build like a hirarchy (don't wanna use the word inheritance in C... hehe) where the lowest level packet is an ethernet packet. Then an IP packet contains the stuff of an ethernet packet plus the ip components and so on. So because of this I DO include the ethernet header myself. But I noticed that if I just filled in the src and dst ip and port I could set the src and dst mac to anything and the kernel would update the mac of the dst with the one used by my dst ip's mac address.
inquam
But you pass the pointer to the IP header to the send() function. If there are some other bytes (like the Ethernet header) before this address, it won't care.
harper
I use the write function to write my packet to the network. If I set the macaddresses in my ethheader it is reflected in my sent packet when I look at it with wireshark. This allows my to spoof my src mac address. The det macaddress if overwritten by the on retrivet by the kernel if I send tha packet as a TCP packet or similar though.
inquam