aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-08-08 10:10:36 -0700
committerGuy Harris <guy@alum.mit.edu>2014-08-08 17:11:03 +0000
commit9b9005eb94d9c89a02d93e8dda0c19b8e2d1a6d7 (patch)
treef5a9c6f552bec38fff10c479f6fd1a1755b80af9
parent57927c8a56ad132c3a9ca507bdb1584043a94abb (diff)
The DRM DCP CRC-16 is the same as the X.25 CRC-16.
So just use crc16_x25_ccitt_tvb(), which goes a byte at a time rather than a bit at a time, and which takes a tvbuff rather than requiring you to call tvb_get_ptr(). It also doesn't 1's-complement the result, so we can compare it against the 0x1D0F in ETSI TS 102 821 V1.4.1 (2012-10) rather than against a 1's-complement version, 0xE2F0. Change-Id: Ia513f851f0a8ff1e7853278ddf3618c532fb2aba Reviewed-on: https://code.wireshark.org/review/3507 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/dissectors/packet-dcp-etsi.c16
-rw-r--r--wsutil/CMakeLists.txt1
-rw-r--r--wsutil/Makefile.common2
-rw-r--r--wsutil/crcdrm.c49
-rw-r--r--wsutil/crcdrm.h34
5 files changed, 7 insertions, 95 deletions
diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c
index 2b30b1c8f4..9a41e96db3 100644
--- a/epan/dissectors/packet-dcp-etsi.c
+++ b/epan/dissectors/packet-dcp-etsi.c
@@ -28,7 +28,7 @@
#include <epan/packet.h>
#include <epan/reassemble.h>
-#include <wsutil/crcdrm.h>
+#include <epan/crc16-tvb.h>
#include <epan/reedsolomon.h>
#include <epan/wmem/wmem.h>
#include <string.h>
@@ -494,11 +494,10 @@ dissect_pft(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
if (tree) {
proto_item *ci = NULL;
guint header_len = offset+2;
- const char *crc_buf = (const char *) tvb_get_ptr(tvb, 0, header_len);
- unsigned long c = crc_drm(crc_buf, header_len, 16, 0x11021, 1);
+ guint16 c = crc16_x25_ccitt_tvb(tvb, header_len);
ci = proto_tree_add_item (pft_tree, hf_edcp_hcrc, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_item_append_text(ci, " (%s)", (c==0xe2f0)?"Ok":"bad");
- proto_tree_add_boolean(pft_tree, hf_edcp_hcrc_ok, tvb, offset, 2, c==0xe2f0);
+ proto_item_append_text(ci, " (%s)", (c==0x1D0F)?"Ok":"bad");
+ proto_tree_add_boolean(pft_tree, hf_edcp_hcrc_ok, tvb, offset, 2, c==0x1D0F);
}
offset += 2;
if (fcount > 1) { /* fragmented*/
@@ -580,10 +579,9 @@ dissect_af (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
ci = proto_tree_add_item (af_tree, hf_edcp_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
if (ver & 0x80) { /* crc valid */
guint len = offset+2;
- const char *crc_buf = (const char *) tvb_get_ptr(tvb, 0, len);
- unsigned long c = crc_drm(crc_buf, len, 16, 0x11021, 1);
- proto_item_append_text(ci, " (%s)", (c==0xe2f0)?"Ok":"bad");
- proto_tree_add_boolean(af_tree, hf_edcp_crc_ok, tvb, offset, 2, c==0xe2f0);
+ guint16 c = crc16_x25_ccitt_tvb(tvb, len);
+ proto_item_append_text(ci, " (%s)", (c==0x1D0F)?"Ok":"bad");
+ proto_tree_add_boolean(af_tree, hf_edcp_crc_ok, tvb, offset, 2, c==0x1D0F);
}
/*offset += 2;*/
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 9efb7b26a4..0a3c1a969a 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -60,7 +60,6 @@ set(WSUTIL_FILES
crc7.c
crc8.c
crc11.c
- crcdrm.c
des.c
eax.c
filesystem.c
diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common
index 95736cd1f8..cb595977c1 100644
--- a/wsutil/Makefile.common
+++ b/wsutil/Makefile.common
@@ -48,7 +48,6 @@ LIBWSUTIL_SRC = \
crc16.c \
crc16-plain.c \
crc32.c \
- crcdrm.c \
des.c \
eax.c \
filesystem.c \
@@ -101,7 +100,6 @@ libwsutil_nonrepl_INCLUDES = \
crc16.h \
crc16-plain.h \
crc32.h \
- crcdrm.h \
des.h \
eax.h \
filesystem.h \
diff --git a/wsutil/crcdrm.c b/wsutil/crcdrm.c
deleted file mode 100644
index cd0e560384..0000000000
--- a/wsutil/crcdrm.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* crcdrm.c
- * another CRC 16
- * Copyright 2006, British Broadcasting Corporation
- *
- * 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.
- */
-
-#include <stdlib.h>
-
-#include <wsutil/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
deleted file mode 100644
index e08f2f949e..0000000000
--- a/wsutil/crcdrm.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* crcdrm.h
- * another CRC 16
- * Copyright 2006, British Broadcasting Corporation
- *
- * 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.
- */
-
-#ifndef __CRCDRM_H__
-#define __CRCDRM_H__
-
-
-#include "ws_symbol_export.h"
-
-WS_DLL_PUBLIC
-unsigned long crc_drm(const char *data, size_t bytesize,
- unsigned short num_crc_bits, unsigned long crc_gen, int invert);
-
-#endif /* __CRCDRM_H__ */