[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to access packet header ?



>hi,
>
>when configuring a packet header, I found there are two approaches to access
>the packet header. For example, assuming p is the packet, to access the IP
>header of p, two approaches can be used :
>1)  hdr_ip *iph = (hdr_ip *) p->access(hdr_ip::offset_);
>2)  In initializing :
>         bind("off_ip_", &off_ip_);
>    Then use :
>         hdr_ip *iph = (hdr_ip *) p->access(off_ip_);
>
>What is the difference between these two approaches ? Which one is correct ?
>
>Thanks in advance for any answers.

They're equivalent, but choice (1) is faster because it doesn't
require the tcl bind initialization code.

   -John Heidemann