/* start the capture */
pcap_loop(adhandle, 0, packet_handler, NULL);
The above starts the capture,but I don't find a way to stop the capture except exit the programe...
/* start the capture */
pcap_loop(adhandle, 0, packet_handler, NULL);
The above starts the capture,but I don't find a way to stop the capture except exit the programe...
Call pcap_breakloop()
in your pcap_handler
(you've named it packet_handler
in your example). The call to pcap_loop()
will then return -2
.
Alternatively, make repeated calls to pcap_dispatch()
until you're done, or specify a nonzero value for count
to handle that number of packets before returning.