Date: Mon, 6 Mar 2017 08:13:19 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314769 - head/lib/libpcap Message-ID: <201703060813.v268DJUq041691@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Mon Mar 6 08:13:19 2017 New Revision: 314769 URL: https://svnweb.freebsd.org/changeset/base/314769 Log: Remove compatibility with old libpcap. Differential Revision: https://reviews.freebsd.org/D9606 Modified: head/lib/libpcap/pcap-netmap.c Modified: head/lib/libpcap/pcap-netmap.c ============================================================================== --- head/lib/libpcap/pcap-netmap.c Mon Mar 6 07:11:23 2017 (r314768) +++ head/lib/libpcap/pcap-netmap.c Mon Mar 6 08:13:19 2017 (r314769) @@ -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, 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, c *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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703060813.v268DJUq041691>