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"
38 #include "capture-wpcap.h"
39 #include "capture_errs.h"
41 #include <wsutil/file_util.h>
43 /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
44 #include "tools/lemon/cppmagic.h"
46 #define MAX_WIN_IF_NAME_LEN 511
49 gboolean has_wpcap = FALSE;
54 * XXX - should we require at least WinPcap 3.1 both for building an
55 * for using Wireshark?
58 static char* (*p_pcap_lookupdev) (char *);
59 static void (*p_pcap_close) (pcap_t *);
60 static int (*p_pcap_stats) (pcap_t *, struct pcap_stat *);
61 static int (*p_pcap_dispatch) (pcap_t *, int, pcap_handler, guchar *);
62 static int (*p_pcap_snapshot) (pcap_t *);
63 static int (*p_pcap_datalink) (pcap_t *);
64 static int (*p_pcap_setfilter) (pcap_t *, struct bpf_program *);
65 static char* (*p_pcap_geterr) (pcap_t *);
66 static int (*p_pcap_compile) (pcap_t *, struct bpf_program *, const char *, int,
68 static int (*p_pcap_compile_nopcap) (int, int, struct bpf_program *, const char *, int,
70 static int (*p_pcap_lookupnet) (const char *, bpf_u_int32 *, bpf_u_int32 *,
72 static pcap_t* (*p_pcap_open_live) (const char *, int, int, int, char *);
73 static int (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *);
74 #ifdef HAVE_PCAP_OPEN_DEAD
75 static pcap_t* (*p_pcap_open_dead) (int, int);
77 static void (*p_pcap_freecode) (struct bpf_program *);
78 #ifdef HAVE_PCAP_FINDALLDEVS
79 static int (*p_pcap_findalldevs) (pcap_if_t **, char *);
80 static void (*p_pcap_freealldevs) (pcap_if_t *);
82 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
83 static int (*p_pcap_datalink_name_to_val) (const char *);
85 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
86 static const char *(*p_pcap_datalink_val_to_name) (int);
88 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
89 static const char *(*p_pcap_datalink_val_to_description) (int);
91 #ifdef HAVE_PCAP_BREAKLOOP
92 static void (*p_pcap_breakloop) (pcap_t *);
94 static const char *(*p_pcap_lib_version) (void);
95 static int (*p_pcap_setbuff) (pcap_t *, int dim);
96 static int (*p_pcap_next_ex) (pcap_t *, struct pcap_pkthdr **pkt_header, const u_char **pkt_data);
97 #ifdef HAVE_PCAP_REMOTE
98 static pcap_t* (*p_pcap_open) (const char *, int, int, int,
99 struct pcap_rmtauth *, char *);
100 static int (*p_pcap_findalldevs_ex) (char *, struct pcap_rmtauth *,
101 pcap_if_t **, char *);
102 static int (*p_pcap_createsrcstr) (char *, int, const char *, const char *,
103 const char *, char *);
105 #ifdef HAVE_PCAP_SETSAMPLING
106 static struct pcap_samp* (*p_pcap_setsampling)(pcap_t *);
109 #ifdef HAVE_PCAP_LIST_DATALINKS
110 static int (*p_pcap_list_datalinks)(pcap_t *, int **);
113 #ifdef HAVE_PCAP_SET_DATALINK
114 static int (*p_pcap_set_datalink)(pcap_t *, int);
117 #ifdef HAVE_PCAP_FREE_DATALINKS
118 static int (*p_pcap_free_datalinks)(int *);
121 #ifdef HAVE_BPF_IMAGE
122 static char *(*p_bpf_image) (const struct bpf_insn *, int);
131 #define SYM(x, y) { STRINGIFY(x) , (gpointer) &CONCAT(p_,x), y }
137 /* These are the symbols I need or want from Wpcap */
138 static const symbol_table_t symbols[] = {
139 SYM(pcap_lookupdev, FALSE),
140 SYM(pcap_close, FALSE),
141 SYM(pcap_stats, FALSE),
142 SYM(pcap_dispatch, FALSE),
143 SYM(pcap_snapshot, FALSE),
144 SYM(pcap_datalink, FALSE),
145 SYM(pcap_setfilter, FALSE),
146 SYM(pcap_geterr, FALSE),
147 SYM(pcap_compile, FALSE),
148 SYM(pcap_compile_nopcap, FALSE),
149 SYM(pcap_lookupnet, FALSE),
150 #ifdef HAVE_PCAP_REMOTE
151 SYM(pcap_open, FALSE),
152 SYM(pcap_findalldevs_ex, FALSE),
153 SYM(pcap_createsrcstr, FALSE),
155 SYM(pcap_open_live, FALSE),
156 #ifdef HAVE_PCAP_OPEN_DEAD
157 SYM(pcap_open_dead, FALSE),
159 #ifdef HAVE_PCAP_SETSAMPLING
160 SYM(pcap_setsampling, TRUE),
162 SYM(pcap_loop, FALSE),
163 SYM(pcap_freecode, TRUE),
164 #ifdef HAVE_PCAP_FINDALLDEVS
165 SYM(pcap_findalldevs, TRUE),
166 SYM(pcap_freealldevs, TRUE),
168 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
169 SYM(pcap_datalink_name_to_val, TRUE),
171 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
172 SYM(pcap_datalink_val_to_name, TRUE),
174 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
175 SYM(pcap_datalink_val_to_description, TRUE),
177 #ifdef HAVE_PCAP_BREAKLOOP
179 * We don't try to work around the lack of this at
180 * run time; it's present in WinPcap 3.1, which is
181 * the version we build with and ship with.
183 SYM(pcap_breakloop, FALSE),
185 SYM(pcap_lib_version, TRUE),
186 SYM(pcap_setbuff, TRUE),
187 SYM(pcap_next_ex, TRUE),
188 #ifdef HAVE_PCAP_LIST_DATALINKS
189 SYM(pcap_list_datalinks, FALSE),
191 #ifdef HAVE_PCAP_SET_DATALINK
192 SYM(pcap_set_datalink, FALSE),
194 #ifdef HAVE_PCAP_FREE_DATALINKS
195 SYM(pcap_free_datalinks, TRUE),
197 #ifdef HAVE_BPF_IMAGE
198 SYM(bpf_image, FALSE),
200 { NULL, NULL, FALSE }
203 GModule *wh; /* wpcap handle */
204 const symbol_table_t *sym;
206 wh = ws_module_open("wpcap.dll", 0);
214 if (!g_module_symbol(wh, sym->name, sym->ptr)) {
217 * We don't care if it's missing; we just
223 * We require this symbol.
236 pcap_lookupdev (char *a)
241 return p_pcap_lookupdev(a);
245 pcap_close(pcap_t *a)
252 pcap_stats(pcap_t *a, struct pcap_stat *b)
255 return p_pcap_stats(a, b);
259 pcap_dispatch(pcap_t *a, int b, pcap_handler c, guchar *d)
262 return p_pcap_dispatch(a, b, c, d);
266 pcap_snapshot(pcap_t *a)
269 return p_pcap_snapshot(a);
273 pcap_datalink(pcap_t *a)
276 return p_pcap_datalink(a);
279 #ifdef HAVE_PCAP_SET_DATALINK
281 pcap_set_datalink(pcap_t *p, int dlt)
284 return p_pcap_set_datalink(p, dlt);
289 pcap_setfilter(pcap_t *a, struct bpf_program *b)
292 return p_pcap_setfilter(a, b);
296 pcap_geterr(pcap_t *a)
299 return p_pcap_geterr(a);
303 pcap_compile(pcap_t *a, struct bpf_program *b, const char *c, int d,
307 return p_pcap_compile(a, b, c, d, e);
311 pcap_compile_nopcap(int a, int b, struct bpf_program *c, const char *d, int e,
315 return p_pcap_compile_nopcap(a, b, c, d, e, f);
319 pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d)
322 return p_pcap_lookupnet(a, b, c, d);
326 pcap_open_live(const char *a, int b, int c, int d, char *e)
329 g_snprintf(e, PCAP_ERRBUF_SIZE,
330 "unable to load WinPcap (wpcap.dll); can't open %s to capture",
334 return p_pcap_open_live(a, b, c, d, e);
337 #ifdef HAVE_PCAP_OPEN_DEAD
339 pcap_open_dead(int a, int b)
344 return p_pcap_open_dead(a, b);
348 #ifdef HAVE_BPF_IMAGE
350 bpf_image(const struct bpf_insn *a, int b)
355 return p_bpf_image(a, b);
359 #ifdef HAVE_PCAP_REMOTE
361 pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *f)
364 g_snprintf(f, PCAP_ERRBUF_SIZE,
365 "unable to load WinPcap (wpcap.dll); can't open %s to capture",
369 return p_pcap_open(a, b, c, d, e, f);
373 pcap_findalldevs_ex(char *a, struct pcap_rmtauth *b, pcap_if_t **c, char *d)
376 return p_pcap_findalldevs_ex(a, b, c, d);
380 pcap_createsrcstr(char *a, int b, const char *c, const char *d, const char *e,
384 return p_pcap_createsrcstr(a, b, c, d, e, f);
388 #ifdef HAVE_PCAP_SETSAMPLING
390 pcap_setsampling(pcap_t *a)
393 if (p_pcap_setsampling != NULL) {
394 return p_pcap_setsampling(a);
401 pcap_loop(pcap_t *a, int b, pcap_handler c, guchar *d)
404 return p_pcap_loop(a, b, c, d);
408 pcap_freecode(struct bpf_program *a)
411 if(p_pcap_freecode) {
416 #ifdef HAVE_PCAP_FINDALLDEVS
418 pcap_findalldevs(pcap_if_t **a, char *b)
420 g_assert(has_wpcap && p_pcap_findalldevs != NULL);
421 return p_pcap_findalldevs(a, b);
425 pcap_freealldevs(pcap_if_t *a)
427 g_assert(has_wpcap && p_pcap_freealldevs != NULL);
428 p_pcap_freealldevs(a);
432 #if defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION)
434 * Table of DLT_ types, names, and descriptions, for use if the version
435 * of WinPcap we have installed lacks "pcap_datalink_name_to_val()"
436 * or "pcap_datalink_val_to_name()".
440 const char *description;
444 #define DLT_CHOICE(code, description) { #code, description, code }
445 #define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
447 static struct dlt_choice dlt_choices[] = {
448 DLT_CHOICE(DLT_NULL, "BSD loopback"),
449 DLT_CHOICE(DLT_EN10MB, "Ethernet"),
450 DLT_CHOICE(DLT_IEEE802, "Token ring"),
451 DLT_CHOICE(DLT_ARCNET, "ARCNET"),
452 DLT_CHOICE(DLT_SLIP, "SLIP"),
453 DLT_CHOICE(DLT_PPP, "PPP"),
454 DLT_CHOICE(DLT_FDDI, "FDDI"),
455 DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"),
456 DLT_CHOICE(DLT_RAW, "Raw IP"),
457 #ifdef DLT_SLIP_BSDOS
458 DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
461 DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
464 DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
466 #ifdef DLT_PPP_SERIAL
467 DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
470 DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
473 DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
475 #ifdef DLT_IEEE802_11
476 DLT_CHOICE(DLT_IEEE802_11, "802.11"),
479 DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
482 DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
485 DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
488 DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
491 DLT_CHOICE(DLT_LTALK, "Localtalk"),
494 DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
496 #ifdef DLT_PRISM_HEADER
497 DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
499 #ifdef DLT_IP_OVER_FC
500 DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
503 DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
505 #ifdef DLT_IEEE802_11_RADIO
506 DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"),
508 #ifdef DLT_ARCNET_LINUX
509 DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
511 #ifdef DLT_LINUX_IRDA
512 DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
514 #ifdef DLT_LINUX_LAPD
515 DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
518 DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
521 DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"),
524 DLT_CHOICE(DLT_HDLC, "Cisco HDLC"),
527 DLT_CHOICE(DLT_PPI, "Per-Packet Information"),
531 #endif /* defined(HAVE_PCAP_DATALINK_NAME_TO_VAL) || defined(HAVE_PCAP_DATALINK_VAL_TO_NAME) || defined(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION */
533 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
535 pcap_datalink_name_to_val(const char *name)
541 if (p_pcap_datalink_name_to_val != NULL)
542 return p_pcap_datalink_name_to_val(name);
545 * We don't have it in WinPcap; do it ourselves.
547 for (i = 0; dlt_choices[i].name != NULL; i++) {
548 if (g_ascii_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
550 return dlt_choices[i].dlt;
557 #ifdef HAVE_PCAP_LIST_DATALINKS
559 pcap_list_datalinks(pcap_t *p, int **ddlt)
562 return p_pcap_list_datalinks(p, ddlt);
566 #ifdef HAVE_PCAP_FREE_DATALINKS
568 pcap_free_datalinks(int *ddlt)
573 * If we don't have pcap_free_datalinks() in WinPcap,
574 * we don't free the memory - we can't use free(), as
575 * we might not have been built with the same version
576 * of the C runtime library as WinPcap was, and, if we're
577 * not, free() isn't guaranteed to work on something
578 * allocated by WinPcap.
580 if (p_pcap_free_datalinks != NULL)
581 p_pcap_free_datalinks(ddlt);
585 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
587 pcap_datalink_val_to_name(int dlt)
593 if (p_pcap_datalink_val_to_name != NULL)
594 return p_pcap_datalink_val_to_name(dlt);
597 * We don't have it in WinPcap; do it ourselves.
599 for (i = 0; dlt_choices[i].name != NULL; i++) {
600 if (dlt_choices[i].dlt == dlt)
601 return dlt_choices[i].name + sizeof("DLT_") - 1;
608 #ifdef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
610 pcap_datalink_val_to_description(int dlt)
616 if (p_pcap_datalink_val_to_description != NULL)
617 return p_pcap_datalink_val_to_description(dlt);
620 * We don't have it in WinPcap; do it ourselves.
622 for (i = 0; dlt_choices[i].name != NULL; i++) {
623 if (dlt_choices[i].dlt == dlt)
624 return (dlt_choices[i].description);
631 #ifdef HAVE_PCAP_BREAKLOOP
632 void pcap_breakloop(pcap_t *a)
638 /* setbuff is win32 specific! */
639 int pcap_setbuff(pcap_t *a, int b)
642 return p_pcap_setbuff(a, b);
645 /* pcap_next_ex is available since libpcap 0.8 / WinPcap 3.0! */
646 /* (if you get a declaration warning here, try to update to at least WinPcap 3.1b4 develpack) */
647 int pcap_next_ex (pcap_t *a, struct pcap_pkthdr **b, const u_char **c)
650 return p_pcap_next_ex(a, b, c);
653 #ifdef HAVE_PCAP_REMOTE
655 get_remote_interface_list(const char *hostname, const char *port,
656 int auth_type, const char *username,
657 const char *passwd, int *err, char **err_str)
659 struct pcap_rmtauth auth;
660 char source[PCAP_BUF_SIZE];
661 char errbuf[PCAP_ERRBUF_SIZE];
664 if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port,
665 NULL, errbuf) == -1) {
666 *err = CANT_GET_INTERFACE_LIST;
668 *err_str = cant_get_if_list_error_message(errbuf);
672 auth.type = auth_type;
673 auth.username = g_strdup(username);
674 auth.password = g_strdup(passwd);
676 result = get_interface_list_findalldevs_ex(source, &auth, err, err_str);
677 g_free(auth.username);
678 g_free(auth.password);
685 * This will use "pcap_findalldevs()" if we have it, otherwise it'll
686 * fall back on "pcap_lookupdev()".
689 get_interface_list(int *err, char **err_str)
694 char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
695 char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
697 char errbuf[PCAP_ERRBUF_SIZE];
701 * We don't have WinPcap, so we can't get a list of
704 *err = DONT_HAVE_PCAP;
705 *err_str = cant_load_winpcap_err("you");
709 #ifdef HAVE_PCAP_FINDALLDEVS
710 if (p_pcap_findalldevs != NULL)
711 return get_interface_list_findalldevs(err, err_str);
715 * In WinPcap, pcap_lookupdev is implemented by calling
716 * PacketGetAdapterNames. According to the documentation
719 * http://www.winpcap.org/docs/man/html/Packet32_8c.html#a43
723 * On Windows OT (95, 98, Me), pcap_lookupdev returns a sequence
724 * of bytes consisting of:
726 * a sequence of null-terminated ASCII strings (i.e., each
727 * one is terminated by a single 0 byte), giving the names
730 * an empty ASCII string (i.e., a single 0 byte);
732 * a sequence of null-terminated ASCII strings, giving the
733 * descriptions of the interfaces;
735 * an empty ASCII string.
737 * On Windows NT (NT 4.0, W2K, WXP, W2K3, etc.), pcap_lookupdev
738 * returns a sequence of bytes consisting of:
740 * a sequence of null-terminated double-byte Unicode strings
741 * (i.e., each one consits of a sequence of double-byte
742 * characters, terminated by a double-byte 0), giving the
743 * names of the interfaces;
745 * an empty Unicode string (i.e., a double 0 byte);
747 * a sequence of null-terminated ASCII strings, giving the
748 * descriptions of the interfaces;
750 * an empty ASCII string.
752 * The Nth string in the first sequence is the name of the Nth
753 * adapter; the Nth string in the second sequence is the
754 * description of the Nth adapter.
757 names = (wchar_t *)pcap_lookupdev(errbuf);
766 * If names[0] is less than 256 it means the first
767 * byte is 0. This implies that we are using Unicode
770 while (*(names+desc_pos) || *(names+desc_pos-1))
772 desc_pos++; /* Step over the extra '\0' */
773 desc = (char*)(names + desc_pos); /* cast *after* addition */
775 while (names[i] != 0) {
777 * Copy the Unicode description to an ASCII
782 if (j < MAX_WIN_IF_NAME_LEN)
783 ascii_desc[j++] = *desc;
786 ascii_desc[j] = '\0';
790 * Copy the Unicode name to an ASCII string.
793 while (names[i] != 0) {
794 if (j < MAX_WIN_IF_NAME_LEN)
795 ascii_name[j++] = (char) names[i++];
797 ascii_name[j] = '\0';
799 il = g_list_append(il,
800 if_info_new(ascii_name, ascii_desc));
804 * Otherwise we are in Windows 95/98 and using ASCII
805 * (8-bit) characters.
807 win95names=(char *)names;
808 while (*(win95names+desc_pos) || *(win95names+desc_pos-1))
810 desc_pos++; /* Step over the extra '\0' */
811 desc = win95names + desc_pos;
813 while (win95names[i] != '\0') {
815 * "&win95names[i]" points to the current
816 * interface name, and "desc" points to
817 * that interface's description.
819 il = g_list_append(il,
820 if_info_new(&win95names[i], desc));
823 * Skip to the next description.
830 * Skip to the next name.
832 while (win95names[i] != 0)
841 * No interfaces found.
843 *err = NO_INTERFACES_FOUND;
852 * Get an error message string for a CANT_GET_INTERFACE_LIST error from
853 * "get_interface_list()".
856 cant_get_if_list_error_message(const char *err_str)
859 * If the error message includes "Not enough storage is available
860 * to process this command" or "The operation completed successfully",
861 * suggest that they install a WinPcap version later than 3.0.
863 if (strstr(err_str, "Not enough storage is available to process this command") != NULL ||
864 strstr(err_str, "The operation completed successfully") != NULL) {
865 return g_strdup_printf("Can't get list of interfaces: %s\n"
866 "This might be a problem with WinPcap 3.0; you should try updating to\n"
867 "a later version of WinPcap - see the WinPcap site at www.winpcap.org",
870 return g_strdup_printf("Can't get list of interfaces: %s", err_str);
874 * Append the version of WinPcap with which we were compiled to a GString.
877 get_compiled_pcap_version(GString *str)
879 g_string_append(str, "with WinPcap (version unknown)");
883 * Append the version of WinPcap with which we we're running to a GString.
886 get_runtime_pcap_version(GString *str)
889 * On Windows, we might have been compiled with WinPcap but
890 * might not have it loaded; indicate whether we have it or
891 * not and, if we have it and we have "pcap_lib_version()",
892 * what version we have.
894 GModule *handle; /* handle returned by ws_module_open */
895 static gchar *packetVer;
899 g_string_append_printf(str, "with ");
900 if (p_pcap_lib_version != NULL)
901 g_string_append_printf(str, p_pcap_lib_version());
904 * An alternative method of obtaining the version
905 * number, by using the PacketLibraryVersion
906 * string from packet.dll.
908 * Unfortunately, in WinPcap 3.0, it returns
909 * "3.0 alpha3", even in the final version of
910 * WinPcap 3.0, so if there's a blank in the
911 * string, we strip it and everything after
912 * it from the string, so we don't misleadingly
913 * report that 3.0 alpha3 is being used when
914 * the final version is being used.
916 if (packetVer == NULL) {
917 packetVer = "version unknown";
918 handle = ws_module_open("packet.dll", 0);
919 if (handle != NULL) {
920 if (g_module_symbol(handle,
921 "PacketLibraryVersion",
922 (gpointer*)&packetVer)) {
923 packetVer = g_strdup(packetVer);
924 blankp = strchr(packetVer, ' ');
928 packetVer = "version unknown";
930 g_module_close(handle);
933 g_string_append_printf(str, "WinPcap (%s)", packetVer);
936 g_string_append(str, "without WinPcap");
939 #else /* HAVE_LIBPCAP */
948 * Append an indication that we were not compiled with WinPcap
952 get_compiled_pcap_version(GString *str)
954 g_string_append(str, "without WinPcap");
958 * Don't append anything, as we weren't even compiled to use WinPcap.
961 get_runtime_pcap_version(GString *str _U_)
965 #endif /* HAVE_LIBPCAP */