Salvadoravi
May 11th, 2008, 02:23 PM
Hi all,
I capture the incoming and outgoing packets.
char PacketData[4088] contain all the packet info (ethernet , ip etc..)
using ip.h , tcp.h & udp.h I assign the packet data into the struct defined in those headers.
Now I want to check the data type of the ethernet header (the first 14 bytes of my array) is IP (0x0800).
because I couldn't find the header for ethernet I am using the following code:
if (PacketData[sizeof(ether_header)-2]==8 &&
PacketData[sizeof(ether_header)-1]==0)
But I don't think it's the right way espeacially becuase I am worried about big and little endians.
Can someone please recommend me the right way to do it?
Many many thanks!!
I capture the incoming and outgoing packets.
char PacketData[4088] contain all the packet info (ethernet , ip etc..)
using ip.h , tcp.h & udp.h I assign the packet data into the struct defined in those headers.
Now I want to check the data type of the ethernet header (the first 14 bytes of my array) is IP (0x0800).
because I couldn't find the header for ethernet I am using the following code:
if (PacketData[sizeof(ether_header)-2]==8 &&
PacketData[sizeof(ether_header)-1]==0)
But I don't think it's the right way espeacially becuase I am worried about big and little endians.
Can someone please recommend me the right way to do it?
Many many thanks!!