Rtos API example
lwip_inet_chksum.c File Reference
Incluse internet checksum functions. More...
Go to the source code of this file.
Functions | |
u16_t | lwip_standard_chksum (const void *dataptr, int len) |
lwip checksum | |
static u16_t | inet_cksum_pseudo_base (struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc) |
Parts of the pseudo checksum which are common to IPv4 and IPv6. | |
u16_t | ip6_chksum_pseudo (struct pbuf *p, u8_t proto, u16_t proto_len, const ip6_addr_t *src, const ip6_addr_t *dest) |
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. | |
static u16_t | inet_cksum_pseudo_partial_base (struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, u32_t acc) |
Parts of the pseudo checksum which are common to IPv4 and IPv6. | |
u16_t | ip6_chksum_pseudo_partial (struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest) |
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. | |
u16_t | inet_chksum_pbuf (struct pbuf *p) |
Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used). | |
u16_t | lwip_chksum_copy (void *dst, const void *src, u16_t len) |
Safe but slow: first call MEMCPY, then call LWIP_CHKSUM. |
Detailed Description
Incluse internet checksum functions.
These are some reference implementations of the checksum algorithm, with the aim of being simple, correct and fully portable. Checksumming is the first thing you would want to optimize for your platform. If you create your own version, link it in and in your cc.h put:
#define LWIP_CHKSUM your_checksum_routine
Or you can select from the implementations below by defining LWIP_CHKSUM_ALGORITHM to 1, 2 or 3.
Definition in file lwip_inet_chksum.c.
Function Documentation
u16_t inet_chksum_pbuf | ( | struct pbuf * | p ) |
Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).
- Parameters:
-
p pbuf chain over that the checksum should be calculated
- Returns:
- checksum (as u16_t) to be saved directly in the protocol header
Definition at line 568 of file lwip_inet_chksum.c.
static u16_t inet_cksum_pseudo_base | ( | struct pbuf * | p, |
u8_t | proto, | ||
u16_t | proto_len, | ||
u32_t | acc | ||
) | [static] |
Parts of the pseudo checksum which are common to IPv4 and IPv6.
Definition at line 260 of file lwip_inet_chksum.c.
static u16_t inet_cksum_pseudo_partial_base | ( | struct pbuf * | p, |
u8_t | proto, | ||
u16_t | proto_len, | ||
u16_t | chksum_len, | ||
u32_t | acc | ||
) | [static] |
Parts of the pseudo checksum which are common to IPv4 and IPv6.
Definition at line 399 of file lwip_inet_chksum.c.
u16_t ip6_chksum_pseudo | ( | struct pbuf * | p, |
u8_t | proto, | ||
u16_t | proto_len, | ||
const ip6_addr_t * | src, | ||
const ip6_addr_t * | dest | ||
) |
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain.
IPv6 addresses are expected to be in network byte order.
- Parameters:
-
p chain of pbufs over that a checksum should be calculated (ip data part) proto ipv6 protocol/next header (used for checksum of pseudo header) proto_len length of the ipv6 payload (used for checksum of pseudo header) src source ipv6 address (used for checksum of pseudo header) dest destination ipv6 address (used for checksum of pseudo header)
- Returns:
- checksum (as u16_t) to be saved directly in the protocol header
Definition at line 343 of file lwip_inet_chksum.c.
u16_t ip6_chksum_pseudo_partial | ( | struct pbuf * | p, |
u8_t | proto, | ||
u16_t | proto_len, | ||
u16_t | chksum_len, | ||
const ip6_addr_t * | src, | ||
const ip6_addr_t * | dest | ||
) |
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain.
IPv6 addresses are expected to be in network byte order. Will only compute for a portion of the payload.
- Parameters:
-
p chain of pbufs over that a checksum should be calculated (ip data part) proto ipv6 protocol/next header (used for checksum of pseudo header) proto_len length of the ipv6 payload (used for checksum of pseudo header) chksum_len number of payload bytes used to compute chksum src source ipv6 address (used for checksum of pseudo header) dest destination ipv6 address (used for checksum of pseudo header)
- Returns:
- checksum (as u16_t) to be saved directly in the protocol header
Definition at line 491 of file lwip_inet_chksum.c.
u16_t lwip_chksum_copy | ( | void * | dst, |
const void * | src, | ||
u16_t | len | ||
) |
Safe but slow: first call MEMCPY, then call LWIP_CHKSUM.
For architectures with big caches, data might still be in cache when generating the checksum after copying.
Definition at line 604 of file lwip_inet_chksum.c.
u16_t lwip_standard_chksum | ( | const void * | dataptr, |
int | len | ||
) |
lwip checksum
An optimized checksum routine.
- Parameters:
-
dataptr points to start of data to be summed at any boundary len length of data to be summed
- Returns:
- host order (!) lwip checksum (non-inverted Internet sum)
- Note:
- accumulator size limits summable length to 64k
- host endianess is irrelevant (p3 RFC1071)
Basically, it uses loop-unrolling on the checksum loop, treating the head and tail bytes specially, whereas the inner loop acts on 8 bytes at a time.
- start of buffer to be checksummed. May be an odd byte address. number of bytes in the buffer to be checksummed.
- Returns:
- host order (!) lwip checksum (non-inverted Internet sum)
Definition at line 80 of file lwip_inet_chksum.c.
Generated on Sun Jul 17 2022 08:25:34 by 1.7.2