2021-10-19 12:43:28 +02:00
|
|
|
/* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
* Copyright (c) 2021 Red Hat GmbH
|
|
|
|
* Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2022-03-26 00:05:31 +01:00
|
|
|
#ifndef CHECKSUM_H
|
|
|
|
#define CHECKSUM_H
|
|
|
|
|
2022-10-19 02:43:46 +02:00
|
|
|
struct udphdr;
|
2022-10-19 02:43:45 +02:00
|
|
|
struct icmphdr;
|
2022-10-19 02:43:44 +02:00
|
|
|
struct icmp6hdr;
|
|
|
|
|
2022-03-26 07:23:21 +01:00
|
|
|
uint32_t sum_16b(const void *buf, size_t len);
|
2021-09-14 19:02:36 +02:00
|
|
|
uint16_t csum_fold(uint32_t sum);
|
2022-03-26 07:23:21 +01:00
|
|
|
uint16_t csum_unaligned(const void *buf, size_t len, uint32_t init);
|
2022-10-19 02:43:48 +02:00
|
|
|
void csum_ip4_header(struct iphdr *ip4h);
|
2022-10-19 02:43:47 +02:00
|
|
|
void csum_udp4(struct udphdr *udp4hr, in_addr_t saddr, in_addr_t daddr,
|
|
|
|
const void *payload, size_t len);
|
2022-10-19 02:43:45 +02:00
|
|
|
void csum_icmp4(struct icmphdr *ih, const void *payload, size_t len);
|
2022-10-19 02:43:46 +02:00
|
|
|
void csum_udp6(struct udphdr *udp6hr,
|
|
|
|
const struct in6_addr *saddr, const struct in6_addr *daddr,
|
|
|
|
const void *payload, size_t len);
|
2022-10-19 02:43:44 +02:00
|
|
|
void csum_icmp6(struct icmp6hdr *icmp6hr,
|
|
|
|
const struct in6_addr *saddr, const struct in6_addr *daddr,
|
|
|
|
const void *payload, size_t len);
|
2021-09-14 19:02:36 +02:00
|
|
|
uint16_t csum(const void *buf, size_t len, uint32_t init);
|
2022-03-26 00:05:31 +01:00
|
|
|
|
|
|
|
#endif /* CHECKSUM_H */
|