简体   繁体   English

pcap_handler 回调仅在使用 npcap v0.9991 时包含空包

[英]pcap_handler callback contains empty packets only when using npcap v0.9991

I have some code that is supposed to capture data from an ethernet adapter.我有一些代码应该从以太网适配器捕获数据。 I am using the following steps to get the data (after determining the name of the device in the format: "rpcap://\Device\NPF_{0C5[...]C89}"):我正在使用以下步骤获取数据(在确定设备名称的格式后:“rpcap://\Device\NPF_{0C5[...]C89}”):

deviceHandle = pcap_open(device_name, 65536, 1 /* promiscous */, 100, NULL, errbuf)

Then running a loop (until capture is supposed to be stopped) over:然后运行一个循环(直到应该停止捕获):

pcap_dispatch(deviceHandle, -1, pcap_handler, userHandle /* unsigned char* to user handle */)

When running this with the npcap dll "wpcap.dll" loaded from Windows\System32\Npcap folder I get calls to the pcap_handler callback but all parameters in the callback are always zero:使用从 Windows\System32\Npcap 文件夹加载的 npcap dll "wpcap.dll" 运行此程序时,我会调用 pcap_handler 回调,但回调中的所有参数始终为零:

header->caplen == 0
header->len == 0
header->ts.tv_sec == 0
header->ts.tv_usec == 0

The unsigned char* data is not NULL but the memory it points to is zeros only. unsigned char* 数据不是 NULL 但它指向的 memory 仅为零。

When I run the exact same code with just using Win10Pcap v10.2.5002 wpcap.dll from "Program Files (x86)\Win10Pcap\x64" (currently latest version) everything works fine and I get the captured data properly.当我仅使用“Program Files (x86)\Win10Pcap\x64”(当前最新版本)中的 Win10Pcap v10.2.5002 wpcap.dll 运行完全相同的代码时,一切正常,我可以正确获取捕获的数据。 The code was working about a year ago, so there might have been changes to npcap that cause a difference in the behavior, but I couldn't find why there is no data provided in the callback.该代码大约在一年前工作,因此可能对 npcap 进行了更改,导致行为有所不同,但我找不到回调中没有提供数据的原因。

The npcap installation and dll is part of a Wireshark v3.2.4 64bit installation and when running Wireshark and capturing data on the same ethernet adapter the data is properly shown in Wireshark, so the npcap library is working properly in that scenario. npcap 安装和 dll 是 Wireshark v3.2.4 64 位安装的一部分,当运行 Wireshark 并在同一以太网适配器上捕获数据时,数据会正确显示在 Wireshark 中,因此 npcap 库在这种情况下正常工作。

Can anyone give me a hint where the problem might be?谁能给我一个提示问题可能出在哪里? I am running the code on 64bit Windows 10. As it was working before there probably has been a change in npcap v0.9991 that was changing the behavior or requirements to get the captured data that I'm not aware of which is causing the issue.我在 64 位 Windows 10 上运行代码。因为它在 npcap v0.9991 中可能已经发生变化之前正在工作,这可能会改变获取捕获数据的行为或要求,但我不知道这是导致问题的原因.

Best regards, Gunnar最好的问候,贡纳尔

This is probably Npcap issue #178 , which is fixed in Npcap 0.9992, so it should also be fixed in the current release (0.9994 as of the time I'm writing this).这可能是Npcap 问题 #178 ,已在 Npcap 0.9992 中修复,因此它也应该在当前版本中修复(截至我撰写本文时为 0.9994)。 Upgrade your Npcap installation.升级你的 Npcap 安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM