Index: head/lib/libpcap/pcap-netmap.c =================================================================== --- head/lib/libpcap/pcap-netmap.c +++ head/lib/libpcap/pcap-netmap.c @@ -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 @@ 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 @@ } } nm_close(d); -#ifdef HAVE_NO_PRIV - free(pn); - SET_PRIV(p, NULL); // unnecessary -#endif pcap_cleanup_live_common(p); } @@ -216,10 +197,6 @@ 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 @@ *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); }