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