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 --- pcap-util-unix.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'pcap-util-unix.c') diff --git a/pcap-util-unix.c b/pcap-util-unix.c index 6e3e8676a9..29015769b6 100644 --- a/pcap-util-unix.c +++ b/pcap-util-unix.c @@ -1,7 +1,7 @@ /* pcap-util-unix.c * UN*X-specific utility routines for packet capture * - * $Id: pcap-util-unix.c,v 1.1 2003/10/10 03:00:10 guy Exp $ + * $Id: pcap-util-unix.c,v 1.2 2003/10/10 06:05:48 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -26,10 +26,10 @@ # include "config.h" #endif -#ifdef HAVE_LIBPCAP - #include +#ifdef HAVE_LIBPCAP + #include #include #include @@ -270,4 +270,54 @@ search_for_if_cb(gpointer data, gpointer user_data) } #endif /* HAVE_PCAP_FINDALLDEVS */ +/* + * Append the version of libpcap with which we were compiled to a GString. + */ +void +get_compiled_pcap_version(GString *str) +{ +#ifdef HAVE_PCAP_VERSION + extern char pcap_version[]; + + g_string_sprintfa(str, "with libpcap %s", pcap_version); +#else + g_string_append(str, "with libpcap (version unknown)"); +#endif +} + +/* + * Append the version of libpcap with which we we're running to a GString. + */ +void +get_runtime_pcap_version(GString *str) +{ + g_string_sprintfa(str, "with "); +#ifdef HAVE_PCAP_LIB_VERSION + g_string_sprintfa(str, pcap_lib_version()); +#else + g_string_append(str, "libpcap (version unknown)"); +#endif + g_string_append(str, " "); +} + +#else /* HAVE_LIBPCAP */ + +/* + * Append an indication that we were not compiled with libpcap + * to a GString. + */ +void +get_compiled_pcap_version(GString *str) +{ + g_string_append(str, "without libpcap"); +} + +/* + * 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