From 5262edafad5bc5784d91cd8e4a68ecd2668ca51e Mon Sep 17 00:00:00 2001 From: mickey Date: Mon, 4 Mar 1996 15:47:12 +0000 Subject: [PATCH] Update to the latest LBL release. --- lib/libpcap/CHANGES | 50 ++++++++++++++++++++++++++++++++++++++- lib/libpcap/Makefile | 1 + lib/libpcap/README | 3 ++- lib/libpcap/bpf_image.c | 1 + lib/libpcap/etherent.c | 1 + lib/libpcap/ethertype.h | 1 + lib/libpcap/gencode.c | 1 + lib/libpcap/gencode.h | 1 + lib/libpcap/grammar.y | 2 ++ lib/libpcap/inet.c | 1 + lib/libpcap/nametoaddr.c | 1 + lib/libpcap/optimize.c | 1 + lib/libpcap/pcap-bpf.c | 1 + lib/libpcap/pcap-int.h | 1 + lib/libpcap/pcap-namedb.h | 1 + lib/libpcap/pcap.3 | 1 + lib/libpcap/pcap.c | 17 +++++++++---- lib/libpcap/pcap.h | 1 + lib/libpcap/savefile.c | 45 ++++++++++++++++++++++++++++------- lib/libpcap/scanner.l | 1 + 20 files changed, 116 insertions(+), 16 deletions(-) diff --git a/lib/libpcap/CHANGES b/lib/libpcap/CHANGES index 4053d1c0a24..0032e5da6f5 100644 --- a/lib/libpcap/CHANGES +++ b/lib/libpcap/CHANGES @@ -1,5 +1,53 @@ +$OpenBSD: CHANGES,v 1.2 1996/03/04 15:47:12 mickey 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) +@(#) 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. v0.0 Mon Jun 20 19:20:16 PDT 1994 diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile index 2037374a59c..9f6be6b5e14 100644 --- a/lib/libpcap/Makefile +++ b/lib/libpcap/Makefile @@ -1,3 +1,4 @@ +# $OpenBSD: Makefile,v 1.2 1996/03/04 15:47:13 mickey Exp $ # $NetBSD: Makefile,v 1.1 1995/03/06 11:38:04 mycroft Exp $ LIB= pcap diff --git a/lib/libpcap/README b/lib/libpcap/README index d4d7b634c00..5c05f881b74 100644 --- a/lib/libpcap/README +++ b/lib/libpcap/README @@ -1,7 +1,8 @@ +$OpenBSD: README,v 1.2 1996/03/04 15:47:15 mickey 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 +LIBPCAP 0.0.6 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 963effb9915..9d2ede4709b 100644 --- a/lib/libpcap/bpf_image.c +++ b/lib/libpcap/bpf_image.c @@ -1,3 +1,4 @@ +/* $OpenBSD: bpf_image.c,v 1.2 1996/03/04 15:47:16 mickey Exp $ */ /* $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 227e674f70c..99eaeddb90a 100644 --- a/lib/libpcap/etherent.c +++ b/lib/libpcap/etherent.c @@ -1,3 +1,4 @@ +/* $OpenBSD: etherent.c,v 1.2 1996/03/04 15:47:17 mickey Exp $ */ /* $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 21c0a6d4095..81156475cc2 100644 --- a/lib/libpcap/ethertype.h +++ b/lib/libpcap/ethertype.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ethertype.h,v 1.2 1996/03/04 15:47:17 mickey Exp $ */ /* $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 4cdfc31265c..b2ed7cb2d9e 100644 --- a/lib/libpcap/gencode.c +++ b/lib/libpcap/gencode.c @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/gencode.h b/lib/libpcap/gencode.h index 28ee5d49890..6c223f3655b 100644 --- a/lib/libpcap/gencode.h +++ b/lib/libpcap/gencode.h @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/grammar.y b/lib/libpcap/grammar.y index c005228fe73..5057f6fa21d 100644 --- a/lib/libpcap/grammar.y +++ b/lib/libpcap/grammar.y @@ -1,4 +1,5 @@ %{ +/* $OpenBSD: grammar.y,v 1.2 1996/03/04 15:47:21 mickey Exp $ */ /* $NetBSD: grammar.y,v 1.2 1995/03/06 11:38:27 mycroft Exp $ */ /* @@ -69,6 +70,7 @@ 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 09bac3deb9f..197f4d188a6 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/nametoaddr.c b/lib/libpcap/nametoaddr.c index d7ac9fdf616..b38d00e6eb9 100644 --- a/lib/libpcap/nametoaddr.c +++ b/lib/libpcap/nametoaddr.c @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/optimize.c b/lib/libpcap/optimize.c index c416d70ecb7..5c09695798b 100644 --- a/lib/libpcap/optimize.c +++ b/lib/libpcap/optimize.c @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/pcap-bpf.c b/lib/libpcap/pcap-bpf.c index 6e5c8e2e81f..1b781f36a0c 100644 --- a/lib/libpcap/pcap-bpf.c +++ b/lib/libpcap/pcap-bpf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pcap-bpf.c,v 1.3 1996/03/04 15:47:25 mickey Exp $ */ /* $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 c3d6f5c705b..2d5fa4a2a47 100644 --- a/lib/libpcap/pcap-int.h +++ b/lib/libpcap/pcap-int.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pcap-int.h,v 1.2 1996/03/04 15:47:26 mickey Exp $ */ /* $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 7093c4a2bf4..98d9cc8cade 100644 --- a/lib/libpcap/pcap-namedb.h +++ b/lib/libpcap/pcap-namedb.h @@ -1,3 +1,4 @@ +/* $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 $ */ /* diff --git a/lib/libpcap/pcap.3 b/lib/libpcap/pcap.3 index 95a2d8a38e0..77202b5a53b 100644 --- a/lib/libpcap/pcap.3 +++ b/lib/libpcap/pcap.3 @@ -1,3 +1,4 @@ +.\" $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 $ .\" .\" Copyright (c) 1994 diff --git a/lib/libpcap/pcap.c b/lib/libpcap/pcap.c index a59f65a127d..6f47bc160ff 100644 --- a/lib/libpcap/pcap.c +++ b/lib/libpcap/pcap.c @@ -1,7 +1,8 @@ +/* $OpenBSD: pcap.c,v 1.2 1996/03/04 15:47:28 mickey Exp $ */ /* $NetBSD: pcap.c,v 1.2 1995/03/06 11:39:05 mycroft Exp $ */ /* - * Copyright (c) 1993, 1994 + * Copyright (c) 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,10 +49,16 @@ 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)); - else - return (pcap_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); + } int @@ -59,7 +66,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; @@ -89,7 +96,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 0ff43eebbf0..c93285f3d48 100644 --- a/lib/libpcap/pcap.h +++ b/lib/libpcap/pcap.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pcap.h,v 1.3 1996/03/04 15:47:29 mickey Exp $ */ /* $NetBSD: pcap.h,v 1.2 1995/03/06 11:39:07 mycroft Exp $ */ /* diff --git a/lib/libpcap/savefile.c b/lib/libpcap/savefile.c index ae15ce6f81e..8b6f2047506 100644 --- a/lib/libpcap/savefile.c +++ b/lib/libpcap/savefile.c @@ -1,3 +1,4 @@ +/* $OpenBSD: savefile.c,v 1.2 1996/03/04 15:47:30 mickey Exp $ */ /* $NetBSD: savefile.c,v 1.2 1995/03/06 11:39:10 mycroft Exp $ */ /* @@ -206,15 +207,38 @@ sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, int buflen) } if (hdr->caplen > buflen) { - sprintf(p->errbuf, "bad dump file format"); - return (-1); - } + /* + * 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); - /* read the packet itself */ + } else { + /* 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); } @@ -234,8 +258,11 @@ 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) - return (-1); + if (status) { + if (status == 1) + return (0); + return (status); + } 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 fb203f42527..0b8dd8d6f10 100644 --- a/lib/libpcap/scanner.l +++ b/lib/libpcap/scanner.l @@ -1,4 +1,5 @@ %{ +/* $OpenBSD: scanner.l,v 1.2 1996/03/04 15:47:30 mickey Exp $ */ /* $NetBSD: scanner.l,v 1.2 1995/03/06 11:39:12 mycroft Exp $ */ /* -- 2.20.1