On 5/4/05, Vinay Reddy <vinayvinay@xxxxxxxxx> wrote: > On 5/4/05, Vinay Reddy <vinayvinay@xxxxxxxxx> wrote: > > On 5/4/05, rajat swarup <rajats@xxxxxxxxx> wrote: > > > Hi, > > > I am capturing packets in the Kernel using Netfilter hooks. So I get > > > access to the packets as sk_buff structs. > > > I want to access the IP data field. Could anyone please tell me what > > > is exactly wrong with this math: > > > > > > ptr = sb->data+sb->nh.iph->ihl*4 > > > > > > Andif I want to find the length of the IP data field (when I've just > > > captured packets thru the netfilter PRE_ROUTING hook ) what could be > > > the length of this? > > > For what fields should ntohs() be used to convert from NB to Host order? > > > Now does ptr point to IP data (i.e. just past the IP header)? > > use ptr = skb->nh.raw + (skb->nh.iph)->ipl; > sorry it should have been ihl instead of ipl. > > I have used it. It works. > > Thanks Vinay! Suppose, I need to get the IP data then shouldn't the actual thing be ptr = skb->nh.raw + skb->nh.iph->ihl*4 Isn't the IHL field in the size of 32-bit words? http://www.networksorcery.com/enp/protocol/ip.htm Thanks a lot! Rajat http://rajatswarup.blogspot.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/