iPXE
Functions
crc32.h File Reference
#include <stdint.h>

Go to the source code of this file.

Functions

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

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

References CRCPOLY, data, and src.

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

{
        u32 crc = seed;
        const u8 *src = data;
        u32 mult;
        int i;

        while ( len-- ) {
                crc ^= *src++;
                for ( i = 0; i < 8; i++ ) {
                        mult = ( crc & 1 ) ? CRCPOLY : 0;
                        crc = ( crc >> 1 ) ^ mult;
                }
        }

        return crc;
}