print-sl.c (98527) | print-sl.c (127675) |
---|---|
1/* 2 * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 4 unchanged lines hidden (view full) --- 13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 * the University nor the names of its contributors may be used to endorse 15 * or promote products derived from this software without specific prior 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * | 1/* 2 * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 4 unchanged lines hidden (view full) --- 13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 * the University nor the names of its contributors may be used to endorse 15 * or promote products derived from this software without specific prior 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * |
21 * $FreeBSD: head/contrib/tcpdump/print-sl.c 98527 2002-06-21 00:49:02Z fenner $ | 21 * $FreeBSD: head/contrib/tcpdump/print-sl.c 127675 2004-03-31 14:57:24Z bms $ |
22 */ 23 24#ifndef lint | 22 */ 23 24#ifndef lint |
25static const char rcsid[] = 26 "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.57 2001/07/05 18:54:17 guy Exp $ (LBL)"; | 25static const char rcsid[] _U_ = 26 "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.62.2.2 2003/11/16 08:51:44 guy Exp $ (LBL)"; |
27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 | 27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 |
33#include <sys/param.h> 34#include <sys/time.h> | 33#include <tcpdump-stdinc.h> |
35 | 34 |
36#include <netinet/in.h> 37 38#include <ctype.h> 39#include <netdb.h> | |
40#include <pcap.h> 41#include <stdio.h> 42 43#include "interface.h" 44#include "addrtoname.h" 45#include "extract.h" /* must come after interface.h */ 46 47#include "ip.h" 48#include "tcp.h" 49#include "slip.h" 50#include "slcompress.h" 51 52static u_int lastlen[2][256]; 53static u_int lastconn = 255; 54 55static void sliplink_print(const u_char *, const struct ip *, u_int); 56static void compressed_sl_print(const u_char *, const struct ip *, u_int, int); 57 | 35#include <pcap.h> 36#include <stdio.h> 37 38#include "interface.h" 39#include "addrtoname.h" 40#include "extract.h" /* must come after interface.h */ 41 42#include "ip.h" 43#include "tcp.h" 44#include "slip.h" 45#include "slcompress.h" 46 47static u_int lastlen[2][256]; 48static u_int lastconn = 255; 49 50static void sliplink_print(const u_char *, const struct ip *, u_int); 51static void compressed_sl_print(const u_char *, const struct ip *, u_int, int); 52 |
58void 59sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) | 53u_int 54sl_if_print(const struct pcap_pkthdr *h, const u_char *p) |
60{ 61 register u_int caplen = h->caplen; 62 register u_int length = h->len; 63 register const struct ip *ip; 64 | 55{ 56 register u_int caplen = h->caplen; 57 register u_int length = h->len; 58 register const struct ip *ip; 59 |
65 ++infodelay; 66 ts_print(&h->ts); 67 | |
68 if (caplen < SLIP_HDRLEN) { 69 printf("[|slip]"); | 60 if (caplen < SLIP_HDRLEN) { 61 printf("[|slip]"); |
70 goto out; | 62 return (caplen); |
71 } | 63 } |
72 /* 73 * Some printers want to get back at the link level addresses, 74 * and/or check that they're not walking off the end of the packet. 75 * Rather than pass them all the way down, we set these globals. 76 */ 77 packetp = p; 78 snapend = p + caplen; | |
79 80 length -= SLIP_HDRLEN; 81 82 ip = (struct ip *)(p + SLIP_HDRLEN); 83 84 if (eflag) 85 sliplink_print(p, ip, length); 86 --- 5 unchanged lines hidden (view full) --- 92 case 6: 93 ip6_print((u_char *)ip, length); 94 break; 95#endif 96 default: 97 printf ("ip v%d", IP_V(ip)); 98 } 99 | 64 65 length -= SLIP_HDRLEN; 66 67 ip = (struct ip *)(p + SLIP_HDRLEN); 68 69 if (eflag) 70 sliplink_print(p, ip, length); 71 --- 5 unchanged lines hidden (view full) --- 77 case 6: 78 ip6_print((u_char *)ip, length); 79 break; 80#endif 81 default: 82 printf ("ip v%d", IP_V(ip)); 83 } 84 |
100 if (xflag) 101 default_print((u_char *)ip, caplen - SLIP_HDRLEN); 102 out: 103 putchar('\n'); 104 --infodelay; 105 if (infoprint) 106 info(0); | 85 return (SLIP_HDRLEN); |
107} 108 | 86} 87 |
109 110void 111sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) | 88u_int 89sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p) |
112{ 113 register u_int caplen = h->caplen; 114 register u_int length = h->len; 115 register const struct ip *ip; 116 | 90{ 91 register u_int caplen = h->caplen; 92 register u_int length = h->len; 93 register const struct ip *ip; 94 |
117 ++infodelay; 118 ts_print(&h->ts); 119 | |
120 if (caplen < SLIP_HDRLEN) { 121 printf("[|slip]"); | 95 if (caplen < SLIP_HDRLEN) { 96 printf("[|slip]"); |
122 goto out; | 97 return (caplen); |
123 } | 98 } |
124 /* 125 * Some printers want to get back at the link level addresses, 126 * and/or check that they're not walking off the end of the packet. 127 * Rather than pass them all the way down, we set these globals. 128 */ 129 packetp = p; 130 snapend = p + caplen; | |
131 132 length -= SLIP_HDRLEN; 133 134 ip = (struct ip *)(p + SLIP_HDRLEN); 135 136#ifdef notdef 137 if (eflag) 138 sliplink_print(p, ip, length); 139#endif 140 141 ip_print((u_char *)ip, length); 142 | 99 100 length -= SLIP_HDRLEN; 101 102 ip = (struct ip *)(p + SLIP_HDRLEN); 103 104#ifdef notdef 105 if (eflag) 106 sliplink_print(p, ip, length); 107#endif 108 109 ip_print((u_char *)ip, length); 110 |
143 if (xflag) 144 default_print((u_char *)ip, caplen - SLIP_HDRLEN); 145 out: 146 putchar('\n'); 147 --infodelay; 148 if (infoprint) 149 info(0); | 111 return (SLIP_HDRLEN); |
150} 151 152static void 153sliplink_print(register const u_char *p, register const struct ip *ip, 154 register u_int length) 155{ 156 int dir; 157 u_int hlen; --- 122 unchanged lines hidden --- | 112} 113 114static void 115sliplink_print(register const u_char *p, register const struct ip *ip, 116 register u_int length) 117{ 118 int dir; 119 u_int hlen; --- 122 unchanged lines hidden --- |