X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/bfe85f7ca97259256e8089349e1a462b6c7dbd00..af0b220756571bc8faf57a0c7b7389dd86a60376:/src/crc16.c diff --git a/src/crc16.c b/src/crc16.c index 37fb4ca7..d3a232ba 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -2,8 +2,9 @@ /* * Copyright 2001-2010 Georges Menie (www.menie.org) - * Copyright 2010 Salvatore Sanfilippo (adapted to Redis coding style) + * Copyright 2010-2012 Salvatore Sanfilippo (adapted to Redis coding style) * All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * @@ -28,7 +29,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* CRC16 implementation acording to CCITT standards */ +/* CRC16 implementation acording to CCITT standards. + * + * Note by @antirez: this is actually the XMODEM CRC 16 algorithm, using the + * following parameters: + * + * Name : "XMODEM", also known as "ZMODEM", "CRC-16/ACORN" + * Width : 16 bit + * Poly : 1021 (That is actually x^16 + x^12 + x^5 + 1) + * Initialization : 0000 + * Reflect Input byte : False + * Reflect Output CRC : False + * Xor constant to output CRC : 0000 + * Output for "123456789" : 31C3 + */ static const uint16_t crc16tab[256]= { 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,