Configure whether we have WinPcap based on whether WINPCAP_VERSION is
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 10 Oct 2003 09:48:54 +0000 (09:48 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 10 Oct 2003 09:48:54 +0000 (09:48 +0000)
set in the config.nmake file.

Configure whether we have pcap_findalldevs() based on whether
WINPCAP_VERSION is 2.3 (if so, we don't) or 3.0 or 3.1 (if so, we do).

WinPcap 3.0 has the new libpcap declarations of "pcap_lookupnet()" and
"pcap_open_live()" in which the first argument is a "const char *"
rather than a "char *"; declare the functions and pointers to them
appropriately based on the version of WinPcap.

If we don't have pcap_findalldevs(), don't declare a pointer to it, as
we don't have a declaration of pcap_if_t.

We also need to refer to "pcap_freealldevs()", so make a pointer for it.

"symbols[]" is a const array; make the pointer to elements in it a const
pointer.

Fix some typoes.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8660 f5534014-38df-0310-8fa8-9805f1628bb7

Makefile.nmake
capture-wpcap.c
config.h.win32
config.nmake

index a2698cd5f8e110f5c5d039ffc20937ff09ade2ff..b02a9682303f4b253e754415c60434f76ab8bee8 100644 (file)
@@ -1,7 +1,7 @@
 ## Makefile for building ethereal.exe with Microsoft C and nmake
 ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
 #
-# $Id: Makefile.nmake,v 1.344 2003/10/06 19:25:20 guy Exp $
+# $Id: Makefile.nmake,v 1.345 2003/10/10 09:48:54 guy Exp $
 
 include config.nmake
 include <win32.mak>
@@ -566,7 +566,12 @@ randpkt.exe        : $(randpkt_OBJECTS) $(EXTRA_OBJECTS)
 <<
 
 config.h       : config.h.win32 config.nmake
-       sed -e s/@VERSION@/$(VERSION)/ -e "s/@HAVE_GNU_ADNS@/$(ADNS_CONFIG)/" < config.h.win32 > $@
+       sed -e s/@VERSION@/$(VERSION)/ \
+           -e "s/@HAVE_GNU_ADNS@/$(ADNS_CONFIG)/" \
+           -e "s/@HAVE_LIBPCAP@/$(WINPCAP_CONFIG)/" \
+           -e "s/@HAVE_PCAP_FINDALLDEVS@/$(PCAP_FINDALLDEVS_CONFIG)/" \
+           -e "s/@WPCAP_CONSTIFIED@/$(WPCAP_CONSTIFIED_CONFIG)/" \
+           < config.h.win32 > $@
 
 ps.c   : rdps.exe print.ps
        rdps print.ps ps.c
index 36f232f27709ac6e9d8729516bf195bd1ec22c00..d9ece52ba78be1cf8d73897fc2b56e38e1271487 100644 (file)
@@ -3,7 +3,7 @@
  * time, so that we only need one Ethereal binary and one Tethereal binary
  * for Windows, regardless of whether WinPcap is installed or not.
  *
- * $Id: capture-wpcap.c,v 1.5 2003/10/10 06:05:48 guy Exp $
+ * $Id: capture-wpcap.c,v 1.6 2003/10/10 09:48:54 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -55,11 +55,20 @@ static int     (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
 static char*   (*p_pcap_geterr) (pcap_t *);
 static int     (*p_pcap_compile) (pcap_t *, struct bpf_program *, char *, int,
                        bpf_u_int32);
+#ifdef WPCAP_CONSTIFIED
+static int     (*p_pcap_lookupnet) (const char *, bpf_u_int32 *, bpf_u_int32 *,
+                       char *);
+static pcap_t* (*p_pcap_open_live) (const char *, int, int, int, char *);
+#else
 static int     (*p_pcap_lookupnet) (char *, bpf_u_int32 *, bpf_u_int32 *,
                        char *);
 static pcap_t* (*p_pcap_open_live) (char *, int, int, int, char *);
+#endif
 static int     (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
+#ifdef HAVE_PCAP_FINDALLDEVS
 static int     (*p_pcap_findalldevs) (pcap_if_t **, char *);
+static void    (*p_pcap_freealldevs) (pcap_if_t *);
+#endif
 static const char *(*p_pcap_lib_version) (void);
 
 typedef struct {
@@ -88,13 +97,16 @@ load_wpcap(void)
                SYM(pcap_lookupnet, FALSE),
                SYM(pcap_open_live, FALSE),
                SYM(pcap_loop, FALSE),
+#ifdef HAVE_PCAP_FINDALLDEVS
                SYM(pcap_findalldevs, TRUE),
+               SYM(pcap_freealldevs, TRUE),
+#endif
                SYM(pcap_lib_version, TRUE),
                { NULL, NULL, FALSE }
        };
 
        GModule         *wh; /* wpcap handle */
-       symbol_table_t  *sym;
+       const symbol_table_t    *sym;
 
        wh = g_module_open("wpcap", 0);
 
@@ -192,14 +204,22 @@ pcap_compile(pcap_t *a, struct bpf_program *b, char *c, int d,
 }
 
 int
+#ifdef WPCAP_CONSTIFIED
+pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
+#else
 pcap_lookupnet(char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
+#endif
 {
        g_assert(has_wpcap);
        return p_pcap_lookupnet(a, b, c, d);
 }
 
 pcap_t*
+#ifdef WPCAP_CONSTIFIED
+pcap_open_live(const char *a, int b, int c, int d, char *e)
+#else
 pcap_open_live(char *a, int b, int c, int d, char *e)
+#endif
 {
        g_assert(has_wpcap);
        return p_pcap_open_live(a, b, c, d, e);
@@ -216,9 +236,16 @@ pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
 int
 pcap_findalldevs(pcap_if_t **a, char *b)
 {
-       g_assert(has_wpcap && p_pcap_findalldevs != NULL)
+       g_assert(has_wpcap && p_pcap_findalldevs != NULL);
        return p_pcap_findalldevs(a, b);
 }
+
+void
+pcap_freealldevs(pcap_if_t *a)
+{
+       g_assert(has_wpcap && p_pcap_freealldevs != NULL);
+       p_pcap_freealldevs(a);
+}
 #endif
 
 /*
@@ -237,7 +264,7 @@ get_interface_list(int *err, char *err_str)
 
 #ifdef HAVE_PCAP_FINDALLDEVS
        if (p_pcap_findalldevs != NULL)
-               return get_interface_list_findalldevs(err, errstr);
+               return get_interface_list_findalldevs(err, err_str);
 #endif
 
        /*
index 15b1380ff6e141ca3d3f1c3da4ac5b4a591b951a..c5789483989fae6339506dba46aa60219ad45f0a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: config.h.win32,v 1.40 2003/06/12 09:45:42 guy Exp $ */
+/* $Id: config.h.win32,v 1.41 2003/10/10 09:48:54 guy Exp $ */
 /* config.h.win32 Generated manually. :-) */
 /* config.h.  Generated automatically by configure.  */
 /* config.h.in.  Generated automatically from configure.in by autoheader.  */
@@ -41,7 +41,9 @@
 
 #define NEED_MKSTEMP 1
 
-#define HAVE_LIBPCAP 1
+@HAVE_LIBPCAP@
+@HAVE_PCAP_FINDALLDEVS@
+@WPCAP_CONSTIFIED@
 
 #define HAVE_NET_SNMP 1
 #define HAVE_SOME_SNMP 1
index df85ec92f5e14bc9dc70b50cdc9a9251defd4cdb..9a9f48a4a7897b23a687db7242d9996f82dafb14 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: config.nmake,v 1.59 2003/09/08 03:13:14 gerald Exp $
+# $Id: config.nmake,v 1.60 2003/10/10 09:48:54 guy Exp $
 
 VERSION=0.9.15
 #
@@ -15,6 +15,8 @@ VERSION=0.9.15
 RC_VERSION=0,9,15
 WTAP_VERSION=0.0
 
+WINPCAP_VERSION=2.3
+
 GTK_VERSION=1.3
 GLIB_VERSION=2.0
 
@@ -123,6 +125,22 @@ GTK_LIBS=$(GTK_DIR)\lib\gtk-win32-$(GTK_VERSION).lib \
        $(GLIB_LIBS)
 !ENDIF
 
+!IFDEF WINPCAP_VERSION
+# Nmake uses carets to escape special characters
+WINPCAP_CONFIG=^#define HAVE_LIBPCAP 1
+!IF "$(WINPCAP_VERSION)" == "3.0" || "$(WINPCAP_VERSION)" == "3.1"
+PCAP_FINDALLDEVS_CONFIG=^#define HAVE_PCAP_FINDALLDEVS 1
+WPCAP_CONSTIFIED_CONFIG=^#define WPCAP_CONSTIFIED 1
+!ELSE
+PCAP_FINDALLDEVS_CONFIG=
+WPCAP_CONSTIFIED=
+!ENDIF
+!ELSE
+WINPCAP_CONFIG=
+PCAP_FINDALLDEVS_CONFIG=
+WPCAP_CONSTIFIED=
+!ENDIF
+
 !IFDEF ADNS_DIR
 ADNS_CFLAGS=/I$(ADNS_DIR)\src /I$(ADNS_DIR)\adns_win32
 ADNS_LIBS=$(ADNS_DIR)\adns_win32\lib\adns_dll.lib