mirror of
https://github.com/nmap/nmap.git
synced 2025-12-29 02:49:01 +00:00
Update libpcap to 1.9.0 (no patches applied yet)
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -95,8 +95,8 @@ again:
|
||||
case EWOULDBLOCK:
|
||||
return (0); /* XXX */
|
||||
}
|
||||
pcap_snprintf(p->errbuf, sizeof(p->errbuf),
|
||||
"read: %s", pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
|
||||
errno, "read");
|
||||
return (-1);
|
||||
}
|
||||
sh = (struct snoopheader *)p->buffer;
|
||||
@@ -150,8 +150,8 @@ pcap_inject_snoop(pcap_t *p, const void *buf, size_t size)
|
||||
*/
|
||||
ret = write(p->fd, buf, size);
|
||||
if (ret == -1) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "send");
|
||||
return (-1);
|
||||
}
|
||||
return (ret);
|
||||
@@ -167,8 +167,8 @@ pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
|
||||
rs = &rawstats;
|
||||
memset(rs, 0, sizeof(*rs));
|
||||
if (ioctl(p->fd, SIOCRAWSTATS, (char *)rs) < 0) {
|
||||
pcap_snprintf(p->errbuf, sizeof(p->errbuf),
|
||||
"SIOCRAWSTATS: %s", pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
|
||||
errno, "SIOCRAWSTATS");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ pcap_activate_snoop(pcap_t *p)
|
||||
|
||||
fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
|
||||
if (fd < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snoop socket: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "snoop socket");
|
||||
goto bad;
|
||||
}
|
||||
p->fd = fd;
|
||||
@@ -228,14 +228,14 @@ pcap_activate_snoop(pcap_t *p)
|
||||
* they might be the same error, if they both end up
|
||||
* meaning "snoop doesn't know about that device".
|
||||
*/
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snoop bind: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "snoop bind");
|
||||
goto bad;
|
||||
}
|
||||
memset(&sf, 0, sizeof(sf));
|
||||
if (ioctl(fd, SIOCADDSNOOP, &sf) < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCADDSNOOP: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "SIOCADDSNOOP");
|
||||
goto bad;
|
||||
}
|
||||
if (p->opt.buffer_size != 0)
|
||||
@@ -323,6 +323,17 @@ pcap_activate_snoop(pcap_t *p)
|
||||
return (PCAP_ERROR_RFMON_NOTSUP);
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn a negative snapshot value (invalid), a snapshot value of
|
||||
* 0 (unspecified), or a value bigger than the normal maximum
|
||||
* value, into the maximum allowed value.
|
||||
*
|
||||
* If some application really *needs* a bigger snapshot
|
||||
* length, we should just increase MAXIMUM_SNAPLEN.
|
||||
*/
|
||||
if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
|
||||
p->snapshot = MAXIMUM_SNAPLEN;
|
||||
|
||||
#ifdef SIOCGIFMTU
|
||||
/*
|
||||
* XXX - IRIX appears to give you an error if you try to set the
|
||||
@@ -332,8 +343,8 @@ pcap_activate_snoop(pcap_t *p)
|
||||
*/
|
||||
(void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFMTU, (char *)&ifr) < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMTU: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "SIOCGIFMTU");
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
@@ -366,22 +377,22 @@ pcap_activate_snoop(pcap_t *p)
|
||||
if (snooplen < 0)
|
||||
snooplen = 0;
|
||||
if (ioctl(fd, SIOCSNOOPLEN, &snooplen) < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCSNOOPLEN: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "SIOCSNOOPLEN");
|
||||
goto bad;
|
||||
}
|
||||
v = 1;
|
||||
if (ioctl(fd, SIOCSNOOPING, &v) < 0) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCSNOOPING: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "SIOCSNOOPING");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
p->bufsize = 4096; /* XXX */
|
||||
p->buffer = malloc(p->bufsize);
|
||||
if (p->buffer == NULL) {
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "malloc");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@@ -428,8 +439,29 @@ can_be_bound(const char *name _U_)
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||
static int
|
||||
get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
|
||||
{
|
||||
return (pcap_findalldevs_interfaces(alldevsp, errbuf, can_be_bound));
|
||||
/*
|
||||
* Nothing we can do.
|
||||
* XXX - is there a way to find out whether an adapter has
|
||||
* something plugged into it?
|
||||
*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
|
||||
{
|
||||
return (pcap_findalldevs_interfaces(devlistp, errbuf, can_be_bound,
|
||||
get_if_flags));
|
||||
}
|
||||
|
||||
/*
|
||||
* Libpcap version string.
|
||||
*/
|
||||
const char *
|
||||
pcap_lib_version(void)
|
||||
{
|
||||
return (PCAP_VERSION_STRING);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user