From 8e51328bc2b613cefffac72eafda0c45a142568d Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 10 Oct 2003 06:05:48 +0000 Subject: Get the version number of the libpcap/WinPcap with which we're running with "pcap_lib_version()", if available. svn path=/trunk/; revision=8656 --- capture-wpcap.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'capture-wpcap.c') diff --git a/capture-wpcap.c b/capture-wpcap.c index 88f6cbfd15..36f232f277 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.4 2003/10/10 03:00:09 guy Exp $ + * $Id: capture-wpcap.c,v 1.5 2003/10/10 06:05:48 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -59,6 +59,8 @@ 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 *); static int (*p_pcap_loop) (pcap_t *, int, pcap_handler, guchar *); +static int (*p_pcap_findalldevs) (pcap_if_t **, char *); +static const char *(*p_pcap_lib_version) (void); typedef struct { const char *name; @@ -87,6 +89,7 @@ load_wpcap(void) SYM(pcap_open_live, FALSE), SYM(pcap_loop, FALSE), SYM(pcap_findalldevs, TRUE), + SYM(pcap_lib_version, TRUE), { NULL, NULL, FALSE } }; @@ -372,6 +375,38 @@ get_interface_list(int *err, char *err_str) return il; } +/* + * Append the version of WinPcap with which we were compiled to a GString. + */ +void +get_compiled_pcap_version(GString *str) +{ + g_string_append(str, "with WinPcap (version unknown)"); +} + +/* + * Append the version of WinPcap with which we we're running to a GString. + */ +void +get_runtime_pcap_version(GString *str) +{ + /* + * On Windows, we might have been compiled with WinPcap but + * might not have it loaded; indicate whether we have it or + * not and, if we have it and we have "pcap_lib_version()", + * what version we have. + */ + if (has_wpcap) { + g_string_sprintfa(str, "with "); + if (p_pcap_lib_version != NULL) + g_string_sprintfa(str, p_pcap_lib_version()); + else + g_string_append(str, "WinPcap (version unknown)"); + } else + g_string_append(str, "without WinPcap"); + g_string_append(str, " "); +} + #else /* HAVE_LIBPCAP */ void @@ -380,4 +415,22 @@ load_wpcap(void) return; } +/* + * Append an indication that we were not compiled with WinPcap + * to a GString. + */ +void +get_compiled_pcap_version(GString *str) +{ + g_string_append(str, "without WinPcap"); +} + +/* + * Don't append anything, as we weren't even compiled to use WinPcap. + */ +void +get_runtime_pcap_version(GString *str _U_) +{ +} + #endif /* HAVE_LIBPCAP */ -- cgit v1.2.3