Remove compatibility with old libpcap.

Differential Revision:	https://reviews.freebsd.org/D9606
This commit is contained in:
Xin LI 2017-03-06 08:13:19 +00:00
parent dae3dadc43
commit 0d64c8a06d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314769

View file

@ -22,6 +22,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifdef HAVE_CONFIG_H
@ -42,24 +44,7 @@
#include "pcap-int.h"
/*
* $FreeBSD$
*
* This code is meant to build also on other versions of libpcap.
*
* older libpcap miss p->priv, use p->md.device instead (and allocate).
* Also opt.timeout was in md.timeout before.
* Use #define PCAP_IF_UP to discriminate
*/
#ifdef PCAP_IF_UP
#define NM_PRIV(p) ((struct pcap_netmap *)(p->priv))
#define the_timeout opt.timeout
#else
#define HAVE_NO_PRIV
#define NM_PRIV(p) ((struct pcap_netmap *)(p->md.device))
#define SET_PRIV(p, x) p->md.device = (void *)x
#define the_timeout md.timeout
#endif
#if defined (linux)
/* On FreeBSD we use IFF_PPROMISC which is in ifr_flagshigh.
@ -124,7 +109,7 @@ pcap_netmap_dispatch(pcap_t *p, int cnt, pcap_handler cb, u_char *user)
if (ret != 0)
break;
errno = 0;
ret = poll(&pfd, 1, p->the_timeout);
ret = poll(&pfd, 1, p->opt.timeout);
}
return ret;
}
@ -197,10 +182,6 @@ pcap_netmap_close(pcap_t *p)
}
}
nm_close(d);
#ifdef HAVE_NO_PRIV
free(pn);
SET_PRIV(p, NULL); // unnecessary
#endif
pcap_cleanup_live_common(p);
}
@ -216,10 +197,6 @@ pcap_netmap_activate(pcap_t *p)
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"netmap open: cannot access %s: %s\n",
p->opt.device, pcap_strerror(errno));
#ifdef HAVE_NO_PRIV
free(pn);
SET_PRIV(p, NULL); // unnecessary
#endif
pcap_cleanup_live_common(p);
return (PCAP_ERROR);
}
@ -261,23 +238,9 @@ pcap_netmap_create(const char *device, char *ebuf, int *is_ours)
*is_ours = (!strncmp(device, "netmap:", 7) || !strncmp(device, "vale", 4));
if (! *is_ours)
return NULL;
#ifdef HAVE_NO_PRIV
{
void *pn = calloc(1, sizeof(struct pcap_netmap));
if (pn == NULL)
return NULL;
p = pcap_create_common(device, ebuf);
if (p == NULL) {
free(pn);
return NULL;
}
SET_PRIV(p, pn);
}
#else
p = pcap_create_common(ebuf, sizeof (struct pcap_netmap));
if (p == NULL)
return (NULL);
#endif
p->activate_op = pcap_netmap_activate;
return (p);
}