aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2011-08-31 09:00:54 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2011-08-31 09:00:54 +0000
commit5359494b1f7fbfa4fce2e98e4d9e579a0fdafff4 (patch)
tree8d6f30d58eeb9b379d0db577f7f5d9e975a1d149 /epan
parent48221f4dfda01b750f5d00548d8c37a578d3a53b (diff)
Second try to move crc routines to libwsutil.
This time keep the tvb routines in epan. Now we can use common crc routines outside epan. svn path=/trunk/; revision=38810
Diffstat (limited to 'epan')
-rw-r--r--epan/CMakeLists.txt15
-rw-r--r--epan/Makefile.am6
-rw-r--r--epan/Makefile.common18
-rw-r--r--epan/Makefile.nmake24
-rw-r--r--epan/crc/Makefile.am54
-rw-r--r--epan/crc/Makefile.common33
-rw-r--r--epan/crc/Makefile.nmake31
-rw-r--r--epan/crc/crc-16-plain.c105
-rw-r--r--epan/crc/crc-16-plain.h87
-rw-r--r--epan/crc10.c97
-rw-r--r--epan/crc10.h27
-rw-r--r--epan/crc16-tvb.c106
-rw-r--r--epan/crc16-tvb.h (renamed from epan/crc16.h)44
-rw-r--r--epan/crc16.c254
-rw-r--r--epan/crc32-tvb.c107
-rw-r--r--epan/crc32-tvb.h (renamed from epan/crc32.h)51
-rw-r--r--epan/crc32.c275
-rw-r--r--epan/crc6.c53
-rw-r--r--epan/crc6.h26
-rw-r--r--epan/crc8-tvb.c (renamed from epan/crc8.c)4
-rw-r--r--epan/crc8-tvb.h (renamed from epan/crc8.h)6
-rw-r--r--epan/crcdrm.c50
-rw-r--r--epan/crcdrm.h32
-rw-r--r--epan/crypt/airpdcap.c2
-rw-r--r--epan/crypt/airpdcap_wep.c2
-rw-r--r--epan/dissectors/packet-assa_r3.c2
-rw-r--r--epan/dissectors/packet-dcp-etsi.c2
-rw-r--r--epan/dissectors/packet-dmp.c2
-rw-r--r--epan/dissectors/packet-eth.c2
-rw-r--r--epan/dissectors/packet-fc.c2
-rw-r--r--epan/dissectors/packet-fcoe.c2
-rw-r--r--epan/dissectors/packet-fcoib.c2
-rw-r--r--epan/dissectors/packet-ieee80211.c3
-rw-r--r--epan/dissectors/packet-ieee802154.c2
-rw-r--r--epan/dissectors/packet-iscsi.c2
-rw-r--r--epan/dissectors/packet-iuup.c4
-rw-r--r--epan/dissectors/packet-iwarp-mpa.c2
-rw-r--r--epan/dissectors/packet-lapd.c2
-rw-r--r--epan/dissectors/packet-mtp2.c2
-rw-r--r--epan/dissectors/packet-mux27010.c2
-rw-r--r--epan/dissectors/packet-nfs.c7
-rw-r--r--epan/dissectors/packet-ntlmssp.c2
-rw-r--r--epan/dissectors/packet-ppp.c4
-rw-r--r--epan/dissectors/packet-radiotap.c2
-rw-r--r--epan/dissectors/packet-sctp.c2
-rw-r--r--epan/dissectors/packet-srp.c3
-rw-r--r--epan/dissectors/packet-synphasor.c2
-rw-r--r--epan/dissectors/packet-teamspeak2.c3
-rw-r--r--epan/dissectors/packet-zrtp.c2
-rw-r--r--epan/libwireshark.def9
-rw-r--r--epan/sigcomp-udvm.c2
51 files changed, 288 insertions, 1292 deletions
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index bbcad3ab23..86b78341f0 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -39,10 +39,6 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/wspython
)
-set(CRC_FILES
- crc/crc-16-plain.c
-)
-
set(CRYPT_FILES
crypt/airpdcap.c
crypt/airpdcap_ccmp.c
@@ -1209,12 +1205,9 @@ set(LIBWIRESHARK_FILES
column.c
column-utils.c
conversation.c
- crc10.c
- crc16.c
- crc32.c
- crc6.c
- crc8.c
- crcdrm.c
+ crc16-tvb.c
+ crc32-tvb.c
+ crc8-tvb.c
dissector_filters.c
emem.c
epan.c
@@ -1310,7 +1303,6 @@ set(CLEAN_FILES
#x11-declarations.h
#x11-register-info.h
${LIBWIRESHARK_CLEAN_FILES}
- ${CRC_FILES}
${CRYPT_FILES}
${DFILTER_CLEAN_FILES}
${FTYPE_FILES}
@@ -1339,7 +1331,6 @@ add_library(epan ${LINK_MODE_LIB}
#x11-declarations.h
#x11-register-info.h
${LIBWIRESHARK_FILES}
- ${CRC_FILES}
${CRYPT_FILES}
${DFILTER_FILES}
${FTYPE_FILES}
diff --git a/epan/Makefile.am b/epan/Makefile.am
index a0a224b64e..d624c49c01 100644
--- a/epan/Makefile.am
+++ b/epan/Makefile.am
@@ -46,7 +46,7 @@ wspython_dist_dir = wspython
py_dissectors_dir = -DPYTHONDIR=
endif
-SUBDIRS = crc crypt ftypes dfilter dissectors $(wslua_dir) $(wspython_dir)
+SUBDIRS = crypt ftypes dfilter dissectors $(wslua_dir) $(wspython_dir)
DIST_SUBDIRS = $(SUBDIRS) $(wslua_dist_dir) $(wspython_dist_dir)
@@ -133,7 +133,7 @@ MAINTAINERCLEANFILES = \
#
libwireshark_la_LIBADD = \
libwireshark_generated.la \
- libwireshark_asmopt.la crc/libcrc.la crypt/libairpdcap.la \
+ libwireshark_asmopt.la crypt/libairpdcap.la \
ftypes/libftypes.la dfilter/libdfilter.la dissectors/libdissectors.la \
dissectors/libdirtydissectors.la $(wslua_lib) $(wspython_lib) @SOCKET_LIBS@ @NSL_LIBS@ \
@C_ARES_LIBS@ @ADNS_LIBS@ @LIBGCRYPT_LIBS@ @LIBGNUTLS_LIBS@ \
@@ -143,7 +143,7 @@ libwireshark_la_LIBADD = \
libwireshark_la_DEPENDENCIES = \
libwireshark_generated.la \
- libwireshark_asmopt.la crc/libcrc.la crypt/libairpdcap.la \
+ libwireshark_asmopt.la crypt/libairpdcap.la \
ftypes/libftypes.la dfilter/libdfilter.la dissectors/libdissectors.la \
dissectors/libdirtydissectors.la $(wslua_lib) $(wspython_lib) \
${top_builddir}/wsutil/libwsutil.la \
diff --git a/epan/Makefile.common b/epan/Makefile.common
index 63c35ad076..9ef81117ba 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -40,12 +40,9 @@ LIBWIRESHARK_SRC = \
column.c \
column-utils.c \
conversation.c \
- crc10.c \
- crc16.c \
- crc32.c \
- crc6.c \
- crc8.c \
- crcdrm.c \
+ crc16-tvb.c \
+ crc32-tvb.c \
+ crc8-tvb.c \
dissector_filters.c \
emem.c \
epan.c \
@@ -150,12 +147,9 @@ LIBWIRESHARK_INCLUDES = \
column_info.h \
column-utils.h \
conversation.h \
- crc6.h \
- crc8.h \
- crc10.h \
- crc16.h \
- crc32.h \
- crcdrm.h \
+ crc16-tvb.h \
+ crc32-tvb.h \
+ crc8-tvb.h \
diam_dict.h \
dissector_filters.h \
dtd.h \
diff --git a/epan/Makefile.nmake b/epan/Makefile.nmake
index 4efc7924cc..8d9cf96324 100644
--- a/epan/Makefile.nmake
+++ b/epan/Makefile.nmake
@@ -52,7 +52,6 @@ libwireshark_LIBS = \
$(GEOIP_LIBS) \
..\wsutil\libwsutil.lib \
..\wiretap\wiretap-$(WTAP_VERSION).lib \
- crc\crc.lib \
crypt\airpdcap.lib \
ftypes\ftypes.lib \
dfilter\dfilter.lib \
@@ -77,17 +76,17 @@ DOXYGEN_DEP=doxygen
!ENDIF
!IFDEF ENABLE_LIBWIRESHARK
-all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.dll
+all: crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.dll
!ELSE
-all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.lib
+all: crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.lib
!ENDIF
# For use when making libwireshark.dll
libwireshark.lib: libwireshark.dll
libwireshark.exp: libwireshark.dll
-libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
- crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) $(WSPYTHON_LIB) ..\image\libwireshark.res
+libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
+ crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) $(WSPYTHON_LIB) ..\image\libwireshark.res
@echo Linking libwireshark.dll
$(link) $(dlllflags) $(conlibsdll) shell32.lib \
$(LOCAL_LDFLAGS) $(DLL_LDFLAGS) \
@@ -97,8 +96,8 @@ libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt
dissectors\register.obj \
$(EXTRA_OBJECTS)
-libwireshark.lib : ..\config.h $(LIBWIRESHARK_OBJECTS) crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
- crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib $(WSLUA_LIB) $(WSPYTHON_LIB) dissectors\dissectors.lib
+libwireshark.lib : ..\config.h $(LIBWIRESHARK_OBJECTS) crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
+ crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib $(WSLUA_LIB) $(WSPYTHON_LIB) dissectors\dissectors.lib
link /lib /out:libwireshark.lib $(LIBWIRESHARK_OBJECTS) \
$(EXTRA_OBJECTS)
@@ -115,8 +114,6 @@ clean-local:
if exist html rm -rf html
clean: clean-local
- cd crc
- $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ../crypt
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ../ftypes
@@ -149,8 +146,6 @@ distclean-local: clean-local
dtd_grammar.out sminmpec.c
distclean: distclean-local
- cd crc
- $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
cd ../crypt
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
cd ../ftypes
@@ -168,8 +163,6 @@ distclean: distclean-local
maintainer-clean-local: distclean-local
maintainer-clean: maintainer-clean-local
- cd crc
- $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
cd ../crypt
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
cd ../ftypes
@@ -184,11 +177,6 @@ maintainer-clean: maintainer-clean-local
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
cd ..
-crc:: ..\config.h
- cd crc
- $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
- cd ..
-
crypt:: ..\config.h
cd crypt
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
diff --git a/epan/crc/Makefile.am b/epan/crc/Makefile.am
deleted file mode 100644
index 28ad880193..0000000000
--- a/epan/crc/Makefile.am
+++ /dev/null
@@ -1,54 +0,0 @@
-# Makefile.am
-# Automake file for crc routines for Wireshark
-#
-# $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.
-
-INCLUDES = -I$(top_srcdir)
-
-include Makefile.common
-
-if HAVE_WARNINGS_AS_ERRORS
-AM_CFLAGS = -Werror
-endif
-
-noinst_LTLIBRARIES = libcrc.la
-
-CLEANFILES = \
- libcrc.a \
- libcrc.la \
- *~
-
-DISTCLEANFILES =
-
-MAINTAINERCLEANFILES = \
- Makefile.in
-
-libcrc_la_SOURCES = \
- $(CRC_SRC) \
- $(CRC_INCLUDES)
-
-EXTRA_DIST = \
- Makefile.common \
- Makefile.nmake
-
-checkapi:
- $(PERL) ../../tools/checkAPIs.pl -g termoutput \
- $(CRC_SRC)
diff --git a/epan/crc/Makefile.common b/epan/crc/Makefile.common
deleted file mode 100644
index 7aa9cb7512..0000000000
--- a/epan/crc/Makefile.common
+++ /dev/null
@@ -1,33 +0,0 @@
-# Makefile.common
-# Contains the stuff from Makefile.am and Makefile.nmake that is
-# a) common to both files and
-# b) portable between both files
-#
-# $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.
-
-# crc-16-plain.c: pycrc.py --model crc-16 --algorithm table-driven --symbol-prefix crc16_plain_ --crc-type guint16 --include-file glib.h --generate c -o crc-16-plain.c
-# crc-16-plain.h: pycrc.py --model crc-16 --algorithm table-driven --symbol-prefix crc16_plain_ --crc-type guint16 --include-file glib.h --generate h -o crc-16-plain.h
-
-CRC_SRC = \
- crc-16-plain.c
-
-CRC_INCLUDES = \
- crc-16-plain.h
diff --git a/epan/crc/Makefile.nmake b/epan/crc/Makefile.nmake
deleted file mode 100644
index 9b336d8040..0000000000
--- a/epan/crc/Makefile.nmake
+++ /dev/null
@@ -1,31 +0,0 @@
-## Makefile for building crc.lib with Microsoft C and nmake
-## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
-#
-# $Id$
-
-include ..\..\config.nmake
-include Makefile.common
-
-############### no need to modify below this line #########
-
-CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
- /I../.. $(GLIB_CFLAGS)
-
-.c.obj::
- $(CC) $(CFLAGS) -Fd.\ -c $<
-
-CRC_OBJECTS = $(CRC_SRC:.c=.obj)
-
-crc.lib: $(CRC_OBJECTS)
- link /lib /out:crc.lib $(CRC_OBJECTS)
-
-clean:
- rm -f $(CRC_OBJECTS) crc.lib *.pdb
-
-distclean: clean
-
-maintainer-clean: distclean
-
-checkapi:
- $(PERL) ../../tools/checkAPIs.pl -g termoutput \
- $(CRC_SRC)
diff --git a/epan/crc/crc-16-plain.c b/epan/crc/crc-16-plain.c
deleted file mode 100644
index 863f939d4a..0000000000
--- a/epan/crc/crc-16-plain.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * \file crc-16-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 "crc-16-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/epan/crc/crc-16-plain.h b/epan/crc/crc-16-plain.h
deleted file mode 100644
index 2ad0217066..0000000000
--- a/epan/crc/crc-16-plain.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * \file crc-16-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/epan/crc10.c b/epan/crc10.c
deleted file mode 100644
index 77d5068624..0000000000
--- a/epan/crc10.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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/epan/crc10.h b/epan/crc10.h
deleted file mode 100644
index a0b5a0fa09..0000000000
--- a/epan/crc10.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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/epan/crc16-tvb.c b/epan/crc16-tvb.c
new file mode 100644
index 0000000000..d0271626f7
--- /dev/null
+++ b/epan/crc16-tvb.c
@@ -0,0 +1,106 @@
+/* crc16-tvb.c
+ * CRC-16 tvb routines
+ *
+ * 2004 Richard van der Hoff <richardv@mxtelecom.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.
+ *
+ * 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>
+
+
+guint16 crc16_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 crc16_ccitt(buf, len);
+}
+
+guint16 crc16_x25_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 crc16_x25_ccitt(buf, len);
+}
+
+guint16 crc16_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 crc16_ccitt(buf, len);
+}
+
+guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed)
+{
+ const guint8 *buf;
+
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ 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_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ 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_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, offset, len);
+
+ crc = crc16_plain_update(crc, buf, len);
+
+ return crc16_plain_finalize(crc);
+}
+
diff --git a/epan/crc16.h b/epan/crc16-tvb.h
index 0fb0548dc4..504bcd31a9 100644
--- a/epan/crc16.h
+++ b/epan/crc16-tvb.h
@@ -1,16 +1,14 @@
-/* crc16.h
- * Declaration of CRC-16 routines and table
+/* crc16-tvb.h
+ * Declaration of CRC-16 tvbuff routines
*
* 2004 Richard van der Hoff <richardv@mxtelecom.com>
*
* $Id$
*
* Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@xxxxxxxxxxxx>
+ * 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
@@ -26,43 +24,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __CRC16_H_
-#define __CRC16_H_
+#ifndef __CRC16_TVB_H__
+#define __CRC16_TVB_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.
@@ -123,4 +91,4 @@ extern guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
}
#endif /* __cplusplus */
-#endif /* crc16.h */
+#endif /* crc16-tvb.h */
diff --git a/epan/crc16.c b/epan/crc16.c
deleted file mode 100644
index 5fcd105dca..0000000000
--- a/epan/crc16.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* 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 <epan/crc16.h>
-#include <epan/crc/crc-16-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/epan/crc32-tvb.c b/epan/crc32-tvb.c
new file mode 100644
index 0000000000..91cd7c13f2
--- /dev/null
+++ b/epan/crc32-tvb.c
@@ -0,0 +1,107 @@
+/* crc32-tvb.c
+ * CRC-32 tvbuff routines
+ *
+ * $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.
+ *
+ * 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>
+
+
+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/epan/crc32.h b/epan/crc32-tvb.h
index 7bc63bdde4..400920ee18 100644
--- a/epan/crc32.h
+++ b/epan/crc32-tvb.h
@@ -1,5 +1,5 @@
-/* crc32.h
- * Declaration of CRC-32 routine and table
+/* crc32-tvb.h
+ * Declaration of CRC-32 tvbuff routines
*
* $Id$
*
@@ -7,8 +7,6 @@
* 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
@@ -24,52 +22,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __CRC32_H_
-#define __CRC32_H_
+#ifndef __CRC32_TVB_H__
+#define __CRC32_TVB_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.
@@ -113,4 +72,4 @@ extern guint32 crc32_802_tvb(tvbuff_t *tvb, guint len);
}
#endif /* __cplusplus */
-#endif /* crc32.h */
+#endif /* crc32-tvb.h */
diff --git a/epan/crc32.c b/epan/crc32.c
deleted file mode 100644
index 0fe2b29547..0000000000
--- a/epan/crc32.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* 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 <epan/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/epan/crc6.c b/epan/crc6.c
deleted file mode 100644
index 333a1a51cd..0000000000
--- a/epan/crc6.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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/epan/crc6.h b/epan/crc6.h
deleted file mode 100644
index c8abfb4ad4..0000000000
--- a/epan/crc6.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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/epan/crc8.c b/epan/crc8-tvb.c
index 630eda7f6c..f2fc0902b9 100644
--- a/epan/crc8.c
+++ b/epan/crc8-tvb.c
@@ -33,12 +33,12 @@
*/
#ifdef HAVE_CONFIG_H
- # include "config.h"
+# include "config.h"
#endif
#include <glib.h>
#include <epan/tvbuff.h>
-#include <epan/crc8.h>
+#include <epan/crc8-tvb.h>
/**
* Reversed CRC table
diff --git a/epan/crc8.h b/epan/crc8-tvb.h
index d8268ba9ab..cb4775c17c 100644
--- a/epan/crc8.h
+++ b/epan/crc8-tvb.h
@@ -41,4 +41,10 @@
* \param received_fcs The received FCS.
* \return Returns TRUE if the checksum is correct, FALSE if it is not correct
*****************************************************************************/
+
+#ifndef __CRC8_TVB_H__
+#define __CRC8_TVB_H__
+
extern gboolean check_fcs(tvbuff_t *p, guint8 len, guint8 offset, guint8 received_fcs);
+
+#endif /* __CRC8_TVB_H__ */
diff --git a/epan/crcdrm.c b/epan/crcdrm.c
deleted file mode 100644
index 345a232bb9..0000000000
--- a/epan/crcdrm.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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/epan/crcdrm.h b/epan/crcdrm.h
deleted file mode 100644
index 195cee09d1..0000000000
--- a/epan/crcdrm.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* 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/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c
index 740a148c8b..1de4ade2a4 100644
--- a/epan/crypt/airpdcap.c
+++ b/epan/crypt/airpdcap.c
@@ -41,7 +41,7 @@
#endif
#include <epan/tvbuff.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include <epan/strutil.h>
#include <epan/emem.h>
#include <epan/pint.h>
diff --git a/epan/crypt/airpdcap_wep.c b/epan/crypt/airpdcap_wep.c
index 45d02df7eb..6007f115ba 100644
--- a/epan/crypt/airpdcap_wep.c
+++ b/epan/crypt/airpdcap_wep.c
@@ -41,7 +41,7 @@
/* File includes */
#include <epan/tvbuff.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include "airpdcap_system.h"
#include "airpdcap_int.h"
diff --git a/epan/dissectors/packet-assa_r3.c b/epan/dissectors/packet-assa_r3.c
index 0e5d379fa9..4921ef8070 100644
--- a/epan/dissectors/packet-assa_r3.c
+++ b/epan/dissectors/packet-assa_r3.c
@@ -3213,7 +3213,7 @@ static mfgFieldDissectorParser_t r3upstreammfgfield_dissect [] =
/*
* ***************************************************************************
*
- * Cannot use epan/crc routines as ccitt-x25 uses a starting value of 0xffff
+ * Cannot use wsutil/crc routines as ccitt-x25 uses a starting value of 0xffff
* and we use 0x0000 (legacy compatibility). If an override method to set
* the starting value existed, these could be replaced.
*/
diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c
index 32cef5d7f5..d60836182b 100644
--- a/epan/dissectors/packet-dcp-etsi.c
+++ b/epan/dissectors/packet-dcp-etsi.c
@@ -32,7 +32,7 @@
#include <epan/packet.h>
#include <epan/reassemble.h>
-#include <epan/crcdrm.h>
+#include <wsutil/crcdrm.h>
#include <epan/reedsolomon.h>
#include <epan/emem.h>
#include <string.h>
diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c
index 44586de447..a7982d4fa6 100644
--- a/epan/dissectors/packet-dmp.c
+++ b/epan/dissectors/packet-dmp.c
@@ -50,7 +50,7 @@
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/expert.h>
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
#include <epan/asn1.h>
#include <epan/strutil.h>
#include <epan/uat.h>
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c
index 6c1c720767..09dfdb9a5e 100644
--- a/epan/dissectors/packet-eth.c
+++ b/epan/dissectors/packet-eth.c
@@ -38,7 +38,7 @@
#include "packet-llc.h"
#include "packet-sll.h"
#include "packet-usb.h"
-#include <epan/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/tap.h>
#include <epan/expert.h>
diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c
index 7aecad064d..b10cbd0d8c 100644
--- a/epan/dissectors/packet-fc.c
+++ b/epan/dissectors/packet-fc.c
@@ -53,7 +53,7 @@
#include "packet-fcbls.h"
#include <epan/tap.h>
#include <epan/emem.h>
-#include <epan/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/expert.h>
#define FC_HEADER_SIZE 24
diff --git a/epan/dissectors/packet-fcoe.c b/epan/dissectors/packet-fcoe.c
index 09094df5f6..9612bbd02d 100644
--- a/epan/dissectors/packet-fcoe.c
+++ b/epan/dissectors/packet-fcoe.c
@@ -40,7 +40,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
-#include <epan/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/etypes.h>
#include <epan/expert.h>
diff --git a/epan/dissectors/packet-fcoib.c b/epan/dissectors/packet-fcoib.c
index c4c298d818..933f01d9a2 100644
--- a/epan/dissectors/packet-fcoib.c
+++ b/epan/dissectors/packet-fcoib.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
-#include <epan/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/etypes.h>
#include <epan/expert.h>
#include <errno.h>
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index dfa5331b64..8fe8c1263a 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -116,7 +116,8 @@
#include <epan/etypes.h>
#include <epan/greproto.h>
#include <epan/oui.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/tap.h>
#include <epan/emem.h>
#include <epan/crypt/wep-wpadefs.h>
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index 5c970fa6e4..362a603053 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -75,7 +75,7 @@
#include <epan/emem.h>
#include <epan/packet.h>
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
#include <epan/expert.h>
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c
index bbbdcf877a..1bad474973 100644
--- a/epan/dissectors/packet-iscsi.c
+++ b/epan/dissectors/packet-iscsi.c
@@ -49,7 +49,7 @@
#include <epan/nstime.h>
#include <epan/emem.h>
#include <epan/range.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
/* the absolute values of these constants don't matter as long as
* latter revisions of the protocol are assigned a larger number */
diff --git a/epan/dissectors/packet-iuup.c b/epan/dissectors/packet-iuup.c
index e9ae3a0755..20d2b92991 100644
--- a/epan/dissectors/packet-iuup.c
+++ b/epan/dissectors/packet-iuup.c
@@ -40,8 +40,8 @@
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/expert.h>
-#include <epan/crc10.h>
-#include <epan/crc6.h>
+#include <wsutil/crc10.h>
+#include <wsutil/crc6.h>
typedef struct _iuup_rfci_t {
diff --git a/epan/dissectors/packet-iwarp-mpa.c b/epan/dissectors/packet-iwarp-mpa.c
index ec85288d90..62e4a81f8e 100644
--- a/epan/dissectors/packet-iwarp-mpa.c
+++ b/epan/dissectors/packet-iwarp-mpa.c
@@ -36,7 +36,7 @@
#include <epan/conversation.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/expert.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
/* DEFINES */
diff --git a/epan/dissectors/packet-lapd.c b/epan/dissectors/packet-lapd.c
index 9453808d6f..dc970d8b72 100644
--- a/epan/dissectors/packet-lapd.c
+++ b/epan/dissectors/packet-lapd.c
@@ -46,7 +46,7 @@
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/xdlc.h>
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
#include <epan/prefs.h>
#include <epan/lapd_sapi.h>
diff --git a/epan/dissectors/packet-mtp2.c b/epan/dissectors/packet-mtp2.c
index 24c0519810..f44bcc45ef 100644
--- a/epan/dissectors/packet-mtp2.c
+++ b/epan/dissectors/packet-mtp2.c
@@ -35,7 +35,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
#include <epan/expert.h>
/* Initialize the protocol and registered fields */
diff --git a/epan/dissectors/packet-mux27010.c b/epan/dissectors/packet-mux27010.c
index 5e6c6b6eaa..af9f4a90ac 100644
--- a/epan/dissectors/packet-mux27010.c
+++ b/epan/dissectors/packet-mux27010.c
@@ -30,7 +30,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/reassemble.h>
-#include <epan/crc8.h>
+#include <epan/crc8-tvb.h>
#include <expert.h>
#include <string.h>
diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c
index a775228620..fa071842c2 100644
--- a/epan/dissectors/packet-nfs.c
+++ b/epan/dissectors/packet-nfs.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <glib.h>
#include "packet-rpc.h"
#include "packet-nfs.h"
@@ -40,12 +41,10 @@
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/strutil.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include <epan/expert.h>
-#include <epan/crc16.h>
-#include <glib.h>
-#include <glib/gprintf.h>
+#include <wsutil/crc16.h>
static int proto_nfs = -1;
static int hf_nfs_access_check = -1;
diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c
index 8fcb676332..0fa3783b69 100644
--- a/epan/dissectors/packet-ntlmssp.c
+++ b/epan/dissectors/packet-ntlmssp.c
@@ -53,7 +53,7 @@
#include <epan/crypt/crypt-des.h>
#include "packet-dcerpc.h"
#include "packet-gssapi.h"
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include "packet-ntlmssp.h"
diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c
index 63145bb636..2dceec9ece 100644
--- a/epan/dissectors/packet-ppp.c
+++ b/epan/dissectors/packet-ppp.c
@@ -43,8 +43,8 @@
#include "packet-ipx.h"
#include "packet-vines.h"
#include <epan/nlpid.h>
-#include <epan/crc16.h>
-#include <epan/crc32.h>
+#include <epan/crc16-tvb.h>
+#include <epan/crc32-tvb.h>
#include <epan/ipproto.h>
#include "packet-usb.h"
#include "packet-sll.h"
diff --git a/epan/dissectors/packet-radiotap.c b/epan/dissectors/packet-radiotap.c
index 6a7f9e4cdb..fba0dacce7 100644
--- a/epan/dissectors/packet-radiotap.c
+++ b/epan/dissectors/packet-radiotap.c
@@ -33,7 +33,7 @@
#include <errno.h>
#include <epan/packet.h>
-#include <epan/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/frequency-utils.h>
#include <epan/tap.h>
#include <epan/prefs.h>
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 45bed6cadc..081f5ea8c1 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -65,7 +65,7 @@
#include <epan/emem.h>
#include <epan/expert.h>
#include <packet-frame.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include <epan/adler32.h>
#define LT(x, y) ((gint32)((x) - (y)) < 0)
diff --git a/epan/dissectors/packet-srp.c b/epan/dissectors/packet-srp.c
index 415a3057db..7054a28601 100644
--- a/epan/dissectors/packet-srp.c
+++ b/epan/dissectors/packet-srp.c
@@ -32,8 +32,7 @@
#include <epan/bitswap.h>
#include <epan/circuit.h>
#include <epan/stream.h>
-/* #include <epan/reassemble.h> */
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
/* Wireshark ID of the protocols */
static int proto_srp = -1;
diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c
index 799b8ea80f..4178db562e 100644
--- a/epan/dissectors/packet-synphasor.c
+++ b/epan/dissectors/packet-synphasor.c
@@ -30,7 +30,7 @@
#include <glib.h>
#include <epan/conversation.h>
-#include <epan/crc16.h>
+#include <epan/crc16-tvb.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/packet.h>
#include <epan/prefs.h>
diff --git a/epan/dissectors/packet-teamspeak2.c b/epan/dissectors/packet-teamspeak2.c
index 8873becac4..eec8748787 100644
--- a/epan/dissectors/packet-teamspeak2.c
+++ b/epan/dissectors/packet-teamspeak2.c
@@ -29,7 +29,8 @@
#endif
#include <epan/packet.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
+#include <epan/crc32-tvb.h>
#include <epan/reassemble.h>
#include <epan/conversation.h>
#include <stdlib.h>
diff --git a/epan/dissectors/packet-zrtp.c b/epan/dissectors/packet-zrtp.c
index b9d00d8771..5ce53ceddb 100644
--- a/epan/dissectors/packet-zrtp.c
+++ b/epan/dissectors/packet-zrtp.c
@@ -34,7 +34,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/strutil.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
#include "packet-rtp.h"
#include "packet-rtcp.h"
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index afedf81c6a..604a415ea0 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -114,14 +114,15 @@ copy_persconffile_profile
copy_prefs
crc16_ccitt_tvb
crc16_plain_tvb_offset
-crc32c_calculate
-crc32_ccitt
-crc32_ccitt_seed
+crc16_ccitt_tvb_offset
+crc16_ccitt_tvb_offset_seed
+crc16_ccitt_tvb_seed
+crc16_x25_ccitt_tvb
+crc32_802_tvb
crc32_ccitt_tvb
crc32_ccitt_tvb_offset
crc32_ccitt_tvb_seed
crc32_ccitt_tvb_offset_seed
-crc32_802_tvb
create_dissector_handle
create_persconffile_dir
create_persconffile_profile
diff --git a/epan/sigcomp-udvm.c b/epan/sigcomp-udvm.c
index de28f7f6de..6e87a4adfc 100644
--- a/epan/sigcomp-udvm.c
+++ b/epan/sigcomp-udvm.c
@@ -44,7 +44,7 @@
#include "sigcomp-udvm.h"
#include "sigcomp_state_hdlr.h"
#include "crypt/crypt-sha1.h"
-#include "crc16.h"
+#include "wsutil/crc16.h"
#include "except.h"
#define SIGCOMP_INSTR_DECOMPRESSION_FAILURE 0