22 #ifdef HAVE_SYS_BUFMOD_H
29 #define CHUNKSIZE 65536
35 #define PKTBUFSIZE CHUNKSIZE
45 #define PKTBUFSIZE (MAXDLBUF * sizeof(bpf_u_int32))
49 #include <sys/types.h>
51 #ifdef HAVE_SYS_BUFMOD_H
52 #include <sys/bufmod.h>
55 #include <sys/stream.h>
72 #ifdef HAVE_SYS_BUFMOD_H
73 static void pcap_stream_err(
const char *,
int,
char *);
119 #if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
120 (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \
121 (defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
122 (defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \
123 (defined(__s390__) || defined(__s390x__) || defined(__zarch__))
127 #define REQUIRE_ALIGNMENT
136 int count, u_char *bufp,
int len)
139 int n, caplen, origlen;
142 #ifdef HAVE_SYS_BUFMOD_H
144 #ifdef REQUIRE_ALIGNMENT
153 #ifdef HAVE_SYS_BUFMOD_H
174 #ifdef REQUIRE_ALIGNMENT
175 if ((
long)bufp & 3) {
177 memcpy(sbp, bufp,
sizeof(*sbp));
180 sbp = (
struct sb_hdr *)bufp;
181 pd->stat.ps_drop = sbp->sbh_drops;
182 pk = bufp +
sizeof(*sbp);
183 bufp += sbp->sbh_totlen;
184 origlen = sbp->sbh_origlen;
185 caplen = sbp->sbh_msglen;
194 #ifdef HAVE_SYS_BUFMOD_H
195 pkthdr.
ts.tv_sec = sbp->sbh_timestamp.tv_sec;
196 pkthdr.
ts.tv_usec = sbp->sbh_timestamp.tv_usec;
200 pkthdr.
len = origlen;
205 (*callback)(user, &pkthdr, pk);
212 #ifdef HAVE_SYS_BUFMOD_H
243 p->
dlt_list = (u_int *)malloc(
sizeof(u_int) * 2);
311 #ifdef HAVE_SYS_BUFMOD_H
316 pcap_conf_bufmod(
pcap_t *p,
int snaplen)
322 if (
ioctl(p->
fd, I_PUSH,
"bufmod") != 0) {
323 pcap_stream_err(
"I_PUSH bufmod",
errno, p->
errbuf);
329 strioctl(p->
fd, SBIOCSSNAP,
sizeof(ss), (
char *)&ss) != 0) {
338 if (
strioctl(p->
fd, SBIOCSTIME,
sizeof(to), (
char *)&to) != 0) {
346 to.tv_usec = (p->
opt.
timeout * 1000) % 1000000;
347 if (
strioctl(p->
fd, SBIOCSTIME,
sizeof(to), (
char *)&to) != 0) {
355 if (
strioctl(p->
fd, SBIOCSCHUNK,
sizeof(chunksize), (
char *)&chunksize)
397 if ((retv =
ioctl(fd, I_STR, &str)) < 0)
403 #ifdef HAVE_SYS_BUFMOD_H
408 pcap_stream_err(
const char *func,
int err,
char *errbuf)
u_int pcap_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, u_int buflen)
int strioctl(int fd, int cmd, int len, char *dp)
int pcap_process_mactype(pcap_t *p, u_int mactype)
int pcap_alloc_databuf(pcap_t *p)
int pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
int pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, int count, u_char *bufp, int len)
void pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, const char *fmt,...)
int snprintf(char *, size_t, const char *,...)
int gettimeofday(struct timeval *, struct timezone *)
int ioctl(int, int, caddr_t)
#define PACKET_COUNT_IS_UNLIMITED(count)
void(* pcap_handler)(u_char *, const struct pcap_pkthdr *, const u_char *)
struct bpf_insn * bf_insns