66 #define P_32 (0xEDB88320L) 67 #define P_CCITT (0x1021) 68 #define P_DNP (0xA6BC) 69 #define P_KERMIT (0x8408) 70 #define P_SICK (0x8005) 103 static unsigned long crc_tab32[256];
123 static void init_crc32_tab(
void );
143 unsigned short tmp, short_c;
145 short_c = 0x00ff & (
unsigned short) c;
149 tmp = (crc >> 8) ^ short_c;
171 unsigned short short_c, short_p;
173 short_c = 0x00ff & (
unsigned short) c;
174 short_p = (
unsigned short)(( 0x00ff & (
unsigned short) prev_byte ) << 8);
176 if ( crc & 0x8000 ) crc = (
unsigned short)(( crc << 1 ) ^
P_SICK);
177 else crc = (
unsigned short)(crc << 1);
180 crc ^= ( short_c | short_p );
200 unsigned short tmp, short_c;
202 short_c = 0x00ff & (
unsigned short) c;
209 crc = (crc >> 8) ^
crc_tab16[ (
unsigned int)(tmp & 0xff) ];
229 unsigned short tmp, short_c;
231 short_c = 0x00ff & (
unsigned short) c;
256 unsigned short tmp, short_c;
258 short_c = 0x00ff & (
unsigned short) c;
283 unsigned long update_crc_32(
unsigned long crc,
char c ) {
285 unsigned long tmp, long_c;
287 long_c = 0x000000ffL & (
unsigned long) c;
289 if ( ! crc_tab32_init ) init_crc32_tab();
292 crc = (crc >> 8) ^ crc_tab32[ tmp & 0xff ];
313 unsigned short crc, c;
315 for (i=0; i<256; i++) {
318 c = (
unsigned short) i;
320 for (j=0; j<8; j++) {
322 if ( (crc ^ c) & 0x0001 ) crc = ( crc >> 1 ) ^
P_16;
349 unsigned short crc, c;
351 for (i=0; i<256; i++) {
354 c = (
unsigned short) i;
356 for (j=0; j<8; j++) {
358 if ( (crc ^ c) & 0x0001 ) crc = ( crc >> 1 ) ^
P_KERMIT;
385 unsigned short crc, c;
387 for (i=0; i<256; i++) {
390 c = (
unsigned short) i;
392 for (j=0; j<8; j++) {
394 if ( (crc ^ c) & 0x0001 ) crc = ( crc >> 1 ) ^
P_DNP;
420 static void init_crc32_tab(
void ) {
425 for (i=0; i<256; i++) {
427 crc = (
unsigned long) i;
429 for (j=0; j<8; j++) {
431 if ( crc & 0x00000001L ) crc = ( crc >> 1 ) ^
P_32;
457 unsigned short crc, c;
459 for (i=0; i<256; i++) {
462 c = (
unsigned short)(((
unsigned short) i) << 8);
464 for (j=0; j<8; j++) {
466 if ( (crc ^ c) & 0x8000 ) crc = (
unsigned short)(( crc << 1 ) ^
P_CCITT);
467 else crc = (
unsigned short)(crc << 1);
469 c = (
unsigned short)(c << 1);
static unsigned short crc_tab16[256]
unsigned short update_crc_dnp(unsigned short crc, char c)
static int crc_tab16_init
unsigned short update_crc_sick(unsigned short crc, char c, char prev_byte)
static unsigned short crc_tabkermit[256]
unsigned short update_crc_16(unsigned short crc, char c)
static int crc_tabdnp_init
static unsigned short crc_tabccitt[256]
static void init_crc16_tab(void)
static void init_crckermit_tab(void)
static int crc_tabccitt_init
static unsigned short crc_tabdnp[256]
unsigned short update_crc_ccitt(unsigned short crc, char c)
static void init_crcdnp_tab(void)
static int crc_tabkermit_init
unsigned short update_crc_kermit(unsigned short crc, char c)
static void init_crcccitt_tab(void)