FreeBSD kernel IPv4 code
in_cksum.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mbuf.h>
#include <sys/systm.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <machine/in_cksum.h>
Include dependency graph for in_cksum.c:

Go to the source code of this file.

Data Structures

union  l_util
 
union  q_util
 
struct  cksum_skip_partial_args
 

Macros

#define ADDCARRY(x)   (x > 65535 ? x -= 65535 : x)
 
#define REDUCE32
 
#define REDUCE16
 

Functions

 __FBSDID ("$FreeBSD$")
 
static u_int64_t in_cksumdata (const void *buf, int len)
 
u_short in_addword (u_short a, u_short b)
 
u_short in_pseudo (u_int32_t a, u_int32_t b, u_int32_t c)
 
static int in_cksum_skip_partial (void *arg, void *data, u_int len)
 
u_short in_cksum_skip (struct mbuf *m, int len, int skip)
 
u_int in_cksum_hdr (const struct ip *ip)
 

Variables

static const u_int32_t in_masks []
 

Macro Definition Documentation

◆ ADDCARRY

#define ADDCARRY (   x)    (x > 65535 ? x -= 65535 : x)

Definition at line 66 of file in_cksum.c.

◆ REDUCE16

#define REDUCE16
Value:
{ \
q_util.q = sum; \
l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
sum = l_util.s[0] + l_util.s[1]; \
ADDCARRY(sum); \
}
u_int16_t s[2]
Definition: in_cksum.c:97
u_int16_t s[4]
Definition: in_cksum.c:101

Definition at line 72 of file in_cksum.c.

◆ REDUCE32

#define REDUCE32
Value:
{ \
q_util.q = sum; \
sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
}

Definition at line 67 of file in_cksum.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ in_addword()

u_short in_addword ( u_short  a,
u_short  b 
)

Definition at line 188 of file in_cksum.c.

References ADDCARRY.

Referenced by tcp_lro_rx_csum_data().

Here is the caller graph for this function:

◆ in_cksum_hdr()

u_int in_cksum_hdr ( const struct ip ip)

Definition at line 249 of file in_cksum.c.

References in_cksumdata(), and REDUCE16.

Referenced by ip_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_cksum_skip()

u_short in_cksum_skip ( struct mbuf *  m,
int  len,
int  skip 
)

Definition at line 228 of file in_cksum.c.

References cksum_skip_partial_args::clen, cksum_skip_partial_args::csum, in_cksum_skip_partial(), and REDUCE16.

Referenced by in_delayed_cksum(), and siftr_chkpkt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_cksum_skip_partial()

static int in_cksum_skip_partial ( void *  arg,
void *  data,
u_int  len 
)
static

Definition at line 214 of file in_cksum.c.

References cksum_skip_partial_args::clen, cksum_skip_partial_args::csum, and in_cksumdata().

Referenced by in_cksum_skip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_cksumdata()

static u_int64_t in_cksumdata ( const void *  buf,
int  len 
)
static

Definition at line 107 of file in_cksum.c.

References in_masks, and REDUCE32.

Referenced by in_cksum_hdr(), and in_cksum_skip_partial().

Here is the caller graph for this function:

◆ in_pseudo()

u_short in_pseudo ( u_int32_t  a,
u_int32_t  b,
u_int32_t  c 
)

Variable Documentation

◆ in_masks

const u_int32_t in_masks[]
static
Initial value:
= {
0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF,
0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00,
0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000,
0x00000000, 0xFF000000, 0xFF000000, 0xFF000000,
}

Definition at line 80 of file in_cksum.c.

Referenced by in_cksumdata().