Use pcap_setnonblock() on Linux.
authorEmil Mikulic <emikulic@gmail.com>
Wed, 12 Aug 2009 12:48:24 +0000 (22:48 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Mon, 17 Aug 2009 08:34:07 +0000 (18:34 +1000)
cap.c

diff --git a/cap.c b/cap.c
index 4c53e59..f304ec9 100644 (file)
--- a/cap.c
+++ b/cap.c
@@ -134,9 +134,14 @@ cap_init(const char *device, const char *filter, int promisc)
    pcap_fd = pcap_fileno(pcap);
 
    /* set non-blocking */
+#ifdef linux
+   if (pcap_setnonblock(pcap, 1, errbuf) == -1)
+      errx(1, "pcap_setnonblock(): %s", errbuf);
+#else
 { int one = 1;
    if (ioctl(pcap_fd, FIONBIO, &one) == -1)
       err(1, "ioctl(pcap_fd, FIONBIO)"); }
+#endif
 
 #ifdef BIOCSETWF
 {