X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/536f5125835b031330f472aebed8241a1718b018..refs/heads/tcpdump-3.9:/print-sl.c diff --git a/print-sl.c b/print-sl.c index 08dd0d69..f00d3943 100644 --- a/print-sl.c +++ b/print-sl.c @@ -20,32 +20,16 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.50 2000-09-23 08:54:40 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005-04-06 21:32:42 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef HAVE_NET_SLIP_H -#include -#include -#include -#include -#include -#include -#include +#include -struct mbuf; -struct rtentry; -#include - -#include -#include - -#include -#include #include #include @@ -55,9 +39,8 @@ struct rtentry; #include "ip.h" #include "tcp.h" - -#include -#include +#include "slip.h" +#include "slcompress.h" static u_int lastlen[2][256]; static u_int lastconn = 255; @@ -65,36 +48,17 @@ static u_int lastconn = 255; static void sliplink_print(const u_char *, const struct ip *, u_int); static void compressed_sl_print(const u_char *, const struct ip *, u_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 - -/* XXX needs more hacking to work right */ - -void -sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +sl_if_print(const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; - ts_print(&h->ts); - if (caplen < SLIP_HDRLEN) { printf("[|slip]"); - goto out; + return (caplen); } - /* - * Some printers want to get back at the link level addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; length -= SLIP_HDRLEN; @@ -103,9 +67,9 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) if (eflag) sliplink_print(p, ip, length); - switch (ip->ip_v) { + switch (IP_V(ip)) { case 4: - ip_print((u_char *)ip, length); + ip_print(gndo, (u_char *)ip, length); break; #ifdef INET6 case 6: @@ -113,36 +77,23 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) break; #endif default: - printf ("ip v%d", ip->ip_v); + printf ("ip v%d", IP_V(ip)); } - if (xflag) - default_print((u_char *)ip, caplen - SLIP_HDRLEN); - out: - putchar('\n'); + return (SLIP_HDRLEN); } - -void -sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; - ts_print(&h->ts); - if (caplen < SLIP_HDRLEN) { printf("[|slip]"); - goto out; + return (caplen); } - /* - * Some printers want to get back at the link level addresses, - * and/or check that they're not walking off the end of the packet. - * Rather than pass them all the way down, we set these globals. - */ - packetp = p; - snapend = p + caplen; length -= SLIP_HDRLEN; @@ -153,12 +104,9 @@ sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) sliplink_print(p, ip, length); #endif - ip_print((u_char *)ip, length); + ip_print(gndo, (u_char *)ip, length); - if (xflag) - default_print((u_char *)ip, caplen - SLIP_HDRLEN); - out: - putchar('\n'); + return (SLIP_HDRLEN); } static void @@ -194,8 +142,8 @@ sliplink_print(register const u_char *p, register const struct ip *ip, * has restored the IP header copy to IPPROTO_TCP. */ lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p; - hlen = ip->ip_hl; - hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off; + hlen = IP_HL(ip); + hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); printf("utcp %d: ", lastconn); break; @@ -284,33 +232,8 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip, * 'cp - chdr' is the length of the compressed header. * 'length - hlen' is the amount of data in the packet. */ - hlen = ip->ip_hl; - hlen += ((struct tcphdr *)&((int32_t *)ip)[hlen])->th_off; + hlen = IP_HL(ip); + hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); - printf(" %d (%d)", lastlen[dir][lastconn], cp - chdr); + printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)); } -#else -#include -#include - -#include -#include - -#include "interface.h" - -void -sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) -{ - - error("not configured for slip"); - /* NOTREACHED */ -} - -void -sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) -{ - - error("not configured for slip"); - /* NOTREACHED */ -} -#endif