<div dir="ltr">It looks like I just misinterpreted this piece of the documentation:<div><br></div><div>"Defines if the local adapter will capture its own generated traffic.</div><div>This flag tells the underlying capture driver to drop the packets that were sent by itself. This is usefult when building applications like bridges, that should ignore the traffic they just sent."</div><div><br></div><div>But PCAP_OPENFLAG_NOCAPTURE_LOCAL doesn't do *quite* that, instead of being based on if the traffic was sent by the driver/local adapter it actually seems to be dependent on if it was sent by the exact pcap_open function that the device pointer holds. If I open the interface a single time and pass the device to the threads rather than call pcap_open() with that flag in each thread it seems to filter just fine!</div><div><br></div><div>Thanks for the tip on Npcap though, looks like an interesting fork to try out.</div><div><br></div><div>Daniel Smith</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 28, 2016 at 10:00 PM, 食肉大灰兔V5 <span dir="ltr"><<a href="mailto:hsluoyz@gmail.com" target="_blank">hsluoyz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Daniel,<div><br></div><div>You can try Npcap: <a href="https://github.com/nmap/npcap" target="_blank">https://github.com/<wbr>nmap/npcap</a>.</div><div>The releases are published here: <a href="https://github.com/nmap/npcap/releases" target="_blank">https://github.com/nmap/<wbr>npcap/releases</a></div><div><br></div><div>It's a fork of WinPcap. And it supports latest libpcap 1.8.0 interface. So maybe the PCAP_SETDIRECTION function works for Npcap, if it works on latest libpcap. If I remembered right, The PCAP_OPENFLAG_NOCAPTURE_LOCAL flag is also one thing that Npcap fixed before.</div><div><br></div><div>I have also provided a "Send-to-Rx" feature in Npcap and designed a bridge application called "UserBridge" to use that feature here: <a href="https://github.com/hsluoyz/UserBridge" target="_blank">https://github.com/<wbr>hsluoyz/UserBridge</a>. UserBridge mainly do this:</div><div><br></div><div><span style="color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",roboto,helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:16px">If you want all received traffic on </span><code style="font-family:consolas,"liberation mono",menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-radius:3px;color:rgb(51,51,51)">Adapter A</code><span style="color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",roboto,helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:16px"> seems like to be received on </span><code style="font-family:consolas,"liberation mono",menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-radius:3px;color:rgb(51,51,51)">Adapter B</code><span style="color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",roboto,helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:16px">, and all traffic sent out from </span><code style="font-family:consolas,"liberation mono",menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-radius:3px;color:rgb(51,51,51)">Adapter B</code><span style="color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,"segoe ui",roboto,helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:16px"> to be actually sent out from </span><code style="font-family:consolas,"liberation mono",menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-radius:3px;color:rgb(51,51,51)">Adapter A</code><br></div><div><br></div><div>"Send-to-Rx" means to inject packets to a network interface's receive path that makes the interface think it receives those packets (instead of sending them out). You can just use it to fulfill a customized need.</div><div><br></div><div><br></div><div>Cheers,</div><div>Yang</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 29, 2016 at 8:50 AM, Daniel Smith <span dir="ltr"><<a href="mailto:zamadatix@gmail.com" target="_blank">zamadatix@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I have been trying to make a custom software bridge using winpcap. Unfortunately this means sending and receiving packets that arrive on a pair of interfaces which means there needs to be some sort of logic preventing infinitely copying any packet that appears in a cycle. As it is a bridge I can't apply a capture filter to match the source MAC/IP of the interfaces since many (known and uknown) MACs/IPs may need to transit the link pair. After digging through the documentation I came across two possible solutions:</div><div><br></div><div>PCAP_SETDIRECTION(device, PCAP_D_IN) - a directional filter to the capture. Unfortunately this returns -1 as it does not seem to be supported on Windows.</div><div>pcap_open() instead of pcap_open_live() - pcap_open() has flags for the 3rd argument, one of which being PCAP_OPENFLAG_NOCAPTURE_<wbr>LOCAL which is supposed to prevent capturing packets sent by the driver itself.</div><div><br></div><div><br></div><div>Unfortuntaley when I launch 2 threads, one capturing on the interface and one sending, I still receive the sent packets in the capturing thread. I am using the following to open the interface in both threads: pcap_open(InterfaceNa<wbr>me, 65536, PCAP_OPENFLAG_NOCAPTURE_LOCAL, 1000, nullptr, ErrorBuffer)</div><div><br></div><div><br></div><div><br></div><div>Does anyone have any guidance on why pcap_open() might be behaving this way or another way to achieve my goal of not capturing packets libpcap itself put on the interface?</div><div><br></div><div><br></div><div>Thank you,</div><div><br></div><div>Daniel Smith</div></div>
<br>______________________________<wbr>_________________<br>
Winpcap-users mailing list<br>
<a href="mailto:Winpcap-users@winpcap.org" target="_blank">Winpcap-users@winpcap.org</a><br>
<a href="https://www.winpcap.org/mailman/listinfo/winpcap-users" rel="noreferrer" target="_blank">https://www.winpcap.org/mailma<wbr>n/listinfo/winpcap-users</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Winpcap-users mailing list<br>
<a href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</a><br>
<a href="https://www.winpcap.org/mailman/listinfo/winpcap-users" rel="noreferrer" target="_blank">https://www.winpcap.org/<wbr>mailman/listinfo/winpcap-users</a><br>
<br></blockquote></div><br></div>