aboutsummaryrefslogtreecommitdiffstats
path: root/capture-wpcap.c
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 /capture-wpcap.c
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
Diffstat (limited to 'capture-wpcap.c')
-rw-r--r--capture-wpcap.c35
1 files changed, 31 insertions, 4 deletions
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
/*