aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-01-17 03:09:26 -0800
committerGitHub <noreply@github.com>2017-01-17 03:09:26 -0800
commitc700a2f42df3d1076cc007676e139a35f4c6fdf8 (patch)
tree6d39a0d2c22cb7016a6c2cc1c1f190669d95de6d /pcap-linux.c
parent470df104c6f55f6d6f390df7448d8eb65c7642b9 (diff)
parentc3c41321429c045c826e019081b991aaea1618e6 (diff)
Merge pull request #429 from msekletar/bpf-userland-cooked
bpf: increase snaplen if doing cooked mode userspace filtering
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index c35d0952..b9a4bd77 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -4653,6 +4653,7 @@ static int pcap_handle_packet_mmap(
unsigned char *bp;
struct sockaddr_ll *sll;
struct pcap_pkthdr pcaphdr;
+ unsigned int snaplen = tp_snaplen;
/* perform sanity check on internal offset. */
if (tp_mac + tp_snaplen > handle->bufsize) {
@@ -4713,6 +4714,8 @@ static int pcap_handle_packet_mmap(
hdrp->sll_halen = htons(sll->sll_halen);
memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
hdrp->sll_protocol = sll->sll_protocol;
+
+ snaplen += sizeof(struct sll_header);
}
if (handlep->filter_in_userland && handle->fcode.bf_insns) {
@@ -4721,8 +4724,11 @@ static int pcap_handle_packet_mmap(
aux_data.vlan_tag = tp_vlan_tci & 0x0fff;
aux_data.vlan_tag_present = tp_vlan_tci_valid;
- if (bpf_filter_with_aux_data(handle->fcode.bf_insns, bp,
- tp_len, tp_snaplen, &aux_data) == 0)
+ if (bpf_filter_with_aux_data(handle->fcode.bf_insns,
+ bp,
+ tp_len,
+ snaplen,
+ &aux_data) == 0)
return 0;
}