lwIP 2.1.1 Lightweight IP stack

Functions
inet_chksum.c File Reference
`#include "lwip/opt.h"`
`#include "lwip/inet_chksum.h"`
`#include "lwip/def.h"`
`#include "lwip/ip_addr.h"`
`#include <string.h>`

## Functions
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)
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)
u16_t | inet_chksum_pbuf (struct pbuf *p)

## Detailed Description

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.

## Function Documentation

## ◆ inet_chksum_pbuf()

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

## ◆ ip6_chksum_pseudo()

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

## ◆ ip6_chksum_pseudo_partial()

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