mirror of
https://github.com/nmap/nmap.git
synced 2025-12-26 17:39:03 +00:00
Updated the included libpcap to 1.5.3
This commit is contained in:
@@ -52,7 +52,6 @@ static const char rcsid[] _U_ =
|
||||
static int dlpromiscon(pcap_t *, bpf_u_int32);
|
||||
static int pcap_read_libdlpi(pcap_t *, int, pcap_handler, u_char *);
|
||||
static int pcap_inject_libdlpi(pcap_t *, const void *, size_t);
|
||||
static void pcap_close_libdlpi(pcap_t *);
|
||||
static void pcap_libdlpi_err(const char *, const char *, int, char *);
|
||||
static void pcap_cleanup_libdlpi(pcap_t *);
|
||||
|
||||
@@ -101,6 +100,7 @@ list_interfaces(const char *linkname, void *arg)
|
||||
static int
|
||||
pcap_activate_libdlpi(pcap_t *p)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int retv;
|
||||
dlpi_handle_t dh;
|
||||
dlpi_info_t dlinfo;
|
||||
@@ -122,7 +122,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
p->errbuf);
|
||||
return (err);
|
||||
}
|
||||
p->dlpi_hd = dh;
|
||||
pd->dlpi_hd = dh;
|
||||
|
||||
if (p->opt.rfmon) {
|
||||
/*
|
||||
@@ -134,7 +134,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
}
|
||||
|
||||
/* Bind with DLPI_ANY_SAP. */
|
||||
if ((retv = dlpi_bind(p->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
|
||||
if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_bind", retv, p->errbuf);
|
||||
goto bad;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
}
|
||||
|
||||
/* Determine link type. */
|
||||
if ((retv = dlpi_info(p->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
|
||||
if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_info", retv, p->errbuf);
|
||||
goto bad;
|
||||
}
|
||||
@@ -189,10 +189,10 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
if (pcap_process_mactype(p, dlinfo.di_mactype) != 0)
|
||||
goto bad;
|
||||
|
||||
p->fd = dlpi_fd(p->dlpi_hd);
|
||||
p->fd = dlpi_fd(pd->dlpi_hd);
|
||||
|
||||
/* Push and configure bufmod. */
|
||||
if (pcap_conf_bufmod(p, p->snapshot, p->md.timeout) != 0)
|
||||
if (pcap_conf_bufmod(p, p->snapshot) != 0)
|
||||
goto bad;
|
||||
|
||||
/*
|
||||
@@ -235,9 +235,11 @@ bad:
|
||||
static int
|
||||
dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int retv;
|
||||
int err;
|
||||
|
||||
retv = dlpi_promiscon(p->hd, level);
|
||||
retv = dlpi_promiscon(pd->dlpi_hd, level);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES))
|
||||
@@ -299,6 +301,7 @@ done:
|
||||
static int
|
||||
pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int len;
|
||||
u_char *bufp;
|
||||
size_t msglen;
|
||||
@@ -324,7 +327,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
|
||||
msglen = p->bufsize;
|
||||
bufp = p->buffer + p->offset;
|
||||
|
||||
retv = dlpi_recv(p->dlpi_hd, NULL, NULL, bufp,
|
||||
retv = dlpi_recv(pd->dlpi_hd, NULL, NULL, bufp,
|
||||
&msglen, -1, NULL);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
/*
|
||||
@@ -336,7 +339,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
|
||||
len = 0;
|
||||
continue;
|
||||
}
|
||||
pcap_libdlpi_err(dlpi_linkname(p->dlpi_hd),
|
||||
pcap_libdlpi_err(dlpi_linkname(pd->dlpi_hd),
|
||||
"dlpi_recv", retv, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
@@ -350,11 +353,12 @@ process_pkts:
|
||||
static int
|
||||
pcap_inject_libdlpi(pcap_t *p, const void *buf, size_t size)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int retv;
|
||||
|
||||
retv = dlpi_send(p->dlpi_hd, NULL, 0, buf, size, NULL);
|
||||
retv = dlpi_send(pd->dlpi_hd, NULL, 0, buf, size, NULL);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
pcap_libdlpi_err(dlpi_linkname(p->dlpi_hd), "dlpi_send", retv,
|
||||
pcap_libdlpi_err(dlpi_linkname(pd->dlpi_hd), "dlpi_send", retv,
|
||||
p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
@@ -372,9 +376,11 @@ pcap_inject_libdlpi(pcap_t *p, const void *buf, size_t size)
|
||||
static void
|
||||
pcap_cleanup_libdlpi(pcap_t *p)
|
||||
{
|
||||
if (p->dlpi_hd != NULL) {
|
||||
dlpi_close(p->dlpi_hd);
|
||||
p->dlpi_hd = NULL;
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
|
||||
if (pd->dlpi_hd != NULL) {
|
||||
dlpi_close(pd->dlpi_hd);
|
||||
pd->dlpi_hd = NULL;
|
||||
p->fd = -1;
|
||||
}
|
||||
pcap_cleanup_live_common(p);
|
||||
@@ -391,11 +397,11 @@ pcap_libdlpi_err(const char *linkname, const char *func, int err, char *errbuf)
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
pcap_create(const char *device, char *ebuf)
|
||||
pcap_create_interface(const char *device, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = pcap_create_common(device, ebuf);
|
||||
p = pcap_create_common(device, ebuf, sizeof (struct pcap_dlpi));
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user