s/PCAP_ERRBUFF_SIZE/PCAP_ERRBUF_SIZE/ (fatal typo)
This commit is contained in:
parent
c867b499b0
commit
466c37aaa3
8
inet.c
8
inet.c
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.31 2000-04-27 11:18:02 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.32 2000-04-27 14:24:11 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -153,7 +153,7 @@ pcap_lookupdev(errbuf)
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUFF_SIZE,
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"socket: %s", pcap_strerror(errno));
|
"socket: %s", pcap_strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ pcap_lookupdev(errbuf)
|
||||||
buf = malloc (buf_size);
|
buf = malloc (buf_size);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
close (fd);
|
close (fd);
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUFF_SIZE,
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"out of memory");
|
"out of memory");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ pcap_lookupdev(errbuf)
|
||||||
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|
||||||
&& errno != EINVAL) {
|
&& errno != EINVAL) {
|
||||||
free (buf);
|
free (buf);
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUFF_SIZE,
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||||
"SIOCGIFCONF: %s", pcap_strerror(errno));
|
"SIOCGIFCONF: %s", pcap_strerror(errno));
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
66
pcap-dlpi.c
66
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.55 2000-04-27 11:16:19 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.56 2000-04-27 14:24:12 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -242,7 +242,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUFF_SIZE);
|
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
|
@ -252,13 +252,13 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
*/
|
*/
|
||||||
cp = strpbrk(device, "0123456789");
|
cp = strpbrk(device, "0123456789");
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s missing unit number", device);
|
"%s missing unit number", device);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
ppa = strtol(cp, &eos, 10);
|
ppa = strtol(cp, &eos, 10);
|
||||||
if (*eos != '\0') {
|
if (*eos != '\0') {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s bad unit number", device);
|
"%s bad unit number", device);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
/* Map network device to /dev/dlpi unit */
|
/* Map network device to /dev/dlpi unit */
|
||||||
cp = "/dev/dlpi";
|
cp = "/dev/dlpi";
|
||||||
if ((p->fd = open(cp, O_RDWR)) < 0) {
|
if ((p->fd = open(cp, O_RDWR)) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s: %s", cp, pcap_strerror(errno));
|
"%s: %s", cp, pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -288,14 +288,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
*cp = '\0';
|
*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_ERRBUFF_SIZE, "%s: %s", dname,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try again with unit number */
|
/* Try again with unit number */
|
||||||
if ((p->fd = open(dname2, O_RDWR)) < 0) {
|
if ((p->fd = open(dname2, O_RDWR)) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "%s: %s", dname2,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s", dname2,
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "unknown mac type 0x%lu",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "unknown mac type 0x%lu",
|
||||||
infop->dl_mac_type);
|
infop->dl_mac_type);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
** This is a non standard SunOS hack to get the ethernet header.
|
** This is a non standard SunOS hack to get the ethernet header.
|
||||||
*/
|
*/
|
||||||
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "DLIOCRAW: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
** Another non standard call to get the data nicely buffered
|
** Another non standard call to get the data nicely buffered
|
||||||
*/
|
*/
|
||||||
if (ioctl(p->fd, I_PUSH, "bufmod") != 0) {
|
if (ioctl(p->fd, I_PUSH, "bufmod") != 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "I_PUSH bufmod: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "I_PUSH bufmod: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -455,7 +455,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
#endif
|
#endif
|
||||||
if (ss > 0 &&
|
if (ss > 0 &&
|
||||||
strioctl(p->fd, SBIOCSSNAP, sizeof(ss), (char *)&ss) != 0) {
|
strioctl(p->fd, SBIOCSSNAP, sizeof(ss), (char *)&ss) != 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SBIOCSSNAP: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCSSNAP: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -464,13 +464,13 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
** Set up the bufmod flags
|
** Set up the bufmod flags
|
||||||
*/
|
*/
|
||||||
if (strioctl(p->fd, SBIOCGFLAGS, sizeof(flag), (char *)&flag) < 0) {
|
if (strioctl(p->fd, SBIOCGFLAGS, sizeof(flag), (char *)&flag) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SBIOCGFLAGS: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCGFLAGS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
flag |= SB_NO_DROPS;
|
flag |= SB_NO_DROPS;
|
||||||
if (strioctl(p->fd, SBIOCSFLAGS, sizeof(flag), (char *)&flag) != 0) {
|
if (strioctl(p->fd, SBIOCSFLAGS, sizeof(flag), (char *)&flag) != 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SBIOCSFLAGS: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCSFLAGS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
to.tv_sec = to_ms / 1000;
|
to.tv_sec = to_ms / 1000;
|
||||||
to.tv_usec = (to_ms * 1000) % 1000000;
|
to.tv_usec = (to_ms * 1000) % 1000000;
|
||||||
if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
|
if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SBIOCSTIME: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCSTIME: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
** As the last operation flush the read side.
|
** As the last operation flush the read side.
|
||||||
*/
|
*/
|
||||||
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "FLUSHR: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ send_request(int fd, char *ptr, int len, char *what, char *ebuf)
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) {
|
if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"send_request: putmsg \"%s\": %s",
|
"send_request: putmsg \"%s\": %s",
|
||||||
what, pcap_strerror(errno));
|
what, pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -549,7 +549,7 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf)
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if (getmsg(fd, &ctl, (struct strbuf*)NULL, &flags) < 0) {
|
if (getmsg(fd, &ctl, (struct strbuf*)NULL, &flags) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "recv_ack: %s getmsg: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s getmsg: %s",
|
||||||
what, pcap_strerror(errno));
|
what, pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -571,24 +571,24 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf)
|
||||||
switch (dlp->error_ack.dl_errno) {
|
switch (dlp->error_ack.dl_errno) {
|
||||||
|
|
||||||
case DL_BADPPA:
|
case DL_BADPPA:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s bad ppa (device unit)", what);
|
"recv_ack: %s bad ppa (device unit)", what);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case DL_SYSERR:
|
case DL_SYSERR:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "recv_ack: %s: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: %s",
|
||||||
what, pcap_strerror(dlp->error_ack.dl_unix_errno));
|
what, pcap_strerror(dlp->error_ack.dl_unix_errno));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DL_UNSUPPORTED:
|
case DL_UNSUPPORTED:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s: Service not supplied by provider",
|
"recv_ack: %s: Service not supplied by provider",
|
||||||
what);
|
what);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s error 0x%x",
|
"recv_ack: %s error 0x%x",
|
||||||
what, (bpf_u_int32)dlp->error_ack.dl_errno);
|
what, (bpf_u_int32)dlp->error_ack.dl_errno);
|
||||||
break;
|
break;
|
||||||
|
@ -596,14 +596,14 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s unexpected primitive ack 0x%x ",
|
"recv_ack: %s unexpected primitive ack 0x%x ",
|
||||||
what, (bpf_u_int32)dlp->dl_primitive);
|
what, (bpf_u_int32)dlp->dl_primitive);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctl.len < size) {
|
if (ctl.len < size) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"recv_ack: %s ack too small (%d < %d)",
|
"recv_ack: %s ack too small (%d < %d)",
|
||||||
what, ctl.len, size);
|
what, ctl.len, size);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -754,7 +754,7 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
||||||
bpf_u_int32 buf[MAXDLBUF];
|
bpf_u_int32 buf[MAXDLBUF];
|
||||||
|
|
||||||
if (stat(device, &statbuf) < 0) {
|
if (stat(device, &statbuf) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"stat: %s: %s", device, pcap_strerror(errno));
|
"stat: %s: %s", device, pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -778,12 +778,12 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
||||||
ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
|
ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
|
||||||
}
|
}
|
||||||
if (i == ap->dl_count) {
|
if (i == ap->dl_count) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"can't find PPA for %s", device);
|
"can't find PPA for %s", device);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (ip->dl_hdw_state == HDW_DEAD) {
|
if (ip->dl_hdw_state == HDW_DEAD) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"%s: hardware state: DOWN\n", device);
|
"%s: hardware state: DOWN\n", device);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -819,19 +819,19 @@ get_dlpi_ppa(register int fd, register const char *ifname, register int unit,
|
||||||
if (cp != NULL)
|
if (cp != NULL)
|
||||||
ifname = cp + 1;
|
ifname = cp + 1;
|
||||||
if (nlist(path_vmunix, &nl) < 0) {
|
if (nlist(path_vmunix, &nl) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "nlist %s failed",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "nlist %s failed",
|
||||||
path_vmunix);
|
path_vmunix);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (nl[NL_IFNET].n_value == 0) {
|
if (nl[NL_IFNET].n_value == 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"could't find %s kernel symbol",
|
"could't find %s kernel symbol",
|
||||||
nl[NL_IFNET].n_name);
|
nl[NL_IFNET].n_name);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
kd = open("/dev/kmem", O_RDONLY);
|
kd = open("/dev/kmem", O_RDONLY);
|
||||||
if (kd < 0) {
|
if (kd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "kmem open: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "kmem open: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +854,7 @@ get_dlpi_ppa(register int fd, register const char *ifname, register int unit,
|
||||||
return (ifnet.if_index);
|
return (ifnet.if_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "Can't find %s", ifname);
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "Can't find %s", ifname);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,17 +865,17 @@ dlpi_kread(register int fd, register off_t addr,
|
||||||
register int cc;
|
register int cc;
|
||||||
|
|
||||||
if (lseek(fd, addr, SEEK_SET) < 0) {
|
if (lseek(fd, addr, SEEK_SET) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "lseek: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "lseek: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
cc = read(fd, buf, len);
|
cc = read(fd, buf, len);
|
||||||
if (cc < 0) {
|
if (cc < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "read: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "read: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
} else if (cc != len) {
|
} else if (cc != len) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "short read (%d != %d)", cc,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,
|
||||||
len);
|
len);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
22
pcap-linux.c
22
pcap-linux.c
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.17 2000-04-27 11:16:19 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.18 2000-04-27 14:24:12 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -148,7 +148,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, PCAP_ERRBUFF_SIZE,
|
snprint(ebuf, PCAP_ERRBUF_SIZE, PCAP_ERRBUF_SIZE,
|
||||||
"malloc: %s", pcap_strerror(errno));
|
"malloc: %s", pcap_strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
|
fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "socket: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "socket: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
sa.sa_family = AF_INET;
|
sa.sa_family = AF_INET;
|
||||||
(void)strncpy(sa.sa_data, device, sizeof(sa.sa_data));
|
(void)strncpy(sa.sa_data, device, sizeof(sa.sa_data));
|
||||||
if (bind(p->fd, &sa, sizeof(sa))) {
|
if (bind(p->fd, &sa, sizeof(sa))) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "bind: %s: %s", device,
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "bind: %s: %s", device,
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||||
if (ioctl(p->fd, SIOCGIFHWADDR, &ifr) < 0 ) {
|
if (ioctl(p->fd, SIOCGIFHWADDR, &ifr) < 0 ) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "SIOCGIFHWADDR: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "SIOCGIFHWADDR: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE,
|
snprint(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"unknown physical layer type 0x%x",
|
"unknown physical layer type 0x%x",
|
||||||
ifr.ifr_hwaddr.sa_family);
|
ifr.ifr_hwaddr.sa_family);
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@ -266,7 +266,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||||
if (ioctl(p->fd, SIOCGIFMTU, &ifr) < 0 ) {
|
if (ioctl(p->fd, SIOCGIFMTU, &ifr) < 0 ) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "SIOCGIFMTU: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "SIOCGIFMTU: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p->buffer = (u_char *)malloc(p->bufsize + p->offset);
|
p->buffer = (u_char *)malloc(p->bufsize + p->offset);
|
||||||
if (p->buffer == NULL) {
|
if (p->buffer == NULL) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "malloc: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -286,14 +286,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||||
if (ioctl(p->fd, SIOCGIFFLAGS, &ifr) < 0 ) {
|
if (ioctl(p->fd, SIOCGIFFLAGS, &ifr) < 0 ) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "SIOCGIFFLAGS: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "SIOCGIFFLAGS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
saved_ifr = ifr;
|
saved_ifr = ifr;
|
||||||
ifr.ifr_flags |= IFF_PROMISC;
|
ifr.ifr_flags |= IFF_PROMISC;
|
||||||
if (ioctl(p->fd, SIOCSIFFLAGS, &ifr) < 0 ) {
|
if (ioctl(p->fd, SIOCSIFFLAGS, &ifr) < 0 ) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "SIOCSIFFLAGS: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "SIOCSIFFLAGS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p->md.device = strdup(device);
|
p->md.device = strdup(device);
|
||||||
if (p->md.device == NULL) {
|
if (p->md.device == NULL) {
|
||||||
snprint(ebuf, PCAP_ERRBUFF_SIZE, "malloc: %s",
|
snprint(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
12
pcap-nit.c
12
pcap-nit.c
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.33 2000-04-27 11:16:20 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.34 2000-04-27 14:24:12 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -175,7 +175,7 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
|
||||||
nioc.nioc_flags |= NF_PROMISC;
|
nioc.nioc_flags |= NF_PROMISC;
|
||||||
|
|
||||||
if (ioctl(fd, SIOCSNIT, &nioc) < 0) {
|
if (ioctl(fd, SIOCSNIT, &nioc) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SIOCSNIT: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SIOCSNIT: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUFF_SIZE);
|
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
bzero(p, sizeof(*p));
|
bzero(p, sizeof(*p));
|
||||||
p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
|
p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"socket: %s", pcap_strerror(errno));
|
"socket: %s", pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
(void)strncpy(snit.snit_ifname, device, NITIFSIZ);
|
(void)strncpy(snit.snit_ifname, device, NITIFSIZ);
|
||||||
|
|
||||||
if (bind(fd, (struct sockaddr *)&snit, sizeof(snit))) {
|
if (bind(fd, (struct sockaddr *)&snit, sizeof(snit))) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"bind: %s: %s", snit.snit_ifname, pcap_strerror(errno));
|
"bind: %s: %s", snit.snit_ifname, pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
p->bufsize = BUFSPACE;
|
p->bufsize = BUFSPACE;
|
||||||
p->buffer = (u_char *)malloc(p->bufsize);
|
p->buffer = (u_char *)malloc(p->bufsize);
|
||||||
if (p->buffer == NULL) {
|
if (p->buffer == NULL) {
|
||||||
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUFF_SIZE);
|
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
return (p);
|
return (p);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.9 2000-04-27 11:16:20 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.10 2000-04-27 14:24:12 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/param.h> /* optionally get BSD define */
|
#include <sys/param.h> /* optionally get BSD define */
|
||||||
|
@ -56,7 +56,7 @@ pcap_t *
|
||||||
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)strlcpy(ebuf, nosup, PCAP_ERRBUFF_SIZE);
|
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
pcap-pf.c
18
pcap-pf.c
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.55 2000-04-27 09:11:13 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.56 2000-04-27 14:24:13 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -212,14 +212,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"pcap_open_live: %s", pcap_strerror(errno));
|
"pcap_open_live: %s", pcap_strerror(errno));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
bzero((char *)p, sizeof(*p));
|
bzero((char *)p, sizeof(*p));
|
||||||
p->fd = pfopen(device, O_RDONLY);
|
p->fd = pfopen(device, O_RDONLY);
|
||||||
if (p->fd < 0) {
|
if (p->fd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "pf open: %s: %s\n\
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "pf open: %s: %s\n\
|
||||||
your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
device, pcap_strerror(errno));
|
device, pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@ -229,7 +229,7 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
if (promisc)
|
if (promisc)
|
||||||
enmode |= ENPROMISC;
|
enmode |= ENPROMISC;
|
||||||
if (ioctl(p->fd, EIOCMBIS, (caddr_t)&enmode) < 0) {
|
if (ioctl(p->fd, EIOCMBIS, (caddr_t)&enmode) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCMBIS: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCMBIS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -240,13 +240,13 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
#endif
|
#endif
|
||||||
/* set the backlog */
|
/* set the backlog */
|
||||||
if (ioctl(p->fd, EIOCSETW, (caddr_t)&backlog) < 0) {
|
if (ioctl(p->fd, EIOCSETW, (caddr_t)&backlog) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCSETW: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCSETW: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
/* discover interface type */
|
/* discover interface type */
|
||||||
if (ioctl(p->fd, EIOCDEVP, (caddr_t)&devparams) < 0) {
|
if (ioctl(p->fd, EIOCDEVP, (caddr_t)&devparams) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCDEVP: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCDEVP: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
snaplen += pcap_fddipad;
|
snaplen += pcap_fddipad;
|
||||||
#endif
|
#endif
|
||||||
if (ioctl(p->fd, EIOCTRUNCATE, (caddr_t)&snaplen) < 0) {
|
if (ioctl(p->fd, EIOCTRUNCATE, (caddr_t)&snaplen) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCTRUNCATE: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCTRUNCATE: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
Filter.enf_Priority = 37; /* anything > 2 */
|
Filter.enf_Priority = 37; /* anything > 2 */
|
||||||
Filter.enf_FilterLen = 0; /* means "always true" */
|
Filter.enf_FilterLen = 0; /* means "always true" */
|
||||||
if (ioctl(p->fd, EIOCSETF, (caddr_t)&Filter) < 0) {
|
if (ioctl(p->fd, EIOCSETF, (caddr_t)&Filter) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCSETF: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCSETF: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
timeout.tv_sec = to_ms / 1000;
|
timeout.tv_sec = to_ms / 1000;
|
||||||
timeout.tv_usec = (to_ms * 1000) % 1000000;
|
timeout.tv_usec = (to_ms * 1000) % 1000000;
|
||||||
if (ioctl(p->fd, EIOCSRTIMEOUT, (caddr_t)&timeout) < 0) {
|
if (ioctl(p->fd, EIOCSRTIMEOUT, (caddr_t)&timeout) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "EIOCSRTIMEOUT: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCSRTIMEOUT: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
22
pcap-snit.c
22
pcap-snit.c
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.47 2000-04-27 11:16:20 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.48 2000-04-27 14:24:13 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -182,7 +182,7 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
|
||||||
si.ic_len = sizeof(timeout);
|
si.ic_len = sizeof(timeout);
|
||||||
si.ic_dp = (char *)&timeout;
|
si.ic_dp = (char *)&timeout;
|
||||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "NIOCSTIME: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSTIME: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
|
||||||
si.ic_len = sizeof(flags);
|
si.ic_len = sizeof(flags);
|
||||||
si.ic_dp = (char *)&flags;
|
si.ic_dp = (char *)&flags;
|
||||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "NIOCSFLAGS: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSFLAGS: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUFF_SIZE);
|
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,19 +226,19 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
bzero(p, sizeof(*p));
|
bzero(p, sizeof(*p));
|
||||||
p->fd = fd = open(dev, O_RDONLY);
|
p->fd = fd = open(dev, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "%s: %s", dev,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s", dev,
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* arrange to get discrete messages from the STREAM and use NIT_BUF */
|
/* arrange to get discrete messages from the STREAM and use NIT_BUF */
|
||||||
if (ioctl(fd, I_SRDOPT, (char *)RMSGD) < 0) {
|
if (ioctl(fd, I_SRDOPT, (char *)RMSGD) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "I_SRDOPT: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "I_SRDOPT: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (ioctl(fd, I_PUSH, "nbuf") < 0) {
|
if (ioctl(fd, I_PUSH, "nbuf") < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "push nbuf: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "push nbuf: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
si.ic_len = sizeof(chunksize);
|
si.ic_len = sizeof(chunksize);
|
||||||
si.ic_dp = (char *)&chunksize;
|
si.ic_dp = (char *)&chunksize;
|
||||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "NIOCSCHUNK: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSCHUNK: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
si.ic_len = sizeof(ifr);
|
si.ic_len = sizeof(ifr);
|
||||||
si.ic_dp = (char *)𝔦
|
si.ic_dp = (char *)𝔦
|
||||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "NIOCBIND: %s: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCBIND: %s: %s",
|
||||||
ifr.ifr_name, pcap_strerror(errno));
|
ifr.ifr_name, pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
si.ic_len = sizeof(snaplen);
|
si.ic_len = sizeof(snaplen);
|
||||||
si.ic_dp = (char *)&snaplen;
|
si.ic_dp = (char *)&snaplen;
|
||||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "NIOCSSNAP: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSSNAP: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
p->bufsize = BUFSPACE;
|
p->bufsize = BUFSPACE;
|
||||||
p->buffer = (u_char *)malloc(p->bufsize);
|
p->buffer = (u_char *)malloc(p->bufsize);
|
||||||
if (p->buffer == NULL) {
|
if (p->buffer == NULL) {
|
||||||
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUFF_SIZE);
|
strlcpy(ebuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
return (p);
|
return (p);
|
||||||
|
|
18
pcap-snoop.c
18
pcap-snoop.c
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.22 2000-04-27 09:11:14 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.23 2000-04-27 14:24:13 itojun Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -132,14 +132,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
p = (pcap_t *)malloc(sizeof(*p));
|
p = (pcap_t *)malloc(sizeof(*p));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "malloc: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
bzero((char *)p, sizeof(*p));
|
bzero((char *)p, sizeof(*p));
|
||||||
fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
|
fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "snoop socket: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "snoop socket: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -148,27 +148,27 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
sr.sr_family = AF_RAW;
|
sr.sr_family = AF_RAW;
|
||||||
(void)strncpy(sr.sr_ifname, device, sizeof(sr.sr_ifname));
|
(void)strncpy(sr.sr_ifname, device, sizeof(sr.sr_ifname));
|
||||||
if (bind(fd, (struct sockaddr *)&sr, sizeof(sr))) {
|
if (bind(fd, (struct sockaddr *)&sr, sizeof(sr))) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "snoop bind: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "snoop bind: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
bzero((char *)&sf, sizeof(sf));
|
bzero((char *)&sf, sizeof(sf));
|
||||||
if (ioctl(fd, SIOCADDSNOOP, &sf) < 0) {
|
if (ioctl(fd, SIOCADDSNOOP, &sf) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SIOCADDSNOOP: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SIOCADDSNOOP: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
v = 64 * 1024;
|
v = 64 * 1024;
|
||||||
(void)setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&v, sizeof(v));
|
(void)setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&v, sizeof(v));
|
||||||
if (ioctl(fd, SIOCSNOOPLEN, &snaplen) < 0) {
|
if (ioctl(fd, SIOCSNOOPLEN, &snaplen) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SIOCSNOOPLEN: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SIOCSNOOPLEN: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
p->snapshot = snaplen;
|
p->snapshot = snaplen;
|
||||||
v = 1;
|
v = 1;
|
||||||
if (ioctl(fd, SIOCSNOOPING, &v) < 0) {
|
if (ioctl(fd, SIOCSNOOPING, &v) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SIOCSNOOPING: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "SIOCSNOOPING: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
} else if (strncmp("lo", device, 2) == 0) {
|
} else if (strncmp("lo", device, 2) == 0) {
|
||||||
p->linktype = DLT_NULL;
|
p->linktype = DLT_NULL;
|
||||||
} else {
|
} else {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE,
|
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||||
"snoop: unknown physical layer type");
|
"snoop: unknown physical layer type");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
p->bufsize = 4096; /* XXX */
|
p->bufsize = 4096; /* XXX */
|
||||||
p->buffer = (u_char *)malloc(p->bufsize);
|
p->buffer = (u_char *)malloc(p->bufsize);
|
||||||
if (p->buffer == NULL) {
|
if (p->buffer == NULL) {
|
||||||
snprintf(ebuf, PCAP_ERRBUFF_SIZE, "malloc: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||||
pcap_strerror(errno));
|
pcap_strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue