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

Question about next_packet() method in the Sniffer class. #482

Open
gleb-kun opened this issue Jul 5, 2022 · 0 comments
Open

Question about next_packet() method in the Sniffer class. #482

gleb-kun opened this issue Jul 5, 2022 · 0 comments

Comments

@gleb-kun
Copy link

gleb-kun commented Jul 5, 2022

Hello and thanks for your work!

I have a question about using a Sniffer. I use Sniffer like this:

// Init
Tins::SnifferConfiguration snifferConfiguration;
snifferConfiguration.set_promisc_mode(true);
std::unique_ptr<Tins::Sniffer> sniffer = std::make_unique<Tins::Sniffer>(interfaceName, snifferConfiguration);
...

// Sniff
void f1()
{
  Tins::PDU *currentPduPacket = sniffer->next_packet();
  ...
     // Doing the processing
  ...
}

// Change channel
void f2()
{
  ...
  // Executing a channel change
  ...
}

Functions f1() and f2() are executed on a timer in the same thread. If there is no packets on some channel, then next_packet() method will wait until the packet appears, although it may never appear. Is there any way I can make sure there is a potential packet to capture before executing next_packet() method? Or if there is no package, then after some time, break the execution of the next_packet() method?

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

1 participant