Nmap Development mailing list archives
Nsock has trouble handling pcap reads on Windows
From: Luis MartinGarcia <luis.mgarc () gmail com>
Date: Tue, 3 Aug 2010 15:28:39 +0200
Hi, I've detected that Nsock has trouble handling pcap read events on Windows. The thing is that on Windows, the pcap descriptor is not selectable. Therefore, when Nsock waits for an event, with fselect(), it does not detect new packets being captured until the fselect() call times out and the pcap descriptor is checked for new data. This way, if we schedule a pcap read event like this: nsock_pcap_read_packet(nsp, pcap_nsi, pcap_event_handler, 10000, NULL) // Timeout 10s nsock_loop(nsp, 5000); // Timeout 5s Nsock does not call pcap_event_handler() until the nsock_loop() times out after 5s, even if we captured a hundred packets in the meantime. To solve this, we need to detect when a pcap read event has been scheduled, and make any select() call to timeout quickly, so the pcap descriptor can be polled often, and nsock delivers captured packets to the application, as soon as possible. I attach a patch that should fix this problem. Please let me know if you have any comments. Regards, Luis MartinGarcia.
Attachment:
polling_pcap_nsock.diff
Description:
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Nsock has trouble handling pcap reads on Windows Luis MartinGarcia (Aug 03)
- Re: Nsock has trouble handling pcap reads on Windows David Fifield (Aug 04)
- Re: Nsock has trouble handling pcap reads on Windows Luis MartinGarcia (Aug 05)
- Re: Nsock has trouble handling pcap reads on Windows David Fifield (Aug 04)