]>
Commit | Line | Data |
---|---|---|
17b48d7d QY |
1 | #include <stdint.h> |
2 | #include <netinet/in.h> | |
3 | ||
5e244469 RW |
4 | #ifdef __cplusplus |
5 | extern "C" { | |
6 | #endif | |
7 | ||
17b48d7d QY |
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 | ||
d8a4e42b | 31 | #define FLETCHER_CHECKSUM_VALIDATE 0xffff |
d7c0a89a QY |
32 | extern uint16_t fletcher_checksum(uint8_t *, const size_t len, |
33 | const uint16_t offset); | |
5e244469 RW |
34 | |
35 | #ifdef __cplusplus | |
36 | } | |
37 | #endif |