diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-10 07:23:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-10 07:23:34 +0000 |
commit | 332935dd8b0b130d349a7889ea13c5537c878d71 (patch) | |
tree | 8d2f42c06027401c804d3b5491edb3f226b33281 | |
parent | f77493d25f3eff7d86bcc20c60d101af4a8b1642 (diff) |
merge to latest libpcap
-rw-r--r-- | lib/libpcap/CHANGES | 51 | ||||
-rw-r--r-- | lib/libpcap/Makefile | 11 | ||||
-rw-r--r-- | lib/libpcap/README | 4 | ||||
-rw-r--r-- | lib/libpcap/bpf_image.c | 2 | ||||
-rw-r--r-- | lib/libpcap/etherent.c | 2 | ||||
-rw-r--r-- | lib/libpcap/ethertype.h | 2 | ||||
-rw-r--r-- | lib/libpcap/gencode.c | 126 | ||||
-rw-r--r-- | lib/libpcap/gencode.h | 16 | ||||
-rw-r--r-- | lib/libpcap/grammar.y | 3 | ||||
-rw-r--r-- | lib/libpcap/inet.c | 6 | ||||
-rw-r--r-- | lib/libpcap/nametoaddr.c | 16 | ||||
-rw-r--r-- | lib/libpcap/optimize.c | 60 | ||||
-rw-r--r-- | lib/libpcap/pcap-bpf.c | 2 | ||||
-rw-r--r-- | lib/libpcap/pcap-int.h | 2 | ||||
-rw-r--r-- | lib/libpcap/pcap-namedb.h | 6 | ||||
-rw-r--r-- | lib/libpcap/pcap.3 | 12 | ||||
-rw-r--r-- | lib/libpcap/pcap.c | 18 | ||||
-rw-r--r-- | lib/libpcap/pcap.h | 9 | ||||
-rw-r--r-- | lib/libpcap/savefile.c | 46 | ||||
-rw-r--r-- | lib/libpcap/scanner.l | 2 |
20 files changed, 158 insertions, 238 deletions
diff --git a/lib/libpcap/CHANGES b/lib/libpcap/CHANGES index 0032e5da6f5..e6370e4994e 100644 --- a/lib/libpcap/CHANGES +++ b/lib/libpcap/CHANGES @@ -1,53 +1,6 @@ -$OpenBSD: CHANGES,v 1.2 1996/03/04 15:47:12 mickey Exp $ +$OpenBSD: CHANGES,v 1.3 1996/06/10 07:23:23 deraadt Exp $ $NetBSD: CHANGES,v 1.2 1995/03/06 11:37:58 mycroft Exp $ -@(#) Header: CHANGES,v 1.4+ 94/06/20 19:22:33 leres Exp $ (LBL) - -v0.0.6 Fri Apr 28 04:07:13 PDT 1995 - -- Add missing variable declaration missing from 0.0.6 - -v0.0.5 Fri Apr 28 00:22:21 PDT 1995 - -- Workaround for problems when pcap_read() returns 0 due to the timeout - expiring. - -v0.0.4 Thu Apr 20 20:41:48 PDT 1995 - -- Change configuration to not use gcc v2 flags with gcc v1. - -- Fixed a bug in pcap_next(); if pcap_dispatch() returns 0, pcap_next() - should also return 0. Thanks to Richard Stevens (rstevens@noao.edu). - -- Fixed configure to test for snoop before dlpi to avoid problems under - IRIX 5. Thanks to J. Eric Townsend (jet@abulafia.genmagic.com). - -- Hack around deficiency in Ultrix's make. - -- Fix two bugs related to the Solaris pre-5.3.2 bufmod bug; handle - savefiles that have more than snapshot bytes of data in them (so we - can read old savefiles) and avoid writing such files. - -v0.0.3 Tue Oct 18 18:13:46 PDT 1994 - -- Fixed configure to test for snoop before dlpi to avoid problems under - IRIX 5. Thanks to J. Eric Townsend (jet@abulafia.genmagic.com). - -v0.0.2 Wed Oct 12 20:56:37 PDT 1994 - -- Implement timeout in the dlpi pcap_open_live(). Thanks to Richard - Stevens. - -- Determine pcap link type from dlpi media type. Resulted from report - by Mahesh Jethanandani (mahesh@npix.com). - -v0.0.1 Fri Jun 24 14:50:57 PDT 1994 - -- Fixed bug in nit_setflags() in pcap-snit.c. The streams ioctl timeout - wasn't being initialized sometimes resulting in an "NIOCSFLAGS: - Invalid argument" error under OSF/1. Reported by Matt Day - (mday@artisoft.com) and Danny Mitzel (dmitzel@whitney.hitc.com). - -- Turn on FDDI support by default. +@(#) Header: CHANGES,v 1.4 94/06/20 19:22:33 leres Exp (LBL) v0.0 Mon Jun 20 19:20:16 PDT 1994 diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile index 62e46b92268..614119b36b1 100644 --- a/lib/libpcap/Makefile +++ b/lib/libpcap/Makefile @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile,v 1.3 1996/05/06 21:44:25 deraadt Exp $ -# $NetBSD: Makefile,v 1.2 1996/04/29 20:32:24 jtc Exp $ +# $OpenBSD: Makefile,v 1.4 1996/06/10 07:23:24 deraadt Exp $ +# $NetBSD: Makefile,v 1.3 1996/05/10 21:54:24 cgd Exp $ LIB= pcap MAN= pcap.3 @@ -16,10 +16,11 @@ CLEANFILES+= grammar.c scanner.c y.tab.h includes: @cd ${.CURDIR}; for i in $(HDRS); do \ - cmp -s $$i ${DESTDIR}/usr/include/$$i || \ - { j="install -c -o ${BINOWN} -g ${BINGRP} -m 444 $$i \ + j="cmp -s $$i ${DESTDIR}/usr/include/$$i || \ + install -c -o ${BINOWN} -g ${BINGRP} -m 444 $$i \ ${DESTDIR}/usr/include"; \ - echo $$j; $$j; } \ + echo $$j; \ + eval "$$j"; \ done .include <bsd.lib.mk> diff --git a/lib/libpcap/README b/lib/libpcap/README index 5c05f881b74..9e545b83898 100644 --- a/lib/libpcap/README +++ b/lib/libpcap/README @@ -1,8 +1,8 @@ -$OpenBSD: README,v 1.2 1996/03/04 15:47:15 mickey Exp $ +$OpenBSD: README,v 1.3 1996/06/10 07:23:24 deraadt Exp $ $NetBSD: README,v 1.2 1995/03/06 11:38:07 mycroft Exp $ @(#) Header: README,v 1.7 94/06/20 18:56:55 leres Exp (LBL) -LIBPCAP 0.0.6 +LIBPCAP 0.0 Lawrence Berkeley Laboratory Network Research Group libpcap@ee.lbl.gov diff --git a/lib/libpcap/bpf_image.c b/lib/libpcap/bpf_image.c index 9d2ede4709b..3a75dd44051 100644 --- a/lib/libpcap/bpf_image.c +++ b/lib/libpcap/bpf_image.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf_image.c,v 1.2 1996/03/04 15:47:16 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: bpf_image.c,v 1.2 1995/03/06 11:38:11 mycroft Exp $ */ /* diff --git a/lib/libpcap/etherent.c b/lib/libpcap/etherent.c index 99eaeddb90a..53f9a07ef46 100644 --- a/lib/libpcap/etherent.c +++ b/lib/libpcap/etherent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: etherent.c,v 1.2 1996/03/04 15:47:17 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: etherent.c,v 1.2 1995/03/06 11:38:14 mycroft Exp $ */ /* diff --git a/lib/libpcap/ethertype.h b/lib/libpcap/ethertype.h index 81156475cc2..f4e16434915 100644 --- a/lib/libpcap/ethertype.h +++ b/lib/libpcap/ethertype.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ethertype.h,v 1.2 1996/03/04 15:47:17 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: ethertype.h,v 1.2 1995/03/06 11:38:17 mycroft Exp $ */ /* diff --git a/lib/libpcap/gencode.c b/lib/libpcap/gencode.c index b2ed7cb2d9e..db37ff18932 100644 --- a/lib/libpcap/gencode.c +++ b/lib/libpcap/gencode.c @@ -1,5 +1,5 @@ -/* $OpenBSD: gencode.c,v 1.2 1996/03/04 15:47:18 mickey Exp $ */ -/* $NetBSD: gencode.c,v 1.2 1995/03/06 11:38:21 mycroft Exp $ */ +/* $OpenBSD */ +/* $NetBSD: gencode.c,v 1.2.6.1 1996/06/05 18:04:23 cgd Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994 @@ -26,7 +26,7 @@ static char rcsid[] = "@(#) Header: gencode.c,v 1.55 94/06/20 19:07:53 leres Exp (LBL)"; #endif -#include <sys/types.h> +#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> @@ -130,29 +130,29 @@ static inline void syntax(void); static void backpatch(struct block *, struct block *); static void merge(struct block *, struct block *); -static struct block *gen_cmp(u_int, u_int, long); -static struct block *gen_mcmp(u_int, u_int, long, u_long); +static struct block *gen_cmp(u_int, u_int, int32_t); +static struct block *gen_mcmp(u_int, u_int, int32_t, u_int32_t); static struct block *gen_bcmp(u_int, u_int, u_char *); static struct block *gen_uncond(int); static inline struct block *gen_true(void); static inline struct block *gen_false(void); static struct block *gen_linktype(int); -static struct block *gen_hostop(u_long, u_long, int, int, u_int, u_int); +static struct block *gen_hostop(u_int32_t, u_int32_t, int, int, u_int, u_int); static struct block *gen_ehostop(u_char *, int); #ifdef FDDI static struct block *gen_fhostop(u_char *, int); #endif -static struct block *gen_dnhostop(u_long, int, u_int); -static struct block *gen_host(u_long, u_long, int, int); -static struct block *gen_gateway(u_char *, u_long **, int, int); +static struct block *gen_dnhostop(u_int32_t, int, u_int); +static struct block *gen_host(u_int32_t, u_int32_t, int, int); +static struct block *gen_gateway(u_char *, u_int32_t **, int, int); static struct block *gen_ipfrag(void); -static struct block *gen_portatom(int, long); +static struct block *gen_portatom(int, int32_t); struct block *gen_portop(int, int, int); static struct block *gen_port(int, int, int); static int lookup_proto(char *, int); static struct block *gen_proto(int, int, int); -static u_long net_mask(u_long *); -static u_long net_mask(u_long *); +static u_int32_t net_mask(u_int32_t *); +static u_int32_t net_mask(u_int32_t *); static struct slist *xfer_to_x(struct arth *); static struct slist *xfer_to_a(struct arth *); static struct block *gen_len(int, int); @@ -164,8 +164,8 @@ newchunk(n) struct chunk *cp; int k, size; - /* XXX Round up to nearest long. */ - n = (n + sizeof(long) - 1) & ~(sizeof(long) - 1); + /* XXX Round to structure boundary. */ + n = ALIGN(n); cp = &chunks[cur_chunk]; if (n > cp->n_left) { @@ -247,12 +247,12 @@ syntax() bpf_error("syntax error in filter expression"); } -static u_long netmask; +static u_int32_t netmask; static int snaplen; int pcap_compile(pcap_t *p, struct bpf_program *program, - char *buf, int optimize, u_long mask) + char *buf, int optimize, u_int32_t mask) { extern int n_errors; int len; @@ -372,7 +372,7 @@ gen_not(b) static struct block * gen_cmp(offset, size, v) u_int offset, size; - long v; + int32_t v; { struct slist *s; struct block *b; @@ -390,8 +390,8 @@ gen_cmp(offset, size, v) static struct block * gen_mcmp(offset, size, v, mask) u_int offset, size; - long v; - u_long mask; + int32_t v; + u_int32_t mask; { struct block *b = gen_cmp(offset, size, v); struct slist *s; @@ -414,7 +414,7 @@ gen_bcmp(offset, size, v) b = NULL; while (size >= 4) { u_char *p = &v[size - 4]; - long w = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; + int32_t w = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; tmp = gen_cmp(offset + size - 4, BPF_W, w); if (b != NULL) gen_and(b, tmp); @@ -423,7 +423,7 @@ gen_bcmp(offset, size, v) } while (size >= 2) { u_char *p = &v[size - 2]; - long w = (p[0] << 8) | p[1]; + int32_t w = (p[0] << 8) | p[1]; tmp = gen_cmp(offset + size - 2, BPF_H, w); if (b != NULL) gen_and(b, tmp); @@ -431,7 +431,7 @@ gen_bcmp(offset, size, v) size -= 2; } if (size > 0) { - tmp = gen_cmp(offset, BPF_B, (long)v[0]); + tmp = gen_cmp(offset, BPF_B, (int32_t)v[0]); if (b != NULL) gen_and(b, tmp); b = tmp; @@ -547,13 +547,13 @@ gen_linktype(proto) proto = 0x0021; /* XXX - need ppp.h defs */ break; } - return gen_cmp(off_linktype, BPF_H, (long)proto); + return gen_cmp(off_linktype, BPF_H, (int32_t)proto); } static struct block * gen_hostop(addr, mask, dir, proto, src_off, dst_off) - u_long addr; - u_long mask; + u_int32_t addr; + u_int32_t mask; int dir, proto; u_int src_off, dst_off; { @@ -587,7 +587,7 @@ gen_hostop(addr, mask, dir, proto, src_off, dst_off) abort(); } b0 = gen_linktype(proto); - b1 = gen_mcmp(offset, BPF_W, (long)addr, mask); + b1 = gen_mcmp(offset, BPF_W, (int32_t)addr, mask); gen_and(b0, b1); return b1; } @@ -679,7 +679,7 @@ gen_fhostop(eaddr, dir) */ static struct block * gen_dnhostop(addr, dir, base_off) - u_long addr; + u_int32_t addr; int dir; u_int base_off; { @@ -720,23 +720,23 @@ gen_dnhostop(addr, dir, base_off) b0 = gen_linktype(ETHERTYPE_DN); /* Check for pad = 1, long header case */ tmp = gen_mcmp(base_off + 2, BPF_H, - (long)ntohs(0x0681), (long)ntohs(0x07FF)); - b1 = gen_cmp(base_off + 2 + 1 + offset_lh, BPF_H, (long)ntohs(addr)); + (int32_t)ntohs(0x0681), (int32_t)ntohs(0x07FF)); + b1 = gen_cmp(base_off + 2 + 1 + offset_lh, BPF_H, (int32_t)ntohs(addr)); gen_and(tmp, b1); /* Check for pad = 0, long header case */ - tmp = gen_mcmp(base_off + 2, BPF_B, (long)0x06, (long)0x7); - b2 = gen_cmp(base_off + 2 + offset_lh, BPF_H, (long)ntohs(addr)); + tmp = gen_mcmp(base_off + 2, BPF_B, (int32_t)0x06, (int32_t)0x7); + b2 = gen_cmp(base_off + 2 + offset_lh, BPF_H, (int32_t)ntohs(addr)); gen_and(tmp, b2); gen_or(b2, b1); /* Check for pad = 1, short header case */ tmp = gen_mcmp(base_off + 2, BPF_H, - (long)ntohs(0x0281), (long)ntohs(0x07FF)); - b2 = gen_cmp(base_off + 2 + 1 + offset_sh, BPF_H, (long)ntohs(addr)); + (int32_t)ntohs(0x0281), (int32_t)ntohs(0x07FF)); + b2 = gen_cmp(base_off + 2 + 1 + offset_sh, BPF_H, (int32_t)ntohs(addr)); gen_and(tmp, b2); gen_or(b2, b1); /* Check for pad = 0, short header case */ - tmp = gen_mcmp(base_off + 2, BPF_B, (long)0x02, (long)0x7); - b2 = gen_cmp(base_off + 2 + offset_sh, BPF_H, (long)ntohs(addr)); + tmp = gen_mcmp(base_off + 2, BPF_B, (int32_t)0x02, (int32_t)0x7); + b2 = gen_cmp(base_off + 2 + offset_sh, BPF_H, (int32_t)ntohs(addr)); gen_and(tmp, b2); gen_or(b2, b1); @@ -747,8 +747,8 @@ gen_dnhostop(addr, dir, base_off) static struct block * gen_host(addr, mask, proto, dir) - u_long addr; - u_long mask; + u_int32_t addr; + u_int32_t mask; int proto; int dir; { @@ -806,7 +806,7 @@ gen_host(addr, mask, proto, dir) static struct block * gen_gateway(eaddr, alist, proto, dir) u_char *eaddr; - u_long **alist; + u_int32_t **alist; int proto; int dir; { @@ -853,19 +853,19 @@ gen_proto_abbrev(proto) case Q_TCP: b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_TCP); + b1 = gen_cmp(off_nl + 9, BPF_B, (int32_t)IPPROTO_TCP); gen_and(b0, b1); break; case Q_UDP: b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_UDP); + b1 = gen_cmp(off_nl + 9, BPF_B, (int32_t)IPPROTO_UDP); gen_and(b0, b1); break; case Q_ICMP: b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_ICMP); + b1 = gen_cmp(off_nl + 9, BPF_B, (int32_t)IPPROTO_ICMP); gen_and(b0, b1); break; @@ -926,7 +926,7 @@ gen_ipfrag() static struct block * gen_portatom(off, v) int off; - long v; + int32_t v; { struct slist *s; struct block *b; @@ -951,29 +951,29 @@ gen_portop(port, proto, dir) struct block *b0, *b1, *tmp; /* ip proto 'proto' */ - tmp = gen_cmp(off_nl + 9, BPF_B, (long)proto); + tmp = gen_cmp(off_nl + 9, BPF_B, (int32_t)proto); b0 = gen_ipfrag(); gen_and(tmp, b0); switch (dir) { case Q_SRC: - b1 = gen_portatom(0, (long)port); + b1 = gen_portatom(0, (int32_t)port); break; case Q_DST: - b1 = gen_portatom(2, (long)port); + b1 = gen_portatom(2, (int32_t)port); break; case Q_OR: case Q_DEFAULT: - tmp = gen_portatom(0, (long)port); - b1 = gen_portatom(2, (long)port); + tmp = gen_portatom(0, (int32_t)port); + b1 = gen_portatom(2, (int32_t)port); gen_or(tmp, b1); break; case Q_AND: - tmp = gen_portatom(0, (long)port); - b1 = gen_portatom(2, (long)port); + tmp = gen_portatom(0, (int32_t)port); + b1 = gen_portatom(2, (int32_t)port); gen_and(tmp, b1); break; @@ -1059,7 +1059,7 @@ gen_proto(v, proto, dir) case Q_DEFAULT: case Q_IP: b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 9, BPF_B, (long)v); + b1 = gen_cmp(off_nl + 9, BPF_B, (int32_t)v); gen_and(b0, b1); return b1; @@ -1112,11 +1112,11 @@ gen_proto(v, proto, dir) /* * Left justify 'addr' and return its resulting network mask. */ -static u_long +static u_int32_t net_mask(addr) - u_long *addr; + u_int32_t *addr; { - register u_long m = 0xffffffff; + register u_int32_t m = 0xffffffff; if (*addr) while ((*addr & 0xff000000) == 0) @@ -1133,7 +1133,7 @@ gen_scode(name, q) int proto = q.proto; int dir = q.dir; u_char *eaddr; - u_long mask, addr, **alist; + u_int32_t mask, addr, **alist; struct block *b, *tmp; int port, real_proto; @@ -1236,10 +1236,10 @@ gen_scode(name, q) struct block * gen_ncode(v, q) - u_long v; + u_int32_t v; struct qual q; { - u_long mask; + u_int32_t mask; int proto = q.proto; int dir = q.dir; @@ -1632,16 +1632,16 @@ gen_byteop(op, idx, val) abort(); case '=': - return gen_cmp((u_int)idx, BPF_B, (long)val); + return gen_cmp((u_int)idx, BPF_B, (int32_t)val); case '<': - b = gen_cmp((u_int)idx, BPF_B, (long)val); + b = gen_cmp((u_int)idx, BPF_B, (int32_t)val); b->s.code = JMP(BPF_JGE); gen_not(b); return b; case '>': - b = gen_cmp((u_int)idx, BPF_B, (long)val); + b = gen_cmp((u_int)idx, BPF_B, (int32_t)val); b->s.code = JMP(BPF_JGT); return b; @@ -1665,7 +1665,7 @@ struct block * gen_broadcast(proto) int proto; { - u_long hostmask; + u_int32_t hostmask; struct block *b0, *b1, *b2; static u_char ebroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -1685,9 +1685,9 @@ gen_broadcast(proto) case Q_IP: b0 = gen_linktype(ETHERTYPE_IP); hostmask = ~netmask; - b1 = gen_mcmp(off_nl + 16, BPF_W, (long)0, hostmask); + b1 = gen_mcmp(off_nl + 16, BPF_W, (int32_t)0, hostmask); b2 = gen_mcmp(off_nl + 16, BPF_W, - (long)(~0 & hostmask), hostmask); + (int32_t)(~0 & hostmask), hostmask); gen_or(b1, b2); gen_and(b0, b2); return b2; @@ -1731,7 +1731,7 @@ gen_multicast(proto) case Q_IP: b0 = gen_linktype(ETHERTYPE_IP); - b1 = gen_cmp(off_nl + 16, BPF_B, (long)224); + b1 = gen_cmp(off_nl + 16, BPF_B, (int32_t)224); b1->s.code = JMP(BPF_JGE); gen_and(b0, b1); return b1; diff --git a/lib/libpcap/gencode.h b/lib/libpcap/gencode.h index 6c223f3655b..608ad0aef3b 100644 --- a/lib/libpcap/gencode.h +++ b/lib/libpcap/gencode.h @@ -1,5 +1,5 @@ -/* $OpenBSD: gencode.h,v 1.2 1996/03/04 15:47:20 mickey Exp $ */ -/* $NetBSD: gencode.h,v 1.2 1995/03/06 11:38:24 mycroft Exp $ */ +/* $OpenBSD */ +/* $NetBSD: gencode.h,v 1.2.6.1 1996/06/05 18:04:30 cgd Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994 @@ -63,7 +63,7 @@ struct stmt { int code; - long k; + int32_t k; }; struct slist { @@ -75,14 +75,14 @@ struct slist { * A bit vector to represent definition sets. We assume TOT_REGISTERS * is smaller than 8*sizeof(atomset). */ -typedef u_long atomset; +typedef u_int32_t atomset; #define ATOMMASK(n) (1 << (n)) #define ATOMELEM(d, n) (d & ATOMMASK(n)) /* * An unbounded set. */ -typedef u_long *uset; +typedef u_int32_t *uset; /* * Total number of atomic entities, including accumulator (A) and index (X). @@ -117,8 +117,8 @@ struct block { atomset def, kill; atomset in_use; atomset out_use; - long oval; - long val[N_ATOMS]; + int32_t oval; + int32_t val[N_ATOMS]; }; struct arth { @@ -150,7 +150,7 @@ void gen_not(struct block *); struct block *gen_scode(char *, struct qual); struct block *gen_ecode(u_char *, struct qual); -struct block *gen_ncode(u_long, struct qual); +struct block *gen_ncode(u_int32_t, struct qual); struct block *gen_proto_abbrev(int); struct block *gen_relation(int, struct arth *, struct arth *, int); struct block *gen_less(int); diff --git a/lib/libpcap/grammar.y b/lib/libpcap/grammar.y index 5057f6fa21d..7731a550e45 100644 --- a/lib/libpcap/grammar.y +++ b/lib/libpcap/grammar.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: grammar.y,v 1.2 1996/03/04 15:47:21 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: grammar.y,v 1.2 1995/03/06 11:38:27 mycroft Exp $ */ /* @@ -70,7 +70,6 @@ pcap_parse() %} %union { -#define yylval pcap_lval int i; u_long h; u_char *e; diff --git a/lib/libpcap/inet.c b/lib/libpcap/inet.c index 197f4d188a6..9a29bea094a 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,5 +1,5 @@ -/* $OpenBSD: inet.c,v 1.2 1996/03/04 15:47:22 mickey Exp $ */ -/* $NetBSD: inet.c,v 1.2 1995/03/06 11:38:29 mycroft Exp $ */ +/* $OpenBSD */ +/* $NetBSD: inet.c,v 1.2.6.1 1996/06/05 18:04:32 cgd Exp $ */ /* * Copyright (c) 1994 @@ -152,7 +152,7 @@ pcap_lookupdev(errbuf) int pcap_lookupnet(device, netp, maskp, errbuf) register char *device; - register u_long *netp, *maskp; + register u_int32_t *netp, *maskp; register char *errbuf; { register int fd; diff --git a/lib/libpcap/nametoaddr.c b/lib/libpcap/nametoaddr.c index b38d00e6eb9..a8b75eee3f0 100644 --- a/lib/libpcap/nametoaddr.c +++ b/lib/libpcap/nametoaddr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: nametoaddr.c,v 1.2 1996/03/04 15:47:22 mickey Exp $ */ -/* $NetBSD: nametoaddr.c,v 1.3 1995/04/29 05:42:23 cgd Exp $ */ +/* $OpenBSD */ +/* $NetBSD: nametoaddr.c,v 1.3.6.1 1996/06/05 18:04:34 cgd Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994 @@ -65,24 +65,24 @@ static inline int xdtoi(int); * Convert host name to internet address. * Return 0 upon failure. */ -u_long ** +u_int32_t ** pcap_nametoaddr(const char *name) { #ifndef h_addr - static u_long *hlist[2]; + static u_int32_t *hlist[2]; #endif - u_long **p; + u_int32_t **p; struct hostent *hp; if ((hp = gethostbyname(name)) != NULL) { #ifndef h_addr - hlist[0] = (u_long *)hp->h_addr; + hlist[0] = (u_int32_t *)hp->h_addr; NTOHL(hp->h_addr); return hlist; #else - for (p = (u_long **)hp->h_addr_list; *p; ++p) + for (p = (u_int32_t **)hp->h_addr_list; *p; ++p) NTOHL(**p); - return (u_long **)hp->h_addr_list; + return (u_int32_t **)hp->h_addr_list; #endif } else diff --git a/lib/libpcap/optimize.c b/lib/libpcap/optimize.c index 5c09695798b..8d631463909 100644 --- a/lib/libpcap/optimize.c +++ b/lib/libpcap/optimize.c @@ -1,5 +1,5 @@ -/* $OpenBSD: optimize.c,v 1.2 1996/03/04 15:47:24 mickey Exp $ */ -/* $NetBSD: optimize.c,v 1.3 1995/04/29 05:42:28 cgd Exp $ */ +/* $OpenBSD */ +/* $NetBSD: optimize.c,v 1.3.6.1 1996/06/05 18:04:37 cgd Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 @@ -100,8 +100,8 @@ static int atomdef(struct stmt *); static void compute_local_ud(struct block *); static void find_ud(struct block *); static void init_val(void); -static long F(int, long, long); -static inline void vstore(struct stmt *, long *, long, int); +static int32_t F(int, int32_t, int32_t); +static inline void vstore(struct stmt *, int32_t *, int32_t, int); static void opt_blk(struct block *, int); static int use_conflict(struct block *, struct block *); static void opt_j(struct edge *); @@ -112,11 +112,11 @@ static inline void link_inedge(struct edge *, struct block *); static void find_inedges(struct block *); static void opt_root(struct block **); static void opt_loop(struct block *, int); -static void fold_op(struct stmt *, long, long); +static void fold_op(struct stmt *, int32_t, int32_t); static inline struct slist *this_op(struct slist *); static void opt_not(struct block *); static void opt_peep(struct block *); -static void opt_stmt(struct stmt *, long[], int); +static void opt_stmt(struct stmt *, int32_t[], int); static void deadstmt(struct stmt *, struct stmt *[]); static void opt_deadstores(struct block *); static void opt_blk(struct block *, int); @@ -142,8 +142,8 @@ struct edge **edges; static int nodewords; static int edgewords; struct block **levels; -u_long *space; -#define BITS_PER_WORD (8*sizeof(u_long)) +u_int32_t *space; +#define BITS_PER_WORD (8*sizeof(u_int32_t)) /* * True if a is in uset {p} */ @@ -167,7 +167,7 @@ u_long *space; */ #define SET_INTERSECT(a, b, n)\ {\ - register u_long *_x = a, *_y = b;\ + register u_int32_t *_x = a, *_y = b;\ register int _n = n;\ while (--_n >= 0) *_x++ &= *_y++;\ } @@ -177,7 +177,7 @@ u_long *space; */ #define SET_SUBTRACT(a, b, n)\ {\ - register u_long *_x = a, *_y = b;\ + register u_int32_t *_x = a, *_y = b;\ register int _n = n;\ while (--_n >= 0) *_x++ &=~ *_y++;\ } @@ -187,7 +187,7 @@ u_long *space; */ #define SET_UNION(a, b, n)\ {\ - register u_long *_x = a, *_y = b;\ + register u_int32_t *_x = a, *_y = b;\ register int _n = n;\ while (--_n >= 0) *_x++ |= *_y++;\ } @@ -248,7 +248,7 @@ find_dom(root) { int i; struct block *b; - u_long *x; + u_int32_t *x; /* * Initialize sets to contain all nodes. @@ -499,8 +499,8 @@ find_ud(root) */ struct valnode { int code; - long v0, v1; - long val; + int32_t v0, v1; + int32_t val; struct valnode *next; }; @@ -514,7 +514,7 @@ static int maxval; struct vmapinfo { int is_const; - long const_val; + int32_t const_val; }; struct vmapinfo *vmap; @@ -531,10 +531,10 @@ init_val() } /* Because we really don't have an IR, this stuff is a little messy. */ -static long +static int32_t F(code, v0, v1) int code; - long v0, v1; + int32_t v0, v1; { u_int hash; int val; @@ -567,8 +567,8 @@ F(code, v0, v1) static inline void vstore(s, valp, newval, alter) struct stmt *s; - long *valp; - long newval; + int32_t *valp; + int32_t newval; int alter; { if (alter && *valp == newval) @@ -580,9 +580,9 @@ vstore(s, valp, newval, alter) static void fold_op(s, v0, v1) struct stmt *s; - long v0, v1; + int32_t v0, v1; { - long a, b; + int32_t a, b; a = vmap[v0].const_val; b = vmap[v1].const_val; @@ -660,7 +660,7 @@ opt_peep(b) struct slist *s; struct slist *next, *last; int val; - long v; + int32_t v; s = b->stmts; if (s == 0) @@ -848,11 +848,11 @@ opt_peep(b) static void opt_stmt(s, val, alter) struct stmt *s; - long val[]; + int32_t val[]; int alter; { int op; - long v; + int32_t v; switch (s->code) { @@ -1086,7 +1086,7 @@ opt_blk(b, do_stmts) struct slist *s; struct edge *p; int i; - long aval; + int32_t aval; /* * Initialize the atom values. @@ -1230,7 +1230,7 @@ opt_j(ep) */ top: for (i = 0; i < edgewords; ++i) { - register u_long x = ep->edom[i]; + register u_int32_t x = ep->edom[i]; while (x != 0) { k = ffs(x) - 1; @@ -1763,7 +1763,7 @@ static void opt_init(root) struct block *root; { - u_long *p; + u_int32_t *p; int i, n, max_stmts; /* @@ -1785,11 +1785,11 @@ opt_init(root) */ levels = (struct block **)malloc(n_blocks * sizeof(*levels)); - edgewords = n_edges / (8 * sizeof(u_long)) + 1; - nodewords = n_blocks / (8 * sizeof(u_long)) + 1; + edgewords = n_edges / (8 * sizeof(u_int32_t)) + 1; + nodewords = n_blocks / (8 * sizeof(u_int32_t)) + 1; /* XXX */ - space = (u_long *)malloc(2 * n_blocks * nodewords * sizeof(*space) + space = (u_int32_t *)malloc(2 * n_blocks * nodewords * sizeof(*space) + n_edges * edgewords * sizeof(*space)); p = space; all_dom_sets = p; diff --git a/lib/libpcap/pcap-bpf.c b/lib/libpcap/pcap-bpf.c index dd95befdfe5..4fe4b6ddfa2 100644 --- a/lib/libpcap/pcap-bpf.c +++ b/lib/libpcap/pcap-bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcap-bpf.c,v 1.4 1996/03/23 18:30:11 tholo Exp $ */ +/* $OpenBSD */ /* $NetBSD: pcap-bpf.c,v 1.3 1995/04/29 05:42:31 cgd Exp $ */ /* diff --git a/lib/libpcap/pcap-int.h b/lib/libpcap/pcap-int.h index 2d5fa4a2a47..a6eb72b6d49 100644 --- a/lib/libpcap/pcap-int.h +++ b/lib/libpcap/pcap-int.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcap-int.h,v 1.2 1996/03/04 15:47:26 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: pcap-int.h,v 1.2 1995/03/06 11:38:47 mycroft Exp $ */ /* diff --git a/lib/libpcap/pcap-namedb.h b/lib/libpcap/pcap-namedb.h index 98d9cc8cade..8547c2e9769 100644 --- a/lib/libpcap/pcap-namedb.h +++ b/lib/libpcap/pcap-namedb.h @@ -1,5 +1,5 @@ -/* $OpenBSD: pcap-namedb.h,v 1.2 1996/03/04 15:47:26 mickey Exp $ */ -/* $NetBSD: pcap-namedb.h,v 1.2 1995/03/06 11:38:48 mycroft Exp $ */ +/* $OpenBSD */ +/* $NetBSD: pcap-namedb.h,v 1.2.6.1 1996/06/05 18:04:40 cgd Exp $ */ /* * Copyright (c) 1994 @@ -57,7 +57,7 @@ struct pcap_etherent *pcap_next_etherent(FILE *); u_char *pcap_ether_hostton(const char*); u_char *pcap_ether_aton(const char *); -u_long **pcap_nametoaddr(const char *); +u_int32_t **pcap_nametoaddr(const char *); u_long pcap_nametonetaddr(const char *); int pcap_nametoport(const char *, int *, int *); diff --git a/lib/libpcap/pcap.3 b/lib/libpcap/pcap.3 index 77202b5a53b..fecdb0e850f 100644 --- a/lib/libpcap/pcap.3 +++ b/lib/libpcap/pcap.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: pcap.3,v 1.3 1996/03/04 15:47:27 mickey Exp $ -.\" $NetBSD: pcap.3,v 1.2 1995/03/06 11:39:03 mycroft Exp $ +.\" $OpenBSD +.\" $NetBSD: pcap.3,v 1.2.6.1 1996/06/05 18:04:43 cgd Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -40,9 +40,9 @@ pcap_dumper_t *pcap_dump_open(pcap_t *p, char *fname) .ft B char errbuf[PCAP_ERRBUF_SIZE]; char *pcap_lookupdev(char *errbuf) -int pcap_lookupnet(char *device, u_long *netp, +int pcap_lookupnet(char *device, u_int32_t *netp, .ti +8 -u_long *maskp, char *errbuf) +u_int32_t *maskp, char *errbuf) .ft .LP .ft B @@ -68,7 +68,7 @@ int pcap_immediate(pcap_t *p) .ft B int pcap_compile(pcap_t *p, struct bpf_program *fp, .ti +8 -char *str, int optimize, u_long netmask) +char *str, int optimize, u_int32_t netmask) int pcap_setfilter(pcap_t *p, struct bpf_program *fp) .ft .LP @@ -174,7 +174,7 @@ Both and .I maskp are -.I u_long +.I u_int32_t pointers. A return of -1 indicates an error in which case .I errbuf diff --git a/lib/libpcap/pcap.c b/lib/libpcap/pcap.c index 6f47bc160ff..889e4aabb21 100644 --- a/lib/libpcap/pcap.c +++ b/lib/libpcap/pcap.c @@ -1,8 +1,8 @@ -/* $OpenBSD: pcap.c,v 1.2 1996/03/04 15:47:28 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: pcap.c,v 1.2 1995/03/06 11:39:05 mycroft Exp $ */ /* - * Copyright (c) 1993, 1994, 1995 + * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,16 +49,10 @@ static char rcsid[] = int pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { - register int cc; - if (p->sf.rfile != NULL) return (pcap_offline_read(p, cnt, callback, user)); - /* XXX keep reading until we get something (or an error occurs) */ - do { - cc = pcap_read(p, cnt, callback, user); - } while (cc == 0); - return (cc); - + else + return (pcap_read(p, cnt, callback, user)); } int @@ -66,7 +60,7 @@ pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { for (;;) { int n = pcap_dispatch(p, cnt, callback, user); - if (n <= 0) + if (n < 0) return (n); if (cnt > 0) { cnt -= n; @@ -96,7 +90,7 @@ pcap_next(pcap_t *p, struct pcap_pkthdr *h) struct singleton s; s.hdr = h; - if (pcap_dispatch(p, 1, pcap_oneshot, (u_char*)&s) <= 0) + if (pcap_dispatch(p, 1, pcap_oneshot, (u_char*)&s) < 0) return (0); return (s.pkt); } diff --git a/lib/libpcap/pcap.h b/lib/libpcap/pcap.h index af7e3ce4875..5efc16c8868 100644 --- a/lib/libpcap/pcap.h +++ b/lib/libpcap/pcap.h @@ -1,5 +1,5 @@ -/* $OpenBSD: pcap.h,v 1.4 1996/05/07 05:55:50 deraadt Exp $ */ -/* $NetBSD: pcap.h,v 1.3 1996/05/02 00:18:28 cgd Exp $ */ +/* $OpenBSD */ +/* $NetBSD: pcap.h,v 1.3.4.1 1996/06/05 18:04:46 cgd Exp $ */ /* * Copyright (c) 1993, 1994 @@ -103,7 +103,7 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, const u_char *); char *pcap_lookupdev(char *); -int pcap_lookupnet(char *, u_long *, u_long *, char *); +int pcap_lookupnet(char *, u_int32_t *, u_int32_t *, char *); pcap_t *pcap_open_live(char *, int, int, int, char *); pcap_t *pcap_open_offline(char *, char *); void pcap_close(pcap_t *); @@ -111,13 +111,12 @@ int pcap_loop(pcap_t *, int, pcap_handler, u_char *); int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *); const u_char* pcap_next(pcap_t *, struct pcap_pkthdr *); -int pcap_inject(pcap_t *, const void *, size_t); int pcap_stats(pcap_t *, struct pcap_stat *); int pcap_setfilter(pcap_t *, struct bpf_program *); void pcap_perror(pcap_t *, char *); char *pcap_strerror(int); char *pcap_geterr(pcap_t *); -int pcap_compile(pcap_t *, struct bpf_program *, char *, int, u_long); +int pcap_compile(pcap_t *, struct bpf_program *, char *, int, u_int32_t); /* XXX */ int pcap_freecode(pcap_t *, struct bpf_program *); int pcap_datalink(pcap_t *); diff --git a/lib/libpcap/savefile.c b/lib/libpcap/savefile.c index 8b6f2047506..99a1adae3ca 100644 --- a/lib/libpcap/savefile.c +++ b/lib/libpcap/savefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savefile.c,v 1.2 1996/03/04 15:47:30 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: savefile.c,v 1.2 1995/03/06 11:39:10 mycroft Exp $ */ /* @@ -207,38 +207,15 @@ sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, int buflen) } if (hdr->caplen > buflen) { - /* - * This can happen due to Solaris 2.3 systems tripping - * over the BUFMOD problem and not setting the snapshot - * correctly in the savefile header. If the caplen isn't - * grossly wrong, try to salvage. - */ - static u_char *tp = NULL; - static int tsize = 0; - - if (tsize < hdr->caplen) { - tsize = ((hdr->caplen + 1023) / 1024) * 1024; - if (tp != NULL) - free((u_char *)tp); - tp = (u_char *)malloc(tsize); - if (tp == NULL) { - sprintf(p->errbuf, "BUFMOD hack malloc"); - return (-1); - } - } - if (fread((char *)tp, hdr->caplen, 1, fp) != 1) { - sprintf(p->errbuf, "truncated dump file"); - return (-1); - } - memcpy((char *)buf, (char *)tp, buflen); + sprintf(p->errbuf, "bad dump file format"); + return (-1); + } - } else { - /* read the packet itself */ + /* read the packet itself */ - if (fread((char *)buf, hdr->caplen, 1, fp) != 1) { - sprintf(p->errbuf, "truncated dump file"); - return (-1); - } + if (fread((char *)buf, hdr->caplen, 1, fp) != 1) { + sprintf(p->errbuf, "truncated dump file"); + return (-1); } return (0); } @@ -258,11 +235,8 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) struct pcap_pkthdr h; status = sf_next_packet(p, &h, p->buffer, p->bufsize); - if (status) { - if (status == 1) - return (0); - return (status); - } + if (status) + return (-1); if (fcode == NULL || bpf_filter(fcode, p->buffer, h.len, h.caplen)) { diff --git a/lib/libpcap/scanner.l b/lib/libpcap/scanner.l index 0b8dd8d6f10..fb627872ca5 100644 --- a/lib/libpcap/scanner.l +++ b/lib/libpcap/scanner.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scanner.l,v 1.2 1996/03/04 15:47:30 mickey Exp $ */ +/* $OpenBSD */ /* $NetBSD: scanner.l,v 1.2 1995/03/06 11:39:12 mycroft Exp $ */ /* |