]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-netmap.c
Fix typpo.
[libpcap] / pcap-netmap.c
index 3c9de68aee4abfdefc344c7eca3ab28860d47888..ee8d8b3afbc81590eecc0b54e43329691ce674e9 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <poll.h>
@@ -188,13 +188,14 @@ static int
 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);
        }
@@ -204,6 +205,18 @@ pcap_netmap_activate(pcap_t *p)
                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)) {
@@ -244,11 +257,12 @@ pcap_netmap_create(const char *device, char *ebuf, int *is_ours)
 }
 
 /*
- * 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;
 }
-