aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-30 13:46:42 +0000
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-30 13:46:42 +0000
commited574dde2dceea0ea2e33f4c0105d37aad437c24 (patch)
tree4b1f8343011ca58ba5cd44782166f029cc7e3a8b /wsutil
parentb094cd58543b26be83409f6cc558cf24eaed4f83 (diff)
Move all crc routines to libwsutil.
This way we can use the crc routines in wiretap. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38800 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/CMakeLists.txt7
-rw-r--r--wsutil/Makefile.common14
-rw-r--r--wsutil/crc10.c97
-rw-r--r--wsutil/crc10.h27
-rw-r--r--wsutil/crc16-plain.c105
-rw-r--r--wsutil/crc16-plain.h87
-rw-r--r--wsutil/crc16.c254
-rw-r--r--wsutil/crc16.h126
-rw-r--r--wsutil/crc32.c275
-rw-r--r--wsutil/crc32.h116
-rw-r--r--wsutil/crc6.c53
-rw-r--r--wsutil/crc6.h26
-rw-r--r--wsutil/crc8.c89
-rw-r--r--wsutil/crc8.h44
-rw-r--r--wsutil/crcdrm.c50
-rw-r--r--wsutil/crcdrm.h32
-rw-r--r--wsutil/libwsutil.def32
17 files changed, 1434 insertions, 0 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 25eabb1d64..9501920acb 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -35,6 +35,13 @@ set(WSUTIL_FILES
# @INET_PTON_LO@ # inet_pton.c
# @STRNCASECMP_LO@ # strncasecmp.c
# @STRPTIME_LO@ # strptime.c
+ crc10.c
+ crc16.c
+ crc16-plain.c
+ crc32.c
+ crc6.c
+ crc8.c
+ crcdrm.c
mpeg-audio.c
privileges.c
str_util.c
diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common
index cbe90655ac..9f50c297bf 100644
--- a/wsutil/Makefile.common
+++ b/wsutil/Makefile.common
@@ -29,6 +29,13 @@
# generated from YACC or Lex files (as Automake doesn't want them in
# _SOURCES variables).
LIBWSUTIL_SRC = \
+ crc10.c \
+ crc16.c \
+ crc16-plain.c \
+ crc32.c \
+ crc6.c \
+ crc8.c \
+ crcdrm.c \
mpeg-audio.c \
privileges.c \
str_util.c \
@@ -36,6 +43,13 @@ LIBWSUTIL_SRC = \
# Header files that are not generated from other files
LIBWSUTIL_INCLUDES = \
+ crc6.h \
+ crc8.h \
+ crc10.h \
+ crc16.h \
+ crc16-plain.h \
+ crc32.h \
+ crcdrm.h \
mpeg-audio.h \
privileges.h \
str_util.h \
diff --git a/wsutil/crc10.c b/wsutil/crc10.c
new file mode 100644
index 0000000000..77d5068624
--- /dev/null
+++ b/wsutil/crc10.c
@@ -0,0 +1,97 @@
+/*
+ * crc10.c
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+
+#include "crc10.h"
+
+/*
+ * Charles Michael Heard's CRC-10 code, from
+ *
+ * http://cell-relay.indiana.edu/cell-relay/publications/software/CRC/crc10.html
+ *
+ * with the CRC table initialized with values computed by
+ * his "gen_byte_crc10_table()" routine, rather than by calling that
+ * routine at run time, and with various data type cleanups.
+ */
+static const guint16 byte_crc10_table[256] = {
+ 0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
+ 0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
+ 0x0031, 0x0202, 0x0264, 0x0057, 0x02a8, 0x009b, 0x00fd, 0x02ce,
+ 0x0330, 0x0103, 0x0165, 0x0356, 0x01a9, 0x039a, 0x03fc, 0x01cf,
+ 0x0062, 0x0251, 0x0237, 0x0004, 0x02fb, 0x00c8, 0x00ae, 0x029d,
+ 0x0363, 0x0150, 0x0136, 0x0305, 0x01fa, 0x03c9, 0x03af, 0x019c,
+ 0x0053, 0x0260, 0x0206, 0x0035, 0x02ca, 0x00f9, 0x009f, 0x02ac,
+ 0x0352, 0x0161, 0x0107, 0x0334, 0x01cb, 0x03f8, 0x039e, 0x01ad,
+ 0x00c4, 0x02f7, 0x0291, 0x00a2, 0x025d, 0x006e, 0x0008, 0x023b,
+ 0x03c5, 0x01f6, 0x0190, 0x03a3, 0x015c, 0x036f, 0x0309, 0x013a,
+ 0x00f5, 0x02c6, 0x02a0, 0x0093, 0x026c, 0x005f, 0x0039, 0x020a,
+ 0x03f4, 0x01c7, 0x01a1, 0x0392, 0x016d, 0x035e, 0x0338, 0x010b,
+ 0x00a6, 0x0295, 0x02f3, 0x00c0, 0x023f, 0x000c, 0x006a, 0x0259,
+ 0x03a7, 0x0194, 0x01f2, 0x03c1, 0x013e, 0x030d, 0x036b, 0x0158,
+ 0x0097, 0x02a4, 0x02c2, 0x00f1, 0x020e, 0x003d, 0x005b, 0x0268,
+ 0x0396, 0x01a5, 0x01c3, 0x03f0, 0x010f, 0x033c, 0x035a, 0x0169,
+ 0x0188, 0x03bb, 0x03dd, 0x01ee, 0x0311, 0x0122, 0x0144, 0x0377,
+ 0x0289, 0x00ba, 0x00dc, 0x02ef, 0x0010, 0x0223, 0x0245, 0x0076,
+ 0x01b9, 0x038a, 0x03ec, 0x01df, 0x0320, 0x0113, 0x0175, 0x0346,
+ 0x02b8, 0x008b, 0x00ed, 0x02de, 0x0021, 0x0212, 0x0274, 0x0047,
+ 0x01ea, 0x03d9, 0x03bf, 0x018c, 0x0373, 0x0140, 0x0126, 0x0315,
+ 0x02eb, 0x00d8, 0x00be, 0x028d, 0x0072, 0x0241, 0x0227, 0x0014,
+ 0x01db, 0x03e8, 0x038e, 0x01bd, 0x0342, 0x0171, 0x0117, 0x0324,
+ 0x02da, 0x00e9, 0x008f, 0x02bc, 0x0043, 0x0270, 0x0216, 0x0025,
+ 0x014c, 0x037f, 0x0319, 0x012a, 0x03d5, 0x01e6, 0x0180, 0x03b3,
+ 0x024d, 0x007e, 0x0018, 0x022b, 0x00d4, 0x02e7, 0x0281, 0x00b2,
+ 0x017d, 0x034e, 0x0328, 0x011b, 0x03e4, 0x01d7, 0x01b1, 0x0382,
+ 0x027c, 0x004f, 0x0029, 0x021a, 0x00e5, 0x02d6, 0x02b0, 0x0083,
+ 0x012e, 0x031d, 0x037b, 0x0148, 0x03b7, 0x0184, 0x01e2, 0x03d1,
+ 0x022f, 0x001c, 0x007a, 0x0249, 0x00b6, 0x0285, 0x02e3, 0x00d0,
+ 0x011f, 0x032c, 0x034a, 0x0179, 0x0386, 0x01b5, 0x01d3, 0x03e0,
+ 0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1
+};
+
+/* update the data block's CRC-10 remainder one byte at a time */
+guint16 update_crc10_by_bytes(guint16 crc10, const guint8 *data_blk_ptr,
+ int data_blk_size)
+{
+ register int i;
+ guint16 crc10_accum = 0;
+
+ for (i = 0; i < data_blk_size; i++) {
+ crc10_accum = ((crc10_accum << 8) & 0x3ff)
+ ^ byte_crc10_table[( crc10_accum >> 2) & 0xff]
+ ^ *data_blk_ptr++;
+ }
+ crc10_accum = ((crc10_accum << 8) & 0x3ff)
+ ^ byte_crc10_table[( crc10_accum >> 2) & 0xff]
+ ^ (crc10>>2);
+ crc10_accum = ((crc10_accum << 8) & 0x3ff)
+ ^ byte_crc10_table[( crc10_accum >> 2) & 0xff]
+ ^ ((crc10<<6) & 0xFF);
+
+ return crc10_accum;
+}
+
diff --git a/wsutil/crc10.h b/wsutil/crc10.h
new file mode 100644
index 0000000000..a0b5a0fa09
--- /dev/null
+++ b/wsutil/crc10.h
@@ -0,0 +1,27 @@
+/*
+ * crc10.h
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* update the data block's CRC-10 remainder one byte at a time */
+extern guint16 update_crc10_by_bytes(guint16 crc10, const guint8 *data_blk_ptr, int data_blk_size);
diff --git a/wsutil/crc16-plain.c b/wsutil/crc16-plain.c
new file mode 100644
index 0000000000..13e31a74a4
--- /dev/null
+++ b/wsutil/crc16-plain.c
@@ -0,0 +1,105 @@
+/**
+ * \file crc16-plain.c
+ * Functions and types for CRC checks.
+ *
+ * Generated on Wed Mar 18 14:12:09 2009,
+ * by pycrc v0.7, http://www.tty1.net/pycrc/
+ * using the configuration:
+ * Width = 16
+ * Poly = 0x8005
+ * XorIn = 0x0000
+ * ReflectIn = True
+ * XorOut = 0x0000
+ * ReflectOut = True
+ * Algorithm = table-driven
+ * Direct = True
+ *
+ * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
+ * appears not to have it; we're using GLib types, instead.
+ *****************************************************************************/
+#include "glib.h"
+#include "crc16-plain.h"
+#include <stdlib.h>
+
+/**
+ * Static table used for the table_driven implementation.
+ *****************************************************************************/
+static const crc16_plain_t crc_table[256] = {
+ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
+ 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
+ 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
+ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
+ 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
+ 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
+ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
+ 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
+ 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
+ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
+ 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
+ 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
+ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
+ 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
+ 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
+ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
+ 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
+ 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
+ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
+ 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
+ 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
+ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
+ 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
+ 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
+ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
+ 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
+ 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
+ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
+ 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
+ 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
+ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
+ 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
+};
+
+/**
+ * Reflect all bits of a \a data word of \a data_len bytes.
+ *
+ * \param data The data word to be reflected.
+ * \param data_len The width of \a data expressed in number of bits.
+ * \return The reflected data.
+ *****************************************************************************/
+long crc16_plain_reflect(long data, size_t data_len)
+{
+ unsigned int i;
+ long ret;
+
+ ret = data & 0x01;
+ for (i = 1; i < data_len; i++)
+ {
+ data >>= 1;
+ ret = (ret << 1) | (data & 0x01);
+ }
+ return ret;
+}
+
+
+/**
+ * Update the crc value with new data.
+ *
+ * \param crc The current crc value.
+ * \param data Pointer to a buffer of \a data_len bytes.
+ * \param data_len Number of bytes in the \a data buffer.
+ * \return The updated crc value.
+ *****************************************************************************/
+crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len)
+{
+ unsigned int tbl_idx;
+
+ while (data_len--) {
+ tbl_idx = (crc ^ *data) & 0xff;
+ crc = (crc_table[tbl_idx] ^ (crc >> 8)) & 0xffff;
+
+ data++;
+ }
+ return crc & 0xffff;
+}
+
+
diff --git a/wsutil/crc16-plain.h b/wsutil/crc16-plain.h
new file mode 100644
index 0000000000..f6593562af
--- /dev/null
+++ b/wsutil/crc16-plain.h
@@ -0,0 +1,87 @@
+/**
+ * \file crc16-plain.h
+ * Functions and types for CRC checks.
+ *
+ * Generated on Wed Mar 18 14:12:15 2009,
+ * by pycrc v0.7, http://www.tty1.net/pycrc/
+ * using the configuration:
+ * Width = 16
+ * Poly = 0x8005
+ * XorIn = 0x0000
+ * ReflectIn = True
+ * XorOut = 0x0000
+ * ReflectOut = True
+ * Algorithm = table-driven
+ * Direct = True
+ *
+ * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
+ * appears not to have it; we're using GLib types, instead.
+ *****************************************************************************/
+#ifndef __CRC____PLAIN_H__
+#define __CRC____PLAIN_H__
+
+#include "glib.h"
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The definition of the used algorithm.
+ *****************************************************************************/
+#define CRC_ALGO_TABLE_DRIVEN 1
+
+/**
+ * The type of the CRC values.
+ *
+ * This type must be big enough to contain at least 16 bits.
+ *****************************************************************************/
+typedef guint16 crc16_plain_t;
+
+/**
+ * Reflect all bits of a \a data word of \a data_len bytes.
+ *
+ * \param data The data word to be reflected.
+ * \param data_len The width of \a data expressed in number of bits.
+ * \return The reflected data.
+ *****************************************************************************/
+long crc16_plain_reflect(long data, size_t data_len);
+
+/**
+ * Calculate the initial crc value.
+ *
+ * \return The initial crc value.
+ *****************************************************************************/
+static inline crc16_plain_t crc16_plain_init(void)
+{
+ return 0x0000;
+}
+
+/**
+ * Update the crc value with new data.
+ *
+ * \param crc The current crc value.
+ * \param data Pointer to a buffer of \a data_len bytes.
+ * \param data_len Number of bytes in the \a data buffer.
+ * \return The updated crc value.
+ *****************************************************************************/
+crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len);
+
+/**
+ * Calculate the final crc value.
+ *
+ * \param crc The current crc value.
+ * \return The final crc value.
+ *****************************************************************************/
+static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc)
+{
+ return crc ^ 0x0000;
+}
+
+
+#ifdef __cplusplus
+} /* closing brace for extern "C" */
+#endif
+
+#endif /* __CRC____PLAIN_H__ */
diff --git a/wsutil/crc16.c b/wsutil/crc16.c
new file mode 100644
index 0000000000..fe18fead58
--- /dev/null
+++ b/wsutil/crc16.c
@@ -0,0 +1,254 @@
+/* crc16.c
+ * CRC-16 routine
+ *
+ * 2004 Richard van der Hoff <richardv@mxtelecom.com>
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@xxxxxxxxxxxx>
+ * Copyright 1998 Gerald Combs
+ *
+ * Copied from README.developer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * References:
+ * "A Painless Guide to CRC Error Detection Algorithms", Ross Williams
+ * http://www.repairfaq.org/filipg/LINK/F_crc_v3.html
+ *
+ * ITU-T Recommendation V.42 (2002), "Error-Correcting Procedures for
+ * DCEs using asynchronous-to-synchronous conversion", Para. 8.1.1.6.1
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/tvbuff.h>
+#include <wsutil/crc16.h>
+#include <wsutil/crc16-plain.h>
+
+
+/*****************************************************************/
+
+/*
+ * Table for the CCITT/ITU/CRC-16 16-bit CRC
+ *
+ * Polynomial is
+ *
+ * x^16 + x^12 + x^5 + 1
+ */
+
+/* */
+/* CRC LOOKUP TABLE */
+/* ================ */
+/* The following CRC lookup table was generated automagically */
+/* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+/* Program V1.0 using the following model parameters: */
+/* */
+/* Width : 2 bytes. */
+/* Poly : 0x1021 */
+/* Reverse : TRUE. */
+/* */
+/* For more information on the Rocksoft^tm Model CRC Algorithm, */
+/* see the document titled "A Painless Guide to CRC Error */
+/* Detection Algorithms" by Ross Williams. See */
+/* */
+/* http://www.ross.net/crc/crcpaper.html */
+/* */
+/* which links to a text version and an HTML-but-not-all-on-one- */
+/* page version, or various HTML-all-on-one-page versions such */
+/* as the one at */
+/* */
+/* http://www.geocities.com/SiliconValley/Pines/8659/crc.htm */
+/* */
+/* (search for the title to find others). */
+/* */
+/*****************************************************************/
+
+static const guint crc16_ccitt_table_reverse[256] =
+{
+ 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
+ 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
+ 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
+ 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
+ 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
+ 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
+ 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
+ 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
+ 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
+ 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
+ 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
+ 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
+ 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
+ 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
+ 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
+ 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
+ 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
+ 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
+ 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
+ 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
+ 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
+ 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
+ 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
+ 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
+ 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
+ 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
+ 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
+ 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
+ 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
+ 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
+ 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
+ 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
+};
+
+/* Same as above, only without reverse (Reverse=FALSE) */
+static const guint crc16_ccitt_table[256] =
+{
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
+ 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
+ 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
+ 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
+ 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
+ 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
+ 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
+ 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
+ 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
+ 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
+ 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
+ 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
+ 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
+ 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
+ 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
+ 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
+ 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
+ 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
+ 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
+ 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
+ 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
+ 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
+ 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
+};
+
+static const guint16 crc16_ccitt_start = 0xFFFF;
+static const guint16 crc16_ccitt_xorout = 0xFFFF;
+
+/* two types of crcs are possible: unreflected (bits shift left) and
+ * reflected (bits shift right).
+ */
+static guint16 crc16_unreflected(const guint8 *buf, guint len,
+ guint16 crc_in, const guint table[])
+{
+ /* we use guints, rather than guint16s, as they are likely to be
+ faster. We just ignore the top 16 bits and let them do what they want.
+ */
+ guint crc16 = (guint)crc_in;;
+
+ while( len-- != 0 )
+ crc16 = table[((crc16 >> 8) ^ *buf++) & 0xff] ^ (crc16 << 8);
+
+ return (guint16)crc16;
+}
+
+static guint16 crc16_reflected(const guint8 *buf, guint len,
+ guint16 crc_in, const guint table[])
+{
+ /* we use guints, rather than guint16s, as they are likely to be
+ faster. We just ignore the top 16 bits and let them do what they want.
+ XXX - does any time saved not zero-extending guint16's to 32 bits
+ into a register outweigh any increased cache footprint from the
+ larger CRC table? */
+ guint crc16 = (guint)crc_in;
+
+ while( len-- != 0 )
+ crc16 = table[(crc16 ^ *buf++) & 0xff] ^ (crc16 >> 8);
+
+ return (guint16)crc16;
+}
+
+guint16 crc16_ccitt(const guint8 *buf, guint len)
+{
+ return crc16_reflected(buf,len,crc16_ccitt_start,crc16_ccitt_table_reverse)
+ ^ crc16_ccitt_xorout;
+}
+
+guint16 crc16_x25_ccitt(const guint8 *buf, guint len)
+{
+ return crc16_unreflected(buf,len,crc16_ccitt_start,crc16_ccitt_table);
+}
+
+guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed)
+{
+ return crc16_reflected(buf,len,seed,crc16_ccitt_table_reverse)
+ ^ crc16_ccitt_xorout;
+}
+
+guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len)
+{
+ const guint8* buf = tvb_get_ptr(tvb, 0, len);
+
+ return crc16_ccitt(buf, len);
+}
+
+guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len)
+{
+ const guint8* buf = tvb_get_ptr(tvb, 0, len);
+
+ return crc16_x25_ccitt(buf, len);
+}
+
+guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len)
+{
+ const guint8* buf = tvb_get_ptr(tvb, offset, len);
+
+ return crc16_ccitt(buf, len);
+}
+
+guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed)
+{
+ const guint8* buf = tvb_get_ptr(tvb, 0, len);
+
+ return crc16_ccitt_seed(buf, len, seed);
+}
+
+guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed)
+{
+ const guint8* buf = tvb_get_ptr(tvb, offset, len);
+
+ return crc16_ccitt_seed(buf, len, seed);
+}
+
+guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len)
+{
+ guint16 crc = crc16_plain_init();
+
+ const guint8* buf = tvb_get_ptr(tvb, offset, len);
+
+ crc = crc16_plain_update(crc, buf, len);
+
+ return crc16_plain_finalize(crc);
+}
+
diff --git a/wsutil/crc16.h b/wsutil/crc16.h
new file mode 100644
index 0000000000..0fb0548dc4
--- /dev/null
+++ b/wsutil/crc16.h
@@ -0,0 +1,126 @@
+/* crc16.h
+ * Declaration of CRC-16 routines and table
+ *
+ * 2004 Richard van der Hoff <richardv@mxtelecom.com>
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@xxxxxxxxxxxx>
+ * Copyright 1998 Gerald Combs
+ *
+ * Copied from README.developer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __CRC16_H_
+#define __CRC16_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Calculate the CCITT/ITU/CRC-16 16-bit CRC
+
+ (parameters for this CRC are:
+ Polynomial: x^16 + x^12 + x^5 + 1 (0x1021);
+ Start value 0xFFFF;
+ XOR result with 0xFFFF;
+ First bit is LSB)
+*/
+
+/** Compute CRC16 CCITT checksum of a buffer of data.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 CCITT checksum. */
+extern guint16 crc16_ccitt(const guint8 *buf, guint len);
+
+/** Compute CRC16 X.25 CCITT checksum of a buffer of data.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 X.25 CCITT checksum. */
+extern guint16 crc16_x25_ccitt(const guint8 *buf, guint len);
+
+/** Compute CRC16 CCITT checksum of a buffer of data. If computing the
+ * checksum over multiple buffers and you want to feed the partial CRC16
+ * back in, remember to take the 1's complement of the partial CRC16 first.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC16 CCITT checksum (using the given seed). */
+extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
+
+/** Compute CRC16 CCITT checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 CCITT checksum. */
+extern guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
+
+/** Compute CRC16 X.25 CCITT checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 X.25 CCITT checksum. */
+extern guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len);
+
+/** Compute CRC16 CCITT checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param offset The offset into the tv buffer.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 CCITT checksum. */
+extern guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
+
+/** Compute CRC16 CCITT checksum of a tv buffer. If computing the
+ * checksum over multiple tv buffers and you want to feed the partial CRC16
+ * back in, remember to take the 1's complement of the partial CRC16 first.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC16 CCITT checksum (using the given seed). */
+extern guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
+
+/** Compute CRC16 CCITT checksum of a tv buffer. If computing the
+ * checksum over multiple tv buffers and you want to feed the partial CRC16
+ * back in, remember to take the 1's complement of the partial CRC16 first.
+ @param tvb The tv buffer containing the data.
+ @param offset The offset into the tv buffer.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC16 CCITT checksum (using the given seed). */
+extern guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
+ guint len, guint16 seed);
+
+/** Compute the "plain" CRC16 checksum of a tv buffer using the following
+ * parameters:
+ * Width = 16
+ * Poly = 0x8005
+ * XorIn = 0x0000
+ * ReflectIn = True
+ * XorOut = 0x0000
+ * ReflectOut = True
+ * Algorithm = table-driven
+ * Direct = True
+ @param tvb The tv buffer containing the data.
+ @param offset The offset into the tv buffer.
+ @param len The number of bytes to include in the computation.
+ @return The CRC16 checksum. */
+extern guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* crc16.h */
diff --git a/wsutil/crc32.c b/wsutil/crc32.c
new file mode 100644
index 0000000000..82de71481a
--- /dev/null
+++ b/wsutil/crc32.c
@@ -0,0 +1,275 @@
+/* crc32.c
+ * CRC-32 routine
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * Copied from README.developer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Credits:
+ *
+ * Table from Solomon Peachy
+ * Routine from Chris Waters
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/tvbuff.h>
+#include <wsutil/crc32.h>
+
+/*****************************************************************/
+/* */
+/* CRC32C LOOKUP TABLE */
+/* +++================ */
+/* The following CRC lookup table was generated automagically */
+/* by the Rocksoft^tm Model CRC Algorithm Table Generation */
+/* Program V1.0 using the following model parameters: */
+/* */
+/* Width : 4 bytes. */
+/* Poly : 0x1EDC6F41L */
+/* Reverse : TRUE. */
+/* */
+/* For more information on the Rocksoft^tm Model CRC Algorithm, */
+/* see the document titled "A Painless Guide to CRC Error */
+/* Detection Algorithms" by Ross Williams */
+/* (ross@guest.adelaide.edu.au.). This document is likely to be */
+/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
+/* */
+/*****************************************************************/
+const guint32 crc32c_table[256] = {
+ 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL,
+ 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0x8AD958CFL, 0x78B2DBCCL,
+ 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L,
+ 0x5E133C24L, 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL,
+ 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, 0x9A879FA0L,
+ 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, 0x5D1D08BFL, 0xAF768BBCL,
+ 0xBC267848L, 0x4E4DFB4BL, 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L,
+ 0x33ED7D2AL, 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L,
+ 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, 0x6DFE410EL,
+ 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, 0x30E349B1L, 0xC288CAB2L,
+ 0xD1D83946L, 0x23B3BA45L, 0xF779DEAEL, 0x05125DADL, 0x1642AE59L,
+ 0xE4292D5AL, 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL,
+ 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, 0x417B1DBCL,
+ 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, 0x86E18AA3L, 0x748A09A0L,
+ 0x67DAFA54L, 0x95B17957L, 0xCBA24573L, 0x39C9C670L, 0x2A993584L,
+ 0xD8F2B687L, 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L,
+ 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, 0x96BF4DCCL,
+ 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, 0xDBFC821CL, 0x2997011FL,
+ 0x3AC7F2EBL, 0xC8AC71E8L, 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L,
+ 0x0F36E6F7L, 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L,
+ 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, 0xEB1FCBADL,
+ 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, 0x2C855CB2L, 0xDEEEDFB1L,
+ 0xCDBE2C45L, 0x3FD5AF46L, 0x7198540DL, 0x83F3D70EL, 0x90A324FAL,
+ 0x62C8A7F9L, 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L,
+ 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, 0x3CDB9BDDL,
+ 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, 0x82F63B78L, 0x709DB87BL,
+ 0x63CD4B8FL, 0x91A6C88CL, 0x456CAC67L, 0xB7072F64L, 0xA457DC90L,
+ 0x563C5F93L, 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L,
+ 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, 0x92A8FC17L,
+ 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, 0x55326B08L, 0xA759E80BL,
+ 0xB4091BFFL, 0x466298FCL, 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL,
+ 0x0B21572CL, 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L,
+ 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, 0x65D122B9L,
+ 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, 0x2892ED69L, 0xDAF96E6AL,
+ 0xC9A99D9EL, 0x3BC21E9DL, 0xEF087A76L, 0x1D63F975L, 0x0E330A81L,
+ 0xFC588982L, 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL,
+ 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, 0x38CC2A06L,
+ 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, 0xFF56BD19L, 0x0D3D3E1AL,
+ 0x1E6DCDEEL, 0xEC064EEDL, 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L,
+ 0xD0DDD530L, 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL,
+ 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, 0x8ECEE914L,
+ 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, 0xD3D3E1ABL, 0x21B862A8L,
+ 0x32E8915CL, 0xC083125FL, 0x144976B4L, 0xE622F5B7L, 0xF5720643L,
+ 0x07198540L, 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L,
+ 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, 0xE330A81AL,
+ 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, 0x24AA3F05L, 0xD6C1BC06L,
+ 0xC5914FF2L, 0x37FACCF1L, 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L,
+ 0x7AB90321L, 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL,
+ 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, 0x34F4F86AL,
+ 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, 0x79B737BAL, 0x8BDCB4B9L,
+ 0x988C474DL, 0x6AE7C44EL, 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L,
+ 0xAD7D5351L };
+
+/*
+ * Table for the AUTODIN/HDLC/802.x CRC.
+ *
+ * Polynomial is
+ *
+ * x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^8 + x^7 +
+ * x^5 + x^4 + x^2 + x + 1
+ */
+const guint32 crc32_ccitt_table[256] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
+ 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
+ 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
+ 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
+ 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
+ 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
+ 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
+ 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
+ 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
+ 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
+ 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
+ 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
+ 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
+ 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
+ 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
+ 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
+ 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
+ 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
+ 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
+ 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
+ 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
+ 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
+ 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
+ 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
+ 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
+ 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
+ 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
+ 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
+ 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
+ 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
+ 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
+ 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
+ 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
+ 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
+ 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
+ 0x2d02ef8d
+};
+
+#define CRC32_CCITT_SEED 0xFFFFFFFF
+
+guint32
+crc32c_calculate(const void *buf, int len, guint32 crc)
+{
+ const guint8 *p = (const guint8 *)buf;
+ crc = CRC32C_SWAP(crc);
+ while (len-- > 0) {
+ CRC32C(crc, *p++);
+ }
+ return CRC32C_SWAP(crc);
+}
+
+guint32
+crc32_ccitt(const guint8 *buf, guint len)
+{
+ return (crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED));
+}
+
+guint32
+crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed)
+{
+ guint i;
+ guint32 crc32 = seed;
+
+ for (i = 0; i < len; i++)
+ crc32 = crc32_ccitt_table[(crc32 ^ buf[i]) & 0xff] ^ (crc32 >> 8);
+
+ return ( ~crc32 );
+}
+
+guint32
+crc32_ccitt_tvb(tvbuff_t *tvb, guint len)
+{
+ const guint8* buf;
+
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, 0, len);
+
+ return ( crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED) );
+}
+
+guint32
+crc32_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len)
+{
+ const guint8* buf;
+
+ tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, offset, len);
+
+ return ( crc32_ccitt(buf, len) );
+}
+
+guint32
+crc32_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint32 seed)
+{
+ const guint8* buf;
+
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, 0, len);
+
+ return ( crc32_ccitt_seed(buf, len, seed) );
+}
+
+guint32
+crc32_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len,
+ guint32 seed)
+{
+ const guint8* buf;
+
+ tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, offset, len);
+
+ return ( crc32_ccitt_seed(buf, len, seed) );
+}
+
+/*
+ * IEEE 802.x version (Ethernet and 802.11, at least) - byte-swap
+ * the result of "crc32()".
+ *
+ * XXX - does this mean we should fetch the Ethernet and 802.11
+ * FCS with "tvb_get_letohl()" rather than "tvb_get_ntohl()",
+ * or is fetching it big-endian and byte-swapping the CRC done
+ * to cope with 802.x sending stuff out in reverse bit order?
+ */
+guint32
+crc32_802_tvb(tvbuff_t *tvb, guint len)
+{
+ guint32 c_crc;
+
+ c_crc = crc32_ccitt_tvb(tvb, len);
+
+ /* Byte reverse. */
+ c_crc = ((unsigned char)(c_crc>>0)<<24) |
+ ((unsigned char)(c_crc>>8)<<16) |
+ ((unsigned char)(c_crc>>16)<<8) |
+ ((unsigned char)(c_crc>>24)<<0);
+
+ return ( c_crc );
+}
diff --git a/wsutil/crc32.h b/wsutil/crc32.h
new file mode 100644
index 0000000000..7bc63bdde4
--- /dev/null
+++ b/wsutil/crc32.h
@@ -0,0 +1,116 @@
+/* crc32.h
+ * Declaration of CRC-32 routine and table
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * Copied from README.developer
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __CRC32_H_
+#define __CRC32_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define CRC32C_PRELOAD 0xffffffff
+
+/*
+ * Byte swap fix contributed by Dave Wysochanski <davidw@netapp.com>.
+ */
+#define CRC32C_SWAP(crc32c_value) \
+ (((crc32c_value & 0xff000000) >> 24) | \
+ ((crc32c_value & 0x00ff0000) >> 8) | \
+ ((crc32c_value & 0x0000ff00) << 8) | \
+ ((crc32c_value & 0x000000ff) << 24))
+
+#define CRC32C(c,d) (c=(c>>8)^crc32c_table[(c^(d))&0xFF])
+
+extern const guint32 crc32c_table[256];
+
+/** Compute CRC32C checksum of a buffer of data.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @param crc The preload value for the CRC32C computation.
+ @return The CRC32C checksum. */
+extern guint32 crc32c_calculate(const void *buf, int len, guint32 crc);
+
+extern const guint32 crc32_ccitt_table[256];
+
+/** Compute CRC32 CCITT checksum of a buffer of data.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC32 CCITT checksum. */
+extern guint32 crc32_ccitt(const guint8 *buf, guint len);
+
+/** Compute CRC32 CCITT checksum of a buffer of data. If computing the
+ * checksum over multiple buffers and you want to feed the partial CRC32
+ * back in, remember to take the 1's complement of the partial CRC32 first.
+ @param buf The buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC32 CCITT checksum (using the given seed). */
+extern guint32 crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed);
+
+/** Compute CRC32 CCITT checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The CRC32 CCITT checksum. */
+extern guint32 crc32_ccitt_tvb(tvbuff_t *tvb, guint len);
+
+/** Compute CRC32 CCITT checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param offset The offset into the tv buffer.
+ @param len The number of bytes to include in the computation.
+ @return The CRC32 CCITT checksum. */
+extern guint32 crc32_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
+
+/** Compute CRC32 CCITT checksum of a tv buffer. If computing the
+ * checksum over multiple tv buffers and you want to feed the partial CRC32
+ * back in, remember to take the 1's complement of the partial CRC32 first.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC32 CCITT checksum (using the given seed). */
+extern guint32 crc32_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint32 seed);
+
+/** Compute CRC32 CCITT checksum of a tv buffer. If computing the
+ * checksum over multiple tv buffers and you want to feed the partial CRC32
+ * back in, remember to take the 1's complement of the partial CRC32 first.
+ @param tvb The tv buffer containing the data.
+ @param offset The offset into the tv buffer.
+ @param len The number of bytes to include in the computation.
+ @param seed The seed to use.
+ @return The CRC32 CCITT checksum (using the given seed). */
+extern guint32 crc32_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
+ guint len, guint32 seed);
+
+/** Compute IEEE 802.x CRC32 checksum of a tv buffer.
+ @param tvb The tv buffer containing the data.
+ @param len The number of bytes to include in the computation.
+ @return The IEEE 802.x CRC32 checksum. */
+extern guint32 crc32_802_tvb(tvbuff_t *tvb, guint len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* crc32.h */
diff --git a/wsutil/crc6.c b/wsutil/crc6.c
new file mode 100644
index 0000000000..333a1a51cd
--- /dev/null
+++ b/wsutil/crc6.c
@@ -0,0 +1,53 @@
+/*
+ * crc6.c
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include "crc6.h"
+
+
+guint16 update_crc6_by_bytes(guint16 crc6, guint8 byte1, guint8 byte2) {
+ int bit;
+ guint32 remainder = ( byte1<<8 | byte2 ) << 6;
+ guint32 polynomial = 0x6F << 15;
+
+ for (bit = 15;
+ bit >= 0;
+ --bit)
+ {
+ if (remainder & (0x40 << bit))
+ {
+ remainder ^= polynomial;
+ }
+ polynomial >>= 1;
+ }
+
+ return (guint16)(remainder ^ crc6);
+}
+
+
diff --git a/wsutil/crc6.h b/wsutil/crc6.h
new file mode 100644
index 0000000000..c8abfb4ad4
--- /dev/null
+++ b/wsutil/crc6.h
@@ -0,0 +1,26 @@
+/*
+ * crc6.h
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+extern guint16 update_crc6_by_bytes(guint16 crc6, guint8 byte1, guint8 byte2);
+
diff --git a/wsutil/crc8.c b/wsutil/crc8.c
new file mode 100644
index 0000000000..92045420f2
--- /dev/null
+++ b/wsutil/crc8.c
@@ -0,0 +1,89 @@
+/* crc8.c
+ *
+ * Checks the checksum (FCS) of the 3G TS 27.010 Multiplexing protocol.
+ * The algorithm to check the FCS is described in "3G TS 27.010 V2.0.0 (1999-06)"
+ * See: www.3gpp.org/ftp/tsg_t/TSG_T/TSGT_04/docs/PDFs/TP-99119.pdf
+ * or: http://www.3gpp.org/ftp/Specs/html-info/27010.htm
+ *
+ * Polynom: (x^8 + x^2 + x^1 + 1)
+ *
+ * 2011 Hans-Christoph Schemmel <hans-christoph.schemmel[AT]cinterion.com>
+ *
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+*/
+
+#ifdef HAVE_CONFIG_H
+ # include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/tvbuff.h>
+#include <wsutil/crc8.h>
+
+/**
+ * Reversed CRC table
+ *****************************************************************************/
+static guint8 crctable[256] = { /*reversed, 8-bit, poly=0x07*/
+0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B,
+0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67,
+0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43,
+0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51, 0x2A, 0xBB, 0xC9, 0x58, 0x2D, 0xBC, 0xCE, 0x5F,
+0x70, 0xE1, 0x93, 0x02, 0x77, 0xE6, 0x94, 0x05, 0x7E, 0xEF, 0x9D, 0x0C, 0x79, 0xE8, 0x9A, 0x0B,
+0x6C, 0xFD, 0x8F, 0x1E, 0x6B, 0xFA, 0x88, 0x19, 0x62, 0xF3, 0x81, 0x10, 0x65, 0xF4, 0x86, 0x17,
+0x48, 0xD9, 0xAB, 0x3A, 0x4F, 0xDE, 0xAC, 0x3D, 0x46, 0xD7, 0xA5, 0x34, 0x41, 0xD0, 0xA2, 0x33,
+0x54, 0xC5, 0xB7, 0x26, 0x53, 0xC2, 0xB0, 0x21, 0x5A, 0xCB, 0xB9, 0x28, 0x5D, 0xCC, 0xBE, 0x2F,
+0xE0, 0x71, 0x03, 0x92, 0xE7, 0x76, 0x04, 0x95, 0xEE, 0x7F, 0x0D, 0x9C, 0xE9, 0x78, 0x0A, 0x9B,
+0xFC, 0x6D, 0x1F, 0x8E, 0xFB, 0x6A, 0x18, 0x89, 0xF2, 0x63, 0x11, 0x80, 0xF5, 0x64, 0x16, 0x87,
+0xD8, 0x49, 0x3B, 0xAA, 0xDF, 0x4E, 0x3C, 0xAD, 0xD6, 0x47, 0x35, 0xA4, 0xD1, 0x40, 0x32, 0xA3,
+0xC4, 0x55, 0x27, 0xB6, 0xC3, 0x52, 0x20, 0xB1, 0xCA, 0x5B, 0x29, 0xB8, 0xCD, 0x5C, 0x2E, 0xBF,
+0x90, 0x01, 0x73, 0xE2, 0x97, 0x06, 0x74, 0xE5, 0x9E, 0x0F, 0x7D, 0xEC, 0x99, 0x08, 0x7A, 0xEB,
+0x8C, 0x1D, 0x6F, 0xFE, 0x8B, 0x1A, 0x68, 0xF9, 0x82, 0x13, 0x61, 0xF0, 0x85, 0x14, 0x66, 0xF7,
+0xA8, 0x39, 0x4B, 0xDA, 0xAF, 0x3E, 0x4C, 0xDD, 0xA6, 0x37, 0x45, 0xD4, 0xA1, 0x30, 0x42, 0xD3,
+0xB4, 0x25, 0x57, 0xC6, 0xB3, 0x22, 0x50, 0xC1, 0xBA, 0x2B, 0x59, 0xC8, 0xBD, 0x2C, 0x5E, 0xCF
+};
+
+
+gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs){
+ /*Init*/
+ guint8 FCS=0xFF;
+ guint8 tmp = 0;
+ /*len is the number of bytes in the message, p points to message*/
+ while (len--) {
+ tmp = FCS^tvb_get_guint8(p,offset);
+ offset++;
+ FCS=crctable[tmp];
+ }
+ /*Ones complement*/
+ FCS=crctable[FCS^received_fcs];
+ /*0xCF is the reversed order of 11110011.*/
+ if (FCS==0xCF) {
+ /*FCS is OK*/
+ return TRUE;
+ }
+ else {
+ /*FCS is not OK*/
+ return FALSE;
+ }
+}
+
+
diff --git a/wsutil/crc8.h b/wsutil/crc8.h
new file mode 100644
index 0000000000..d8268ba9ab
--- /dev/null
+++ b/wsutil/crc8.h
@@ -0,0 +1,44 @@
+/* crc8.h
+ *
+ * Checks the checksum (FCS) of the 3G TS 27.010 Multiplexing protocol.
+ * The algorithm to check the FCS is described in "3G TS 27.010 V2.0.0 (1999-06)"
+ * See: www.3gpp.org/ftp/tsg_t/TSG_T/TSGT_04/docs/PDFs/TP-99119.pdf
+ * or: http://www.3gpp.org/ftp/Specs/html-info/27010.htm
+ *
+ * Polynom: (x^8 + x^2 + x^1 + 1)
+ *
+ * 2011 Hans-Christoph Schemmel <hans-christoph.schemmel[AT]cinterion.com>
+ *
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+/**
+ * Check the final crc value(Receiver code)
+ *
+ * \param p The tv buffer containing the data.
+ * \param len Number of bytes in the message.
+ * \param offset Offset in the message.
+ * \param received_fcs The received FCS.
+ * \return Returns TRUE if the checksum is correct, FALSE if it is not correct
+ *****************************************************************************/
+extern gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs);
diff --git a/wsutil/crcdrm.c b/wsutil/crcdrm.c
new file mode 100644
index 0000000000..345a232bb9
--- /dev/null
+++ b/wsutil/crcdrm.c
@@ -0,0 +1,50 @@
+/* crcdrm.c
+ * another CRC 16
+ * Copyright 2006, British Broadcasting Corporation
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include "crcdrm.h"
+
+unsigned long crc_drm(const char *data, size_t bytesize,
+ unsigned short num_crc_bits, unsigned long crc_gen, int invert)
+{
+ unsigned long crc_holder, ones, i, msb, databit;
+ signed short j;
+
+ ones = (1 << num_crc_bits) - 1;
+ crc_holder = ones;
+ for (i=0; i<bytesize; i++)
+ for (j=7; j>=0; j--)
+ {
+ crc_holder <<= 1;
+ msb = crc_holder >> num_crc_bits;
+ databit = (data[i] >> j) & 1;
+ if ((msb ^ databit) != 0)
+ crc_holder = crc_holder ^ crc_gen;
+ crc_holder = crc_holder & ones;
+ }
+ if (invert)
+ crc_holder = crc_holder ^ ones; /* invert checksum */
+ return crc_holder;
+}
diff --git a/wsutil/crcdrm.h b/wsutil/crcdrm.h
new file mode 100644
index 0000000000..195cee09d1
--- /dev/null
+++ b/wsutil/crcdrm.h
@@ -0,0 +1,32 @@
+/* crcdrm.h
+ * another CRC 16
+ * Copyright 2006, British Broadcasting Corporation
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CRCDRM_H
+
+#include <stdlib.h>
+
+unsigned long crc_drm(const char *data, size_t bytesize,
+ unsigned short num_crc_bits, unsigned long crc_gen, int invert);
+#endif
diff --git a/wsutil/libwsutil.def b/wsutil/libwsutil.def
index 7aadd7e848..09b9d00b6f 100644
--- a/wsutil/libwsutil.def
+++ b/wsutil/libwsutil.def
@@ -9,6 +9,38 @@
;
EXPORTS
+; crc6.c
+update_crc6_by_bytes
+
+; crc8.c
+check_fcs
+
+; crc10.c
+update_crc10_by_bytes
+
+; crc16.c
+crc16_ccitt
+crc16_ccitt_seed
+crc16_ccitt_tvb
+crc16_plain_tvb_offset
+crc16_ccitt_tvb_offset
+crc16_ccitt_tvb_offset_seed
+crc16_ccitt_tvb_seed
+crc16_x25_ccitt
+crc16_x25_ccitt_tvb
+
+; crc32.c
+crc32_802_tvb
+crc32_ccitt
+crc32_ccitt_seed
+crc32_ccitt_table DATA
+crc32_ccitt_tvb
+crc32_ccitt_tvb_offset
+crc32_ccitt_tvb_seed
+crc32_ccitt_tvb_offset_seed
+crc32c_calculate
+crc32c_table DATA
+
; file_util.c
getenv_utf8
ws_stdio_fopen