/*
- * derived from crctester.c
+ * derived from crctester.c 2011 by Nils Faerber <nils.faerber@kernelconcepts.de>
* original header:
* ----------------------------------------------------------------------------
* CRC tester v1.3 written on 4th of February 2003 by Sven Reifegerste (zorc/reflex)
unsigned long crc = crcinit_direct;
- if (refin) crc = reflect(crc, order);
+ if (refin)
+ crc = reflect(crc, order);
+
+ if (!refin)
+ while (len--)
+ crc = (crc << 8) ^ crctab[ ((crc >> (order-8)) & 0xff) ^ *p++];
+ else
+ while (len--)
+ crc = (crc >> 8) ^ crctab[ (crc & 0xff) ^ *p++];
- if (!refin) while (len--) crc = (crc << 8) ^ crctab[ ((crc >> (order-8)) & 0xff) ^ *p++];
- else while (len--) crc = (crc >> 8) ^ crctab[ (crc & 0xff) ^ *p++];
+ if (refout^refin)
+ crc = reflect(crc, order);
- if (refout^refin) crc = reflect(crc, order);
crc^= crcxor;
crc&= crcmask;
static unsigned long crctable (unsigned char* p, unsigned long len)
{
- // normal lookup table algorithm with augmented zero bytes.
- // only usable with polynom orders of 8, 16, 24 or 32.
+ /* normal lookup table algorithm with augmented zero bytes. */
+ /* only usable with polynom orders of 8, 16, 24 or 32. */
unsigned long crc = crcinit_nondirect;
if (refout^refin)
crc = reflect(crc, order);
+
crc^= crcxor;
crc&= crcmask;
unsigned long crcbitbybit(unsigned char* p, unsigned long len) {
- // bit by bit algorithm with augmented zero bytes.
- // does not use lookup table, suited for polynom orders between 1...32.
+ /* bit by bit algorithm with augmented zero bytes. */
+ /* does not use lookup table, suited for polynom orders between 1...32. */
unsigned long i, j, c, bit;
unsigned long crc = crcinit_nondirect;
if (refout)
crc=reflect(crc, order);
+
crc ^= crcxor;
crc &= crcmask;
return(0);
}
#endif
+