From fa67586811765d88d3b4108b3e5b4e51bb07868f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Thu, 7 Aug 2014 00:15:00 +0200 Subject: [PATCH] wpcap: Implement pcap_lib_version. --- configure | 64 ++++++++++++++++++++++++++++++++++++++++++ configure.ac | 12 ++++++++ dlls/wpcap/Makefile.in | 4 +++ dlls/wpcap/wpcap.c | 31 ++++++++++++++++++++ dlls/wpcap/wpcap.spec | 2 +- include/config.h.in | 3 ++ 6 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 dlls/wpcap/wpcap.c diff --git a/configure b/configure index 62e8abc076d..118fbc481c5 100755 --- a/configure +++ b/configure @@ -676,6 +676,7 @@ XSLT_LIBS XSLT_CFLAGS XML2_LIBS XML2_CFLAGS +LIBPCAP X_EXTRA_LIBS X_LIBS X_PRE_LIBS @@ -822,6 +823,7 @@ with_opencl with_opengl with_osmesa with_oss +with_pcap with_png with_pthread with_sane @@ -2091,6 +2093,7 @@ Optional Packages: --without-opengl do not use OpenGL --without-osmesa do not use the OSMesa library --without-oss do not use the OSS sound support + --without-pcap do not use the Packet Capture library --without-png do not use PNG --without-pthread do not use the pthread library --without-sane do not use SANE (scanner support) @@ -3322,6 +3325,12 @@ if test "${with_oss+set}" = set; then : fi +# Check whether --with-pcap was given. +if test "${with_pcap+set}" = set; then : + withval=$with_pcap; if test "x$withval" = "xno"; then ac_cv_header_pcap_pcap_h=no; fi +fi + + # Check whether --with-png was given. if test "${with_png+set}" = set; then : withval=$with_png; @@ -6495,6 +6504,7 @@ for ac_header in \ netinet/in_systm.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ + pcap/pcap.h \ poll.h \ port.h \ process.h \ @@ -10510,6 +10520,60 @@ esac fi test "x$ac_cv_lib_OpenCL_clGetPlatformInfo" != xyes && enable_opencl=${enable_opencl:-no} +if test "$ac_cv_header_pcap_pcap_h" = "yes" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_create in -lpcap" >&5 +$as_echo_n "checking for pcap_create in -lpcap... " >&6; } +if ${ac_cv_lib_pcap_pcap_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcap $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 pcap_create (); +int +main () +{ +return pcap_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pcap_pcap_create=yes +else + ac_cv_lib_pcap_pcap_create=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_pcap_pcap_create" >&5 +$as_echo "$ac_cv_lib_pcap_pcap_create" >&6; } +if test "x$ac_cv_lib_pcap_pcap_create" = xyes; then : + LIBPCAP="-lpcap" + +fi + +fi +if test "x$ac_cv_lib_pcap_pcap_create" != xyes; then : + case "x$with_pcap" in + x) as_fn_append wine_notices "|pcap ${notice_platform}development files not found, wpcap won't be supported." ;; + xno) ;; + *) as_fn_error $? "pcap ${notice_platform}development files not found, wpcap won't be supported. +This is an error since --with-pcap was requested." "$LINENO" 5 ;; +esac +fi +test "x$ac_cv_lib_pcap_pcap_create" != xyes && enable_wpcap=${enable_wpcap:-no} + if test "x$with_xml" != "xno" then diff --git a/configure.ac b/configure.ac index deb6b191497..7de7a87a31f 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,8 @@ AC_ARG_WITH(opencl, AS_HELP_STRING([--without-opencl],[do not use OpenCL]), AC_ARG_WITH(opengl, AS_HELP_STRING([--without-opengl],[do not use OpenGL])) AC_ARG_WITH(osmesa, AS_HELP_STRING([--without-osmesa],[do not use the OSMesa library])) AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound support])) +AC_ARG_WITH(pcap, AS_HELP_STRING([--without-pcap],[do not use the Packet Capture library]), + [if test "x$withval" = "xno"; then ac_cv_header_pcap_pcap_h=no; fi]) AC_ARG_WITH(png, AS_HELP_STRING([--without-png],[do not use PNG])) AC_ARG_WITH(pthread, AS_HELP_STRING([--without-pthread],[do not use the pthread library]), [if test "x$withval" = "xno"; then ac_cv_header_pthread_h=no; fi]) @@ -448,6 +450,7 @@ AC_CHECK_HEADERS(\ netinet/in_systm.h \ netinet/tcp.h \ netinet/tcp_fsm.h \ + pcap/pcap.h \ poll.h \ port.h \ process.h \ @@ -1268,6 +1271,15 @@ WINE_NOTICE_WITH(opencl,[test "x$ac_cv_lib_OpenCL_clGetPlatformInfo" != xyes], [OpenCL ${notice_platform}development files not found, OpenCL won't be supported.]) test "x$ac_cv_lib_OpenCL_clGetPlatformInfo" != xyes && enable_opencl=${enable_opencl:-no} +dnl **** Check for libpcap **** +if test "$ac_cv_header_pcap_pcap_h" = "yes" +then + AC_CHECK_LIB(pcap,pcap_create,[AC_SUBST(LIBPCAP,["-lpcap"])]) +fi +WINE_NOTICE_WITH(pcap,[test "x$ac_cv_lib_pcap_pcap_create" != xyes], + [pcap ${notice_platform}development files not found, wpcap won't be supported.]) +test "x$ac_cv_lib_pcap_pcap_create" != xyes && enable_wpcap=${enable_wpcap:-no} + dnl **** Check for libxml2 **** if test "x$with_xml" != "xno" diff --git a/dlls/wpcap/Makefile.in b/dlls/wpcap/Makefile.in index 5841adc57d3..70a0fec38d2 100644 --- a/dlls/wpcap/Makefile.in +++ b/dlls/wpcap/Makefile.in @@ -1 +1,5 @@ MODULE = wpcap.dll +EXTRALIBS = @LIBPCAP@ + +C_SRCS = \ + wpcap.c diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c new file mode 100644 index 00000000000..e1432946afb --- /dev/null +++ b/dlls/wpcap/wpcap.c @@ -0,0 +1,31 @@ +/* + * WPcap.dll Proxy. + * + * Copyright 2011 André Hentschel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wpcap); + +const char* CDECL wine_pcap_lib_version(void) +{ + const char* ret = pcap_lib_version(); + TRACE("%s\n", debugstr_a(ret)); + return ret; +} diff --git a/dlls/wpcap/wpcap.spec b/dlls/wpcap/wpcap.spec index 81df1b94aba..1b36f335afd 100644 --- a/dlls/wpcap/wpcap.spec +++ b/dlls/wpcap/wpcap.spec @@ -33,7 +33,7 @@ @ stub pcap_getevent @ stub pcap_getnonblock @ stub pcap_is_swapped -@ stub pcap_lib_version +@ cdecl pcap_lib_version() wine_pcap_lib_version @ stub pcap_list_datalinks @ stub pcap_live_dump @ stub pcap_live_dump_ended diff --git a/include/config.h.in b/include/config.h.in index 50cfcb8658f..a58c0b5f968 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -570,6 +570,9 @@ /* Define to 1 if `numaudioengines' is a member of `oss_sysinfo'. */ #undef HAVE_OSS_SYSINFO_NUMAUDIOENGINES +/* Define to 1 if you have the header file. */ +#undef HAVE_PCAP_PCAP_H + /* Define to 1 if you have the `pclose' function. */ #undef HAVE_PCLOSE