Skip to content

Commit

Permalink
IO plugins for libpcap
Browse files Browse the repository at this point in the history
  • Loading branch information
raybellis authored and mcr committed Mar 2, 2020
1 parent 1cd3b0b commit 6796dc9
Show file tree
Hide file tree
Showing 12 changed files with 390 additions and 82 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ set(PROJECT_SOURCE_LIST_C
optimize.c
pcap-common.c
pcap.c
pcap-ioplugin.c
savefile.c
sf-pcapng.c
sf-pcap.c
Expand Down
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ MODULE_C_SRC = @MODULE_C_SRC@
REMOTE_C_SRC = @REMOTE_C_SRC@
COMMON_C_SRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
fmtutils.c \
savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
pcap-ioplugin.c savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
bpf_image.c bpf_filter.c bpf_dump.c
GENERATED_C_SRC = scanner.c grammar.c
LIBOBJS = @LIBOBJS@
Expand Down Expand Up @@ -325,6 +325,7 @@ EXTRA_DIST = \
pcap-enet.c \
pcap-haiku.cpp \
pcap-int.h \
pcap-ioplugin.c \
pcap-libdlpi.c \
pcap-linux.c \
pcap-namedb.h \
Expand Down
1 change: 1 addition & 0 deletions Win32/Prj/wpcap.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Com
<ClCompile Include="..\..\pcap-rpcap.c" />
<ClCompile Include="..\..\pcap-win32.c" />
<ClCompile Include="..\..\pcap.c" />
<ClCompile Include="..\..\pcap-ioplugin.c" />
<ClCompile Include="..\..\savefile.c" />
<ClCompile Include="..\..\scanner.c" />
<ClCompile Include="..\..\sf-pcapng.c" />
Expand Down
9 changes: 9 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
/* Define to 1 if you have the declaration of `ether_hostton' */
#undef HAVE_DECL_ETHER_HOSTTON

/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

/* Define to 1 if you have the `dlopen' function. */
#undef HAVE_DLOPEN

/* Define to 1 if `dl_module_id_1' is a member of `dl_hp_ppa_info_t'. */
#undef HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1

Expand Down Expand Up @@ -75,6 +81,9 @@
/* Define to 1 if you have the `dag' library (-ldag). */
#undef HAVE_LIBDAG

/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL

/* if libdlpi exists */
#undef HAVE_LIBDLPI

Expand Down
69 changes: 69 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -11695,6 +11695,75 @@ fi

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if ${ac_cv_lib_dl_dlopen+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBDL 1
_ACEOF

LIBS="-ldl $LIBS"

fi

for ac_header in dlfcn.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
if test "x$ac_cv_header_dlfcn_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_DLFCN_H 1
_ACEOF

fi

done

for ac_func in dlopen
do :
ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
if test "x$ac_cv_func_dlopen" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_DLOPEN 1
_ACEOF

fi
done


# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2662,6 +2662,11 @@ if test "x$enable_rdma" != "xno"; then
AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
fi

dnl check for dynamic gzip support
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_HEADERS(dlfcn.h)
AC_CHECK_FUNCS(dlopen)

AC_PROG_INSTALL

AC_CONFIG_HEADER(config.h)
Expand Down
21 changes: 21 additions & 0 deletions pcap-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ extern "C" {
((ull & 0x000000000000ff00ULL) << 40) | \
((ull & 0x00000000000000ffULL) << 56)

/*
* Setting O_BINARY on DOS/Windows is a bit tricky
*/
#if defined(_WIN32)
#define SET_BINMODE(f) _setmode(_fileno(f), _O_BINARY)
#elif defined(MSDOS)
#if defined(__HIGHC__)
#define SET_BINMODE(f) setmode(f, O_BINARY)
#else
#define SET_BINMODE(f) setmode(fileno(f), O_BINARY)
#endif
#else
#define SET_BINMODE(f) do {} while(0)
#endif


/*
* Maximum snapshot length.
*
Expand Down Expand Up @@ -560,6 +576,11 @@ int pcap_parsesrcstr_ex(const char *, int *, char *, char *,
extern int pcap_debug;
#endif

/*
* Internal interfaces for I/O plugins
*/
const pcap_ioplugin_t* pcap_ioplugin_init(const char *name);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 6796dc9

Please sign in to comment.