[Click] Stupid question: Crafting packets with correct checksums...

Matthias Petschick razzle at razzle.de
Sun May 18 18:32:39 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

are you looking at your checksums on the receiving or on the sending side?
This may be caused by your OS skipping the checksum calculation and
leaving it to your network card (tcp checksum offloading), if it's the
latter. Afaik OSX does that, no idea if it can be disabled or not.

- - Matthias


Nicholas Weaver wrote:
| I'm doing a little hacking where I'm crafting raw TCP packets.
|
| Things seem to be going well looking at the data received on the other
| side looking at TCPdump, except I can't seem to generate proper TCP
| checksums, either with raw code or a pipeline of
|
| SetTCPChecksum->SetIPChecksum
|
| or with code in the file.  If it helps, this is on OS-X.  I feel like
| I'm doing something incredibly stupid here, and I'm just missing
| something obvious.
|
| Suggestions?
|
|
|
| I'm using the following code (taken from SetTCPChecksum and
| SetIPChecksum), where
| dst_iph and dst_tcph as appropriate are pointing into a buffer of
| bytes I'm using to construct the packet.
|
|
|      dst_iph->ip_len = htons(strlen(reply_string) + (dst_tcph->th_off
| << 2) +
|                              (dst_iph->ip_hl << 2));
|
|      unsigned plen, csum;
|
|      dst_tcph->th_sum = 0;
|
|      plen = ntohs(dst_iph->ip_len) - (dst_iph->ip_hl << 2);
|      csum = click_in_cksum((unsigned char *) tcph, plen);
|
|      dst_tcph->th_sum = click_in_cksum_pseudohdr(csum, dst_iph, plen);
|
|
|      dst_iph->ip_sum = 0;
|      dst_iph->ip_sum = click_in_cksum((unsigned char *)dst_iph,
|                                       dst_iph->ip_hl << 2);
|
|      WritablePacket * dst = Packet::make(data, ntohs(dst_iph->ip_len)
| + 14);
|      dst->set_ip_header(dst_iph, dst_iph->ip_hl << 2);
|
|      output(0).push(dst);
|
|
| _______________________________________________
| click mailing list
| click at amsterdam.lcs.mit.edu
| https://amsterdam.lcs.mit.edu/mailman/listinfo/click

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJIMK6HAAoJEM2TTDXVNjomf7gP/izs8yc8C+MRMrG8aB5MIes2
9RENlbO8ZbMt2YvbFNwG53YHCpWfTlfm+PLzihcKIvyM4F420SvqrNryNBr1+4fr
06sE3eSV7MCXKzaNAkLsNba8G3kBWT439RvUn9tMafrUlqpcMRnvo9nZlcAEgNHo
C2xtEqQV89I5uPvLaeGW4vdIN1SG/41uqnlDMqrLEsmcffmn28s9OgkdnJcBSJe1
94YB2EiYDjnnSUpYRmgigFZOqa9ys8L7fPhNtlnNIW+gPRGjkJVea7rxuZ2v9Ccl
19YdhD8EejYUtDL1LYmQMdFSo4UAqpkd+pXCAHNjbLJ27GNmBQSvRANpa0LFqW9R
HUtvRHtA6oakoVfnNWDpKLR4mrZRctLxaOw82G/qUkkP2hVjvMglDxMsRThOds31
1NLTOQ0bIddevfUi7xwjOVyjSQM4vcxAWqp0f4UVAWE1eEn6fxhKq6GbCUy6Qgta
VhE0VKh4B2mOffXeNQloGPMI/n17tHyiH/a7/z29CBmlOd++Y9QHDPj1pMJk0+Js
3N8ENqoBInjuKmjY8hcxE5uxKtDbNfpjkKRm2k85Mdp6T8s9jQjWDicTkhwnk7CD
C6OAPr/qmOFhYc9i+bYSgK1BiLXBmMszqOhe6DY3WtoxsaB2s1WmrC9uckgBcdeZ
yB1NxZ+1R0wrN+4C6MSG
=bbWN
-----END PGP SIGNATURE-----


More information about the click mailing list