Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * crc16.h - CRC-16 routine |
| 3 | * |
| 4 | * Implements the standard CRC-16: |
| 5 | * Width 16 |
| 6 | * Poly 0x8005 (x^16 + x^15 + x^2 + 1) |
| 7 | * Init 0 |
| 8 | * |
| 9 | * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com> |
| 10 | * |
| 11 | * This source code is licensed under the GNU General Public License, |
| 12 | * Version 2. See the file COPYING for more details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef __CRC16_H |
| 16 | #define __CRC16_H |
| 17 | |
| 18 | extern unsigned short const crc16_table[256]; |
| 19 | |
Jens Axboe | 25dfa84 | 2012-02-29 10:01:34 +0100 | [diff] [blame] | 20 | extern unsigned short fio_crc16(const void *buffer, unsigned int len); |
Jens Axboe | 969f7ed | 2007-07-27 09:07:17 +0200 | [diff] [blame] | 21 | |
| 22 | static inline unsigned short crc16_byte(unsigned short crc, |
| 23 | const unsigned char data) |
| 24 | { |
| 25 | return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; |
| 26 | } |
| 27 | |
| 28 | #endif /* __CRC16_H */ |