Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,25 @@ if(NOT DISABLE_DPDK)
endif()
endif()

#
# Plugin loader — always compiled, discovers pcap-*.so at runtime.
#
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-plugin.c)
set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${CMAKE_DL_LIBS})

#
# Plugin directory (build-time default).
# Exposed as plugindir in libpcap.pc so external projects can
# query it with: pkg-config --variable=plugindir libpcap
#
set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/lib/pcap/plugins" CACHE STRING
"Plugin directory for pcap-*.so modules")
add_definitions(-DPCAP_PLUGIN_DIR="${PLUGIN_DIR}")

check_function_exists(secure_getenv HAVE_SECURE_GETENV)
check_function_exists(issetugid HAVE_ISSETUGID)
check_function_exists(getauxval HAVE_GETAUXVAL)

# Check for Bluetooth sniffing support
if(NOT DISABLE_BLUETOOTH)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down Expand Up @@ -3574,6 +3593,7 @@ if(NOT MSVC)
set(RPATH "")
endif()
endif()
set(plugindir "${PLUGIN_DIR}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin)
Expand Down
8 changes: 7 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ sbindir = @sbindir@
includedir = @includedir@
# Pathname of directory to install the library
libdir = @libdir@
# Pathname of directory to install plugin modules
plugindir = @plugindir@
# Pathname of directory to install the man pages
mandir = @mandir@

Expand All @@ -53,7 +55,7 @@ MKDEP = @MKDEP@
CCOPT = @V_CCOPT@
SHLIB_CCOPT = @V_SHLIB_CCOPT@
INCLS = -I. @V_INCLS@
DEFS = -DBUILDING_PCAP -Dpcap_EXPORTS @DEFS@ @V_DEFS@
DEFS = -DBUILDING_PCAP -Dpcap_EXPORTS -DPCAP_PLUGIN_DIR='"$(plugindir)"' @DEFS@ @V_DEFS@
ADDLOBJS = @ADDLOBJS@
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
LIBS = @LIBS@
Expand Down Expand Up @@ -114,6 +116,7 @@ PUBHDR = \
pcap/nflog.h \
pcap/pcap-inttypes.h \
pcap/pcap.h \
pcap/pcap-plugin.h \
pcap/sll.h \
pcap/socket.h \
pcap/usb.h \
Expand All @@ -132,6 +135,7 @@ HDR = $(PUBHDR) \
optimize.h \
pcap-common.h \
pcap-int.h \
pcap-plugin.h \
pcap-rpcap.h \
pcap-types.h \
pcap-usb-linux-common.h \
Expand Down Expand Up @@ -316,6 +320,8 @@ EXTRA_DIST = \
pcap-netmap.h \
pcap-npf.c \
pcap-null.c \
pcap-plugin.c \
pcap-plugin.h \
pcap-rdmasniff.c \
pcap-rdmasniff.h \
pcap-rpcap.c \
Expand Down
9 changes: 9 additions & 0 deletions cmakeconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#cmakedefine HAVE_FSEEKO 1

/* Define to 1 if you have the `secure_getenv' function. */
#cmakedefine HAVE_SECURE_GETENV 1

/* Define to 1 if you have the `issetugid' function. */
#cmakedefine HAVE_ISSETUGID 1

/* Define to 1 if you have the `getauxval' function. */
#cmakedefine HAVE_GETAUXVAL 1

/* Define to 1 if you have the `getspnam' function. */
#cmakedefine HAVE_GETSPNAM 1

Expand Down
24 changes: 24 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,30 @@ if test "x$enable_rdma" != "xno"; then
AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
fi

#
# Plugin loader — always compiled, discovers pcap-*.so at runtime.
# Needs -ldl on systems where dlopen is in libdl (not needed on
# FreeBSD, musl, etc. where it is in libc).
#
MODULE_C_SRC="$MODULE_C_SRC pcap-plugin.c"
AC_SEARCH_LIBS([dlopen], [dl])

AC_CHECK_FUNCS([secure_getenv issetugid getauxval])

# Plugin directory (build-time default).
# Exposed as plugindir in libpcap.pc so external projects can
# query it with: pkg-config --variable=plugindir libpcap
plugindir='${libdir}/pcap/plugins'
AC_ARG_WITH([plugin-dir],
AS_HELP_STRING([--with-plugin-dir=DIR],
[plugin directory @<:@LIBDIR/pcap/plugins@:>@]),
[
if test "$withval" != no && test "$withval" != yes; then
plugindir="$withval"
fi
])
AC_SUBST(plugindir)

#
# If this is a platform where we need to have the .pc file and
# pcap-config script supply an rpath option to specify the directory
Expand Down
1 change: 1 addition & 0 deletions libpcap.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
includedir="@includedir@"
libdir="@libdir@"
plugindir="@plugindir@"

Name: libpcap
Description: Platform-independent network traffic capture library
Expand Down
6 changes: 5 additions & 1 deletion pcap-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,14 @@ FILE *pcapint_charset_fopen(const char *path, const char *mode);
*/
#ifdef _WIN32
#define pcap_code_handle_t HMODULE
#else
#define pcap_code_handle_t void *
#endif

pcap_code_handle_t pcapint_load_code(const char *);
void *pcapint_find_function(pcap_code_handle_t, const char *);
#endif
void pcapint_unload_code(pcap_code_handle_t);


/*
* Internal interfaces for doing user-mode filtering of packets and
Expand Down
Loading