lkml.org 
[lkml]   [1996]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectPointers to both ip header & tcp header of skbuff ???

Hi, what's the best way to point to the start of the ip header of an
skbuff? And also the best way to point to the start of the tcp header of
an skbuff? Both must be available at the same time.
Let's just say initially, either skb->head or skb->data is
initially pointing to the the start of the ip header of the packet. And I
want to have a pointer to the start of the ip header, and also a pointer to
the start of the tcp header of the packet.

skb->h.th or skb->h.iph is not suitable here as I don't want a copy of
the ip or tcp headers only, I want to be able to modify certain fields of the
two headers also. Furthermore, skb->h is a union, implying that you can have
only one or the other, but I need both.

What do you think of the method below:
Let's say you have a struct sk_buff * skb;, and that skb->head (or
skb->data) is pointing to the start of the ip header. Then, to get the
pointers to the ip headers and the tcp headers, all you have to do is:

(struct iphdr *) myiphdr = (struct iphdr *) skb->head;
__u32 iphdrlen = GETVALUE(myiphdr->ihl);
(struct tcphdr *) mytcphdr = (struct tcphdr *) (skb->head + iphdrlen);

Thanks in advance.
Foo Chun Choong


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.043 / U:1.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site