Commit 82952c8e authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed in pcap_offline_layer::thread()

parent 70725536
Loading
Loading
Loading
Loading
+11 −1
Changes for ccsrc/Protocols/Pcap/pcap_offline_layer.cc: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -158,7 +158,9 @@ void *pcap_offline_layer::thread() {
  while (_running) { // Loop while _running flag is up
    // get next frame
    int result = pcap_next_ex(_device, (struct pcap_pkthdr **)&pkt_header, &pkt_data);
    if (result == 2) {
    // End of the file: 2 with older libpcap, PCAP_ERROR_BREAK (-2) with the current one; pkt_header and pkt_data are
    // then not set, and must not be passed on (an empty packet made the upper layers fail with a negative length)
    if ((result == 2) || (result == PCAP_ERROR_BREAK)) {
      if (_loop) {

      } else {
@@ -166,6 +168,14 @@ void *pcap_offline_layer::thread() {
        return NULL;
      }
    }
    if (result != 1) { // 0: no packet yet (live capture only); PCAP_ERROR: read error
      if (result < 0) {
        loggers::get_instance().warning("pcap_offline_layer::run: pcap_next_ex failed (%d): %s", result, pcap_geterr(_device));
        _running = FALSE;
        return NULL;
      }
      continue;
    }
    if (_realtime) {
      // wait for next packet timestamp
      if (lh.ts.tv_sec | lh.ts.tv_usec) {