title: how to determine the starting byte of IP Header and TCP header in a raw packet
body: <p>I want to use libpcap to capture packets 
  but since the length of ethernet header or 802.11 header may vary
  and the length of IP header may also vary,
  how can I determine the starting byte(pointer) of the IP Header and TCP header
  besides, how to distinguish whether a packet is a pure IP packet, TCP packet or UDP packet?
  are there any APIs or ways to do this?
  thanks!</p>