Try using the new generic plugin Makefile.nmake.
[obnox/wireshark/wip.git] / capture-wpcap.c
1 /* capture-wpcap.c
2  * WinPcap-specific interfaces for capturing.  We load WinPcap at run
3  * time, so that we only need one Ethereal binary and one Tethereal binary
4  * for Windows, regardless of whether WinPcap is installed or not.
5  *
6  * $Id$
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 2001 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_LIBPCAP
32 #include <pcap.h>
33 #endif
34
35 #include <glib.h>
36 #include <gmodule.h>
37
38 #include "capture-pcap-util.h"
39 #include "capture-pcap-util-int.h"
40
41 /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
42 #include "tools/lemon/cppmagic.h"
43
44
45 #define MAX_WIN_IF_NAME_LEN 511
46
47
48 gboolean has_wpcap = FALSE;
49
50 #ifdef HAVE_LIBPCAP
51
52 static char*   (*p_pcap_lookupdev) (char *);
53 static void    (*p_pcap_close) (pcap_t *);
54 static int     (*p_pcap_stats) (pcap_t *, struct pcap_stat *);
55 static int     (*p_pcap_dispatch) (pcap_t *, int, pcap_handler, guchar *);
56 static int     (*p_pcap_snapshot) (pcap_t *);
57 static int     (*p_pcap_datalink) (pcap_t *);
58 static int     (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
59 static char*   (*p_pcap_geterr) (pcap_t *);
60 static int     (*p_pcap_compile) (pcap_t *, struct bpf_program *, char *, int,
61                         bpf_u_int32);
62 #ifdef WPCAP_CONSTIFIED
63 static int     (*p_pcap_lookupnet) (const char *, bpf_u_int32 *, bpf_u_int32 *,
64                         char *);
65 static pcap_t* (*p_pcap_open_live) (const char *, int, int, int, char *);
66 #else
67 static int     (*p_pcap_lookupnet) (char *, bpf_u_int32 *, bpf_u_int32 *,
68                         char *);
69 static pcap_t* (*p_pcap_open_live) (char *, int, int, int, char *);
70 #endif
71 static int     (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
72 static void    (*p_pcap_freecode) (struct bpf_program *);
73 #ifdef HAVE_PCAP_FINDALLDEVS
74 static int     (*p_pcap_findalldevs) (pcap_if_t **, char *);
75 static void    (*p_pcap_freealldevs) (pcap_if_t *);
76 #endif
77 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
78 static int (*p_pcap_datalink_name_to_val) (const char *);
79 #endif
80 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
81 static const char *(*p_pcap_datalink_val_to_name) (int);
82 #endif
83 static const char *(*p_pcap_lib_version) (void);
84 static int     (*p_pcap_setbuff) (pcap_t *, int dim);
85 static int     (*p_pcap_next_ex) (pcap_t *, struct pcap_pkthdr **pkt_header, const u_char **pkt_data);
86
87 typedef struct {
88         const char      *name;
89         gpointer        *ptr;
90         gboolean        optional;
91 } symbol_table_t;
92
93 #define SYM(x, y)       { STRINGIFY(x) , (gpointer) &CONCAT(p_,x), y }
94
95 void
96 load_wpcap(void)
97 {
98
99         /* These are the symbols I need or want from Wpcap */
100         static const symbol_table_t     symbols[] = {
101                 SYM(pcap_lookupdev, FALSE),
102                 SYM(pcap_close, FALSE),
103                 SYM(pcap_stats, FALSE),
104                 SYM(pcap_dispatch, FALSE),
105                 SYM(pcap_snapshot, FALSE),
106                 SYM(pcap_datalink, FALSE),
107                 SYM(pcap_setfilter, FALSE),
108                 SYM(pcap_geterr, FALSE),
109                 SYM(pcap_compile, FALSE),
110                 SYM(pcap_lookupnet, FALSE),
111                 SYM(pcap_open_live, FALSE),
112                 SYM(pcap_loop, FALSE),
113                 SYM(pcap_freecode, TRUE),
114 #ifdef HAVE_PCAP_FINDALLDEVS
115                 SYM(pcap_findalldevs, TRUE),
116                 SYM(pcap_freealldevs, TRUE),
117 #endif
118 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
119                 SYM(pcap_datalink_name_to_val, TRUE),
120 #endif
121 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
122                 SYM(pcap_datalink_val_to_name, TRUE),
123 #endif
124                 SYM(pcap_lib_version, TRUE),
125                 SYM(pcap_setbuff, TRUE),
126                 SYM(pcap_next_ex, TRUE),
127                 { NULL, NULL, FALSE }
128         };
129
130         GModule         *wh; /* wpcap handle */
131         const symbol_table_t    *sym;
132
133         wh = g_module_open("wpcap", 0);
134
135         if (!wh) {
136                 return;
137         }
138
139         sym = symbols;
140         while (sym->name) {
141                 if (!g_module_symbol(wh, sym->name, sym->ptr)) {
142                         if (sym->optional) {
143                                 /*
144                                  * We don't care if it's missing; we just
145                                  * don't use it.
146                                  */
147                                 *sym->ptr = NULL;
148                         } else {
149                                 /*
150                                  * We require this symbol.
151                                  */
152                                 return;
153                         }
154                 }
155                 sym++;
156         }
157
158
159         has_wpcap = TRUE;
160 }
161
162 char*
163 pcap_lookupdev (char *a)
164 {
165         g_assert(has_wpcap);
166         return p_pcap_lookupdev(a);
167 }
168
169 void
170 pcap_close(pcap_t *a)
171 {
172         g_assert(has_wpcap);
173         p_pcap_close(a);
174 }
175
176 int
177 pcap_stats(pcap_t *a, struct pcap_stat *b)
178 {
179         g_assert(has_wpcap);
180         return p_pcap_stats(a, b);
181 }
182
183 int
184 pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d)
185 {
186         g_assert(has_wpcap);
187         return p_pcap_dispatch(a, b, c, d);
188 }
189
190 int
191 pcap_snapshot(pcap_t *a)
192 {
193         g_assert(has_wpcap);
194         return p_pcap_snapshot(a);
195 }
196
197 int
198 pcap_datalink(pcap_t *a)
199 {
200         g_assert(has_wpcap);
201         return p_pcap_datalink(a);
202 }
203
204 int
205 pcap_setfilter(pcap_t *a, struct bpf_program *b)
206 {
207         g_assert(has_wpcap);
208         return p_pcap_setfilter(a, b);
209 }
210
211 char*
212 pcap_geterr(pcap_t *a)
213 {
214         g_assert(has_wpcap);
215         return p_pcap_geterr(a);
216 }
217
218 int
219 pcap_compile(pcap_t *a, struct bpf_program *b, char *c, int d,
220             bpf_u_int32 e)
221 {
222         g_assert(has_wpcap);
223         return p_pcap_compile(a, b, c, d, e);
224 }
225
226 int
227 #ifdef WPCAP_CONSTIFIED
228 pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
229 #else
230 pcap_lookupnet(char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
231 #endif
232 {
233         g_assert(has_wpcap);
234         return p_pcap_lookupnet(a, b, c, d);
235 }
236
237 pcap_t*
238 #ifdef WPCAP_CONSTIFIED
239 pcap_open_live(const char *a, int b, int c, int d, char *e)
240 #else
241 pcap_open_live(char *a, int b, int c, int d, char *e)
242 #endif
243 {
244         g_assert(has_wpcap);
245         return p_pcap_open_live(a, b, c, d, e);
246 }
247
248 int
249 pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
250 {
251         g_assert(has_wpcap);
252         return p_pcap_loop(a, b, c, d);
253 }
254
255 void
256 pcap_freecode(struct bpf_program *a)
257 {
258         g_assert(has_wpcap);
259     if(p_pcap_freecode) {
260             p_pcap_freecode(a);
261     }
262 }
263
264 #ifdef HAVE_PCAP_FINDALLDEVS
265 int
266 pcap_findalldevs(pcap_if_t **a, char *b)
267 {
268         g_assert(has_wpcap && p_pcap_findalldevs != NULL);
269         return p_pcap_findalldevs(a, b);
270 }
271
272 void
273 pcap_freealldevs(pcap_if_t *a)
274 {
275         g_assert(has_wpcap && p_pcap_freealldevs != NULL);
276         p_pcap_freealldevs(a);
277 }
278 #endif
279
280 #if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME)
281 /*
282  * Table of DLT_ types, names, and descriptions, for use if the version
283  * of WinPcap we have installed lacks "pcap_datalink_name_to_val()"
284  * or "pcap_datalink_val_to_name()".
285  */
286 struct dlt_choice {
287         const char *name;
288         const char *description;
289         int     dlt;
290 };
291
292 #define DLT_CHOICE(code, description) { #code, description, code }
293 #define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
294
295 static struct dlt_choice dlt_choices[] = {
296         DLT_CHOICE(DLT_NULL, "BSD loopback"),
297         DLT_CHOICE(DLT_EN10MB, "Ethernet"),
298         DLT_CHOICE(DLT_IEEE802, "Token ring"),
299         DLT_CHOICE(DLT_ARCNET, "ARCNET"),
300         DLT_CHOICE(DLT_SLIP, "SLIP"),
301         DLT_CHOICE(DLT_PPP, "PPP"),
302         DLT_CHOICE(DLT_FDDI, "FDDI"),
303         DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"),
304         DLT_CHOICE(DLT_RAW, "Raw IP"),
305 #ifdef DLT_SLIP_BSDOS
306         DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
307 #endif
308 #ifdef DLT_PPP_BSDOS
309         DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
310 #endif
311 #ifdef DLT_ATM_CLIP
312         DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
313 #endif
314 #ifdef DLT_PPP_SERIAL
315         DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
316 #endif
317 #ifdef DLT_PPP_ETHER
318         DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
319 #endif
320 #ifdef DLT_C_HDLC
321         DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
322 #endif
323 #ifdef DLT_IEEE802_11
324         DLT_CHOICE(DLT_IEEE802_11, "802.11"),
325 #endif
326 #ifdef DLT_FRELAY
327         DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
328 #endif
329 #ifdef DLT_LOOP
330         DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
331 #endif
332 #ifdef DLT_ENC
333         DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
334 #endif
335 #ifdef DLT_LINUX_SLL
336         DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
337 #endif
338 #ifdef DLT_LTALK
339         DLT_CHOICE(DLT_LTALK, "Localtalk"),
340 #endif
341 #ifdef DLT_PFLOG
342         DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
343 #endif
344 #ifdef DLT_PRISM_HEADER
345         DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
346 #endif
347 #ifdef DLT_IP_OVER_FC
348         DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
349 #endif
350 #ifdef DLT_SUNATM
351         DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
352 #endif
353 #ifdef DLT_IEEE802_11_RADIO
354         DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"),
355 #endif
356 #ifdef DLT_ARCNET_LINUX
357         DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
358 #endif
359 #ifdef DLT_LINUX_IRDA
360         DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
361 #endif
362 #ifdef DLT_LINUX_LAPD
363         DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
364 #endif
365 #ifdef DLT_LANE8023
366         DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
367 #endif
368 #ifdef DLT_CIP
369         DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"),
370 #endif
371 #ifdef DLT_HDLC
372         DLT_CHOICE(DLT_HDLC, "Cisco HDLC"),
373 #endif
374         DLT_CHOICE_SENTINEL
375 };
376 #endif /* defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) */
377
378 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
379 int
380 pcap_datalink_name_to_val(const char *name)
381 {
382         int i;
383
384         g_assert(has_wpcap);
385
386         if (p_pcap_datalink_name_to_val != NULL)
387                 return p_pcap_datalink_name_to_val(name);
388         else {
389                 /*
390                  * We don't have it in WinPcap; do it ourselves.
391                  */
392                 for (i = 0; dlt_choices[i].name != NULL; i++) {
393                         if (strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
394                             name) == 0)
395                                 return dlt_choices[i].dlt;
396                 }
397                 return -1;
398         }
399 }
400 #endif
401
402 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
403 const char *
404 pcap_datalink_val_to_name(int dlt)
405 {
406         int i;
407
408         g_assert(has_wpcap);
409
410         if (p_pcap_datalink_val_to_name != NULL)
411                 return p_pcap_datalink_val_to_name(dlt);
412         else {
413                 /*
414                  * We don't have it in WinPcap; do it ourselves.
415                  */
416                 for (i = 0; dlt_choices[i].name != NULL; i++) {
417                         if (dlt_choices[i].dlt == dlt)
418                                 return dlt_choices[i].name + sizeof("DLT_") - 1;
419                 }
420                 return NULL;
421         }
422 }
423 #endif
424
425 /* setbuff is win32 specific! */
426 int pcap_setbuff(pcap_t *a, int b)
427 {
428         g_assert(has_wpcap);
429         return p_pcap_setbuff(a, b);
430 }
431
432 /* pcap_next_ex is available since libpcap 0.8 / WinPcap 3.0! */
433 /* (if you get a declaration warning here, try to update to at least WinPcap 3.1b4 develpack) */
434 int pcap_next_ex (pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
435 {
436         g_assert(has_wpcap);
437         return p_pcap_next_ex(a, b, c);
438 }
439
440 /*
441  * This will use "pcap_findalldevs()" if we have it, otherwise it'll
442  * fall back on "pcap_lookupdev()".
443  */
444 GList *
445 get_interface_list(int *err, char *err_str)
446 {
447         GList  *il = NULL;
448         wchar_t *names;
449         char *win95names;
450         char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
451         char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
452         int i, j;
453
454 #ifdef HAVE_PCAP_FINDALLDEVS
455         if (p_pcap_findalldevs != NULL)
456                 return get_interface_list_findalldevs(err, err_str);
457 #endif
458
459         /*
460          * In WinPcap, pcap_lookupdev is implemented by calling
461          * PacketGetAdapterNames.  According to the documentation
462          * I could find:
463          *
464          *      http://www.winpcap.org/docs/man/html/Packet32_8c.html#a43
465          *
466          * this means that:
467          *
468          * On Windows OT (95, 98, Me), pcap_lookupdev returns a sequence
469          * of bytes consisting of:
470          *
471          *      a sequence of null-terminated ASCII strings (i.e., each
472          *      one is terminated by a single 0 byte), giving the names
473          *      of the interfaces;
474          *
475          *      an empty ASCII string (i.e., a single 0 byte);
476          *
477          *      a sequence of null-terminated ASCII strings, giving the
478          *      descriptions of the interfaces;
479          *
480          *      an empty ASCII string.
481          *
482          * On Windows NT (NT 4.0, W2K, WXP, W2K3, etc.), pcap_lookupdev
483          * returns a sequence of bytes consisting of:
484          *
485          *      a sequence of null-terminated double-byte Unicode strings
486          *      (i.e., each one consits of a sequence of double-byte
487          *      characters, terminated by a double-byte 0), giving the
488          *      names of the interfaces;
489          *
490          *      an empty Unicode string (i.e., a double 0 byte);
491          *
492          *      a sequence of null-terminated ASCII strings, giving the
493          *      descriptions of the interfaces;
494          *
495          *      an empty ASCII string.
496          *
497          * The Nth string in the first sequence is the name of the Nth
498          * adapter; the Nth string in the second sequence is the
499          * description of the Nth adapter.
500          */
501
502         names = (wchar_t *)pcap_lookupdev(err_str);
503         i = 0;
504
505         if (names) {
506                 char* desc = 0;
507                 int desc_pos = 0;
508
509                 if (names[0]<256) {
510                         /*
511                          * If names[0] is less than 256 it means the first
512                          * byte is 0.  This implies that we are using Unicode
513                          * characters.
514                          */
515                         while (*(names+desc_pos) || *(names+desc_pos-1))
516                                 desc_pos++;
517                         desc_pos++;     /* Step over the extra '\0' */
518                         desc = (char*)(names + desc_pos); /* cast *after* addition */
519
520                         while (names[i] != 0) {
521                                 /*
522                                  * Copy the Unicode description to an ASCII
523                                  * string.
524                                  */
525                                 j = 0;
526                                 while (*desc != 0) {
527                                         if (j < MAX_WIN_IF_NAME_LEN)
528                                                 ascii_desc[j++] = *desc;
529                                         desc++;
530                                 }
531                                 ascii_desc[j] = '\0';
532                                 desc++;
533
534                                 /*
535                                  * Copy the Unicode name to an ASCII string.
536                                  */
537                                 j = 0;
538                                 while (names[i] != 0) {
539                                         if (j < MAX_WIN_IF_NAME_LEN)
540                                         ascii_name[j++] = (char) names[i++];
541                                 }
542                                 ascii_name[j] = '\0';
543                                 i++;
544                                 il = g_list_append(il,
545                                     if_info_new(ascii_name, ascii_desc));
546                         }
547                 } else {
548                         /*
549                          * Otherwise we are in Windows 95/98 and using ASCII
550                          * (8-bit) characters.
551                          */
552                         win95names=(char *)names;
553                         while (*(win95names+desc_pos) || *(win95names+desc_pos-1))
554                                 desc_pos++;
555                         desc_pos++;     /* Step over the extra '\0' */
556                         desc = win95names + desc_pos;
557
558                         while (win95names[i] != '\0') {
559                                 /*
560                                  * "&win95names[i]" points to the current
561                                  * interface name, and "desc" points to
562                                  * that interface's description.
563                                  */
564                                 il = g_list_append(il,
565                                     if_info_new(&win95names[i], desc));
566
567                                 /*
568                                  * Skip to the next description.
569                                  */
570                                 while (*desc != 0)
571                                         desc++;
572                                 desc++;
573
574                                 /*
575                                  * Skip to the next name.
576                                  */
577                                 while (win95names[i] != 0)
578                                         i++;
579                                 i++;
580                         }
581                 }
582         }
583
584         if (il == NULL) {
585                 /*
586                  * No interfaces found.
587                  */
588                 *err = NO_INTERFACES_FOUND;
589         }
590
591         return il;
592 }
593
594 /*
595  * Get an error message string for a CANT_GET_INTERFACE_LIST error from
596  * "get_interface_list()".
597  */
598 gchar *
599 cant_get_if_list_error_message(const char *err_str)
600 {
601         /*
602          * If the error message includes "Not enough storage is available
603          * to process this command" or "The operation completed successfully",
604          * suggest that they install a WinPcap version later than 3.0.
605          */
606         if (strstr(err_str, "Not enough storage is available to process this command") != NULL ||
607             strstr(err_str, "The operation completed successfully") != NULL) {
608                 return g_strdup_printf("Can't get list of interfaces: %s\n"
609 "This might be a problem with WinPcap 3.0; you should try updating to\n"
610 "a later version of WinPcap - see the WinPcap site at www.winpcap.org",
611                     err_str);
612         }
613         return g_strdup_printf("Can't get list of interfaces: %s", err_str);
614 }
615
616 /*
617  * Append the version of WinPcap with which we were compiled to a GString.
618  */
619 void
620 get_compiled_pcap_version(GString *str)
621 {
622         g_string_append(str, "with WinPcap (version unknown)");
623 }
624
625 /*
626  * Append the version of WinPcap with which we we're running to a GString.
627  */
628 void
629 get_runtime_pcap_version(GString *str)
630 {
631         /*
632          * On Windows, we might have been compiled with WinPcap but
633          * might not have it loaded; indicate whether we have it or
634          * not and, if we have it and we have "pcap_lib_version()",
635          * what version we have.
636          */
637         GModule *handle;                /* handle returned by dlopen */
638         static gchar *packetVer;
639         gchar *blankp;
640
641         if (has_wpcap) {
642                 g_string_sprintfa(str, "with ");
643                 if (p_pcap_lib_version != NULL)
644                         g_string_sprintfa(str, p_pcap_lib_version());
645                 else {
646                         /*
647                          * An alternative method of obtaining the version
648                          * number, by using the PacketLibraryVersion
649                          * string from packet.dll.
650                          *
651                          * Unfortunately, in WinPcap 3.0, it returns
652                          * "3.0 alpha3", even in the final version of
653                          * WinPcap 3.0, so if there's a blank in the
654                          * string, we strip it and everything after
655                          * it from the string, so we don't misleadingly
656                          * report that 3.0 alpha3 is being used when
657                          * the final version is being used.
658                          */
659                         if (packetVer == NULL) {
660                                 packetVer = "version unknown";
661                                 handle = g_module_open("Packet.dll", 0);
662                                 if (handle != NULL) {
663                                         if (g_module_symbol(handle,
664                                             "PacketLibraryVersion",
665                                             (gpointer*)&packetVer)) {
666                                                 packetVer = g_strdup(packetVer);
667                                                 blankp = strchr(packetVer, ' ');
668                                                 if (blankp != NULL)
669                                                         *blankp = '\0';
670                                         } else {
671                                                 packetVer = "version unknown";
672                                         }
673                                         g_module_close(handle);
674                                 }
675                         }
676                         g_string_sprintfa(str, "WinPcap (%s)", packetVer);
677                 }
678         } else
679                 g_string_append(str, "without WinPcap");
680         g_string_append(str, " ");
681 }
682
683 #else /* HAVE_LIBPCAP */
684
685 void
686 load_wpcap(void)
687 {
688         return;
689 }
690
691 /*
692  * Append an indication that we were not compiled with WinPcap
693  * to a GString.
694  */
695 void
696 get_compiled_pcap_version(GString *str)
697 {
698         g_string_append(str, "without WinPcap");
699 }
700
701 /*
702  * Don't append anything, as we weren't even compiled to use WinPcap.
703  */
704 void
705 get_runtime_pcap_version(GString *str _U_)
706 {
707 }
708
709 #endif /* HAVE_LIBPCAP */