]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use pcap_get_selectable_fd() to get the FD on which to do a select().
authorGuy Harris <[email protected]>
Fri, 24 Jul 2009 19:17:10 +0000 (12:17 -0700)
committerGuy Harris <[email protected]>
Fri, 24 Jul 2009 19:17:10 +0000 (12:17 -0700)
seltest.c

index ffb4ffc7a3d2fec82e6172f3f3c0928e1bef6962..c16afcb538d83158e54bad07c12ebb7ec374f867 100644 (file)
--- a/seltest.c
+++ b/seltest.c
@@ -126,26 +126,28 @@ main(int argc, char **argv)
        printf("Listening on %s\n", device);
        if (doselect) {
                for (;;) {
        printf("Listening on %s\n", device);
        if (doselect) {
                for (;;) {
+                       int selectable_fd;
                        fd_set setread, setexcept;
                        struct timeval timeout;
 
                        fd_set setread, setexcept;
                        struct timeval timeout;
 
+                       selectable_fd = pcap_get_selectable_fd(pd);
                        FD_ZERO(&setread);
                        FD_ZERO(&setread);
-                       FD_SET(pcap_fileno(pd), &setread);
+                       FD_SET(selectable_fd, &setread);
                        FD_ZERO(&setexcept);
                        FD_ZERO(&setexcept);
-                       FD_SET(pcap_fileno(pd), &setexcept);
+                       FD_SET(selectable_fd, &setexcept);
                        if (dotimeout) {
                                timeout.tv_sec = 0;
                                timeout.tv_usec = 1000;
                        if (dotimeout) {
                                timeout.tv_sec = 0;
                                timeout.tv_usec = 1000;
-                               select(pcap_fileno(pd) + 1, &setread, NULL,
+                               select(selectable_fd + 1, &setread, NULL,
                                    &setexcept, &timeout);
                        } else
                                    &setexcept, &timeout);
                        } else
-                               select(pcap_fileno(pd) + 1, &setread, NULL,
+                               select(selectable_fd + 1, &setread, NULL,
                                    &setexcept, NULL);
                                    &setexcept, NULL);
-                       if (FD_ISSET(pcap_fileno(pd), &setread))
+                       if (FD_ISSET(selectable_fd, &setread))
                                printf("Select says descriptor is readable\n");
                        else
                                printf("Select doesn't say descriptor is readable\n");
                                printf("Select says descriptor is readable\n");
                        else
                                printf("Select doesn't say descriptor is readable\n");
-                       if (FD_ISSET(pcap_fileno(pd), &setexcept))
+                       if (FD_ISSET(selectable_fd, &setexcept))
                                printf("Select says descriptor has exceptional condition\n");
                        else
                                printf("Select doesn't say descriptor has exceptional condition\n");
                                printf("Select says descriptor has exceptional condition\n");
                        else
                                printf("Select doesn't say descriptor has exceptional condition\n");