mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 04:09:01 +00:00
Update libpcap to 1.10.5
This commit is contained in:
@@ -19,9 +19,7 @@
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -113,7 +111,7 @@ pcap_read_nit(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);
|
||||
}
|
||||
@@ -181,7 +179,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
caplen = nh->nh_wirelen;
|
||||
if (caplen > p->snapshot)
|
||||
caplen = p->snapshot;
|
||||
if (pcap_filter(p->fcode.bf_insns, cp, nh->nh_wirelen, caplen)) {
|
||||
if (pcapint_filter(p->fcode.bf_insns, cp, nh->nh_wirelen, caplen)) {
|
||||
struct pcap_pkthdr h;
|
||||
h.ts = nh->nh_timestamp;
|
||||
h.len = nh->nh_wirelen;
|
||||
@@ -208,7 +206,7 @@ pcap_inject_nit(pcap_t *p, const void *buf, int size)
|
||||
strncpy(sa.sa_data, device, sizeof(sa.sa_data));
|
||||
ret = sendto(p->fd, buf, size, 0, &sa, sizeof(sa));
|
||||
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);
|
||||
}
|
||||
@@ -251,7 +249,7 @@ nit_setflags(pcap_t *p)
|
||||
nioc.nioc_flags |= NF_PROMISC;
|
||||
|
||||
if (ioctl(p->fd, SIOCSNIT, &nioc) < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "SIOCSNIT");
|
||||
return (-1);
|
||||
}
|
||||
@@ -293,7 +291,7 @@ pcap_activate_nit(pcap_t *p)
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
|
||||
if (fd < 0) {
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "socket");
|
||||
goto bad;
|
||||
}
|
||||
@@ -308,7 +306,7 @@ pcap_activate_nit(pcap_t *p)
|
||||
* they might be the same error, if they both end up
|
||||
* meaning "NIT doesn't know about that device".
|
||||
*/
|
||||
pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
errno, "bind: %s", snit.snit_ifname);
|
||||
goto bad;
|
||||
}
|
||||
@@ -323,7 +321,7 @@ pcap_activate_nit(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");
|
||||
goto bad;
|
||||
}
|
||||
@@ -344,32 +342,32 @@ pcap_activate_nit(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");
|
||||
goto bad;
|
||||
}
|
||||
p->dlt_list[0] = DLT_EN10MB;
|
||||
p->dlt_list[1] = DLT_DOCSIS;
|
||||
p->dlt_count = 2;
|
||||
|
||||
p->read_op = pcap_read_nit;
|
||||
p->inject_op = pcap_inject_nit;
|
||||
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_nit;
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
pcapint_cleanup_live_common(p);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
pcap_create_interface(const char *device _U_, char *ebuf)
|
||||
pcapint_create_interface(const char *device _U_, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
|
||||
@@ -403,9 +401,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