]> The Tcpdump Group git mirrors - tcpdump/blob - interface.h
ASCII patches for tcpdump.
[tcpdump] / interface.h
1 /* $NetBSD: interface.h,v 1.2 1995/03/06 19:10:18 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 *
23 * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.107 1999-10-17 21:56:53 mcr Exp $ (LBL)
24 */
25
26 #ifdef __GNUC__
27 #define inline __inline
28 #ifndef __dead
29 #define __dead volatile
30 #endif
31 #else
32 #define inline
33 #define __dead
34 #endif
35
36 #include "os.h" /* operating system stuff */
37 #include "md.h" /* machine dependent stuff */
38
39 #ifndef SIGRET
40 #define SIGRET void /* default */
41 #endif
42
43 struct token {
44 int v; /* value */
45 char *s; /* string */
46 };
47
48 extern int dflag; /* print filter code */
49 extern int eflag; /* print ethernet header */
50 extern int nflag; /* leave addresses as numbers */
51 extern int Nflag; /* remove domains from printed host names */
52 extern int qflag; /* quick (shorter) output */
53 extern int Sflag; /* print raw TCP sequence numbers */
54 extern int tflag; /* print packet arrival time */
55 extern int vflag; /* verbose */
56 extern int xflag; /* print packet in hex */
57
58 extern int packettype; /* as specified by -T */
59 #define PT_VAT 1 /* Visual Audio Tool */
60 #define PT_WB 2 /* distributed White Board */
61 #define PT_RPC 3 /* Remote Procedure Call */
62 #define PT_RTP 4 /* Real-Time Applications protocol */
63 #define PT_RTCP 5 /* Real-Time Applications control protocol */
64 #define PT_SNMP 6 /* Simple Network Management Protocol */
65
66 #ifndef min
67 #define min(a,b) ((a)>(b)?(b):(a))
68 #endif
69 #ifndef max
70 #define max(a,b) ((b)>(a)?(b):(a))
71 #endif
72
73 /*
74 * The default snapshot length. This value allows most printers to print
75 * useful information while keeping the amount of unwanted data down.
76 * In particular, it allows for an ethernet header, tcp/ip header, and
77 * 14 bytes of data (assuming no ip options).
78 */
79 #define DEFAULT_SNAPLEN 68
80
81 #ifndef BIG_ENDIAN
82 #define BIG_ENDIAN 4321
83 #define LITTLE_ENDIAN 1234
84 #endif
85
86 #ifdef ETHER_HEADER_HAS_EA
87 #define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
88 #define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)
89 #else
90 #define ESRC(ep) ((ep)->ether_shost)
91 #define EDST(ep) ((ep)->ether_dhost)
92 #endif
93
94 #ifdef ETHER_ARP_HAS_X
95 #define SHA(ap) ((ap)->arp_xsha)
96 #define THA(ap) ((ap)->arp_xtha)
97 #define SPA(ap) ((ap)->arp_xspa)
98 #define TPA(ap) ((ap)->arp_xtpa)
99 #else
100 #ifdef ETHER_ARP_HAS_EA
101 #define SHA(ap) ((ap)->arp_sha.ether_addr_octet)
102 #define THA(ap) ((ap)->arp_tha.ether_addr_octet)
103 #else
104 #define SHA(ap) ((ap)->arp_sha)
105 #define THA(ap) ((ap)->arp_tha)
106 #endif
107 #define SPA(ap) ((ap)->arp_spa)
108 #define TPA(ap) ((ap)->arp_tpa)
109 #endif
110
111 #ifndef NTOHL
112 #define NTOHL(x) (x) = ntohl(x)
113 #define NTOHS(x) (x) = ntohs(x)
114 #define HTONL(x) (x) = htonl(x)
115 #define HTONS(x) (x) = htons(x)
116 #endif
117 #endif
118
119 extern char *program_name; /* used to generate self-identifying messages */
120
121 extern int snaplen;
122 /* global pointers to beginning and end of current packet (during printing) */
123 extern const u_char *packetp;
124 extern const u_char *snapend;
125
126 extern int fddipad; /* alignment offset for FDDI headers, in bytes */
127
128 /* Eliminate some bogus warnings. */
129 struct timeval;
130
131 typedef void (*printfunc)(u_char *, struct timeval *, int, int);
132
133 extern void ts_print(const struct timeval *);
134 extern int clock_sigfigs(void);
135 int gmt2local(void);
136
137 extern int fn_print(const u_char *, const u_char *);
138 extern int fn_printn(const u_char *, u_int, const u_char *);
139 extern const char *tok2str(const struct token *, const char *, int);
140 extern char *dnaddr_string(u_short);
141 extern char *savestr(const char *);
142
143 extern int initdevice(char *, int, int *);
144 extern void wrapup(int);
145
146 extern __dead void error(char *, ...);
147 extern void warning(char *, ...);
148
149 extern char *read_infile(char *);
150 extern char *copy_argv(char **);
151
152 extern void usage(void);
153 extern char *isonsap_string(const u_char *);
154 extern char *llcsap_string(u_char);
155 extern char *protoid_string(const u_char *);
156 extern char *dnname_string(u_short);
157 extern char *dnnum_string(u_short);
158
159 /* The printer routines. */
160
161 struct pcap_pkthdr;
162
163 extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
164 const u_char *);
165 extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char*);
166 extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char*);
167 extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
168 extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
169
170 extern void arp_print(const u_char *, int, int);
171 extern void ip_print(const u_char *, int);
172 extern void tcp_print(const u_char *, int, const u_char *);
173 extern void udp_print(const u_char *, int, const u_char *);
174 extern void icmp_print(const u_char *, const u_char *);
175 extern void default_print(const u_char *, int);
176 extern void default_print_unaligned(const u_char *, int);
177
178 extern void aarp_print(const u_char *, int);
179 extern void atalk_print(const u_char *, int);
180 extern void bootp_print(const u_char *, int, u_short, u_short);
181 extern void decnet_print(const u_char *, int, int);
182 extern void egp_print(const u_char *, int, const u_char *);
183 extern int ether_encap_print(u_short, const u_char *, int, int);
184 extern void ipx_print(const u_char *, int length);
185 extern void isoclns_print(const u_char *, int, int,
186 const u_char *, const u_char *);
187 extern int llc_print(const u_char *, int, int, const u_char *, const u_char *);
188 extern void nfsreply_print(const u_char *, int, const u_char *);
189 extern void nfsreq_print(const u_char *, int, const u_char *);
190 extern void ns_print(const u_char *, int);
191 extern void ntp_print(const u_char *, int);
192 extern void ospf_print(const u_char *, int, const u_char *);
193 extern void rip_print(const u_char *, int);
194 extern void snmp_print(const u_char *, int);
195 extern void sunrpcrequest_print(const u_char *, int, const u_char *);
196 extern void tftp_print(const u_char *, int);
197 extern void wb_print(const void *, int);
198 extern void print_ipproto(u_int proto, const struct ip *ip, const u_char *cp, int len);
199
200 #define min(a,b) ((a)>(b)?(b):(a))
201 #define max(a,b) ((b)>(a)?(b):(a))
202
203 /*
204 * The default snapshot length. This value allows most printers to print
205 * useful information while keeping the amount of unwanted data down.
206 * In particular, it allows for an ethernet header, tcp/ip header, and
207 * 14 bytes of data (assuming no ip options).
208 */
209 #define DEFAULT_SNAPLEN 512
210
211 #ifndef BIG_ENDIAN
212 #define BIG_ENDIAN 4321
213 #define LITTLE_ENDIAN 1234
214 #endif