DO NOT MERGE: Modify the pseudo-header checksum functions.
- Remove the initial checksum, which we don't use anywhere.
- Add the upper-layer protocol to the IPv6 function. Currently
this is always the same as the next header field in the IPv6
header, but technically it's the upper-layer header after all
the extension headers. This is required to support fragments.
Bug: 11542311
Change-Id: Ifa8af1bfda182711a0bba5c6452f44045fbd1a7f
diff --git a/dump.c b/dump.c
index 8567655..94e4796 100644
--- a/dump.c
+++ b/dump.c
@@ -147,14 +147,14 @@
/* print ipv4/udp header */
void dump_udp(const struct udphdr *udp, const struct iphdr *ip, const char *payload, size_t payload_size) {
uint32_t temp_checksum;
- temp_checksum = ipv4_pseudo_header_checksum(0, ip, sizeof(*udp) + payload_size);
+ temp_checksum = ipv4_pseudo_header_checksum(ip, sizeof(*udp) + payload_size);
dump_udp_generic(udp, temp_checksum, payload, payload_size);
}
/* print ipv6/udp header */
void dump_udp6(const struct udphdr *udp, const struct ip6_hdr *ip6, const char *payload, size_t payload_size) {
uint32_t temp_checksum;
- temp_checksum = ipv6_pseudo_header_checksum(0, ip6, sizeof(*udp) + payload_size);
+ temp_checksum = ipv6_pseudo_header_checksum(ip6, sizeof(*udp) + payload_size, IPPROTO_UDP);
dump_udp_generic(udp, temp_checksum, payload, payload_size);
}
@@ -203,7 +203,7 @@
void dump_tcp(const struct tcphdr *tcp, const struct iphdr *ip, const char *payload, size_t payload_size, const char *options, size_t options_size) {
uint32_t temp_checksum;
- temp_checksum = ipv4_pseudo_header_checksum(0, ip, sizeof(*tcp) + options_size + payload_size);
+ temp_checksum = ipv4_pseudo_header_checksum(ip, sizeof(*tcp) + options_size + payload_size);
dump_tcp_generic(tcp, options, options_size, temp_checksum, payload, payload_size);
}
@@ -211,7 +211,7 @@
void dump_tcp6(const struct tcphdr *tcp, const struct ip6_hdr *ip6, const char *payload, size_t payload_size, const char *options, size_t options_size) {
uint32_t temp_checksum;
- temp_checksum = ipv6_pseudo_header_checksum(0, ip6, sizeof(*tcp) + options_size + payload_size);
+ temp_checksum = ipv6_pseudo_header_checksum(ip6, sizeof(*tcp) + options_size + payload_size, IPPROTO_TCP);
dump_tcp_generic(tcp, options, options_size, temp_checksum, payload, payload_size);
}