From 0d31ec328f2c523cfc4655f1674a5f0eae80923f Mon Sep 17 00:00:00 2001 From: Joerg Mayer Date: Fri, 13 Apr 2018 17:41:20 +0200 Subject: [PATCH] Check for HAVE_LZ4FRAME_H in the LZ4 detection process and use it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I919621b8c4c809eb181d563251eeb099b767ad82 Reviewed-on: https://code.wireshark.org/review/26940 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin Reviewed-by: Jörg Mayer Reviewed-by: Anders Broman --- acinclude.m4 | 4 ++++ cmake/modules/FindLZ4.cmake | 9 +++++++++ cmakeconfig.h.in | 3 +++ epan/dissectors/packet-kafka.c | 13 +++++-------- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index abccee43ab..dbcea8c92b 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 13ae378ddb..0b4c8d02ab 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 566bfc9d34..d3881196a1 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 71fc71502b..2d8045b19c 100644 --- a/epan/dissectors/packet-kafka.c +++ b/epan/dissectors/packet-kafka.c @@ -21,12 +21,9 @@ #ifdef HAVE_SNAPPY #include #endif -#ifdef HAVE_LZ4 +#ifdef HAVE_LZ4FRAME_H #include -#if LZ4_VERSION_NUMBER >= 10500 #include -#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: