2 * WinPcap-specific interfaces for capturing. We load WinPcap at run
3 * time, so that we only need one Wireshark binary and one TShark binary
4 * for Windows, regardless of whether WinPcap is installed or not.
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 2001 Gerald Combs
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.
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.
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.
35 #include "capture_ifinfo.h"
36 #include "capture-pcap-util.h"
37 #include "capture-pcap-util-int.h"
39 #include <wsutil/file_util.h>
41 /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
42 #include "tools/lemon/cppmagic.h"
44 #define MAX_WIN_IF_NAME_LEN 511
47 gboolean has_wpcap = FALSE;
52 * XXX - should we require at least WinPcap 3.1 both for building an
53 * for using Wireshark?
56 static char* (*p_pcap_lookupdev) (char *);
57 static void (*p_pcap_close) (pcap_t *);
58 static int (*p_pcap_stats) (pcap_t *, struct pcap_stat *);
59 static int (*p_pcap_dispatch) (pcap_t *, int, pcap_handler, guchar *);
60 static int (*p_pcap_snapshot) (pcap_t *);
61 static int (*p_pcap_datalink) (pcap_t *);
62 static int (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
63 static char* (*p_pcap_geterr) (pcap_t *);
64 static int (*p_pcap_compile) (pcap_t *, struct bpf_program *, const char *, int,
66 static int (*p_pcap_compile_nopcap) (int, int, struct bpf_program *, const char *, int,
68 static int (*p_pcap_lookupnet) (const char *, bpf_u_int32 *, bpf_u_int32 *,
70 static pcap_t* (*p_pcap_open_live) (const char *, int, int, int, char *);
71 static int (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
72 #ifdef HAVE_PCAP_OPEN_DEAD
73 static pcap_t* (*p_pcap_open_dead) (int, int);
75 static void (*p_pcap_freecode) (struct bpf_program *);
76 #ifdef HAVE_PCAP_FINDALLDEVS
77 static int (*p_pcap_findalldevs) (pcap_if_t **, char *);
78 static void (*p_pcap_freealldevs) (pcap_if_t *);
80 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
81 static int (*p_pcap_datalink_name_to_val) (const char *);
83 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
84 static const char *(*p_pcap_datalink_val_to_name) (int);
86 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
87 static const char *(*p_pcap_datalink_val_to_description) (int);
89 #ifdef HAVE_PCAP_BREAKLOOP
90 static void (*p_pcap_breakloop) (pcap_t *);
92 static const char *(*p_pcap_lib_version) (void);
93 static int (*p_pcap_setbuff) (pcap_t *, int dim);
94 static int (*p_pcap_next_ex) (pcap_t *, struct pcap_pkthdr **pkt_header, const u_char **pkt_data);
95 #ifdef HAVE_PCAP_REMOTE
96 static pcap_t* (*p_pcap_open) (const char *, int, int, int,
97 struct pcap_rmtauth *, char *);
98 static int (*p_pcap_findalldevs_ex) (char *, struct pcap_rmtauth *,
99 pcap_if_t **, char *);
100 static int (*p_pcap_createsrcstr) (char *, int, const char *, const char *,
101 const char *, char *);
103 #ifdef HAVE_PCAP_SETSAMPLING
104 static struct pcap_samp* (*p_pcap_setsampling)(pcap_t *);
107 #ifdef HAVE_PCAP_LIST_DATALINKS
108 static int (*p_pcap_list_datalinks)(pcap_t *, int **);
111 #ifdef HAVE_PCAP_SET_DATALINK
112 static int (*p_pcap_set_datalink)(pcap_t *, int);
115 #ifdef HAVE_PCAP_FREE_DATALINKS
116 static int (*p_pcap_free_datalinks)(int *);
119 #ifdef HAVE_BPF_IMAGE
120 static char *(*p_bpf_image) (const struct bpf_insn *, int);
129 #define SYM(x, y) { STRINGIFY(x) , (gpointer) &CONCAT(p_,x), y }
135 /* These are the symbols I need or want from Wpcap */
136 static const symbol_table_t symbols[] = {
137 SYM(pcap_lookupdev, FALSE),
138 SYM(pcap_close, FALSE),
139 SYM(pcap_stats, FALSE),
140 SYM(pcap_dispatch, FALSE),
141 SYM(pcap_snapshot, FALSE),
142 SYM(pcap_datalink, FALSE),
143 SYM(pcap_setfilter, FALSE),
144 SYM(pcap_geterr, FALSE),
145 SYM(pcap_compile, FALSE),
146 SYM(pcap_compile_nopcap, FALSE),
147 SYM(pcap_lookupnet, FALSE),
148 #ifdef HAVE_PCAP_REMOTE
149 SYM(pcap_open, FALSE),
150 SYM(pcap_findalldevs_ex, FALSE),
151 SYM(pcap_createsrcstr, FALSE),
153 SYM(pcap_open_live, FALSE),
154 #ifdef HAVE_PCAP_OPEN_DEAD
155 SYM(pcap_open_dead, FALSE),
157 #ifdef HAVE_PCAP_SETSAMPLING
158 SYM(pcap_setsampling, TRUE),
160 SYM(pcap_loop, FALSE),
161 SYM(pcap_freecode, TRUE),
162 #ifdef HAVE_PCAP_FINDALLDEVS
163 SYM(pcap_findalldevs, TRUE),
164 SYM(pcap_freealldevs, TRUE),
166 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
167 SYM(pcap_datalink_name_to_val, TRUE),
169 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
170 SYM(pcap_datalink_val_to_name, TRUE),
172 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
173 SYM(pcap_datalink_val_to_description, TRUE),
175 #ifdef HAVE_PCAP_BREAKLOOP
177 * We don't try to work around the lack of this at
178 * run time; it's present in WinPcap 3.1, which is
179 * the version we build with and ship with.
181 SYM(pcap_breakloop, FALSE),
183 SYM(pcap_lib_version, TRUE),
184 SYM(pcap_setbuff, TRUE),
185 SYM(pcap_next_ex, TRUE),
186 #ifdef HAVE_PCAP_LIST_DATALINKS
187 SYM(pcap_list_datalinks, FALSE),
189 #ifdef HAVE_PCAP_SET_DATALINK
190 SYM(pcap_set_datalink, FALSE),
192 #ifdef HAVE_PCAP_FREE_DATALINKS
193 SYM(pcap_free_datalinks, TRUE),
195 #ifdef HAVE_BPF_IMAGE
196 SYM(bpf_image, FALSE),
198 { NULL, NULL, FALSE }
201 GModule *wh; /* wpcap handle */
202 const symbol_table_t *sym;
204 wh = ws_module_open("wpcap.dll", 0);
212 if (!g_module_symbol(wh, sym->name, sym->ptr)) {
215 * We don't care if it's missing; we just
221 * We require this symbol.
234 pcap_lookupdev (char *a)
239 return p_pcap_lookupdev(a);
243 pcap_close(pcap_t *a)
250 pcap_stats(pcap_t *a, struct pcap_stat *b)
253 return p_pcap_stats(a, b);
257 pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d)
260 return p_pcap_dispatch(a, b, c, d);
264 pcap_snapshot(pcap_t *a)
267 return p_pcap_snapshot(a);
271 pcap_datalink(pcap_t *a)
274 return p_pcap_datalink(a);
277 #ifdef HAVE_PCAP_SET_DATALINK
279 pcap_set_datalink(pcap_t *p, int dlt)
282 return p_pcap_set_datalink(p, dlt);
287 pcap_setfilter(pcap_t *a, struct bpf_program *b)
290 return p_pcap_setfilter(a, b);
294 pcap_geterr(pcap_t *a)
297 return p_pcap_geterr(a);
301 pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d,
305 return p_pcap_compile(a, b, c, d, e);
309 pcap_compile_nopcap(int a, int b, struct bpf_program *c, const char *d, int e,
313 return p_pcap_compile_nopcap(a, b, c, d, e, f);
317 pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
320 return p_pcap_lookupnet(a, b, c, d);
324 pcap_open_live(const char *a, int b, int c, int d, char *e)
329 return p_pcap_open_live(a, b, c, d, e);
332 #ifdef HAVE_PCAP_OPEN_DEAD
334 pcap_open_dead(int a, int b)
339 return p_pcap_open_dead(a, b);
343 #ifdef HAVE_BPF_IMAGE
345 bpf_image(const struct bpf_insn *a, int b)
350 return p_bpf_image(a, b);
354 #ifdef HAVE_PCAP_REMOTE
356 pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *f)
361 return p_pcap_open(a, b, c, d, e, f);
365 pcap_findalldevs_ex(char *a, struct pcap_rmtauth *b, pcap_if_t **c, char *d)
368 return p_pcap_findalldevs_ex(a, b, c, d);
372 pcap_createsrcstr(char *a, int b, const char *c, const char *d, const char *e,
376 return p_pcap_createsrcstr(a, b, c, d, e, f);
380 #ifdef HAVE_PCAP_SETSAMPLING
382 pcap_setsampling(pcap_t *a)
385 if (p_pcap_setsampling != NULL) {
386 return p_pcap_setsampling(a);
393 pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
396 return p_pcap_loop(a, b, c, d);
400 pcap_freecode(struct bpf_program *a)
403 if(p_pcap_freecode) {
408 #ifdef HAVE_PCAP_FINDALLDEVS
410 pcap_findalldevs(pcap_if_t **a, char *b)
412 g_assert(has_wpcap && p_pcap_findalldevs != NULL);
413 return p_pcap_findalldevs(a, b);
417 pcap_freealldevs(pcap_if_t *a)
419 g_assert(has_wpcap && p_pcap_freealldevs != NULL);
420 p_pcap_freealldevs(a);
424 #if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION)
426 * Table of DLT_ types, names, and descriptions, for use if the version
427 * of WinPcap we have installed lacks "pcap_datalink_name_to_val()"
428 * or "pcap_datalink_val_to_name()".
432 const char *description;
436 #define DLT_CHOICE(code, description) { #code, description, code }
437 #define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
439 static struct dlt_choice dlt_choices[] = {
440 DLT_CHOICE(DLT_NULL, "BSD loopback"),
441 DLT_CHOICE(DLT_EN10MB, "Ethernet"),
442 DLT_CHOICE(DLT_IEEE802, "Token ring"),
443 DLT_CHOICE(DLT_ARCNET, "ARCNET"),
444 DLT_CHOICE(DLT_SLIP, "SLIP"),
445 DLT_CHOICE(DLT_PPP, "PPP"),
446 DLT_CHOICE(DLT_FDDI, "FDDI"),
447 DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"),
448 DLT_CHOICE(DLT_RAW, "Raw IP"),
449 #ifdef DLT_SLIP_BSDOS
450 DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
453 DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
456 DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
458 #ifdef DLT_PPP_SERIAL
459 DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
462 DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
465 DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
467 #ifdef DLT_IEEE802_11
468 DLT_CHOICE(DLT_IEEE802_11, "802.11"),
471 DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
474 DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
477 DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
480 DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
483 DLT_CHOICE(DLT_LTALK, "Localtalk"),
486 DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
488 #ifdef DLT_PRISM_HEADER
489 DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
491 #ifdef DLT_IP_OVER_FC
492 DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
495 DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
497 #ifdef DLT_IEEE802_11_RADIO
498 DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"),
500 #ifdef DLT_ARCNET_LINUX
501 DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
503 #ifdef DLT_LINUX_IRDA
504 DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
506 #ifdef DLT_LINUX_LAPD
507 DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
510 DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
513 DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"),
516 DLT_CHOICE(DLT_HDLC, "Cisco HDLC"),
519 DLT_CHOICE(DLT_PPI, "Per-Packet Information"),
523 #endif /* defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION */
525 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
527 pcap_datalink_name_to_val(const char *name)
533 if (p_pcap_datalink_name_to_val != NULL)
534 return p_pcap_datalink_name_to_val(name);
537 * We don't have it in WinPcap; do it ourselves.
539 for (i = 0; dlt_choices[i].name != NULL; i++) {
540 if (g_ascii_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
542 return dlt_choices[i].dlt;
549 #ifdef HAVE_PCAP_LIST_DATALINKS
551 pcap_list_datalinks(pcap_t *p, int **ddlt)
554 return p_pcap_list_datalinks(p, ddlt);
558 #ifdef HAVE_PCAP_FREE_DATALINKS
560 pcap_free_datalinks(int *ddlt)
565 * If we don't have pcap_free_datalinks() in WinPcap,
566 * we don't free the memory - we can't use free(), as
567 * we might not have been built with the same version
568 * of the C runtime library as WinPcap was, and, if we're
569 * not, free() isn't guaranteed to work on something
570 * allocated by WinPcap.
572 if (p_pcap_free_datalinks != NULL)
573 p_pcap_free_datalinks(ddlt);
577 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
579 pcap_datalink_val_to_name(int dlt)
585 if (p_pcap_datalink_val_to_name != NULL)
586 return p_pcap_datalink_val_to_name(dlt);
589 * We don't have it in WinPcap; do it ourselves.
591 for (i = 0; dlt_choices[i].name != NULL; i++) {
592 if (dlt_choices[i].dlt == dlt)
593 return dlt_choices[i].name + sizeof("DLT_") - 1;
600 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
602 pcap_datalink_val_to_description(int dlt)
608 if (p_pcap_datalink_val_to_description != NULL)
609 return p_pcap_datalink_val_to_description(dlt);
612 * We don't have it in WinPcap; do it ourselves.
614 for (i = 0; dlt_choices[i].name != NULL; i++) {
615 if (dlt_choices[i].dlt == dlt)
616 return (dlt_choices[i].description);
623 #ifdef HAVE_PCAP_BREAKLOOP
624 void pcap_breakloop(pcap_t *a)
630 /* setbuff is win32 specific! */
631 int pcap_setbuff(pcap_t *a, int b)
634 return p_pcap_setbuff(a, b);
637 /* pcap_next_ex is available since libpcap 0.8 / WinPcap 3.0! */
638 /* (if you get a declaration warning here, try to update to at least WinPcap 3.1b4 develpack) */
639 int pcap_next_ex (pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
642 return p_pcap_next_ex(a, b, c);
645 #ifdef HAVE_PCAP_REMOTE
647 get_remote_interface_list(const char *hostname, const char *port,
648 int auth_type, const char *username,
649 const char *passwd, int *err, char **err_str)
651 struct pcap_rmtauth auth;
652 char source[PCAP_BUF_SIZE];
653 char errbuf[PCAP_ERRBUF_SIZE];
656 if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port,
657 NULL, errbuf) == -1) {
658 *err = CANT_GET_INTERFACE_LIST;
660 *err_str = cant_get_if_list_error_message(errbuf);
664 auth.type = auth_type;
665 auth.username = g_strdup(username);
666 auth.password = g_strdup(passwd);
668 result = get_interface_list_findalldevs_ex(source, &auth, err, err_str);
669 g_free(auth.username);
670 g_free(auth.password);
677 * This will use "pcap_findalldevs()" if we have it, otherwise it'll
678 * fall back on "pcap_lookupdev()".
681 get_interface_list(int *err, char **err_str)
686 char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
687 char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
689 char errbuf[PCAP_ERRBUF_SIZE];
691 #ifdef HAVE_PCAP_FINDALLDEVS
692 if (p_pcap_findalldevs != NULL)
693 return get_interface_list_findalldevs(err, err_str);
697 * In WinPcap, pcap_lookupdev is implemented by calling
698 * PacketGetAdapterNames. According to the documentation
701 * http://www.winpcap.org/docs/man/html/Packet32_8c.html#a43
705 * On Windows OT (95, 98, Me), pcap_lookupdev returns a sequence
706 * of bytes consisting of:
708 * a sequence of null-terminated ASCII strings (i.e., each
709 * one is terminated by a single 0 byte), giving the names
712 * an empty ASCII string (i.e., a single 0 byte);
714 * a sequence of null-terminated ASCII strings, giving the
715 * descriptions of the interfaces;
717 * an empty ASCII string.
719 * On Windows NT (NT 4.0, W2K, WXP, W2K3, etc.), pcap_lookupdev
720 * returns a sequence of bytes consisting of:
722 * a sequence of null-terminated double-byte Unicode strings
723 * (i.e., each one consits of a sequence of double-byte
724 * characters, terminated by a double-byte 0), giving the
725 * names of the interfaces;
727 * an empty Unicode string (i.e., a double 0 byte);
729 * a sequence of null-terminated ASCII strings, giving the
730 * descriptions of the interfaces;
732 * an empty ASCII string.
734 * The Nth string in the first sequence is the name of the Nth
735 * adapter; the Nth string in the second sequence is the
736 * description of the Nth adapter.
739 names = (wchar_t *)pcap_lookupdev(errbuf);
748 * If names[0] is less than 256 it means the first
749 * byte is 0. This implies that we are using Unicode
752 while (*(names+desc_pos) || *(names+desc_pos-1))
754 desc_pos++; /* Step over the extra '\0' */
755 desc = (char*)(names + desc_pos); /* cast *after* addition */
757 while (names[i] != 0) {
759 * Copy the Unicode description to an ASCII
764 if (j < MAX_WIN_IF_NAME_LEN)
765 ascii_desc[j++] = *desc;
768 ascii_desc[j] = '\0';
772 * Copy the Unicode name to an ASCII string.
775 while (names[i] != 0) {
776 if (j < MAX_WIN_IF_NAME_LEN)
777 ascii_name[j++] = (char) names[i++];
779 ascii_name[j] = '\0';
781 il = g_list_append(il,
782 if_info_new(ascii_name, ascii_desc));
786 * Otherwise we are in Windows 95/98 and using ASCII
787 * (8-bit) characters.
789 win95names=(char *)names;
790 while (*(win95names+desc_pos) || *(win95names+desc_pos-1))
792 desc_pos++; /* Step over the extra '\0' */
793 desc = win95names + desc_pos;
795 while (win95names[i] != '\0') {
797 * "&win95names[i]" points to the current
798 * interface name, and "desc" points to
799 * that interface's description.
801 il = g_list_append(il,
802 if_info_new(&win95names[i], desc));
805 * Skip to the next description.
812 * Skip to the next name.
814 while (win95names[i] != 0)
823 * No interfaces found.
825 *err = NO_INTERFACES_FOUND;
834 * Get an error message string for a CANT_GET_INTERFACE_LIST error from
835 * "get_interface_list()".
838 cant_get_if_list_error_message(const char *err_str)
841 * If the error message includes "Not enough storage is available
842 * to process this command" or "The operation completed successfully",
843 * suggest that they install a WinPcap version later than 3.0.
845 if (strstr(err_str, "Not enough storage is available to process this command") != NULL ||
846 strstr(err_str, "The operation completed successfully") != NULL) {
847 return g_strdup_printf("Can't get list of interfaces: %s\n"
848 "This might be a problem with WinPcap 3.0; you should try updating to\n"
849 "a later version of WinPcap - see the WinPcap site at www.winpcap.org",
852 return g_strdup_printf("Can't get list of interfaces: %s", err_str);
856 * Append the version of WinPcap with which we were compiled to a GString.
859 get_compiled_pcap_version(GString *str)
861 g_string_append(str, "with WinPcap (version unknown)");
865 * Append the version of WinPcap with which we we're running to a GString.
868 get_runtime_pcap_version(GString *str)
871 * On Windows, we might have been compiled with WinPcap but
872 * might not have it loaded; indicate whether we have it or
873 * not and, if we have it and we have "pcap_lib_version()",
874 * what version we have.
876 GModule *handle; /* handle returned by ws_module_open */
877 static gchar *packetVer;
881 g_string_append_printf(str, "with ");
882 if (p_pcap_lib_version != NULL)
883 g_string_append_printf(str, p_pcap_lib_version());
886 * An alternative method of obtaining the version
887 * number, by using the PacketLibraryVersion
888 * string from packet.dll.
890 * Unfortunately, in WinPcap 3.0, it returns
891 * "3.0 alpha3", even in the final version of
892 * WinPcap 3.0, so if there's a blank in the
893 * string, we strip it and everything after
894 * it from the string, so we don't misleadingly
895 * report that 3.0 alpha3 is being used when
896 * the final version is being used.
898 if (packetVer == NULL) {
899 packetVer = "version unknown";
900 handle = ws_module_open("packet.dll", 0);
901 if (handle != NULL) {
902 if (g_module_symbol(handle,
903 "PacketLibraryVersion",
904 (gpointer*)&packetVer)) {
905 packetVer = g_strdup(packetVer);
906 blankp = strchr(packetVer, ' ');
910 packetVer = "version unknown";
912 g_module_close(handle);
915 g_string_append_printf(str, "WinPcap (%s)", packetVer);
918 g_string_append(str, "without WinPcap");
921 #else /* HAVE_LIBPCAP */
930 * Append an indication that we were not compiled with WinPcap
934 get_compiled_pcap_version(GString *str)
936 g_string_append(str, "without WinPcap");
940 * Don't append anything, as we weren't even compiled to use WinPcap.
943 get_runtime_pcap_version(GString *str _U_)
947 #endif /* HAVE_LIBPCAP */