iPXE
Macros | Functions
crc32.c File Reference
#include <ipxe/crc32.h>

Go to the source code of this file.

Macros

#define CRCPOLY   0xedb88320
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
u32 crc32_le (u32 seed, const void *data, size_t len)
 Calculate 32-bit little-endian CRC checksum. More...
 

Macro Definition Documentation

◆ CRCPOLY

#define CRCPOLY   0xedb88320

Definition at line 26 of file crc32.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ crc32_le()

u32 crc32_le ( u32  seed,
const void *  data,
size_t  len 
)

Calculate 32-bit little-endian CRC checksum.

Parameters
seedInitial value
dataData to checksum
lenLength of data

Usually seed is initially zero or all one bits, depending on the protocol. To continue a CRC checksum over multiple calls, pass the return value from one call as the seed parameter to the next.

Definition at line 39 of file crc32.c.

40 {
41  u32 crc = seed;
42  const u8 *src = data;
43  u32 mult;
44  int i;
45 
46  while ( len-- ) {
47  crc ^= *src++;
48  for ( i = 0; i < 8; i++ ) {
49  mult = ( crc & 1 ) ? CRCPOLY : 0;
50  crc = ( crc >> 1 ) ^ mult;
51  }
52  }
53 
54  return crc;
55 }
static const void * src
Definition: string.h:47
#define CRCPOLY
Definition: crc32.c:26
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint32_t len
Length.
Definition: ena.h:14
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

References CRCPOLY, data, len, and src.

Referenced by efirng_get_noise(), fcoe_deliver(), fcoe_rx(), icmpcol(), ipv6col(), start_dhcpv6(), tkip_decrypt(), tkip_encrypt(), validator_start_download(), wep_decrypt(), and wep_encrypt().