how to extract payload from struct ip *pip
I am writing a module for tcptrace. In that module I need to process payload. TCPTRACE _read function passes
struct ip *pip /* the packet */ as an argument. how I can extract payload by using struct ip pointer. |
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 )); |
All times are GMT -5. The time now is 02:58 AM. |