62
62
63
63
#ifndef lint
64
64
static const char rcsid [] _U_ =
65
- "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.103 2004-05-21 09:22:16 guy Exp $ (LBL)" ;
65
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.104 2004-05-21 09:45:31 guy Exp $ (LBL)" ;
66
66
#endif
67
67
68
68
#ifdef HAVE_CONFIG_H
@@ -188,11 +188,13 @@ pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
188
188
* that passed the filter. As filtering is done in userland,
189
189
* this would not include packets dropped because we ran out
190
190
* of buffer space; in order to make this more like other
191
- * platforms (and to keep from confusing applications that,
192
- * for example, compute packet drop percentages), we also make it
193
- * count packets dropped by "bufmod" (otherwise we might run
194
- * the risk of the packet drop count being bigger than the
195
- * received-packet count).
191
+ * platforms (Linux 2.4 and later, BSDs with BPF), where the
192
+ * "packets received" count includes packets received but dropped
193
+ * due to running out of buffer space, and to keep from confusing
194
+ * applications that, for example, compute packet drop percentages,
195
+ * we also make it count packets dropped by "bufmod" (otherwise we
196
+ * might run the risk of the packet drop count being bigger than
197
+ * the received-packet count).
196
198
*
197
199
* "ps_drop" counts packets dropped by "bufmod" because of
198
200
* flow control requirements or resource exhaustion; it doesn't
@@ -205,6 +207,11 @@ pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
205
207
* yet read from libpcap by the application.
206
208
*/
207
209
* ps = p -> md .stat ;
210
+
211
+ /*
212
+ * Add in the drop count, as per the above comment.
213
+ */
214
+ ps -> ps_recv += ps -> ps_drop ;
208
215
return (0 );
209
216
}
210
217
@@ -311,15 +318,6 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
311
318
#endif
312
319
sbp = (struct sb_hdr * )bp ;
313
320
p -> md .stat .ps_drop = sbp -> sbh_drops ;
314
- /*
315
- * On at least some other platforms (Linux 2.4 and later,
316
- * BSDs with BPF), "ps_recv" counts packets that were
317
- * received but dropped due to running out of buffer
318
- * space; we do that here, so that applications that
319
- * compute packet drop percentages don't see more packets
320
- * dropped than received.
321
- */
322
- p -> md .stat .ps_recv += sbp -> sbh_drops ;
323
321
pk = bp + sizeof (* sbp );
324
322
bp += sbp -> sbh_totlen ;
325
323
origlen = sbp -> sbh_origlen ;
0 commit comments