there are multiple ip header structures. see /usr/include/netinet/ip.h for the details. 'struct ip' does not include any ip header options, so make sure that is what you want.
i don't know tcptrace, but in general, this is done through pointer math. for tcp/ip, the ip payload is the tcp header. so here some psuedo code:
struct tcphdr *tcpHdr;
struct ip *ipHdr;
ipHdr = /* some code that allocates memory & reads ip packet into it */
/* start of tcp header is the ip payload */
tcpHdr = (struct tcphdr)(ipHdr + sizeof( struct ip ));
|