ConOpSys V2970  P004.07
ANVILEX control operating system
Macros | 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>
Include dependency graph for inet_chksum.c:

Macros

#define LWIP_CHKSUM   lwip_standard_chksum
 
#define LWIP_CHKSUM_ALGORITHM   2
 

Functions

u16_t lwip_standard_chksum (const void *dataptr, int len)
 
static u16_t inet_cksum_pseudo_base (struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc)
 
u16_t ip_chksum_pseudo (struct pbuf *p, u8_t proto, u16_t proto_len, const ip_addr_t *src, const ip_addr_t *dest)
 
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)
 
u16_t ip_chksum_pseudo_partial (struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, const ip_addr_t *src, const ip_addr_t *dest)
 
u16_t inet_chksum (const void *dataptr, u16_t len)
 
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.

Macro Definition Documentation

◆ LWIP_CHKSUM

#define LWIP_CHKSUM   lwip_standard_chksum

◆ LWIP_CHKSUM_ALGORITHM

#define LWIP_CHKSUM_ALGORITHM   2

Function Documentation

◆ inet_chksum()

u16_t inet_chksum ( const void *  dataptr,
u16_t  len 
)

References pbuf::len, and LWIP_CHKSUM.

◆ 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
ppbuf chain over that the checksum should be calculated
Returns
checksum (as u16_t) to be saved directly in the protocol header

References FOLD_U32T, pbuf::len, LWIP_CHKSUM, pbuf::next, NULL, pbuf::payload, and SWAP_BYTES_IN_WORD.

◆ inet_cksum_pseudo_base()

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

References FOLD_U32T, INET_DEBUG, LWIP_CHKSUM, LWIP_DEBUGF, lwip_htons(), pbuf::next, NULL, SWAP_BYTES_IN_WORD, and X32_F.

Here is the call graph for this function:

◆ inet_cksum_pseudo_partial_base()

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

References FOLD_U32T, INET_DEBUG, LWIP_ASSERT, LWIP_CHKSUM, LWIP_DEBUGF, lwip_htons(), pbuf::next, NULL, SWAP_BYTES_IN_WORD, and X32_F.

Here is the call graph for this function:

◆ ip_chksum_pseudo()

u16_t ip_chksum_pseudo ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
const ip_addr_t src,
const ip_addr_t dest 
)

References ip_2_ip6, and IP_IS_V6.

◆ ip_chksum_pseudo_partial()

u16_t ip_chksum_pseudo_partial ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
u16_t  chksum_len,
const ip_addr_t src,
const ip_addr_t dest 
)

References ip_2_ip6, and IP_IS_V6.

◆ lwip_standard_chksum()

u16_t lwip_standard_chksum ( const void *  dataptr,
int  len 
)

References FOLD_U32T, and SWAP_BYTES_IN_WORD.