[Click] [click]SetIPChecksum

Beyers Cronje bcronje at gmail.com
Fri Aug 8 18:47:44 EDT 2008


Hi Pradeep,

p->ip_header() returns a pointer to the ip header of a packet, which is
stored in the ip header annotation of Packet. The ip header annotation is
set by elements such as MarkIPHeader and CheckIPHeader.

Packet::make() does not set this annotatio by itself, so you either have to
set it yourself by calling 'packet->set_ip_header(iph, iph->ip_hl << 2)' or
let a downstream element such as MarkIPHeader set it for you.

Beyers

On Fri, Aug 8, 2008 at 11:05 PM, Pradeep Pradeep <pradeep_addada at yahoo.co.in
> wrote:

> Hello,
>
>   In the code for the element SetIPChecksum element  there is part which
> tests if a packet is IP packet or not.
>
> It uses
> ---------------------
> ip=p->ip_header();
> if(!ip)
>
>   When can a situation arise which satisfies   !ip?
> -------------------------
>
>  I am genarating  packets which have the following format
> {IP Header}
>  {QoS Data}
> {UDP Header}
>
>
> The code I used is
> _______________________________
>
> void push(Packet* p)
> {
>
>
> WritablePacket *packet = Packet::make(0, 0, data_len+header_room, 0);
>
>   if (packet == 0) {
>       click_chatter( "cannot make packet!");
>       packet = NULL;
>       return;
>     }
>
>     // fill IP header
>
>    click_ip *iph = (click_ip*) packet->data();
>     memcpy(iph, p->ip_header(), sizeof(click_ip));
>     iph->ip_tos |= 0x0c;  // 12 for QoS
>     iph->ip_tos |= 0x01;  // Set ECN capability
>
>     // fill QoS fields
>     QoSSignalFormat* format =
>       (QoSSignalFormat*)(packet->data()+sizeof(click_ip));
>
>
>     // fill UDP header
>     click_udp *udph =
>       (click_udp*)(packet->data()+sizeof(click_ip)+sizeof(struct
> QoSSignalFormat));
>     memcpy(udph, p->udp_header(), sizeof(click_udp));
>
>        p->kill(); // destroy data packet
>     output(0).push((Packet *)packet);
>   }
>   _______________________________
>
> As you can see I am making some changes to IP header. So I want to recompue
> the checksum by passing the packets through SetIPChecksum element. When I
> forward the these packets SetIPChecksum (which is slightly modified that it
> detects the condtion !ip ) the packets are being struck at this !ip
> condtion. Please help me with this.
>
> Regards,
> Pradeep.
>
>
>
>
>      Unlimited freedom, unlimited storage. Get it now, on
> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list