diff options
Diffstat (limited to 'usr.sbin/tcpdump/print-sl.c')
-rw-r--r-- | usr.sbin/tcpdump/print-sl.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/usr.sbin/tcpdump/print-sl.c b/usr.sbin/tcpdump/print-sl.c index bdc746a9c5f..297c4eae87f 100644 --- a/usr.sbin/tcpdump/print-sl.c +++ b/usr.sbin/tcpdump/print-sl.c @@ -1,8 +1,7 @@ -/**//* $OpenBSD: print-sl.c,v 1.3 1996/06/10 07:47:47 deraadt Exp $ */ -/* $NetBSD: print-sl.c,v 1.6 1996/05/20 00:41:11 fvdl Exp $ */ +/* $OpenBSD: print-sl.c,v 1.4 1996/07/13 11:01:30 mickey Exp $ */ /* - * Copyright (c) 1989, 1990, 1991, 1993, 1994 + * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,10 +23,10 @@ #ifndef lint static char rcsid[] = - "@(#)Header: print-sl.c,v 1.28+ 94/06/10 17:01:38 mccanne Exp (LBL)"; + "@(#)Header: print-sl.c,v 1.36 96/06/23 02:11:46 leres Exp (LBL)"; #endif -#ifdef CSLIP +#ifdef HAVE_NET_SLIP_H #include <sys/param.h> #include <sys/time.h> #include <sys/timeb.h> @@ -36,7 +35,11 @@ static char rcsid[] = #include <sys/mbuf.h> #include <sys/socket.h> +#if __STDC__ +struct rtentry; +#endif #include <net/if.h> + #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> @@ -51,7 +54,6 @@ static char rcsid[] = #include <net/slip.h> #include <ctype.h> -#include <errno.h> #include <netdb.h> #include <pcap.h> #include <signal.h> @@ -59,6 +61,7 @@ static char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ static int lastlen[2][256]; static int lastconn = 255; @@ -66,6 +69,14 @@ static int lastconn = 255; static void sliplink_print(const u_char *, const struct ip *, int); static void compressed_sl_print(const u_char *, const struct ip *, int, int); +/* XXX BSD/OS 2.1 compatibility */ +#if !defined(SLIP_HDRLEN) && defined(SLC_BPFHDR) +#define SLIP_HDRLEN SLC_BPFHDR +#define SLX_DIR 0 +#define SLX_CHDR (SLC_BPFHDRLEN - 1) +#define CHDR_LEN (SLC_BPFHDR - SLC_BPFHDRLEN) +#endif + void sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { @@ -115,11 +126,11 @@ sliplink_print(register const u_char *p, register const struct ip *ip, if (nflag) { /* XXX just dump the header */ - int i; + register int i; - for (i = 0; i < 15; ++i) - printf("%02x.", p[SLX_CHDR + i]); - printf("%02x: ", p[SLX_CHDR + 15]); + for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i) + printf("%02x.", p[i]); + printf("%02x: ", p[SLX_CHDR + CHDR_LEN - 1]); return; } switch (p[SLX_CHDR] & 0xf0) { @@ -130,11 +141,11 @@ sliplink_print(register const u_char *p, register const struct ip *ip, case TYPE_UNCOMPRESSED_TCP: /* - * The connection id is stode in the IP protcol field. + * The connection id is stored in the IP protcol field. * Get it from the link layer since sl_uncompress_tcp() * has restored the IP header copy to IPPROTO_TCP. */ - lastconn = ip->ip_p; + lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p; hlen = ip->ip_hl; hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off; lastlen[dir][lastconn] = length - (hlen << 2); @@ -157,7 +168,7 @@ print_sl_change(const char *str, register const u_char *cp) register u_int i; if ((i = *cp++) == 0) { - i = (cp[0] << 8) | cp[1]; + i = EXTRACT_SHORT(cp); cp += 2; } printf(" %s%d", str, i); @@ -170,7 +181,7 @@ print_sl_winchange(register const u_char *cp) register short i; if ((i = *cp++) == 0) { - i = (cp[0] << 8) | cp[1]; + i = EXTRACT_SHORT(cp); cp += 2; } if (i >= 0) @@ -227,7 +238,7 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip, * 'length - hlen' is the amount of data in the packet. */ hlen = ip->ip_hl; - hlen += ((struct tcphdr *)&((int32 *)ip)[hlen])->th_off; + hlen += ((struct tcphdr *)&((int32_t *)ip)[hlen])->th_off; lastlen[dir][lastconn] = length - (hlen << 2); printf(" %d (%d)", lastlen[dir][lastconn], cp - chdr); } |