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