]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-bpf.c
When activating a device, return PCAP_ERROR_IFACE_NOT_UP if the device
[libpcap] / pcap-bpf.c
index 3aa1ccf25cf53b2209b9fb147620d85136f3be43..c55170abcd14bd914f6cb79b395066baf136f749 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.110 2008-04-14 20:40:58 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.111 2008-07-01 08:02:33 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -413,11 +413,23 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
         */
        (void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
        if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
-               snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                   "BIOCSETIF: %s: %s",
-                   p->opt.source, pcap_strerror(errno));
-               close(fd);
-               return (PCAP_ERROR);
+               if (errno == ENETDOWN) {
+                       /*
+                        * Return a "network down" indication, so that
+                        * the application can report that rather than
+                        * saying we had a mysterious failure and
+                        * suggest that they report a problem to the
+                        * libpcap developers.
+                        */
+                       close(fd);
+                       return (PCAP_ERROR_IFACE_NOT_UP);
+               } else {
+                       snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+                           "BIOCSETIF: %s: %s",
+                           p->opt.source, pcap_strerror(errno));
+                       close(fd);
+                       return (PCAP_ERROR);
+               }
        }
 
        /*
@@ -1016,6 +1028,15 @@ check_setif_failure(pcap_t *p, int error)
                 */
                strcpy(p->errbuf, "");
                return (PCAP_ERROR_NO_SUCH_DEVICE);
+       } else if (errno == ENETDOWN) {
+               /*
+                * Return a "network down" indication, so that
+                * the application can report that rather than
+                * saying we had a mysterious failure and
+                * suggest that they report a problem to the
+                * libpcap developers.
+                */
+               return (PCAP_ERROR_IFACE_NOT_UP);
        } else {
                /*
                 * Some other error; fill in the error string, and