*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <poll.h>
pcap_netmap_activate(pcap_t *p)
{
struct pcap_netmap *pn = p->priv;
- struct nm_desc *d = nm_open(p->opt.device, NULL, 0, NULL);
+ struct nm_desc *d;
uint32_t if_flags = 0;
+ d = nm_open(p->opt.device, NULL, 0, NULL);
if (d == NULL) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "netmap open: cannot access %s: %s\n",
- p->opt.device, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "netmap open: cannot access %s",
+ p->opt.device);
pcap_cleanup_live_common(p);
return (PCAP_ERROR);
}
d->first_rx_ring, d->last_rx_ring);
pn->d = d;
p->fd = d->fd;
+
+ /*
+ * Turn a negative snapshot value (invalid), a snapshot value of
+ * 0 (unspecified), or a value bigger than the normal maximum
+ * value, into the maximum allowed value.
+ *
+ * If some application really *needs* a bigger snapshot
+ * length, we should just increase MAXIMUM_SNAPLEN.
+ */
+ if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
+ p->snapshot = MAXIMUM_SNAPLEN;
+
if (p->opt.promisc && !(d->req.nr_ringid & NETMAP_SW_RING)) {
pcap_netmap_ioctl(p, SIOCGIFFLAGS, &if_flags); /* fetch flags */
if (!(if_flags & IFF_PPROMISC)) {
}
/*
- * XXX - is there a way to enumerate the netmap devices?
+ * The "device name" for netmap devices isn't a name for a device, it's
+ * an expression that indicates how the device should be set up, so
+ * there's no way to enumerate them.
*/
int
-pcap_netmap_findalldevs(pcap_if_list_t *devlistp, char *err_str)
+pcap_netmap_findalldevs(pcap_if_list_t *devlistp _U_, char *err_str _U_)
{
return 0;
}
-