1
votes

I am using libpcap (Windows Packet Capturing Library) in C.

I was wondering if i could be notified before the packet_handler function is called. Right now packet_handler is called everytime you receive a packet.

Any suggestions how i can monitor when packets stopped incoming with a 10 second break. I just need to know 'hey we started sending packets again - reset your settings or whatever'

1

1 Answers

0
votes

In your packet_handler, keep track of when you last received a packet, then check the interval every time packet_handler is called.

time_t LastTime = 0;
void packet_handler(....) {
  if (time(0) - LastTime >= 10) {
    resetStuff();
  }
  LastTime = time(0);
  // handle the packet
}