]> git.proxmox.com Git - mirror_frr.git/blame - lib/checksum.h
lib: Adding GR capabilites encode and decode.
[mirror_frr.git] / lib / checksum.h
CommitLineData
17b48d7d
QY
1#include <stdint.h>
2#include <netinet/in.h>
3
5e244469
RW
4#ifdef __cplusplus
5extern "C" {
6#endif
7
17b48d7d
QY
8
9/* IPv4 pseudoheader */
10struct 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 */
19struct 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
27extern int in_cksum(void *data, int nbytes);
28extern int in_cksum_with_ph4(struct ipv4_ph *ph, void *data, int nbytes);
29extern int in_cksum_with_ph6(struct ipv6_ph *ph, void *data, int nbytes);
30
d8a4e42b 31#define FLETCHER_CHECKSUM_VALIDATE 0xffff
d7c0a89a
QY
32extern uint16_t fletcher_checksum(uint8_t *, const size_t len,
33 const uint16_t offset);
5e244469
RW
34
35#ifdef __cplusplus
36}
37#endif