diff options
author | guy <guy> | 2004-12-15 00:05:48 +0000 |
---|---|---|
committer | guy <guy> | 2004-12-15 00:05:48 +0000 |
commit | eec5cdca82e6927da91f3a6447f48500366e3fd9 (patch) | |
tree | 60b261e42a5a12e133d1c2e72f99e3494c59152b /pcap-pf.c | |
parent | 16aa6d8892085dfe2aa39d8bf808050cf67548d3 (diff) |
The BPF code is generated using pcap_fddipad, so if we have to evaluate
it in userland, we should do so *before* skipping the padding.
Diffstat (limited to 'pcap-pf.c')
-rw-r--r-- | pcap-pf.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.88 2004-10-19 07:06:13 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.89 2004-12-15 00:05:48 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -182,10 +182,6 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) inc = ENALIGN(buflen + sp->ens_stamplen); cc -= inc; bp += inc; -#ifdef PCAP_FDDIPAD - p += pad; - buflen -= pad; -#endif pc->md.TotPkts++; pc->md.TotDrops += sp->ens_dropped; pc->md.TotMissed = sp->ens_ifoverflows; @@ -195,6 +191,14 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) /* * Short-circuit evaluation: if using BPF filter * in kernel, no need to do it now. + * +#ifdef PCAP_FDDIPAD + * Note: the filter code was generated assuming + * that pcap_fddipad was the amount of padding + * before the header, as that's what's required + * in the kernel, so we run the filter before + * skipping that padding. +#endif */ if (fcode == NULL || bpf_filter(fcode, p, sp->ens_count, buflen)) { @@ -206,6 +210,10 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) #else h.len = sp->ens_count; #endif +#ifdef PCAP_FDDIPAD + p += pad; + buflen -= pad; +#endif h.caplen = buflen; (*callback)(user, &h, p); if (++n >= cnt && cnt > 0) { |