2 * Try to load WinPcap DLL at run-time.
4 * $Id: capture-wpcap.c,v 1.3 2002/08/28 21:00:05 jmayer Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 2001 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
38 #include "tools/lemon/cppmagic.h"
40 gboolean has_wpcap = FALSE;
45 static char* (*p_pcap_lookupdev) (char *);
46 static void (*p_pcap_close) (pcap_t *);
47 static int (*p_pcap_stats) (pcap_t *, struct pcap_stat *);
48 static int (*p_pcap_dispatch) (pcap_t *, int, pcap_handler, guchar *);
49 static int (*p_pcap_snapshot) (pcap_t *);
50 static int (*p_pcap_datalink) (pcap_t *);
51 static int (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
52 static char* (*p_pcap_geterr) (pcap_t *);
53 static int (*p_pcap_compile) (pcap_t *, struct bpf_program *, char *, int,
55 static int (*p_pcap_lookupnet) (char *, bpf_u_int32 *, bpf_u_int32 *,
57 static pcap_t* (*p_pcap_open_live) (char *, int, int, int, char *);
58 static int (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
65 #define SYM(x) STRINGIFY(x) , (gpointer) &CONCAT(p_,x)
71 /* These are the symbols I need from Wpcap */
72 symbol_table_t symbols[] = {
88 GModule *wh; /* wpcap handle */
91 wh = g_module_open("wpcap", 0);
98 while (sym && sym->name) {
99 if (!g_module_symbol(wh, sym->name, sym->ptr)) {
110 pcap_lookupdev (char *a)
113 return p_pcap_lookupdev(a);
117 pcap_close(pcap_t *a)
124 pcap_stats(pcap_t *a, struct pcap_stat *b)
127 return p_pcap_stats(a, b);
131 pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d)
134 return p_pcap_dispatch(a, b, c, d);
139 pcap_snapshot(pcap_t *a)
142 return p_pcap_snapshot(a);
147 pcap_datalink(pcap_t *a)
150 return p_pcap_datalink(a);
154 pcap_setfilter(pcap_t *a, struct bpf_program *b)
157 return p_pcap_setfilter(a, b);
161 pcap_geterr(pcap_t *a)
164 return p_pcap_geterr(a);
168 pcap_compile(pcap_t *a, struct bpf_program *b, char *c, int d,
172 return p_pcap_compile(a, b, c, d, e);
176 pcap_lookupnet(char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
179 return p_pcap_lookupnet(a, b, c, d);
183 pcap_open_live(char *a, int b, int c, int d, char *e)
186 return p_pcap_open_live(a, b, c, d, e);
190 pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
193 return p_pcap_loop(a, b, c, d);
196 #else /* HAVE_LIBPCAP */
205 #endif /* HAVE_LIBPCAP */