summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/CMakeLists.txt1
-rw-r--r--epan/Makefile.common2
-rw-r--r--epan/crc6-tvb.c39
-rw-r--r--epan/crc6-tvb.h38
-rw-r--r--epan/dissectors/packet-sync.c4
5 files changed, 82 insertions, 2 deletions
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index 4ca89f8e42..e18c8f3667 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -1534,6 +1534,7 @@ set(LIBWIRESHARK_FILES
crc10-tvb.c
crc16-tvb.c
crc32-tvb.c
+ crc6-tvb.c
crc8-tvb.c
decode_as.c
disabled_protos.c
diff --git a/epan/Makefile.common b/epan/Makefile.common
index ef925bf63e..01fc5cf0c8 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -39,6 +39,7 @@ LIBWIRESHARK_SRC = \
crc10-tvb.c \
crc16-tvb.c \
crc32-tvb.c \
+ crc6-tvb.c \
crc8-tvb.c \
decode_as.c \
disabled_protos.c \
@@ -170,6 +171,7 @@ LIBWIRESHARK_INCLUDES = \
crc10-tvb.h \
crc16-tvb.h \
crc32-tvb.h \
+ crc6-tvb.h \
crc8-tvb.h \
decode_as.h \
diam_dict.h \
diff --git a/epan/crc6-tvb.c b/epan/crc6-tvb.c
new file mode 100644
index 0000000000..c9a2e4470d
--- /dev/null
+++ b/epan/crc6-tvb.c
@@ -0,0 +1,39 @@
+/* crc6-tvb.c
+ * CRC-6 tvb routines
+ *
+ * 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 "config.h"
+
+#include <glib.h>
+#include <epan/tvbuff.h>
+#include <wsutil/crc6.h>
+#include <epan/crc6-tvb.h>
+
+guint16
+crc6_compute_tvb(tvbuff_t *tvb, int len)
+{
+ const guint8 *buf;
+
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, 0, len);
+
+ return crc6_compute(buf, len);
+}
diff --git a/epan/crc6-tvb.h b/epan/crc6-tvb.h
new file mode 100644
index 0000000000..19c5bc691f
--- /dev/null
+++ b/epan/crc6-tvb.h
@@ -0,0 +1,38 @@
+/* crc6-tvb.h
+ * Declaration of CRC-6 tvbuff routines
+ *
+ * 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 __CRC6_TVB_H__
+#define __CRC6_TVB_H__
+
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+WS_DLL_PUBLIC guint16 crc6_compute_tvb(tvbuff_t *tvb, int len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* crc6-tvb.h */
diff --git a/epan/dissectors/packet-sync.c b/epan/dissectors/packet-sync.c
index 5247c40979..3497462d8c 100644
--- a/epan/dissectors/packet-sync.c
+++ b/epan/dissectors/packet-sync.c
@@ -28,7 +28,7 @@
#include <glib.h>
#include <epan/packet.h>
-#include <wsutil/crc6.h>
+#include <epan/crc6-tvb.h>
#define TYPE_0_LEN 17
#define TYPE_1_LEN 11
@@ -163,7 +163,7 @@ dissect_sync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
item = proto_tree_add_item(sync_tree, hf_sync_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sync_tree, hf_sync_payload_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text(item, " [Calculated CRC 0x%x]",
- crc6_compute(tvb_get_ptr(tvb, 0, offset),offset));
+ crc6_compute_tvb(tvb, offset));
offset += 2;
/* XXX - The payload may not always be present? */