summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguy <guy>2008-04-09 20:01:26 +0000
committerguy <guy>2008-04-09 20:01:26 +0000
commit8d27de9172abbdf2c4c4421b8727d6a4bb11ca7a (patch)
treeb39c207e9d39a88a408eb2011cacd917b153897d
parent6a32e3ca898ed7a184488fc8144c378ade4625b3 (diff)
downloadtcpdump-8d27de9172abbdf2c4c4421b8727d6a4bb11ca7a.tar.gz
If we get PCAP_ERROR_NO_SUCH_DEVICE or PCAP_ERROR_PERM_DENIED from
pcap_activate(), and there's a non-null error string returned by pcap_geterr(), print it as part of the error message, as it might contain information useful when debugging the problem. If we get PCAP_ERROR, just print the error string from pcap_geterr(), not the device name, as the error string will contain the device name.
-rw-r--r--tcpdump.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tcpdump.c b/tcpdump.c
index d358ee4b..31c05fe5 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.271.2.8 2008-04-06 20:12:35 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.271.2.9 2008-04-09 20:01:26 guy Exp $ (LBL)";
#endif
/*
@@ -983,8 +983,14 @@ main(int argc, char **argv)
}
status = pcap_activate(pd);
if (status != 0) {
+ cp = pcap_geterr(pd);
if (status == PCAP_ERROR)
- error("%s: %s", device, pcap_geterr(pd));
+ error("%s", cp);
+ else if ((status == PCAP_ERROR_NO_SUCH_DEVICE ||
+ status == PCAP_ERROR_PERM_DENIED) &&
+ *cp != '\0')
+ error("%s: %s\n(%s)", device,
+ pcap_errtostr(status), cp);
else
error("%s: %s", device, pcap_errtostr(status));
}