]> The Tcpdump Group git mirrors - libpcap/commitdiff
For mac80211 devices we need to clean up monitor mode on exit.
authorGuy Harris <[email protected]>
Fri, 9 Dec 2011 03:51:00 +0000 (19:51 -0800)
committerGuy Harris <[email protected]>
Fri, 9 Dec 2011 03:51:00 +0000 (19:51 -0800)
Just as with non-mac80211 devices, the stuff we do to enter monitor mode
doesn't automatically get cleaned up when the capture device is closed,
so we need to arrange that pcap_close_all() be called when we exit, to
close all the pcap_t's and turn off monitor mode.

pcap-linux.c

index 5079eb262518a0ee319c9c48bd9f6fab4f084b0f..e0238142427a394d7da324c5ead50dc37b3cf35b 100644 (file)
@@ -902,6 +902,18 @@ added:
         */
        pcap_add_to_pcaps_to_close(handle);
 
         */
        pcap_add_to_pcaps_to_close(handle);
 
+       /*
+        * If we haven't already done so, arrange to have
+        * "pcap_close_all()" called when we exit.
+        */
+       if (!pcap_do_addexit(handle)) {
+               /*
+                * "atexit()" failed; don't put the interface
+                * in rfmon mode, just give up.
+                */
+               return PCAP_ERROR_RFMON_NOTSUP;
+       }
+
        return 1;
 }
 #endif /* HAVE_LIBNL */
        return 1;
 }
 #endif /* HAVE_LIBNL */