In the WinPcap v 3.1 beta 4 documentation, tutorial section
"Interpreting the packets" there is some code as an example. If you
look at that code, on line 203 he "retrieves the position of the udp
header". He uses the following line of code:
ip_len = (ih->ver_ihl & 0xf) * 4;
uh = (udp_header *) ((u_char*)ih + ip_len);
where the declarations have been made as follows (which u can also, of
course, see at the top of the code)
int ip_len
ip_header *ih;
udp_header *uh;
I don't understand how this line of code is giving him the location of
the udp header. In the first line where he says (ih->ver_ihl & 0xf) *
4, why is he first using that bit-wise and operator with the hex value
that follows? And why is he multiplying all of that by 4? If you
wanted to know the length of the IP header why wouldn't you just take
the 4-bit value that is passed in an IP header as the IP header length
field?
cheers,
Mario
==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/winpcap-users@winpcap.polito.it/
To unsubscribe use
mailto: [EMAIL PROTECTED]
==================================================================