From 7871c54e99ed390e6c061d921b290d32103c3e0a Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 15 Dec 2009 19:29:21 +0000 Subject: [PATCH] Behave more gracefully if WinPcap isn't installed. Don't assert if we call pcap_open or pcap_open_live when WinPcap isn't loaded - just return NULL. Don't display the "NPF driver isn't running" dialog if we're capturing from stdin or a file. Fix a cut-and-paste error in capture_pcap_linktype_list. svn path=/trunk/; revision=31275 --- capture-wpcap.c | 10 +++++++--- capture.c | 4 ++-- gtk/main.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/capture-wpcap.c b/capture-wpcap.c index 1c925e2bfe..584e989cdf 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -295,15 +295,19 @@ pcap_lookupnet(const char *a, bpf_u_int32 *b, bpf_u_int32 *c, char *d) pcap_t* pcap_open_live(const char *a, int b, int c, int d, char *e) { - g_assert(has_wpcap); - return p_pcap_open_live(a, b, c, d, e); + if (!has_wpcap) { + return NULL; + } + return p_pcap_open_live(a, b, c, d, e); } #ifdef HAVE_PCAP_REMOTE pcap_t* pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *f) { - g_assert(has_wpcap); + if (!has_wpcap) { + return NULL; + } return p_pcap_open(a, b, c, d, e, f); } diff --git a/capture.c b/capture.c index c2352867f6..493f626eac 100644 --- a/capture.c +++ b/capture.c @@ -759,12 +759,12 @@ capture_pcap_linktype_list(const gchar *ifname, char **err_str) gchar **raw_list, **lt_parts; data_link_info_t *data_link_info; - g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ..."); + g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Linktype List ..."); /* Try to get our interface list */ err = sync_linktype_list_open(ifname, &msg); if (err != 0) { - g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List failed!"); + g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Linktype List failed!"); if (err_str) { *err_str = msg; } else { diff --git a/gtk/main.c b/gtk/main.c index a0f97057ee..2a0d98dacc 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2665,7 +2665,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 /* Warn the user if npf.sys isn't loaded. */ - if (!npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) { + if (!stdin_capture && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) { priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "The NPF driver isn't running. You may have trouble\n" "capturing or listing interfaces.");