Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

crc.c File Reference


Detailed Description

CRC computations.

Author:
Raphael Manfredi
Date:
2003

#include "common.h"
#include "crc.h"
#include "override.h"

Defines

#define POLYNOMIAL   0x04c11db7L
 The generator polynomial used for this version of the package is X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 as specified in the Autodin/Ethernet/ADCCP protocol standards.


Functions

 RCSID ("$Id:crc.c, v 1.8 2005/09/10 10:10:36 daichik Exp $")
void crc32_gen_crc_table (void)
 Generates a 256-word table containing all CRC remainders for every possible 8-bit byte.

guint32 crc32_update_crc (guint32 crc_accum, gconstpointer data, size_t len)
 Update the CRC-32 on the data block one byte at a time.

void crc_init (void)
 Initialize the CRC computations.


Variables

guint32 crc_table [256]


Define Documentation

#define POLYNOMIAL   0x04c11db7L
 

The generator polynomial used for this version of the package is X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 as specified in the Autodin/Ethernet/ADCCP protocol standards.

Other degree 32 polynomials may be substituted by re-defining the symbol POLYNOMIAL below. Lower degree polynomials must first be multiplied by an appropriate power of x. The representation used is that the coefficient of x^0 is stored in the LSB of the 32-bit word and the coefficient of x^31 is stored in the most significant bit. The CRC is to be appended to the data most significant byte first. For those protocols in which bytes are transmitted MSB first and in the same order as they are encountered in the block this convention results in the CRC remainder being transmitted with the coefficient of x^31 first and with that of x^0 last (just as would be done by a hardware shift register mechanization).

The table lookup technique was adapted from the algorithm described by Avram Perez, Byte-wise CRC Calculations, IEEE Micro 3, 40 (1983).


Function Documentation

void crc32_gen_crc_table void   )  [static]
 

Generates a 256-word table containing all CRC remainders for every possible 8-bit byte.

guint32 crc32_update_crc guint32  crc_accum,
gconstpointer  data,
size_t  len
 

Update the CRC-32 on the data block one byte at a time.

Parameters:
crc_accum The CRC accumulator, must be initialized to zero.
data The input data for CRC-32 calculation.
len no brief description.

void crc_init void   ) 
 

Initialize the CRC computations.

RCSID "$Id:crc.  c,
v 1.8 2005/09/10 10:10:36 daichik Exp $" 
 


Variable Documentation

guint32 crc_table[256] [static]
 


Generated on Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6