diff -urN ./Makefile ../tcpdump-2.2.1-ews/Makefile --- ./Makefile Wed Jun 3 04:40:04 1992 +++ ../tcpdump-2.2.1-ews/Makefile Fri Sep 9 14:11:35 1994 @@ -27,7 +27,7 @@ # # CSLIP and PPP work only under BPF. # -DEFINES = -DCSLIP -DPPP -DFDDI +DEFINES = -DFDDI CCOPT = -O INCLUDES = -I.. @@ -35,11 +35,11 @@ GROUP = bpf # Full pathname of where to install the binaries -BINDEST = /usr/etc/tcpdump -TCPSLICE_BINDEST = /usr/local/tcpslice +BINDEST = /usr/local/etc/tcpdump +TCPSLICE_BINDEST = /usr/local/etc/tcpslice # Full pathname of where to install the manual entries -MANDEST = /usr/man/manl/tcpdump.l -TCPSLICE_MANDEST = /usr/man/manl/tcpslice.l +MANDEST = /usr/local/man/manl/tcpdump.l +TCPSLICE_MANDEST = /usr/local/man/manl/tcpslice.l # Standard CFLAGS STANDARD_CFLAGS = $(CCOPT) $(DEFINES) $(INCLUDES) @@ -52,18 +52,23 @@ #sun3-sunos4#CFLAGS = $(STANDARD_CFLAGS) #sun4-sunos4#CFLAGS = $(STANDARD_CFLAGS) #sun4-bsd#CFLAGS = $(STANDARD_CFLAGS) +#sun4-svr4#CFLAGS = $(STANDARD_CFLAGS) +CFLAGS = $(STANDARD_CFLAGS) #tahoe-bsd#CFLAGS = $(STANDARD_CFLAGS) #vax-bsd#CFLAGS = $(STANDARD_CFLAGS) #vax-ultrix#CFLAGS = $(STANDARD_CFLAGS) #mips-irix#CFLAGS = $(STANDARD_CFLAGS) -D_BSD_COMPAT +#sun4-svr4#LIB = -lsocket -lnsl +LIB = -lsocket -lnsl + SUBDIRS = hp300-bsd mips-ultrix sun?-sunos? sun4-bsd tahoe-bsd vax-bsd \ - vax-ultrix rt-bsd mips-irix + vax-ultrix rt-bsd mips-irix sun4-svr4 mips-svr4 # Change these to cc/lex/yacc if you don't have gcc, flex and/or bison. -CC = gcc -g -LEX = flex -YACC = bison -y +CC = cc +LEX = lex +YACC = yacc MAKE = make # Script (or program) that returns the machine and os types, @@ -96,7 +101,7 @@ MSRC = md-hp300.c md-mips.c md-sun3.c md-sun4.c md-vax.c md-rt.c -PSRC = pcap-nit.c pcap-pf.c pcap-snit.c pcap-bpf.c pcap-enet.c +PSRC = pcap-nit.c pcap-pf.c pcap-snit.c pcap-bpf.c pcap-enet.c pcap-dlpi.c OSRC = os-sunos3.c os-sunos4.c os-bsd.c os-ultrix.c @@ -158,6 +163,7 @@ elif [ $$os = "sunos3" ] ; then pcap="nit"; \ elif [ $$os = "sunos4" ] ; then pcap="snit"; \ elif [ $$os = "ultrix" ] ; then pcap="pf"; \ + elif [ $$os = "svr4" ] ; then pcap="dlpi"; \ elif [ -f /usr/include/net/enet.h ] ; then pcap="enet"; \ else pcap="bpf"; fi; \ for i in $(SRC) $(HDR); do list="../$$i $$list"; done; \ diff -urN ./README.svr4 ../tcpdump-2.2.1-ews/README.svr4 --- ./README.svr4 Thu Jan 1 09:00:00 1970 +++ ../tcpdump-2.2.1-ews/README.svr4 Fri Sep 9 13:43:32 1994 @@ -0,0 +1,21 @@ + +This is a patched version of tcpdump 2.2.1. + +This patched version of tcpdump runs on following platforms besides +the original targets: + + machine os packet filter + ------- -- ------------- + sparc SunOS 5.x dlpi + ews4800 EWS-UX/V Rel.4.2 dlpi + +Restrictions: + 1. On the above platforms, tcpdump supports only Ethernet links. + 2. Timestamps of packets are given not by the kernel but by tcpdump. + + + July 22, 1994 + + Hiroshi Nakano + Ryukoku Univ., Seta, Otsu, Japan + diff -urN ./addrtoname.c ../tcpdump-2.2.1-ews/addrtoname.c --- ./addrtoname.c Tue May 26 06:29:09 1992 +++ ../tcpdump-2.2.1-ews/addrtoname.c Fri Sep 9 13:43:24 1994 @@ -27,7 +27,6 @@ #endif #include -#include #include #include #include @@ -43,6 +42,12 @@ #include "nametoaddr.h" #include "etherent.h" +#ifdef SVR4 +#include +#else +#include +#endif + /* * hash tables for whatever-to-name translations */ @@ -198,7 +203,9 @@ hp = gethostbyaddr((char *)&addr, 4, AF_INET); (void)alarm(0); if (hp) { +#ifndef SVR4 char *index(); +#endif char *dotp; u_int len = strlen(hp->h_name) + 1; p->name = (char *)malloc(len); diff -urN ./bpf_filter.c ../tcpdump-2.2.1-ews/bpf_filter.c --- ./bpf_filter.c Tue Apr 7 02:43:28 1992 +++ ../tcpdump-2.2.1-ews/bpf_filter.c Fri Sep 9 13:43:32 1994 @@ -52,6 +52,8 @@ #ifdef sun #include +#else +#include "interface.h" #endif #if defined(sparc) || defined(mips) || defined(ibm032) diff -urN ./gencode.c ../tcpdump-2.2.1-ews/gencode.c --- ./gencode.c Sat May 23 08:39:05 1992 +++ ../tcpdump-2.2.1-ews/gencode.c Fri Sep 9 13:43:30 1994 @@ -1001,16 +1001,16 @@ } struct arth * -gen_load(proto, index, size) +gen_load(proto, idx, size) int proto; - struct arth *index; + struct arth *idx; int size; { struct slist *s, *tmp; struct block *b; int regno = alloc_reg(); - free_reg(index->regno); + free_reg(idx->regno); switch (size) { default: @@ -1033,26 +1033,26 @@ error("unsupported index operation"); case Q_LINK: - s = xfer_to_x(index); + s = xfer_to_x(idx); tmp = new_stmt(BPF_LD|BPF_IND|size); sappend(s, tmp); - sappend(index->s, s); + sappend(idx->s, s); break; case Q_IP: case Q_ARP: case Q_RARP: /* XXX Note that we assume a fixed link link header here. */ - s = xfer_to_x(index); + s = xfer_to_x(idx); tmp = new_stmt(BPF_LD|BPF_IND|size); tmp->s.k = off_nl; sappend(s, tmp); - sappend(index->s, s); + sappend(idx->s, s); b = gen_proto_abbrev(proto); - if (index->b) - gen_and(index->b, b); - index->b = b; + if (idx->b) + gen_and(idx->b, b); + idx->b = b; break; case Q_TCP: @@ -1060,25 +1060,25 @@ case Q_ICMP: s = new_stmt(BPF_LDX|BPF_MSH|BPF_B); s->s.k = off_nl; - sappend(s, xfer_to_a(index)); + sappend(s, xfer_to_a(idx)); sappend(s, new_stmt(BPF_ALU|BPF_ADD|BPF_X)); sappend(s, new_stmt(BPF_MISC|BPF_TAX)); sappend(s, tmp = new_stmt(BPF_LD|BPF_IND|size)); tmp->s.k = off_nl; - sappend(index->s, s); + sappend(idx->s, s); gen_and(gen_proto_abbrev(proto), b = gen_ipfrag()); - if (index->b) - gen_and(index->b, b); - index->b = b; + if (idx->b) + gen_and(idx->b, b); + idx->b = b; break; } - index->regno = regno; + idx->regno = regno; s = new_stmt(BPF_ST); s->s.k = regno; - sappend(index->s, s); + sappend(idx->s, s); - return index; + return idx; } struct block * diff -urN ./inet.c ../tcpdump-2.2.1-ews/inet.c --- ./inet.c Thu Jan 30 05:46:59 1992 +++ ../tcpdump-2.2.1-ews/inet.c Fri Sep 9 13:43:28 1994 @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -36,6 +35,12 @@ #include #include "interface.h" +#ifdef SVR4 +#include +#include +#else +#include +#endif /* Not all systems have IFF_LOOPBACK */ #ifdef IFF_LOOPBACK diff -urN ./md-mips.c ../tcpdump-2.2.1-ews/md-mips.c --- ./md-mips.c Fri Sep 21 18:19:56 1990 +++ ../tcpdump-2.2.1-ews/md-mips.c Fri Sep 9 13:43:23 1994 @@ -32,6 +32,10 @@ int clock_sigfigs() { +#ifdef nec_ews_svr4 + return 2; +#else return 3; +#endif } diff -urN ./md-mips.h ../tcpdump-2.2.1-ews/md-mips.h --- ./md-mips.h Tue May 26 06:28:54 1992 +++ ../tcpdump-2.2.1-ews/md-mips.h Fri Sep 9 13:43:30 1994 @@ -30,6 +30,10 @@ #ifdef ultrix /* SPIM */ +#if !defined(BIT_ZERO_ON_LEFT) && !defined(BIT_ZERO_ON_RIGHT) +#define BIT_ZERO_ON_RIGHT 1 +#endif + #ifndef BYTE_ORDER #define BYTE_ORDER LITTLE_ENDIAN #endif @@ -45,6 +49,10 @@ #else /* MIPS */ +#if !defined(BIT_ZERO_ON_LEFT) && !defined(BIT_ZERO_ON_RIGHT) +#define BIT_ZERO_ON_LEFT 1 +#endif + #ifndef BYTE_ORDER #define BYTE_ORDER BIG_ENDIAN #endif diff -urN ./md-sun4.c ../tcpdump-2.2.1-ews/md-sun4.c --- ./md-sun4.c Fri Sep 21 18:20:01 1990 +++ ../tcpdump-2.2.1-ews/md-sun4.c Fri Sep 9 13:43:29 1994 @@ -24,6 +24,9 @@ "@(#) $Header: md-sun4.c,v 1.2 90/09/21 02:20:17 mccanne Exp $ (LBL)"; #endif +#include +#include "os.h" + /* The sun includes are arranged too stupidly to help us */ #define ARCH_MASK 0xf0000000 @@ -45,6 +48,9 @@ int clock_sigfigs() { +#ifdef SVR4 + return 2; +#else int good = 0; long id = gethostid(); @@ -69,4 +75,5 @@ return 6; else return 2; +#endif } diff -urN ./mdtype ../tcpdump-2.2.1-ews/mdtype --- ./mdtype Mon Feb 17 14:29:48 1992 +++ ../tcpdump-2.2.1-ews/mdtype Fri Sep 9 13:43:23 1994 @@ -5,12 +5,15 @@ # set mach="UNKNOWN" if ( -f /bin/arch ) set mach=`/bin/arch` +if ( { ( /usr/bin/uname -p >&/dev/null ) } ) set mach=`/usr/bin/uname -p` if ($mach == "UNKNOWN") then set temp=`machine` if ($temp != "") set mach=$temp endif # Hack, hack... if ($mach == "sparc") set mach=sun4 +if ($mach == "r4000") set mach=mips +if ($mach == "r3000") set mach=mips echo $mach if ($mach == "UNKNOWN") exit 1 exit 0 diff -urN ./mkdep ../tcpdump-2.2.1-ews/mkdep --- ./mkdep Wed May 27 10:41:03 1992 +++ ../tcpdump-2.2.1-ews/mkdep Fri Sep 9 13:43:24 1994 @@ -13,7 +13,7 @@ # @(#)mkdep.sh 5.11 (Berkeley) 5/5/88 # -PATH=/bin:/usr/bin:/usr/ucb +PATH=/bin:/usr/bin:/usr/ucb:$PATH export PATH MAKE=Makefile # default makefile name is "Makefile" diff -urN ./os-svr4.c ../tcpdump-2.2.1-ews/os-svr4.c --- ./os-svr4.c Thu Jan 1 09:00:00 1970 +++ ../tcpdump-2.2.1-ews/os-svr4.c Fri Sep 9 13:43:22 1994 @@ -0,0 +1,37 @@ +/* + * os-svr4.c + * H.Nakano (93/10/06) + */ + +#include +#include +#include +#include +#include + +u_char * +ETHER_hostton(name) + char *name; +{ + u_char *ep; + + ep = (u_char *)malloc(6); + if (ether_hostton(name, (struct ether_addr *)ep) == 0) + return ep; + free((char *)ep); + return 0; +} + +char * +ETHER_ntohost(ep) + u_char *ep; +{ + char buf[128], *cp; + + if (ether_ntohost(buf, (struct ether_addr *)ep) == 0) { + cp = (char *)malloc(strlen(buf) + 1); + strcpy(cp, buf); + return cp; + } + return 0; +} diff -urN ./os-svr4.h ../tcpdump-2.2.1-ews/os-svr4.h --- ./os-svr4.h Thu Jan 1 09:00:00 1970 +++ ../tcpdump-2.2.1-ews/os-svr4.h Fri Sep 9 13:43:24 1994 @@ -0,0 +1,30 @@ + +#define SVR4 + +#define bcopy(s, d, n) (memcpy(d, s, n)) +#define index(p, c) (strchr(p, c)) +#define rindex(p, c) (strrchr(p, c)) +#define bzero(p, n) (memset(p, 0, n)) +#define bcmp(p, q, n) (memcmp(p, q, n) != 0) + +#define ETHER_SERVICE +u_char *ETHER_hostton(); +char *ETHER_ntohost(); + +#define SHA(ap) ((ap)->arp_sha) +#define SPA(ap) ((ap)->arp_spa) +#define THA(ap) ((ap)->arp_tha) +#define TPA(ap) ((ap)->arp_tpa) + +#if defined(sun) || defined (__sun__) +#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet) +#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet) +#else +#define EDST(ep) ((ep)->ether_dhost) +#define ESRC(ep) ((ep)->ether_shost) +#endif + +#define ETHERPUP_IPTYPE ETHERTYPE_IP +#define ETHERPUP_REVARPTYPE ETHERTYPE_REVARP +#define ETHERPUP_ARPTYPE ETHERTYPE_ARP + diff -urN ./ostype ../tcpdump-2.2.1-ews/ostype --- ./ostype Thu Oct 4 06:24:00 1990 +++ ../tcpdump-2.2.1-ews/ostype Fri Sep 9 13:43:23 1994 @@ -10,6 +10,8 @@ set os="hpux" else if ( -f /etc/uerf ) then set os="ultrix" + else if ( -f /usr/include/sys/dlpi.h ) then + set os="svr4" endif endif echo $os diff -urN ./pcap-dlpi.c ../tcpdump-2.2.1-ews/pcap-dlpi.c --- ./pcap-dlpi.c Thu Jan 1 09:00:00 1970 +++ ../tcpdump-2.2.1-ews/pcap-dlpi.c Fri Sep 9 13:43:22 1994 @@ -0,0 +1,377 @@ +/* + * pcap-dlpi.c + * H.Nakano (93/10/06) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "interface.h" + +#define MAXWAIT 15 /* timeout */ +#define MAXDLBUF 8092 /* buf size */ +#define DEFAULTSAP ETHERTYPE_IP /* IP protocol */ +#define ETHER_ADDR_SIZE 6 /* size of Ethernet addresses */ + +static union DL_primitives *dlattach(); +static union DL_primitives *dlbind(); +static union DL_primitives *dlpromiscon(); +static union DL_primitives *dlinfo(); +static union DL_primitives *dlgetack(); +static void timeout_handler(); + +static int packet_count; + +void +readloop(cnt, if_fd, fp, printit) + int cnt; + int if_fd; + struct bpf_program *fp; + void (*printit)(); +{ + long ctl_buf[MAXDLBUF]; + long buf[MAXDLBUF+sizeof(struct ether_header)/sizeof(long)+1]; + char *data_buf = (char *)buf + sizeof(struct ether_header); + dl_unitdata_ind_t *u = (dl_unitdata_ind_t *)ctl_buf; + struct bpf_insn *fcode; + struct timeval tv, prev_tv; + struct strbuf ctl; + struct strbuf data; + int wirelen, caplen; + int flags; + int ret; + + if (tflag) + gettimeofday(&prev_tv); + + packet_count = 0; + + fcode = fp->bf_insns; + ctl.buf = (char *)ctl_buf; + ctl.len = 0; + ctl.maxlen = MAXDLBUF; + data.buf = data_buf; + data.len = 0; + data.maxlen = MAXDLBUF; + flags = 0; + + while ((ret = getmsg(if_fd, &ctl, &data, &flags)) == 0) { + struct ether_header *e = (struct ether_header *)data_buf; + + wirelen = caplen = data.len + sizeof(struct ether_header); + if (caplen > snaplen) + caplen = snaplen; + if (data.len > 0 && u->dl_primitive == DL_UNITDATA_IND) { + packet_count++; + if (memcmp((char *)&e->ether_type, + (char *)ctl_buf + u->dl_dest_addr_offset + + ETHER_ADDR_SIZE, + sizeof(e->ether_type)) != 0 + || memcmp((char *)EDST(e), + (char *)ctl_buf + u->dl_dest_addr_offset, + ETHER_ADDR_SIZE) != 0 + || memcmp((char *)ESRC(e), + (char *)ctl_buf + u->dl_src_addr_offset, + ETHER_ADDR_SIZE) != 0) { + e = (struct ether_header *)buf; + e->ether_type = *(u_short *) + ((char *)ctl_buf + u->dl_dest_addr_offset + + ETHER_ADDR_SIZE); + memcpy((char *)EDST(e), + (char *)ctl_buf + u->dl_dest_addr_offset, + ETHER_ADDR_SIZE); + memcpy((char *)ESRC(e), + (char *)ctl_buf + u->dl_src_addr_offset, + ETHER_ADDR_SIZE); + } + if (bpf_filter(fcode, (char *)e, wirelen, caplen)) { + if (cnt >= 0 && --cnt < 0) { + wrapup(if_fd); + return; + } + if (tflag) + { + gettimeofday(&tv); + if (tv.tv_sec < prev_tv.tv_sec || + (tv.tv_sec == prev_tv.tv_sec && + tv.tv_usec <= prev_tv.tv_usec)) + { + if (++ prev_tv.tv_usec >= 1000000) + { + prev_tv.tv_sec += + prev_tv.tv_usec / 1000000; + prev_tv.tv_usec %= 1000000; + } + tv = prev_tv; + } + else + prev_tv = tv; + } + (*printit)((char *)e, &tv, wirelen, caplen); + } + } + ctl.len = data.len = 0; + flags = 0; + } + + if (ret < 0) + perror("tcpdump: getmsg"); + else + fprintf(stderr, "tcpdump: getmsg: %d\n", ret); + + exit(-1); +} + +wrapup(if_fd) + int if_fd; +{ + fflush(stdout); + (void)fprintf(stderr, "%d packets received by filter\n", packet_count); + close(if_fd); +} + +int +initdevice(device, pflag, linktype) + char *device; + int pflag; + int *linktype; +{ + char devname[MAXPATHLEN+1]; + char *minorp; + u_long ppa; + int if_fd; + union DL_primitives *dl; + + minorp = strpbrk(device, "0123456789"); + + if (minorp == NULL) { + fprintf(stderr, "tcpdump: invalid interface: %s\n", device); + exit(-1); + } + + strcpy(devname, "/dev/"); + strncat(devname, device, minorp - device); + ppa = atoi(minorp); + + if_fd = open(devname, O_RDWR); + if (if_fd < 0) { + (void) fprintf(stderr, "tcpdump: open: "); + perror(devname); + exit(-1); + } + + if (!dlattach(if_fd, ppa)) { + fprintf(stderr, "tcpdump: dlattach failed: %s\n", devname); + exit(-1); + } + + dl = dlinfo(if_fd); + if (!dl) { + fprintf(stderr, "tcpdump: dlinfo failed: %s\n", devname); + exit(-1); + } + + switch (dl->info_ack.dl_mac_type) { + case DL_CSMACD: + case DL_ETHER: + *linktype = DLT_EN10MB; + break; + default: + fprintf(stderr, "tcpdump: unknown DLPI mac type: %d\n", + dl->info_ack.dl_mac_type); + exit(-1); + } + + if (!dlbind(if_fd, ETHERTYPE_IP, 0, DL_CLDLS, 0, 0)) { + fprintf(stderr, "tcpdump: dlbind failed: %s\n", devname); + exit(-1); + } + + dlpromiscon(if_fd, DL_PROMISC_SAP); + + if (!pflag) { + if (!dlpromiscon(if_fd, DL_PROMISC_PHYS)) { + fprintf(stderr, + "tcpdump: dlpromiscon DL_PROMISC_PHYS failed: %s\n", + devname); + exit(-1); + } + } + + if (ioctl(if_fd, I_SRDOPT, (char *) RMSGD) < 0) { + fprintf(stderr, "tcpdump: ioctl: I_SRDOPT RMSGD: "); + perror(devname); + exit(-1); + } + + return if_fd; +} + +static union DL_primitives * +dlattach(if_fd, ppa) + int if_fd; + u_long ppa; +{ + dl_attach_req_t req; + struct strbuf ctl; + int flags; + + req.dl_primitive = DL_ATTACH_REQ; + req.dl_ppa = ppa; + ctl.maxlen = 0; + ctl.len = sizeof(req); + ctl.buf = (char *)&req; + flags = 0; + + if (putmsg (if_fd, &ctl, (struct strbuf*) NULL, flags) < 0) { + fprintf(stderr, "tcpdump: dlattach: "); + perror("putmsg"); + return (union DL_primitives *)NULL; + } + + return dlgetack(if_fd, DL_OK_ACK, DL_OK_ACK_SIZE); +} + +static union DL_primitives * +dlbind(if_fd, sap, max_conind, service_mode, conn_mgmt, xidtest) + int if_fd; + u_long sap, max_conind, service_mode, conn_mgmt, xidtest; +{ + dl_bind_req_t bind_req; + struct strbuf ctl; + int flags; + + bind_req.dl_primitive = DL_BIND_REQ; + bind_req.dl_sap = sap; + bind_req.dl_max_conind = max_conind; + bind_req.dl_service_mode = service_mode; + bind_req.dl_conn_mgmt = conn_mgmt; + bind_req.dl_xidtest_flg = xidtest; + ctl.maxlen = 0; + ctl.len = sizeof(bind_req); + ctl.buf = (char *)&bind_req; + flags = 0; + + if (putmsg(if_fd, &ctl, (struct strbuf *) NULL, flags) < 0) { + fprintf(stderr, "tcpdump: dlbind: "); + perror("putmsg"); + return (union DL_primitives *)NULL; + } + + return dlgetack(if_fd, DL_BIND_ACK, DL_BIND_ACK_SIZE); +} + +static union DL_primitives * +dlpromiscon(if_fd, level) + int if_fd; + u_long level; +{ + long buf[MAXDLBUF]; + dl_promiscon_req_t promiscon_req; + struct strbuf ctl; + int flags; + + promiscon_req.dl_primitive = DL_PROMISCON_REQ; + promiscon_req.dl_level = level; + ctl.maxlen = 0; + ctl.len = sizeof(promiscon_req); + ctl.buf = (char *)&promiscon_req; + flags = 0; + + if (putmsg(if_fd, &ctl, (struct strbuf *) NULL, flags) < 0) { + fprintf(stderr, "tcpdump: dlpromiscon: "); + perror("putmsg"); + return (union DL_primitives *)NULL; + } + + return dlgetack(if_fd, DL_OK_ACK, DL_OK_ACK_SIZE); +} + +static union DL_primitives * +dlinfo(if_fd) + int if_fd; +{ + union DL_primitives *dl; + dl_info_req_t info_req; + struct strbuf ctl; + int flags; + + info_req.dl_primitive = DL_INFO_REQ; + ctl.maxlen = 0; + ctl.len = sizeof(info_req); + ctl.buf = (char *)&info_req; + flags = RS_HIPRI; + + if (putmsg(if_fd, &ctl, (struct strbuf *) NULL, flags) < 0) { + fprintf(stderr, "tcpdump: dlinfo: "); + perror("putmsg"); + return (union DL_primitives *)NULL; + } + + return dlgetack(if_fd, DL_INFO_ACK, DL_INFO_ACK_SIZE); +} + +static union DL_primitives * +dlgetack(if_fd, ack, size) + int if_fd; + ulong ack; + ulong size; +{ + static long buf[MAXDLBUF]; + struct strbuf ctl; + int flags; + int ret; + + ctl.maxlen = MAXDLBUF; + ctl.len = 0; + ctl.buf = (char *)buf; + flags = 0; + + sigset(SIGALRM, timeout_handler); + if (alarm(MAXWAIT) < 0) { + fprintf(stderr, "tcpdump: dlgetmsg: "); + perror("alarm"); + exit(-1); + } + + ret = getmsg(if_fd, &ctl, (struct strbuf *)NULL, &flags); + if (alarm(0) < 0) { + fprintf(stderr, "tcpdump: dlgetack: "); + perror("alarm"); + exit(-1); + } + + if (ret < 0) { + fprintf(stderr, "tcpdump: dlgetack: "); + perror("getmsg"); + exit(-1); + } + + if ((ret & (MORECTL|MOREDATA)) || ctl.len < size + || ((union DL_primitives *)ctl.buf)->dl_primitive != ack) + return (union DL_primitives *)NULL; + + return (union DL_primitives *)ctl.buf; +} + +static void +timeout_handler() +{ + fprintf(stderr, "tcpdump: dlgetmsg: timeout\n"); + exit(-1); +} + diff -urN ./print-atalk.c ../tcpdump-2.2.1-ews/print-atalk.c --- ./print-atalk.c Fri Mar 27 07:15:52 1992 +++ ../tcpdump-2.2.1-ews/print-atalk.c Fri Sep 9 13:43:25 1994 @@ -45,7 +45,11 @@ #include "interface.h" #include "addrtoname.h" #include "appletalk.h" +#ifdef SVR4 +#include +#else #include +#endif #include "extract.h" static char *ataddr_string(); diff -urN ./print-bootp.c ../tcpdump-2.2.1-ews/print-bootp.c --- ./print-bootp.c Sat Jan 4 18:34:04 1992 +++ ../tcpdump-2.2.1-ews/print-bootp.c Fri Sep 9 13:43:26 1994 @@ -33,10 +33,14 @@ #include #include #include -#include #include #include "interface.h" +#ifdef SVR4 +#include +#else +#include +#endif #include "addrtoname.h" #include "bootp.h" diff -urN ./print-domain.c ../tcpdump-2.2.1-ews/print-domain.c --- ./print-domain.c Tue May 26 06:29:01 1992 +++ ../tcpdump-2.2.1-ews/print-domain.c Fri Sep 9 13:43:30 1994 @@ -37,9 +37,10 @@ #include #include #include -#include #include "interface.h" + +#include #include "addrtoname.h" static char *ns_ops[] = { diff -urN ./print-fddi.c ../tcpdump-2.2.1-ews/print-fddi.c --- ./print-fddi.c Tue Feb 4 09:04:42 1992 +++ ../tcpdump-2.2.1-ews/print-fddi.c Fri Sep 9 13:43:27 1994 @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -48,6 +47,9 @@ #include #include "interface.h" +#ifndef SVR4 +#include +#endif #include "addrtoname.h" /* diff -urN ./print-nfs.c ../tcpdump-2.2.1-ews/print-nfs.c --- ./print-nfs.c Sat Feb 1 05:31:11 1992 +++ ../tcpdump-2.2.1-ews/print-nfs.c Fri Sep 9 13:43:26 1994 @@ -35,6 +35,11 @@ #include #include +#include "interface.h" +#ifdef SVR4 +#include +#include +#endif #include #include #include @@ -46,7 +51,6 @@ #include -#include "interface.h" /* These must come after interface.h for BSD. */ #if BSD >= 199006 #include diff -urN ./print-ntp.c ../tcpdump-2.2.1-ews/print-ntp.c --- ./print-ntp.c Sat Jan 4 18:44:05 1992 +++ ../tcpdump-2.2.1-ews/print-ntp.c Fri Sep 9 13:43:27 1994 @@ -36,10 +36,14 @@ #include #include #include -#include #include #include "interface.h" +#ifdef SVR4 +#include +#else +#include +#endif #include "addrtoname.h" #include "ntp.h" diff -urN ./print-null.c ../tcpdump-2.2.1-ews/print-null.c --- ./print-null.c Tue Oct 8 12:18:10 1991 +++ ../tcpdump-2.2.1-ews/print-null.c Fri Sep 9 13:43:27 1994 @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -48,6 +47,9 @@ #include #include "interface.h" +#ifndef SVR4 +#include +#endif #include "addrtoname.h" #define NULL_HDRLEN 4 diff -urN ./print-snmp.c ../tcpdump-2.2.1-ews/print-snmp.c --- ./print-snmp.c Sat Apr 20 02:46:54 1991 +++ ../tcpdump-2.2.1-ews/print-snmp.c Fri Sep 9 13:43:31 1994 @@ -713,7 +713,7 @@ int length, error; { struct be elem; - int count = 0, index; + int count = 0, idx; /* Sequence of varBind */ if ((count = asn1_parse(np, length, &elem)) < 0) @@ -729,11 +729,11 @@ length = elem.asnlen; np = (u_char *)elem.data.raw; - for (index = 1; length > 0; index++) { + for (idx = 1; length > 0; idx++) { u_char *vbend; int vblength; - if (!error || index == error) + if (!error || idx == error) fputs(" ", stdout); /* Sequence */ @@ -758,7 +758,7 @@ asn1_print(&elem); return; } - if (!error || index == error) + if (!error || idx == error) asn1_print(&elem); length -= count; np += count; @@ -775,9 +775,9 @@ asn1_print(&elem); } } else - if (error && index == error && elem.type != BE_NULL) + if (error && idx == error && elem.type != BE_NULL) fputs("[err objVal!=NULL]", stdout); - if (!error || index == error) + if (!error || idx == error) asn1_print(&elem); length = vblength; diff -urN ./print-sunrpc.c ../tcpdump-2.2.1-ews/print-sunrpc.c --- ./print-sunrpc.c Wed Jun 3 03:36:38 1992 +++ ../tcpdump-2.2.1-ews/print-sunrpc.c Fri Sep 9 13:43:28 1994 @@ -35,6 +35,10 @@ #include #include +#include "interface.h" +#ifdef SVR4 +#include +#endif #include #include #include @@ -48,7 +52,6 @@ #include -#include "interface.h" #include "addrtoname.h" #include "extract.h" diff -urN ./print-tftp.c ../tcpdump-2.2.1-ews/print-tftp.c --- ./print-tftp.c Sat Apr 20 02:46:58 1991 +++ ../tcpdump-2.2.1-ews/print-tftp.c Fri Sep 9 13:43:26 1994 @@ -31,7 +31,11 @@ #include #include "interface.h" +#ifdef SVR4 +#include +#else #include +#endif #include struct int2str { diff -urN ./print-udp.c ../tcpdump-2.2.1-ews/print-udp.c --- ./print-udp.c Sat May 23 11:43:13 1992 +++ ../tcpdump-2.2.1-ews/print-udp.c Fri Sep 9 13:43:25 1994 @@ -34,6 +34,11 @@ #include #include +#include "interface.h" +#ifdef SVR4 +#include +#endif + #include #include #include @@ -45,7 +50,6 @@ #include #include -#include "interface.h" /* These must come after interface.h for BSD. */ #if BSD >= 199006 #include diff -urN ./tcpdump.c ../tcpdump-2.2.1-ews/tcpdump.c --- ./tcpdump.c Wed Jun 3 09:57:44 1992 +++ ../tcpdump-2.2.1-ews/tcpdump.c Fri Sep 9 13:43:29 1994 @@ -46,6 +46,10 @@ #include "savefile.h" #include "addrtoname.h" +#ifdef SVR4 +#include +#endif + int fflag; /* don't translate "foreign" IP address */ int nflag; /* leave addresses as numbers */ int Nflag; /* remove domains from printed host names */ @@ -159,7 +163,11 @@ break; case 'l': +#ifdef SVR4 + setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); +#else setlinebuf(stdout); +#endif break; case 'n': @@ -224,6 +232,14 @@ if (tflag > 0) { struct timeval now; +#ifdef SVR4 + if (gettimeofday(&now) < 0) { + perror("tcpdump: gettimeofday"); + exit(1); + } + tzset(); + thiszone = - (daylight ? altzone : timezone); +#else struct timezone tz; if (gettimeofday(&now, &tz) < 0) { @@ -233,6 +249,7 @@ thiszone = tz.tz_minuteswest * -60; if (localtime((time_t *)&now.tv_sec)->tm_isdst) thiszone += 3600; +#endif } if (RFileName) { diff -urN ./tcplex.l ../tcpdump-2.2.1-ews/tcplex.l --- ./tcplex.l Sat Feb 15 08:16:50 1992 +++ ../tcpdump-2.2.1-ews/tcplex.l Fri Sep 9 13:43:25 1994 @@ -25,18 +25,7 @@ "@(#) $Header: tcplex.l,v 1.26 92/02/14 15:16:35 mccanne Exp $ (LBL)"; #endif -/* - * Compiling with gcc under SunOS will cause problems unless we have this - * cruft here. The flex skeleton includes stddef.h which defines these types - * (under gcc). They will conflict with Sun's definitions in sys/types.h. - */ -#define size_t xxxsize_t -#define ptrdiff_t xxxptrdiff_t -#define wchar_t xxxwchar_t #include -#undef size_t -#undef ptrdiff_t -#undef wchar_t #include "nametoaddr.h" diff -urN ./tcpslice.c ../tcpdump-2.2.1-ews/tcpslice.c --- ./tcpslice.c Wed Jun 3 09:57:48 1992 +++ ../tcpdump-2.2.1-ews/tcpslice.c Fri Sep 9 13:55:54 1994 @@ -40,7 +40,11 @@ #include "savefile.h" #include "version.h" +#include "interface.h" +#ifdef SVR4 +#include +#endif int tflag = 0; /* global that util routines are sensitive to */ @@ -219,8 +223,16 @@ long timestamp; { struct timeval now; - struct timezone tz; long localzone; +#ifdef SVR4 + if (gettimeofday(&now) < 0) { + perror("tcpslice: gettimeofday"); + exit(1); + } + tzset(); + localzone = - (daylight ? altzone : timezone); +#else + struct timezone tz; if (gettimeofday(&now, &tz) < 0) { perror("tcpslice: gettimeofday"); @@ -230,6 +242,7 @@ if (localtime((time_t *) ×tamp)->tm_isdst) localzone += 3600; +#endif return localzone; } diff -urN ./util.c ../tcpdump-2.2.1-ews/util.c --- ./util.c Tue Oct 29 15:09:35 1991 +++ ../tcpdump-2.2.1-ews/util.c Fri Sep 9 13:43:28 1994 @@ -36,6 +36,10 @@ #include #include "interface.h" +#ifdef SVR4 +#include +#include +#endif /* Hex digit to integer. */ static inline int @@ -155,7 +159,9 @@ register char *s; { register char *cp; +#ifndef SVR4 char *rindex(); +#endif cp = rindex(s, '/'); return (cp != 0) ? cp + 1 : s;