Patch from Stefan Hudson <hudson@mbay.net> to handle, on Solaris, device
class names with digits in them.
This commit is contained in:
parent
283da6d726
commit
c711e1de8d
1
CREDITS
1
CREDITS
|
@ -33,6 +33,7 @@ Additional people who have contributed patches:
|
||||||
Peter Jeremy <peter.jeremy@alcatel.com.au>
|
Peter Jeremy <peter.jeremy@alcatel.com.au>
|
||||||
Rafal Maszkowski <rzm@icm.edu.pl>
|
Rafal Maszkowski <rzm@icm.edu.pl>
|
||||||
Rick Jones <raj@cup.hp.com>
|
Rick Jones <raj@cup.hp.com>
|
||||||
|
Stefan Hudson <hudson@mbay.net>
|
||||||
Tony Li <tli@jnx.com>
|
Tony Li <tli@jnx.com>
|
||||||
Uwe Girlich <Uwe.Girlich@philosys.de>
|
Uwe Girlich <Uwe.Girlich@philosys.de>
|
||||||
|
|
||||||
|
|
17
pcap-dlpi.c
17
pcap-dlpi.c
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.64 2001-02-21 09:07:41 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.65 2001-05-21 03:35:04 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -307,12 +307,17 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
/*
|
/*
|
||||||
** Determine device and ppa
|
** Determine device and ppa
|
||||||
*/
|
*/
|
||||||
cp = strpbrk(device, "0123456789");
|
cp = device+strlen(device)-1; /* Start at end of string */
|
||||||
if (cp == NULL) {
|
if (*cp < '0' || *cp > '9') {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
|
||||||
device);
|
device);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Digits at end of string are unit number */
|
||||||
|
while (cp-1 >= device && *(cp-1) >= '0' && *(cp-1) <= '9')
|
||||||
|
cp--;
|
||||||
|
|
||||||
ppa = strtol(cp, &eos, 10);
|
ppa = strtol(cp, &eos, 10);
|
||||||
if (*eos != '\0') {
|
if (*eos != '\0') {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
|
||||||
|
@ -325,10 +330,10 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
|
||||||
device);
|
device);
|
||||||
|
|
||||||
|
strlcpy(dname2, dname, sizeof(dname));
|
||||||
|
*(dname+strlen(dname)-strlen(cp))='\0';
|
||||||
|
|
||||||
/* Try device without unit number */
|
/* Try device without unit number */
|
||||||
strlcpy(dname2, dname, sizeof(dname2));
|
|
||||||
cp = strchr(dname, *cp);
|
|
||||||
*cp = '\0';
|
|
||||||
if ((p->fd = open(dname, O_RDWR)) < 0) {
|
if ((p->fd = open(dname, O_RDWR)) < 0) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
||||||
|
|
Reference in New Issue