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
This commit is contained in:
Gerald Combs 2009-12-15 19:29:21 +00:00
parent ae2b555a96
commit 7871c54e99
3 changed files with 10 additions and 6 deletions

View File

@ -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);
}

View File

@ -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 {

View File

@ -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.");