Skip to content
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

pcap_setmode(m_PcapDescriptor, MODE_CAPT) fails #558

Closed
siilky opened this issue Oct 31, 2021 · 4 comments
Closed

pcap_setmode(m_PcapDescriptor, MODE_CAPT) fails #558

siilky opened this issue Oct 31, 2021 · 4 comments

Comments

@siilky
Copy link

@siilky siilky commented Oct 31, 2021

I'm using npcap in winpcap compatibility mode on windows 11.
When calling pcap_setmode(m_PcapDescriptor, MODE_CAPT) it fails on the DeviceIoControl call inside of PacketSetMode(LPADAPTER AdapterObject,int mode) function.
This seems to be a kind of regression of new releases:
in 1.55 and 1.50 builds call is failing,
1.31 works ok.

@dmiller-nmap
Copy link
Contributor

@dmiller-nmap dmiller-nmap commented Nov 1, 2021

Thanks for the report. Can you provide your DiagReport output and any info on whether other pcap functions are working for you? MODE_CAPT is the default, so unless the descriptor was in MODE_STAT previously, it shouldn't make a difference whether that function is called. (This is an implementation detail and should not be taken to mean that pcap_setmode will never need to be called in other versions, releases, or forks. I mentioned it because it may help us with debugging only.)

@siilky
Copy link
Author

@siilky siilky commented Nov 2, 2021

Which exactly other pcap functions are you interesting in? There are several at initialization process (I'm using that over pcap++, they have related issue for this seladb/PcapPlusPlus#680 which I came from) like pcap_create, pcap_set_timeout, pcap_set_buffer_size, pcap_activate, pcap_datalink - they are ok.
Wireshark capture is working fine on the same setup.
Diag report is attached.
DiagReport-20211102-183847.txt

@dmiller-nmap
Copy link
Contributor

@dmiller-nmap dmiller-nmap commented Nov 29, 2021

This is a regression in Npcap 1.50 and 1.55 due to the change in f82685f which assumed incorrectly that each MODE_* constant was a set bit in the mode parameter. MODE_CAPT is actually defined as 0, so pcap_setmode(p, 0) is rejected. Since this call is effectively a no-op for capture handles that have not previously been set to MODE_STAT, it did not affect the software we were testing with. We will investigate better tests to avoid similar regressions in the future.

The handler for BIOCSMODE IoControl has been rewritten for the next release, and this bug was not reproduced. The next release of Npcap will not be affected. As a workaround, software can avoid calling pcap_setmode with values other than MODE_STAT.

@dmiller-nmap
Copy link
Contributor

@dmiller-nmap dmiller-nmap commented Dec 13, 2021

Fixed in Npcap 1.60.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants