diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-08-08 13:02:46 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-08-08 20:03:29 +0000 |
commit | bbdd34a06b4ca9b4c8fea413ffb283f305881025 (patch) | |
tree | 5dd8e9d8cf5650129f5f0c6bd5224fdc27236da5 /epan | |
parent | 479e2881f85d835982292d3b4a5dd9c144eecc7a (diff) |
Add a tvbuff version of crc6_compute().
Use it in the MBMS synchronisation protocol dissector, rather than
calling tvb_get_ptr() there.
Change-Id: I7ddb3c6b30547826cb5372352c7c483d8a24dc8e
Reviewed-on: https://code.wireshark.org/review/3514
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/CMakeLists.txt | 1 | ||||
-rw-r--r-- | epan/Makefile.common | 2 | ||||
-rw-r--r-- | epan/crc6-tvb.c | 39 | ||||
-rw-r--r-- | epan/crc6-tvb.h | 38 | ||||
-rw-r--r-- | epan/dissectors/packet-sync.c | 4 |
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? */ |