mirror of
https://github.com/nmap/nmap.git
synced 2025-12-25 08:59:01 +00:00
Update libpcap to 1.10.5
This commit is contained in:
@@ -23,9 +23,7 @@
|
||||
* This module now handles the STREAMS based NIT.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -129,7 +127,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
if (cc < 0) {
|
||||
if (errno == EWOULDBLOCK)
|
||||
return (0);
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
|
||||
errno, "pcap_read");
|
||||
return (-1);
|
||||
}
|
||||
@@ -192,7 +190,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
if (caplen > p->snapshot)
|
||||
caplen = p->snapshot;
|
||||
|
||||
if (pcap_filter(p->fcode.bf_insns, cp, nlp->nh_pktlen, caplen)) {
|
||||
if (pcapint_filter(p->fcode.bf_insns, cp, nlp->nh_pktlen, caplen)) {
|
||||
struct pcap_pkthdr h;
|
||||
h.ts = ntp->nh_timestamp;
|
||||
h.len = nlp->nh_pktlen;
|
||||
@@ -225,7 +223,7 @@ pcap_inject_snit(pcap_t *p, const void *buf, int size)
|
||||
data.len = size;
|
||||
ret = putmsg(p->fd, &ctl, &data);
|
||||
if (ret == -1) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "send");
|
||||
return (-1);
|
||||
}
|
||||
@@ -249,7 +247,7 @@ nit_setflags(pcap_t *p)
|
||||
si.ic_len = sizeof(zero);
|
||||
si.ic_dp = (char *)&zero;
|
||||
if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCSCHUNK");
|
||||
return (-1);
|
||||
}
|
||||
@@ -262,7 +260,7 @@ nit_setflags(pcap_t *p)
|
||||
si.ic_len = sizeof(timeout);
|
||||
si.ic_dp = (char *)&timeout;
|
||||
if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCSTIME");
|
||||
return (-1);
|
||||
}
|
||||
@@ -274,7 +272,7 @@ nit_setflags(pcap_t *p)
|
||||
si.ic_len = sizeof(flags);
|
||||
si.ic_dp = (char *)&flags;
|
||||
if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCSFLAGS");
|
||||
return (-1);
|
||||
}
|
||||
@@ -341,7 +339,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
dev);
|
||||
} else {
|
||||
err = PCAP_ERROR;
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "%s", dev);
|
||||
}
|
||||
goto bad;
|
||||
@@ -349,13 +347,13 @@ pcap_activate_snit(pcap_t *p)
|
||||
|
||||
/* arrange to get discrete messages from the STREAM and use NIT_BUF */
|
||||
if (ioctl(fd, I_SRDOPT, (char *)RMSGD) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "I_SRDOPT");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
if (ioctl(fd, I_PUSH, "nbuf") < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "push nbuf");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
@@ -366,7 +364,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
si.ic_len = sizeof(chunksize);
|
||||
si.ic_dp = (char *)&chunksize;
|
||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCSCHUNK");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
@@ -384,7 +382,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
* Is there one that means "that device doesn't support
|
||||
* STREAMS NIT"?
|
||||
*/
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCBIND: %s", ifr.ifr_name);
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
@@ -395,7 +393,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
si.ic_len = sizeof(p->snapshot);
|
||||
si.ic_dp = (char *)&p->snapshot;
|
||||
if (ioctl(fd, I_STR, (char *)&si) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "NIOCSSNAP");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
@@ -414,7 +412,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
p->bufsize = BUFSPACE;
|
||||
p->buffer = malloc(p->bufsize);
|
||||
if (p->buffer == NULL) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "malloc");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
@@ -437,32 +435,33 @@ pcap_activate_snit(pcap_t *p)
|
||||
* Ethernet framing).
|
||||
*/
|
||||
p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
|
||||
/*
|
||||
* If that fails, just leave the list empty.
|
||||
*/
|
||||
if (p->dlt_list != NULL) {
|
||||
p->dlt_list[0] = DLT_EN10MB;
|
||||
p->dlt_list[1] = DLT_DOCSIS;
|
||||
p->dlt_count = 2;
|
||||
if (p->dlt_list == NULL) {
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "malloc");
|
||||
err = PCAP_ERROR;
|
||||
goto bad;
|
||||
}
|
||||
p->dlt_list[0] = DLT_EN10MB;
|
||||
p->dlt_list[1] = DLT_DOCSIS;
|
||||
p->dlt_count = 2;
|
||||
|
||||
p->read_op = pcap_read_snit;
|
||||
p->inject_op = pcap_inject_snit;
|
||||
p->setfilter_op = install_bpf_program; /* no kernel filtering */
|
||||
p->setfilter_op = pcapint_install_bpf_program; /* no kernel filtering */
|
||||
p->setdirection_op = NULL; /* Not implemented. */
|
||||
p->set_datalink_op = NULL; /* can't change data link type */
|
||||
p->getnonblock_op = pcap_getnonblock_fd;
|
||||
p->setnonblock_op = pcap_setnonblock_fd;
|
||||
p->getnonblock_op = pcapint_getnonblock_fd;
|
||||
p->setnonblock_op = pcapint_setnonblock_fd;
|
||||
p->stats_op = pcap_stats_snit;
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
pcapint_cleanup_live_common(p);
|
||||
return (err);
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
pcap_create_interface(const char *device _U_, char *ebuf)
|
||||
pcapint_create_interface(const char *device _U_, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
|
||||
@@ -496,9 +495,9 @@ get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
|
||||
}
|
||||
|
||||
int
|
||||
pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
|
||||
pcapint_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
|
||||
{
|
||||
return (pcap_findalldevs_interfaces(devlistp, errbuf, can_be_bound,
|
||||
return (pcapint_findalldevs_interfaces(devlistp, errbuf, can_be_bound,
|
||||
get_if_flags));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user