]>
The Tcpdump Group git mirrors - tcpdump/blob - interface.h
1 /* $NetBSD: interface.h,v 1.2 1995/03/06 19:10:18 mycroft Exp $ */
4 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
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
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.
23 * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.107 1999-10-17 21:56:53 mcr Exp $ (LBL)
27 #define inline __inline
29 #define __dead volatile
36 #include "os.h" /* operating system stuff */
37 #include "md.h" /* machine dependent stuff */
40 #define SIGRET void /* default */
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 */
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 */
67 #define min(a,b) ((a)>(b)?(b):(a))
70 #define max(a,b) ((b)>(a)?(b):(a))
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).
79 #define DEFAULT_SNAPLEN 68
82 #define BIG_ENDIAN 4321
83 #define LITTLE_ENDIAN 1234
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)
90 #define ESRC(ep) ((ep)->ether_shost)
91 #define EDST(ep) ((ep)->ether_dhost)
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)
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)
104 #define SHA(ap) ((ap)->arp_sha)
105 #define THA(ap) ((ap)->arp_tha)
107 #define SPA(ap) ((ap)->arp_spa)
108 #define TPA(ap) ((ap)->arp_tpa)
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)
119 extern char *program_name
; /* used to generate self-identifying messages */
122 /* global pointers to beginning and end of current packet (during printing) */
123 extern const u_char
*packetp
;
124 extern const u_char
*snapend
;
126 extern int fddipad
; /* alignment offset for FDDI headers, in bytes */
128 /* Eliminate some bogus warnings. */
131 typedef void (*printfunc
)(u_char
*, struct timeval
*, int, int);
133 extern void ts_print(const struct timeval
*);
134 extern int clock_sigfigs(void);
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 *);
143 extern int initdevice(char *, int, int *);
144 extern void wrapup(int);
146 extern __dead
void error(char *, ...);
147 extern void warning(char *, ...);
149 extern char *read_infile(char *);
150 extern char *copy_argv(char **);
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
);
159 /* The printer routines. */
163 extern void ether_if_print(u_char
*, const struct pcap_pkthdr
*,
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
*);
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);
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
);
200 #define min(a,b) ((a)>(b)?(b):(a))
201 #define max(a,b) ((b)>(a)?(b):(a))
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).
209 #define DEFAULT_SNAPLEN 512
212 #define BIG_ENDIAN 4321
213 #define LITTLE_ENDIAN 1234