diff options
author | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-27 18:45:17 +0000 |
---|---|---|
committer | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-27 18:45:17 +0000 |
commit | 35af88c96350eb786f1198dfb6b29a171016e6bf (patch) | |
tree | e883c1f8391d5ca1afd57abd8ed9d2cd7c274b0b /dlpisubs.c | |
parent | 20616273d52132557e786a8aea1637be4c218a08 (diff) | |
download | src-35af88c96350eb786f1198dfb6b29a171016e6bf.tar.gz src-35af88c96350eb786f1198dfb6b29a171016e6bf.zip |
Diffstat (limited to 'dlpisubs.c')
-rw-r--r-- | dlpisubs.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/dlpisubs.c b/dlpisubs.c index 5f6e41af80b5..6815b0ec2cba 100644 --- a/dlpisubs.c +++ b/dlpisubs.c @@ -114,6 +114,20 @@ pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps) } /* + * Does the processor for which we're compiling this support aligned loads? + */ +#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \ + (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \ + (defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \ + (defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \ + (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) + /* Yes, it does. */ +#else + /* No, it doesn't. */ + #define REQUIRE_ALIGNMENT +#endif + +/* * Loop through the packets and call the callback for each packet. * Return the number of packets read. */ @@ -127,12 +141,17 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, struct pcap_pkthdr pkthdr; #ifdef HAVE_SYS_BUFMOD_H struct sb_hdr *sbp; -#ifdef LBL_ALIGN +#ifdef REQUIRE_ALIGNMENT struct sb_hdr sbhdr; #endif #endif - /* Loop through packets */ + /* + * Loop through packets. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. + */ ep = bufp + len; n = 0; @@ -157,7 +176,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, return (n); } } -#ifdef LBL_ALIGN +#ifdef REQUIRE_ALIGNMENT if ((long)bufp & 3) { sbp = &sbhdr; memcpy(sbp, bufp, sizeof(*sbp)); @@ -176,7 +195,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, bufp += caplen; #endif ++pd->stat.ps_recv; - if (bpf_filter(p->fcode.bf_insns, pk, origlen, caplen)) { + if (pcap_filter(p->fcode.bf_insns, pk, origlen, caplen)) { #ifdef HAVE_SYS_BUFMOD_H pkthdr.ts.tv_sec = sbp->sbh_timestamp.tv_sec; pkthdr.ts.tv_usec = sbp->sbh_timestamp.tv_usec; @@ -275,7 +294,7 @@ pcap_process_mactype(pcap_t *p, u_int mactype) * XXX - DL_IPNET devices default to "raw IP" rather than * "IPNET header"; see * - * http://seclists.org/tcpdump/2009/q1/202 + * https://seclists.org/tcpdump/2009/q1/202 * * We'd have to do DL_IOC_IPNET_INFO to enable getting * the IPNET header. @@ -286,7 +305,7 @@ pcap_process_mactype(pcap_t *p, u_int mactype) #endif default: - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x", + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x", mactype); retv = -1; } |