添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Hi all,

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
In article
Post by l***@yahoo.com
Hi all,
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.
pcap_breakloop()
--
Barry Margolin, ***@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
Post by Barry Margolin
In article
Post by l***@yahoo.com
Hi all,
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.
pcap_breakloop()
--
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.
Also, is it possible to set a duration for when packets would be
captured? Something like:

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?
Post by l***@yahoo.com
Also, is it possible to set a duration for when packets would be
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 .
Post by Jorgen Grahn
Post by l***@yahoo.com
Also, is it possible to set a duration for when packets would be
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
--
\X/ snipabacken.se> O o .
Thanks! That works. I must have missed that part in the manual.
Post by k***@gmail.com
I have libpcap version 0.6 and it has no pcap_breakloop(), and i
cannot update, now how can I stop pcap_loop() without using
pcap_breakloop?
Are your sure about the 0.6 bit? libpcap 0.6 is 13 years old at this
point, so I don't know how much support you're going to get for such an
old version.

Regards,
Kristof