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>
This commit is contained in:
Joerg Mayer 2018-04-13 17:41:20 +02:00 committed by Anders Broman
parent 08c2344458
commit 0d31ec328f
4 changed files with 21 additions and 8 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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: