GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / rts / crc.h
blobdc3d18ddc2688342de1c8c09e5750fb2c29e2618
1 /*******************************************************************************
2 * $Id: crc.h 241182 2011-02-17 21:50:03Z $
3 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 * crc.h - a function to compute crc for iLine10 headers
17 ******************************************************************************/
19 #ifndef _RTS_CRC_H_
20 #define _RTS_CRC_H_ 1
22 #include "typedefs.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
29 #define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
30 #define CRC8_GOOD_VALUE 0x9f /* Good final CRC8 checksum value */
31 #define HCS_GOOD_VALUE 0x39 /* Good final header checksum value */
33 #define CRC16_INIT_VALUE 0xffff /* Initial CRC16 checksum value */
34 #define CRC16_GOOD_VALUE 0xf0b8 /* Good final CRC16 checksum value */
36 #define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
37 #define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
39 void hcs(uint8 *, uint);
40 uint8 crc8(uint8 *, uint, uint8);
41 uint16 crc16(uint8 *, uint, uint16);
42 uint32 crc32(uint8 *, uint, uint32);
44 /* macros for common usage */
46 #define APPEND_CRC8(pbytes, nbytes) \
47 do { \
48 uint8 tmp = crc8(pbytes, nbytes, CRC8_INIT_VALUE) ^ 0xff; \
49 (pbytes)[(nbytes)] = tmp; \
50 (nbytes) += 1; \
51 } while (0)
53 #define APPEND_CRC16(pbytes, nbytes) \
54 do { \
55 uint16 tmp = crc16(pbytes, nbytes, CRC16_INIT_VALUE) ^ 0xffff; \
56 (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
57 (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
58 (nbytes) += 2; \
59 } while (0)
61 #define APPEND_CRC32(pbytes, nbytes) \
62 do { \
63 uint32 tmp = crc32(pbytes, nbytes, CRC32_INIT_VALUE) ^ 0xffffffff; \
64 (pbytes)[(nbytes) + 0] = (tmp >> 0) & 0xff; \
65 (pbytes)[(nbytes) + 1] = (tmp >> 8) & 0xff; \
66 (pbytes)[(nbytes) + 2] = (tmp >> 16) & 0xff; \
67 (pbytes)[(nbytes) + 3] = (tmp >> 24) & 0xff; \
68 (nbytes) += 4; \
69 } while (0)
71 #ifdef __cplusplus
73 #endif
75 #endif /* _RTS_CRC_H_ */