Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / libpcap / savefile.c.rej
blob09052d94046a05b013fec145aa2414d7088b7c83
1 --- savefile.c  2008-10-10 19:42:44.000000000 -0700
2 +++ savefile.c  2008-12-15 08:45:30.000000000 -0800
3 @@ -1606,6 +1611,36 @@
4  
5                 if ((fcode = p->fcode.bf_insns) == NULL ||
6                     bpf_filter(fcode, p->buffer, h.len, h.caplen)) {
8 +#ifdef HAVE_REMOTE
9 +                       if (p->rmt_samp.method == PCAP_SAMP_1_EVERY_N)
10 +                       {
11 +                               samp_npkt= (samp_npkt + 1) % p->rmt_samp.value;
13 +                               // Discard all packets that are not '1 out of N'
14 +                               if (samp_npkt != 0)
15 +                                       continue;
16 +                       }
18 +                       if (p->rmt_samp.method == PCAP_SAMP_FIRST_AFTER_N_MS)
19 +                       {
20 +                               // Check if the timestamp of the arrived packet is smaller than our target time
21 +                               if ( (h.ts.tv_sec < samp_time.tv_sec) ||
22 +                                               ( (h.ts.tv_sec == samp_time.tv_sec) && (h.ts.tv_usec < samp_time.tv_usec) ) )
23 +                                       continue;
25 +                               // The arrived packet is suitable for being sent to the remote host
26 +                               // So, let's update the target time
27 +                               samp_time.tv_usec= h.ts.tv_usec + p->rmt_samp.value * 1000;
28 +                               if (samp_time.tv_usec > 1000000)
29 +                               {
30 +                                       samp_time.tv_sec= h.ts.tv_sec + samp_time.tv_usec / 1000000;
31 +                                       samp_time.tv_usec= samp_time.tv_usec % 1000000;
32 +                               }
34 +                       }
35 +#endif /* HAVE_REMOTE */
37                         (*callback)(user, &h, p->buffer);
38                         if (++n >= cnt && cnt > 0)
39                                 break;