Rename pcap_errtostr() to pcap_statustostr(), and have it handle
PCAP_WARNING values as well.
This commit is contained in:
parent
a590c21380
commit
c6aa29a8dc
4
FILES
4
FILES
|
@ -1,4 +1,4 @@
|
|||
CHANGES
|
||||
HANGES
|
||||
ChmodBPF/ChmodBPF
|
||||
ChmodBPF/StartupParameters.plist
|
||||
CREDITS
|
||||
|
@ -133,7 +133,6 @@ pcap_dump_file.3pcap
|
|||
pcap_dump_flush.3pcap
|
||||
pcap_dump_ftell.3pcap
|
||||
pcap_dump_open.3pcap
|
||||
pcap_errtostr.3pcap
|
||||
pcap_file.3pcap
|
||||
pcap_fileno.3pcap
|
||||
pcap_findalldevs.3pcap
|
||||
|
@ -164,6 +163,7 @@ pcap_setfilter.3pcap
|
|||
pcap_setnonblock.3pcap
|
||||
pcap_snapshot.3pcap
|
||||
pcap_stats.3pcap
|
||||
pcap_statustostr.3pcap
|
||||
pcap_strerror.3pcap
|
||||
pcap-filter.4
|
||||
pcap-linktype.4
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.117 2008-04-06 20:22:13 guy Exp $ (LBL)
|
||||
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.118 2008-04-09 21:39:21 guy Exp $ (LBL)
|
||||
|
||||
#
|
||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||
|
@ -115,7 +115,6 @@ MAN3PCAP = pcap.3pcap \
|
|||
pcap_dump_flush.3pcap \
|
||||
pcap_dump_ftell.3pcap \
|
||||
pcap_dump_open.3pcap \
|
||||
pcap_errtostr.3pcap \
|
||||
pcap_file.3pcap \
|
||||
pcap_fileno.3pcap \
|
||||
pcap_findalldevs.3pcap \
|
||||
|
@ -146,6 +145,7 @@ MAN3PCAP = pcap.3pcap \
|
|||
pcap_setnonblock.3pcap \
|
||||
pcap_snapshot.3pcap \
|
||||
pcap_stats.3pcap \
|
||||
pcap_statustostr.3pcap \
|
||||
pcap_strerror.3pcap
|
||||
|
||||
MAN4 = pcap-filter.4 \
|
||||
|
|
36
pcap.c
36
pcap.c
|
@ -33,7 +33,7 @@
|
|||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.118 2008-04-09 21:26:12 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.119 2008-04-09 21:39:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -223,19 +223,19 @@ pcap_t *
|
|||
pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *errbuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
int err;
|
||||
int status;
|
||||
|
||||
p = pcap_create(source, errbuf);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
err = pcap_set_snaplen(p, snaplen);
|
||||
if (err < 0)
|
||||
status = pcap_set_snaplen(p, snaplen);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
err = pcap_set_promisc(p, promisc);
|
||||
if (err < 0)
|
||||
status = pcap_set_promisc(p, promisc);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
err = pcap_set_timeout(p, to_ms);
|
||||
if (err < 0)
|
||||
status = pcap_set_timeout(p, to_ms);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
/*
|
||||
* Mark this as opened with pcap_open_live(), so that, for
|
||||
|
@ -248,17 +248,17 @@ pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *er
|
|||
* the adapter is in monitor mode or not.
|
||||
*/
|
||||
p->oldstyle = 1;
|
||||
err = pcap_activate(p);
|
||||
if (err < 0)
|
||||
status = pcap_activate(p);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
return (p);
|
||||
fail:
|
||||
if (err == PCAP_ERROR || err == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
err == PCAP_ERROR_PERM_DENIED)
|
||||
if (status == PCAP_ERROR || status == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
status == PCAP_ERROR_PERM_DENIED)
|
||||
strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
|
||||
pcap_errtostr(err));
|
||||
pcap_statustostr(status));
|
||||
pcap_close(p);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -893,15 +893,21 @@ pcap_win32strerror(void)
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Generate error strings for PCAP_ERROR_ values.
|
||||
* Generate error strings for PCAP_ERROR_ and PCAP_WARNING_ values.
|
||||
*/
|
||||
const char *
|
||||
pcap_errtostr(int errnum)
|
||||
pcap_statustostr(int errnum)
|
||||
{
|
||||
static char ebuf[15+10+1];
|
||||
|
||||
switch (errnum) {
|
||||
|
||||
case PCAP_WARNING:
|
||||
return("Generic warning");
|
||||
|
||||
case PCAP_WARNING_PROMISC_NOTSUP:
|
||||
return ("That device doesn't support promiscuous mode");
|
||||
|
||||
case PCAP_ERROR:
|
||||
return("Generic error");
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.9 2008-04-09 21:26:12 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.10 2008-04-09 21:39:21 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_pcap_h
|
||||
|
@ -279,7 +279,7 @@ int pcap_getnonblock(pcap_t *, char *);
|
|||
int pcap_setnonblock(pcap_t *, int, char *);
|
||||
int pcap_inject(pcap_t *, const void *, size_t);
|
||||
int pcap_sendpacket(pcap_t *, const u_char *, int);
|
||||
const char *pcap_errtostr(int);
|
||||
const char *pcap_statustostr(int);
|
||||
const char *pcap_strerror(int);
|
||||
char *pcap_geterr(pcap_t *);
|
||||
void pcap_perror(pcap_t *, char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap_errtostr.3pcap,v 1.1 2008-04-06 19:55:33 guy Exp $
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap_statustostr.3pcap,v 1.1 2008-04-09 21:39:21 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -19,9 +19,9 @@
|
|||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_ERRTOSTR 3PCAP "6 April 2008"
|
||||
.TH PCAP_STATUSTOSTR 3PCAP "9 April 2008"
|
||||
.SH NAME
|
||||
pcap_errtostr \- convert a PCAP_ERROR_ value to a string
|
||||
pcap_statustostr \- convert a PCAP_ERROR_ or PCAP_WARNING_ value to a string
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
|
@ -29,13 +29,15 @@ pcap_errtostr \- convert a PCAP_ERROR_ value to a string
|
|||
.ft
|
||||
.LP
|
||||
.ft B
|
||||
const char *pcap_errtostr(int error);
|
||||
const char *pcap_statustostr(int error);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_errtostr()
|
||||
.B pcap_statustostr()
|
||||
converts a
|
||||
.B PCAP_ERROR_
|
||||
or
|
||||
.B PCAP_WARNING_
|
||||
value returned by a libpcap routine to an error string.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP)
|
Reference in New Issue