New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Npcap API documentation shouldn't discourage pcap_getevent() usage *too* strongly #1326

Open
guyharris opened this Issue Sep 17, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@guyharris

guyharris commented Sep 17, 2018

The Npcap API documentation says of pcap_getevent() "We disourage the use of this function because it is not portable."

It's true that it's not portable, but so is pcap_get_selectable_fd(), which is more or less the UN*X equivalent. If a program needs an event loop that waits for multiple events, including availability of packets from a pcap_t, the code will inherently be non-portable because there's no API for event loops that's portable (select() on Windows only works on sockets, as far as I know).

So if a program needs such an event loop, and needs to work on both UN*X and Windows, you don't really have a choice about using pcap_get_selectable_fd() (and, as of 1.9, pcap_get_required_select_timeout(), if you want to be able to support DAG cards) on UN*X and pcap_getevent() on Windows.

@guyharris guyharris changed the title from The "The Npcap API" documentation shouldn't discourage pcap_getevent() usage *too* strongly to The Npcap API documentation shouldn't discourage pcap_getevent() usage *too* strongly Sep 17, 2018

@dmiller-nmap

This comment has been minimized.

Show comment
Hide comment
@dmiller-nmap

dmiller-nmap Sep 26, 2018

This is good info. After all, even Nmap uses pcap_getevent(). I'll elaborate a bit in the docs to indicate:

  1. that portable code should use pcap_get_selectable_fd() on other platforms, and
  2. that portable code should prefer the pcap_loop and pcap_dispatch APIs where they are appropriate.

dmiller-nmap commented Sep 26, 2018

This is good info. After all, even Nmap uses pcap_getevent(). I'll elaborate a bit in the docs to indicate:

  1. that portable code should use pcap_get_selectable_fd() on other platforms, and
  2. that portable code should prefer the pcap_loop and pcap_dispatch APIs where they are appropriate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment