Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
gleb-kun opened this issue Jul 5, 2022 · 1 comment
Open

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

gleb-kun opened this issue Jul 5, 2022 · 1 comment

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?

@ksqrtr
Copy link

ksqrtr commented Nov 17, 2024

Hello!

I have exactly the same question. Did you find a solution or maybe some workaround?

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

No branches or pull requests

2 participants