diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-12-14 23:54:21 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-12-14 23:54:21 -0800 |
commit | 86b47f156ccc8be9b7143e1bc04d7d8fbf995383 (patch) | |
tree | 20bed4ff90845f93c81273d7b6ef4a4a16114036 /pcap-pf.c | |
parent | 1a52c9a05758d162e331dc93d60c51ebeb7b0f55 (diff) |
Add a PACKET_COUNT_IS_UNLIMITED() to test for a packet count <= 0.
In read routines, a packet count <= 0 means "keep supplying packets
until you run out of packets in the buffer", and it means "keep supply
packets until the loop is broken out of or you get an error" in
pcap_loop().
Use the macro in all tests for that, so the right test is always done
(i.e., a count of 0 means "unlimited", not "supply zero packets"); this
fixes some cases where we weren't doing the right test (and hopefully
encourages programmers to use it and get the test right in new modules).
Diffstat (limited to 'pcap-pf.c')
-rw-r--r-- | pcap-pf.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -219,7 +219,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) buflen -= pad; h.caplen = buflen; (*callback)(user, &h, p); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { pc->cc = cc; pc->bp = bp; return (n); |