dect
/
libpcap
Archived
13
0
Fork 0

From Tobias Poschwatta: correctly check the requested packet directions

when processing packets in memory-mapped mode.
This commit is contained in:
Guy Harris 2009-02-14 13:19:13 -08:00
parent 55685bd38c
commit 0359240b1c
2 changed files with 27 additions and 4 deletions

View File

@ -112,6 +112,7 @@ Additional people who have contributed patches:
Stephen Donnelly <stephen at endace dot com>
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
Tobias Poschwatta <posch at sourceforge dot net>
Tony Li <tli at procket dot com>
Torsten Landschoff <torsten at debian dot org>
Uns Lider <unslider at miranda dot org>

View File

@ -2316,11 +2316,33 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
tp_len, tp_snaplen) == 0))
goto skip;
/* check direction and interface index */
/*
* Do checks based on packet direction.
*/
sll = (void *)h.raw + TPACKET_ALIGN(handle->md.tp_hdrlen);
if ((sll->sll_ifindex == handle->md.lo_ifindex) &&
(sll->sll_pkttype == PACKET_OUTGOING))
goto skip;
if (sll->sll_pkttype == PACKET_OUTGOING) {
/*
* Outgoing packet.
* If this is from the loopback device, reject it;
* we'll see the packet as an incoming packet as well,
* and we don't want to see it twice.
*/
if (sll->sll_ifindex == handle->md.lo_ifindex)
goto skip;
/*
* If the user only wants incoming packets, reject it.
*/
if (handle->direction == PCAP_D_IN)
goto skip;
} else {
/*
* Incoming packet.
* If the user only wants outgoing packets, reject it.
*/
if (handle->direction == PCAP_D_OUT)
goto skip;
}
/* get required packet info from ring header */
pcaphdr.ts.tv_sec = tp_sec;