aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Mayer <jmayer@loplof.de>2018-04-13 17:41:20 +0200
committerAnders Broman <a.broman58@gmail.com>2018-04-15 05:34:08 +0000
commit0d31ec328f2c523cfc4655f1674a5f0eae80923f (patch)
tree5e4f3bd287c01af8baeb65dc4d1286a9d126db8a
parent08c234445855bdc038912b943499511fd97e0d91 (diff)
Check for HAVE_LZ4FRAME_H in the LZ4 detection process and use it
Change-Id: I919621b8c4c809eb181d563251eeb099b767ad82 Reviewed-on: https://code.wireshark.org/review/26940 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Jörg Mayer <jmayer@loplof.de> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--acinclude.m44
-rw-r--r--cmake/modules/FindLZ4.cmake9
-rw-r--r--cmakeconfig.h.in3
-rw-r--r--epan/dissectors/packet-kafka.c13
4 files changed, 21 insertions, 8 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index abccee4..dbcea8c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2014,6 +2014,10 @@ AC_DEFUN([AC_WIRESHARK_LZ4_CHECK],
# in order to read compressed capture files.
#
AC_CHECK_FUNCS(LZ4_decompress_safe)
+ #
+ # Check for (optional) lz4frame.h
+ #
+ AC_CHECK_HEADERS(lz4frame.h)
LIBS="$ac_save_LIBS"
fi
diff --git a/cmake/modules/FindLZ4.cmake b/cmake/modules/FindLZ4.cmake
index 13ae378..0b4c8d0 100644
--- a/cmake/modules/FindLZ4.cmake
+++ b/cmake/modules/FindLZ4.cmake
@@ -36,8 +36,17 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( LZ4 DEFAULT_MSG LZ4_INCLUDE_DIR LZ4_LIBRARY )
if( LZ4_FOUND )
+ include( CheckIncludeFile )
+ include( CMakePushCheckState )
+
set( LZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR} )
set( LZ4_LIBRARIES ${LZ4_LIBRARY} )
+
+ cmake_push_check_state()
+ set( CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIRS} )
+ check_include_file( lz4frame.h HAVE_LZ4FRAME_H )
+ cmake_pop_check_state()
+
if (WIN32)
set ( LZ4_DLL_DIR "${LZ4_HINTS}/bin"
CACHE PATH "Path to LZ4 DLL"
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 566bfc9..d388119 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -134,6 +134,9 @@
/* Define to use lz4 library */
#cmakedefine HAVE_LZ4 1
+/* Check for lz4frame */
+#cmakedefine HAVE_LZ4FRAME_H 1
+
/* Define to use snappy library */
#cmakedefine HAVE_SNAPPY 1
diff --git a/epan/dissectors/packet-kafka.c b/epan/dissectors/packet-kafka.c
index 71fc715..2d8045b 100644
--- a/epan/dissectors/packet-kafka.c
+++ b/epan/dissectors/packet-kafka.c
@@ -21,12 +21,9 @@
#ifdef HAVE_SNAPPY
#include <snappy-c.h>
#endif
-#ifdef HAVE_LZ4
+#ifdef HAVE_LZ4FRAME_H
#include <lz4.h>
-#if LZ4_VERSION_NUMBER >= 10500
#include <lz4frame.h>
-#define HAVE_LZ4_FRAME
-#endif /* LZ4_VERSION_NUMBER >= 10500 */
#endif
#include "packet-tcp.h"
@@ -346,7 +343,7 @@ dissect_kafka_message_set(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i
/* HELPERS */
-#ifdef HAVE_LZ4_FRAME
+#ifdef HAVE_LZ4FRAME_H
/* Local copy of XXH32() algorithm as found in https://github.com/lz4/lz4/blob/v1.7.5/lib/xxhash.c
as some packagers are not providing xxhash.h in liblz4 */
typedef struct {
@@ -459,7 +456,7 @@ static guint XXH32(const void* input, size_t len, guint seed)
else
return XXH32_endian(input, len, seed, XXH_bigEndian);
}
-#endif /* HAVE_LZ4_FRAME */
+#endif /* HAVE_LZ4FRAME_H */
static const char *
kafka_error_to_str(kafka_error_t error)
@@ -820,7 +817,7 @@ dissect_kafka_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int s
break;
#endif
case KAFKA_MESSAGE_CODEC_LZ4:
-#ifdef HAVE_LZ4_FRAME
+#ifdef HAVE_LZ4FRAME_H
raw = kafka_get_bytes(subtree, tvb, pinfo, offset);
offset += 4;
if (raw) {
@@ -910,7 +907,7 @@ dissect_kafka_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int s
offset += compressed_size;
}
break;
-#endif /* HAVE_LZ4_FRAME */
+#endif /* HAVE_LZ4FRAME_H */
case KAFKA_MESSAGE_CODEC_NONE:
default: