]> git.proxmox.com Git - mirror_frr.git/blob - lib/checksum.h
lib: guard checksum.h against multiple inclusion
[mirror_frr.git] / lib / checksum.h
1 #ifndef _FRR_CHECKSUM_H
2 #define _FRR_CHECKSUM_H
3
4 #include <stdint.h>
5 #include <netinet/in.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11
12 /* IPv4 pseudoheader */
13 struct ipv4_ph {
14 struct in_addr src;
15 struct in_addr dst;
16 uint8_t rsvd;
17 uint8_t proto;
18 uint16_t len;
19 } __attribute__((packed));
20
21 /* IPv6 pseudoheader */
22 struct ipv6_ph {
23 struct in6_addr src;
24 struct in6_addr dst;
25 uint32_t ulpl;
26 uint8_t zero[3];
27 uint8_t next_hdr;
28 } __attribute__((packed));
29
30 extern int in_cksum(void *data, int nbytes);
31 extern int in_cksum_with_ph4(struct ipv4_ph *ph, void *data, int nbytes);
32 extern int in_cksum_with_ph6(struct ipv6_ph *ph, void *data, int nbytes);
33
34 #define FLETCHER_CHECKSUM_VALIDATE 0xffff
35 extern uint16_t fletcher_checksum(uint8_t *, const size_t len,
36 const uint16_t offset);
37
38 #ifdef __cplusplus
39 }
40 #endif
41
42 #endif /* _FRR_CHECKSUM_H */