tcpdump mailing list archives
Re: pcap_activate can cause pcap_geterr to return
From: Dustin Spicuzza <dustin () virtualroadside com>
Date: Fri, 07 Aug 2009 20:09:02 -0400
Dustin Spicuzza wrote:
On linux using the latest GIT:
If you use pcap_create followed by pcap_activate when an interface
doesn't actually exist (ie, PCAP_ERROR_IFACE_NOT_UP is returned), then
pcap_geterr will return a blank value.
I noticed that the documentation does mention all the various error
codes that could be returned, and that you should call pcap_statustostr
to actually get the string if the error isn't PCAP_ERROR or PCAP_WARNING.
However, thats another decision that has to be made by the user, so it
seems like it would be nice and simple if pcap_geterr just worked no
matter what kind of error was returned. Add two lines to pcap_activate
to make pcap_geterr work as expected:
int
pcap_activate(pcap_t *p)
{
int status;
status = p->activate_op(p);
if (status >= 0)
p->activated = 1;
else if (!p->errbuf[0])
snprintf( p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", p->opt.source,
pcap_statustostr(status) );
return (status);
}
Oh yeah, heres the patch file. Sorry about that. Dustin -- Innovation is just a problem away
diff --git a/pcap.c b/pcap.c
index 310e5d2..b40dac1 100644
--- a/pcap.c
+++ b/pcap.c
@@ -303,6 +303,8 @@ pcap_activate(pcap_t *p)
status = p->activate_op(p);
if (status >= 0)
p->activated = 1;
+ else if (!p->errbuf[0])
+ snprintf( p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", p->opt.source, pcap_statustostr(status) );
return (status);
}
Attachment:
signature.asc
Description: OpenPGP digital signature
Current thread:
- pcap_activate can cause pcap_geterr to return a blank string Dustin Spicuzza (Aug 07)
- Re: pcap_activate can cause pcap_geterr to return Dustin Spicuzza (Aug 07)
- Re: pcap_activate can cause pcap_geterr to return a blank string Guy Harris (Aug 11)
