From 67ab6171729cfcf7867cbb92a2099d88d86f6e6b Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 19 Oct 2022 11:43:45 +1100 Subject: Add csum_icmp4() helper for calculating ICMP checksums Although tap_ip_send() is currently the only place calculating ICMP checksums, create a helper function for symmetry with ICMPv6. For future flexibility it allows the ICMPv6 header and payload to be in separate buffers. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- checksum.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'checksum.h') diff --git a/checksum.h b/checksum.h index d7daabf..bf0620f 100644 --- a/checksum.h +++ b/checksum.h @@ -6,11 +6,13 @@ #ifndef CHECKSUM_H #define CHECKSUM_H +struct icmphdr; struct icmp6hdr; uint32_t sum_16b(const void *buf, size_t len); uint16_t csum_fold(uint32_t sum); uint16_t csum_unaligned(const void *buf, size_t len, uint32_t init); +void csum_icmp4(struct icmphdr *ih, const void *payload, size_t len); void csum_icmp6(struct icmp6hdr *icmp6hr, const struct in6_addr *saddr, const struct in6_addr *daddr, const void *payload, size_t len); -- cgit v1.2.3