]> git.saurik.com Git - apple/network_cmds.git/blob - tcpdump.tproj/interface.h
network_cmds-76.tar.gz
[apple/network_cmds.git] / tcpdump.tproj / interface.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License."
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
26 * The Regents of the University of California. All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that: (1) source code distributions
30 * retain the above copyright notice and this paragraph in its entirety, (2)
31 * distributions including binary code include the above copyright notice and
32 * this paragraph in its entirety in the documentation or other materials
33 * provided with the distribution, and (3) all advertising materials mentioning
34 * features or use of this software display the following acknowledgement:
35 * ``This product includes software developed by the University of California,
36 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
37 * the University nor the names of its contributors may be used to endorse
38 * or promote products derived from this software without specific prior
39 * written permission.
40 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
41 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
43 *
44 * @(#) $Header: /cvs/Darwin/Commands/NeXT/network_cmds/tcpdump.tproj/interface.h,v 1.1.1.1 1999/05/02 03:58:32 wsanchez Exp $ (LBL)
45 */
46
47 #ifndef tcpdump_interface_h
48 #define tcpdump_interface_h
49 #ifndef IPPROTO_ND
50 #define IPPROTO_ND 77
51 #endif
52
53
54 #include "gnuc.h"
55 #ifdef HAVE_OS_PROTO_H
56 #include "os-proto.h"
57 #endif
58
59 struct tok {
60 int v; /* value */
61 char *s; /* string */
62 };
63
64 extern int dflag; /* print filter code */
65 extern int eflag; /* print ethernet header */
66 extern int nflag; /* leave addresses as numbers */
67 extern int Nflag; /* remove domains from printed host names */
68 extern int qflag; /* quick (shorter) output */
69 extern int Sflag; /* print raw TCP sequence numbers */
70 extern int tflag; /* print packet arrival time */
71 extern int vflag; /* verbose */
72 extern int xflag; /* print packet in hex */
73
74 extern int packettype; /* as specified by -T */
75 #define PT_VAT 1 /* Visual Audio Tool */
76 #define PT_WB 2 /* distributed White Board */
77 #define PT_RPC 3 /* Remote Procedure Call */
78 #define PT_RTP 4 /* Real-Time Applications protocol */
79 #define PT_RTCP 5 /* Real-Time Applications control protocol */
80
81 #ifndef min
82 #define min(a,b) ((a)>(b)?(b):(a))
83 #endif
84 #ifndef max
85 #define max(a,b) ((b)>(a)?(b):(a))
86 #endif
87
88 /*
89 * The default snapshot length. This value allows most printers to print
90 * useful information while keeping the amount of unwanted data down.
91 * In particular, it allows for an ethernet header, tcp/ip header, and
92 * 14 bytes of data (assuming no ip options).
93 */
94 #define DEFAULT_SNAPLEN 68
95
96 #ifndef BIG_ENDIAN
97 #define BIG_ENDIAN 4321
98 #define LITTLE_ENDIAN 1234
99 #endif
100
101 #ifdef ETHER_HEADER_HAS_EA
102 #define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
103 #define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)
104 #else
105 #define ESRC(ep) ((ep)->ether_shost)
106 #define EDST(ep) ((ep)->ether_dhost)
107 #endif
108
109 #ifdef ETHER_ARP_HAS_X
110 #define SHA(ap) ((ap)->arp_xsha)
111 #define THA(ap) ((ap)->arp_xtha)
112 #define SPA(ap) ((ap)->arp_xspa)
113 #define TPA(ap) ((ap)->arp_xtpa)
114 #else
115 #ifdef ETHER_ARP_HAS_EA
116 #define SHA(ap) ((ap)->arp_sha.ether_addr_octet)
117 #define THA(ap) ((ap)->arp_tha.ether_addr_octet)
118 #else
119 #define SHA(ap) ((ap)->arp_sha)
120 #define THA(ap) ((ap)->arp_tha)
121 #endif
122 #define SPA(ap) ((ap)->arp_spa)
123 #define TPA(ap) ((ap)->arp_tpa)
124 #endif
125
126 #ifndef NTOHL
127 #define NTOHL(x) (x) = ntohl(x)
128 #define NTOHS(x) (x) = ntohs(x)
129 #define HTONL(x) (x) = htonl(x)
130 #define HTONS(x) (x) = htons(x)
131 #endif
132 #endif
133
134 extern char *program_name; /* used to generate self-identifying messages */
135
136 extern int32_t thiszone; /* seconds offset from gmt to local time */
137
138 extern int snaplen;
139 /* global pointers to beginning and end of current packet (during printing) */
140 extern const u_char *packetp;
141 extern const u_char *snapend;
142
143 /* True if "l" bytes of "var" were captured */
144 #define TTEST2(var, l) ((u_char *)&(var) <= snapend - (l))
145
146 /* True if "var" was captured */
147 #define TTEST(var) TTEST2(var, sizeof(var))
148
149 /* Bail if "l" bytes of "var" were not captured */
150 #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
151
152 /* Bail if "var" was not captured */
153 #define TCHECK(var) TCHECK2(var, sizeof(var))
154
155 #ifdef __STDC__
156 struct timeval;
157 #endif
158
159 extern void ts_print(const struct timeval *);
160 extern int32_t gmt2local(void);
161
162 extern int fn_print(const u_char *, const u_char *);
163 extern int fn_printn(const u_char *, u_int, const u_char *);
164 extern const char *tok2str(const struct tok *, const char *, int);
165 extern char *dnaddr_string(u_short);
166 extern char *savestr(const char *);
167
168 extern void wrapup(int);
169
170 #if __STDC__
171 extern __dead void error(const char *, ...)
172 __attribute__((volatile, format (printf, 1, 2)));
173 extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
174 #endif
175
176 extern char *read_infile(char *);
177 extern char *copy_argv(char **);
178
179 extern char *isonsap_string(const u_char *);
180 extern char *llcsap_string(u_char);
181 extern char *protoid_string(const u_char *);
182 extern char *dnname_string(u_short);
183 extern char *dnnum_string(u_short);
184
185 /* The printer routines. */
186
187 #ifdef __STDC__
188 struct pcap_pkthdr;
189 #endif
190
191 extern int ether_encap_print(u_short, const u_char *, u_int, u_int);
192 extern int llc_print(const u_char *, u_int, u_int, const u_char *,
193 const u_char *);
194 extern void aarp_print(const u_char *, u_int);
195 extern void arp_print(const u_char *, u_int, u_int);
196 extern void atalk_print(const u_char *, u_int);
197 extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
198 extern void bootp_print(const u_char *, u_int, u_short, u_short);
199 extern void decnet_print(const u_char *, u_int, u_int);
200 extern void default_print(const u_char *, u_int);
201 extern void default_print_unaligned(const u_char *, u_int);
202 extern void dvmrp_print(const u_char *, u_int);
203 extern void egp_print(const u_char *, u_int, const u_char *);
204 extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
205 const u_char *);
206 extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
207 extern void gre_print(const u_char *, u_int);
208 extern void icmp_print(const u_char *, const u_char *);
209 extern void igrp_print(const u_char *, u_int, const u_char *);
210 extern void ip_print(const u_char *, u_int);
211 extern void ipx_print(const u_char *, u_int);
212 extern void isoclns_print(const u_char *, u_int, u_int, const u_char *,
213 const u_char *);
214 extern void krb_print(const u_char *, u_int);
215 extern void nfsreply_print(const u_char *, u_int, const u_char *);
216 extern void nfsreq_print(const u_char *, u_int, const u_char *);
217 extern void ns_print(const u_char *, u_int);
218 extern void ntp_print(const u_char *, u_int);
219 extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
220 extern void ospf_print(const u_char *, u_int, const u_char *);
221 extern void pim_print(const u_char *, u_int);
222 extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
223 extern void rip_print(const u_char *, u_int);
224 extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
225 extern void snmp_print(const u_char *, u_int);
226 extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
227 extern void tcp_print(const u_char *, u_int, const u_char *);
228 extern void tftp_print(const u_char *, u_int);
229 extern void udp_print(const u_char *, u_int, const u_char *);
230 extern void wb_print(const void *, u_int);