summaryrefslogtreecommitdiffstats
path: root/translate.h
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-02-10 09:20:05 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-02-14 13:33:04 +0900
commit5a50c0283346a197cda7af19e68f611f14b8fe57 (patch)
tree1cccafeba5bbd41374daa0aed35379faa4c26a88 /translate.h
parenta33592bd08a20c6a521b8508975b7a74ecdf4f03 (diff)
downloadandroid_external_android-clat-5a50c0283346a197cda7af19e68f611f14b8fe57.tar.gz
android_external_android-clat-5a50c0283346a197cda7af19e68f611f14b8fe57.tar.bz2
android_external_android-clat-5a50c0283346a197cda7af19e68f611f14b8fe57.zip
Fix up checksums instead of recalculating them.
Currently the checksums of translated packets are calculated from scratch by checksumming the translated packet. This is slow and does not work in the case of fragments, because the whole packet is not available. Instead, calculate the checksum by adjusting the checksum of the original packet. Bug: 11542311 Bug: 12116252 Change-Id: I6b78a94ca5bd96b13ee2653b6200551193b3dcc1
Diffstat (limited to 'translate.h')
-rw-r--r--translate.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/translate.h b/translate.h
index 9f1ac15..cfb7bbb 100644
--- a/translate.h
+++ b/translate.h
@@ -61,12 +61,14 @@ int icmp6_to_icmp(clat_packet out, int pos, const struct icmp6_hdr *icmp6,
int generic_packet(clat_packet out, int pos, const char *payload, size_t len);
// Translate TCP and UDP packets.
-int tcp_packet(clat_packet out, int pos, const struct tcphdr *tcp, uint32_t checksum, size_t len);
-int udp_packet(clat_packet out, int pos, const struct udphdr *udp, uint32_t checksum, size_t len);
+int tcp_packet(clat_packet out, int pos, const struct tcphdr *tcp,
+ uint32_t old_sum, uint32_t new_sum, size_t len);
+int udp_packet(clat_packet out, int pos, const struct udphdr *udp,
+ uint32_t old_sum, uint32_t new_sum, size_t len);
int tcp_translate(clat_packet out, int pos, const struct tcphdr *tcp, size_t header_size,
- uint32_t checksum, const char *payload, size_t payload_size);
-int udp_translate(clat_packet out, int pos, const struct udphdr *udp, uint32_t checksum,
- const char *payload, size_t payload_size);
+ uint32_t old_sum, uint32_t new_sum, const char *payload, size_t payload_size);
+int udp_translate(clat_packet out, int pos, const struct udphdr *udp,
+ uint32_t old_sum, uint32_t new_sum, const char *payload, size_t payload_size);
#endif /* __TRANSLATE_H__ */