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

Provide stop for sniff even when no packets received #1505

Closed
robgom opened this issue Jun 29, 2018 · 4 comments · Fixed by #1999
Closed

Provide stop for sniff even when no packets received #1505

robgom opened this issue Jun 29, 2018 · 4 comments · Fixed by #1999

Comments

@robgom
Copy link

robgom commented Jun 29, 2018

Hi there,
this is a request to reopen #989 - I haven't received any feedback to my recent question.
Missing the functionality affects our code.

Quoting myself:

Can it be reopened?
We observe the problem on Windows.
With scapy 2.3.1 we distributed local version of scapy, which used the following pattern:

p = None
while stop_filter and stop_filter(p):
... the loop as normal

On Windows it works, because there's PcapTimeout exception raised in case of no packets, which allows the condition to be checked.
It breaks backward compatibility, because it requires stop_filter to be aware of possible "None" as packet.

What about the mentioned stop_sniff additional parameter to sniff as alternative? On Windows it would work, as indicated before, even if stop wouldn't occur immediately. I don't know about other platforms, though.

What's your opinion?

Regards,
Robert

@gpotter2
Copy link
Member

gpotter2 commented Jul 15, 2018

Hi & sorry for the delay.

Would a thing such as #1523 fit your needs ?

@robgom
Copy link
Author

robgom commented Jul 16, 2018

Thank you for the heads up!

I think that sniff interface turned into a beast - way too many arguments.

However, I think that it'd fit for our use case - I haven't had a chance to play with it.

Regards,
Robert

@llamasoft
Copy link

This is going to sound pretty dumb, but when I ran into a similar issue, I worked around it by exploiting the fact that scapy can sniff its own packets. Just send a dummy packet that matches the filter you set up and it'll cause sniff to "wake up" and realize it needs to stop. This is akin to pushing a None into a Queue to indicate that no more work is coming.

Just my $0.02.

@gpotter2
Copy link
Member

gpotter2 commented May 26, 2019

See #1999

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