Skip to content
This repository
Browse code

Check pcap supports monitor mode

Some versions of pcap don't support monitor mode. See this commit:

mattsta@4452d85

Use whether the error code for PCAP_ERROR_RFMON_NOTSUP is defined as
a weak check for pcap support.

Thanks @mattsta!
  • Loading branch information...
commit f74db23d5d4b39ef8af649454ff37aad5f3b23e8 1 parent 94817d2
Michael Santos authored April 11, 2012

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  c_src/epcap.c
4  c_src/epcap.c
@@ -156,8 +156,10 @@ epcap_open(EPCAP_STATE *ep)
156 156
         PCAP_ERRBUF(ep->p = pcap_open_live(ep->dev, ep->snaplen, ep->promisc, ep->timeout, errbuf));
157 157
 
158 158
         /* monitor mode */
  159
+#ifdef PCAP_ERROR_RFMON_NOTSUP
159 160
         if (pcap_can_set_rfmon(ep->p) == 1)
160 161
             (void)pcap_set_rfmon(ep->p, ep->rfmon);
  162
+#endif
161 163
     }
162 164
 
163 165
     return (0);
@@ -295,7 +297,9 @@ usage(EPCAP_STATE *ep)
295 297
             "              -d <directory>   chroot directory\n"
296 298
             "              -i <interface>   interface to snoop\n"
297 299
             "              -f <filename>    read from file instead of live capture\n"
  300
+#ifdef PCAP_ERROR_RFMON_NOTSUP
298 301
             "              -M               wireless monitor (rfmon) mode\n"
  302
+#endif
299 303
             "              -P               promiscuous mode\n"
300 304
             "              -g <group>       unprivileged group\n"
301 305
             "              -u <user>        unprivileged user\n"

0 notes on commit f74db23

Please sign in to comment.
Something went wrong with that request. Please try again.