I have a pcap_loop function in another function, that captures packets
until the user stops it, i.e.
void functionA()
{
pcap_loop(handle, -1, callback, NULL);
...
}
Is it possible to stop the packet capturing process, and return to
functionA()? I've used Ctrl-C but that just terminates the whole
program.
Thank you.
Regards,
Rayne
pcap_breakloop()
--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
I have something like
void functionA()
{
signal(SIGINT, terminate_process);
pcap_loop(handle, -1, got_packet, NULL);
...
}
void terminate_process(int signum)
{
pcap_breakloop(handle);
pcap_close(handle);
}
But Ctrl-C still exits the whole program. I should mention that the
program should run on a Windows system, and I'm not very familar with
the signals used to terminate functions.
if (time(NULL) - start_time > 100)
pcap_breakloop(handle);
But I don't know where to put this, because so far all the example
I've seen used pcap_breakloop in a signal handler, which requires user
intervention. How will the time condition be checked while pcap_loop
is running?
All the examples maybe, but you can surely call pcap_breakloop() from
your pcap_loop callback. It is clearly documented in the pcap(3)
manual page -- I hope you have read that?
(The man page talks a lot about using it in signal handlers, but
that's just because it's a trickier case.)
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Thanks! That works. I must have missed that part in the manual.