aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-10-10 09:48:54 +0000
committerGuy Harris <guy@alum.mit.edu>2003-10-10 09:48:54 +0000
commitbd2ea47524fe1cb574cadbe9448ce918ee3d58e2 (patch)
tree0c7c8669aefcea2eedb7451ef282073bdcfdc134
parente75b86fab1d1f5841046dc3dff1ae1fbb679d77b (diff)
Configure whether we have WinPcap based on whether WINPCAP_VERSION is
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. svn path=/trunk/; revision=8660
-rw-r--r--Makefile.nmake9
-rw-r--r--capture-wpcap.c35
-rw-r--r--config.h.win326
-rw-r--r--config.nmake20
4 files changed, 61 insertions, 9 deletions
diff --git a/Makefile.nmake b/Makefile.nmake
index a2698cd5f8..b02a968230 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -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
diff --git a/capture-wpcap.c b/capture-wpcap.c
index 36f232f277..d9ece52ba7 100644
--- a/capture-wpcap.c
+++ b/capture-wpcap.c
@@ -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
/*
diff --git a/config.h.win32 b/config.h.win32
index 15b1380ff6..c578948398 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -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
diff --git a/config.nmake b/config.nmake
index df85ec92f5..9a9f48a4a7 100644
--- a/config.nmake
+++ b/config.nmake
@@ -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