nmap / nmap/npcap

Fix and update Npcap example code

Open
#784 1 comment 0 reactions 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

The code examples we provide with Npcap (which we inherited from the now-obsolete WinPcap) need to be updated for several reasons:

  • Doesn't always handle the new VLAN tags feature properly. For example it treats ethernet headers as always 14 bytes in various places like "ih = (ip_header *) (pkt_data + 14); //length of ethernet header"
  • The fact that we have 2 separate trees: one is supposed to be mingw-compatible, I think, but we haven't really tried that.
  • Most uses older libpcap API functions like pcap_open_live instead of pcap_create/pcap_activate.
  • There are likely bugs in general that we've never checked for.
  • very ugly code with mixed tabs/spaces
  • Only enable promiscuous mode in the examples in cases where it is likely to be particularly useful rather than as a general approach. Most users don't need it and it harms performance when they set it (sometimes by copying our samples) in cases where it isn't needed. The switch to the pcap_create/pcap_activate API may resolve this since it doesn't have the promisc boolean like pcap_open_live does.

Some users may (reasonably) start from our sample code, so it is especially important for us to set a good example.

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

Locate the two example trees and audit the packet-header handling, pcap_open_live uses, VLAN assumptions, promiscuous-mode settings, and formatting. Compare the examples with the current libpcap API and verify the result across the stated compatibility targets; done means the examples are reviewed and updated consistently, with their existing bugs and assumptions checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.