nmap / nmap/npcap

Feature proposal: notification of new/deleted interfaces via event/handle

Open
#823 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.6k
Forks
592
PR merge metrics
No merged PRs in 30d

Description

At the time NPF_AttachAdapter() finishes, the adapter should be available for capturing. Some mechanism by which to notify the application that a new adapter is available - or that an adapter has disappeared - might be useful; Wireshark could use it, for example, to update its list of adapters (it already does so on macOS, *BSD, and Linux).

A simple event handle would suffice, although all the UN*X platforms on which Wireshark does that provide separate "new interface" and "interface disappeared" indications, and provides the name of the interface - Wireshark doesn't currently use that for new interfaces, but it does use that for deleted interfaces. If Npcap could provide that, it'd fit in with Wireshark (and with any future libpcap platform-independent API for interface list change notifications).

Wireshark would use this in capture/iface_monitor.c. That file defines routines:

  • iface_mon_start() - that takes a pointer to a callback routine, and starts the monitoring process;

  • iface_mon_stop() - that stops the monitoring process;

  • iface_mon_get_sock() - that gets the a UNIX file descriptor for the socket used for monitoring, so that it can be checked in Wireshark's event loop;

  • iface_mon_event() - that is the routine to call from the event loop when events are available on the socket;

  • iface_mon_enable() - takes a flag to indicate whether to temporarily enable or disable the monitoring process, in order to work around a Linux issue.

For Npcap, iface_mon_get_sock() would be replaced by, for example, iface_mon_get_handle(), which would return a HANDLE, which would be provided to Qt (the GUI toolkit for Wireshark) to wait for an event. It looks as if Qt's QWinEventNotifier (https://doc.qt.io/qt-6/qwineventnotifier.html) could be used to wait on the HANDLE. Qt's Windows main loop calls MsgWaitForMultipleObjectsEx() with a null pHandles pointer, so it doesn't wait for the HANDLE, but the QWinEventNotifier code calls SetThreadpoolWait() on the handle, so I guess there's a special thread that does the waiting, with the thread activating an internal Qt signal when the event is triggered. I presume there's a good reason why they do it that way.

iface_mon_enable() would be a no-op routine, as the Linux issue is specific to what I think is the "right" way to capture in monitor mode on Linux (create some kind of cloned adapter and put it into monitor mode).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NPF_AttachAdapter() and Wireshark's capture/iface_monitor.c to understand the expected notification lifecycle and callback flow. Review Qt's QWinEventNotifier as the mentioned HANDLE consumer. Done means a defined Npcap mechanism for new and removed adapters, including interface names and a waitable HANDLE suitable for Wireshark.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.