[Click] SetIPChecksum standard element

Eddie Kohler ekohler at gmail.com
Tue Jan 17 11:17:46 EST 2012


Hi Ruetee,

Fair question. The SetIPChecksum element currently expects that its 
input packet has a network header annotation. You can set this with the 
MarkIPHeader element:

  ... -> MarkIPHeader(0) -> SetIPChecksum -> CheckIPHeader -> ...

Alternately you can update the code, since I changed SetIPChecksum to 
default to the first byte of the packet data for the network header.

Eddie


On 1/17/12 8:48 AM, Ruetee Chitpranee wrote:
> Hi,
>
> I have a doubt regarding SetIPChecksum standard element.
> I test it with *test.click* configuration file (put it before
> CheckIPHeader) and I got bad lengths error.
> Why it returns error since input packet has network header, good header
> length and good packet length?
>
> SetIPChecksum: bad lengths
>
>
>
> Packet *
>
> SetIPChecksum::simple_action(Packet *p_in)
>
> {
>
>      if (WritablePacket *p = p_in->uniqueify()) {
>
>           click_ip *ip;
>
>           unsigned plen, hlen;
>
>
>
>           if (!p->has_network_header())
>
>               goto bad;
>
>           plen = p->network_length();
>
>           if (plen<  sizeof(click_ip))
>
>               goto bad;
>
>           ip = p->ip_header();
>
>           hlen = ip->ip_hl<<  2;
>
>           if (hlen<  sizeof(click_ip) || hlen>  plen)
>
>               goto bad;
>
>
>
>           ip->ip_sum = 0;
>
>           ip->ip_sum = click_in_cksum((unsigned char *)ip, hlen);
>
>           return p;
>
>
>
>        bad:
>
>           click_chatter("SetIPChecksum: bad lengths");
>
>           p->kill();
>
>      }
>
>      return 0;
>
> }
>
> ref: test.click
>
> InfiniteSource(DATA \<00 00 c0 ae 67 ef  00 00 00 00 00 00  08 00
>
> 45 00 00 28  00 00 00 00  40 11 77 c3  01 00 00 01
>
> 02 00 00 02  13 69 13 69  00 14 d6 41  55 44 50 20
>
> 70 61 63 6b  65 74 21 0a>, LIMIT 5, STOP true)
>
>           ->  Strip(14)
>
>           //->  Align(4, 0)    // in case we're not on x86
>
>           ->  CheckIPHeader(BADSRC 18.26.4.255 2.255.255.255 1.255.255.255)
>
>            ->  Print(ok)
>
>           ->  Discard;
>


More information about the click mailing list