Microchip® Advanced Software Framework

inet_chksum.h File Reference
#include "lwip/opt.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"

Macros

#define FOLD_U32T(u)   (((u) >> 16) + ((u) & 0x0000ffffUL))
 Split an u32_t in two u16_ts and add them up. More...
 
#define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest)
 
#define ipX_chksum_pseudo_partial(isipv6, p, proto, proto_len, chksum_len, src, dest)
 
#define LWIP_CHKSUM_COPY_ALGORITHM   0
 
#define SWAP_BYTES_IN_WORD(w)   (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8)
 Swap the bytes in an u16_t: much like htons() for little-endian. More...
 

Functions

u16_t inet_chksum (void *dataptr, u16_t len)
 
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). More...
 
u16_t inet_chksum_pseudo (struct pbuf *p, u8_t proto, u16_t proto_len, ip_addr_t *src, ip_addr_t *dest)
 
u16_t inet_chksum_pseudo_partial (struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest)
 
u16_t ip6_chksum_pseudo (struct pbuf *p, u8_t proto, u16_t proto_len, ip6_addr_t *src, ip6_addr_t *dest)
 Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. More...
 
u16_t ip6_chksum_pseudo_partial (struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest)
 Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. More...
 

#define FOLD_U32T (   u)    (((u) >> 16) + ((u) & 0x0000ffffUL))
#define ipX_chksum_pseudo (   isipv6,
  p,
  proto,
  proto_len,
  src,
  dest 
)
Value:
((isipv6) ? \
ip6_chksum_pseudo(p, proto, proto_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\
inet_chksum_pseudo(p, proto, proto_len, ipX_2_ip(src), ipX_2_ip(dest)))
#define ipX_2_ip(ipaddr)
Definition: ip_addr.h:70
u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, ip6_addr_t *src, ip6_addr_t *dest)
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain.
Definition: inet_chksum.c:342
#define ipX_2_ip6(ip6addr)
Definition: ip_addr.h:69
u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, ip_addr_t *src, ip_addr_t *dest)
Definition: inet_chksum.c:311

Referenced by tcp_input(), tcp_keepalive(), tcp_output_segment(), tcp_rst_impl(), tcp_send_empty_ack(), tcp_zero_window_probe(), and udp_input().

#define ipX_chksum_pseudo_partial (   isipv6,
  p,
  proto,
  proto_len,
  chksum_len,
  src,
  dest 
)
Value:
((isipv6) ? \
ip6_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\
inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip(src), ipX_2_ip(dest)))
#define ipX_2_ip(ipaddr)
Definition: ip_addr.h:70
u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest)
Definition: inet_chksum.c:423
u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest)
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain.
Definition: inet_chksum.c:457
#define ipX_2_ip6(ip6addr)
Definition: ip_addr.h:69

Referenced by tcp_output_segment(), and udp_input().

#define LWIP_CHKSUM_COPY_ALGORITHM   0
#define SWAP_BYTES_IN_WORD (   w)    (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8)

u16_t inet_chksum ( void dataptr,
u16_t  len 
)
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.

Referenced by icmp_input().

u16_t inet_chksum_pseudo ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
ip_addr_t src,
ip_addr_t dest 
)
u16_t inet_chksum_pseudo_partial ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
u16_t  chksum_len,
ip_addr_t src,
ip_addr_t dest 
)
u16_t ip6_chksum_pseudo ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
ip6_addr_t src,
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
pchain of pbufs over that a checksum should be calculated (ip data part)
srcsource ipv6 address (used for checksum of pseudo header)
dstdestination ipv6 address (used for checksum of pseudo header)
protoipv6 protocol/next header (used for checksum of pseudo header)
proto_lenlength of the ipv6 payload (used for checksum of pseudo header)
Returns
checksum (as u16_t) to be saved directly in the protocol header

References FOLD_U32T, and inet_cksum_pseudo_base().

Referenced by icmp6_input(), icmp6_send_response(), mld6_send(), nd6_send_na(), nd6_send_ns(), nd6_send_rs(), and raw_sendto().

u16_t ip6_chksum_pseudo_partial ( struct pbuf p,
u8_t  proto,
u16_t  proto_len,
u16_t  chksum_len,
ip6_addr_t src,
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
pchain of pbufs over that a checksum should be calculated (ip data part)
srcsource ipv6 address (used for checksum of pseudo header)
dstdestination ipv6 address (used for checksum of pseudo header)
protoipv6 protocol/next header (used for checksum of pseudo header)
proto_lenlength of the ipv6 payload (used for checksum of pseudo header)
chksum_lennumber of payload bytes used to compute chksum
Returns
checksum (as u16_t) to be saved directly in the protocol header

References FOLD_U32T, and inet_cksum_pseudo_partial_base().