summaryrefslogtreecommitdiff
path: root/pcap-dag.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-12-14 23:54:21 -0800
committerGuy Harris <guy@alum.mit.edu>2013-12-14 23:54:21 -0800
commit86b47f156ccc8be9b7143e1bc04d7d8fbf995383 (patch)
tree20bed4ff90845f93c81273d7b6ef4a4a16114036 /pcap-dag.c
parent1a52c9a05758d162e331dc93d60c51ebeb7b0f55 (diff)
downloadlibpcap-86b47f156ccc8be9b7143e1bc04d7d8fbf995383.tar.gz
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-dag.c')
-rw-r--r--pcap-dag.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pcap-dag.c b/pcap-dag.c
index 247bee87..70a6d6c2 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -579,7 +579,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/* Only count packets that pass the filter, for consistency with standard Linux behaviour. */
processed++;
- if (processed == cnt && cnt > 0)
+ if (processed == cnt && !PACKET_COUNT_IS_UNLIMITED(cnt))
{
/* Reached the user-specified limit. */
return cnt;