xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h (revision 741913f067e7b214ced38b697919face8d3a52dc)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2161961e0fSrobinson 
227c478bd9Sstevel@tonic-gate /*
23b78ff649Smeem  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*741913f0SGordon Ross  *
26*741913f0SGordon Ross  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef	_SNOOP_H
307c478bd9Sstevel@tonic-gate #define	_SNOOP_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <rpc/types.h>
337c478bd9Sstevel@tonic-gate #include <sys/pfmod.h>
347c478bd9Sstevel@tonic-gate #include <sys/time.h>
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <sys/socket.h>
3745916cd2Sjpk #include <sys/bufmod.h>
387c478bd9Sstevel@tonic-gate #include <net/if.h>
397c478bd9Sstevel@tonic-gate #include <netinet/in.h>
407c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h>
417c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h>
427c478bd9Sstevel@tonic-gate #include <netinet/ip.h>
437c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
447c478bd9Sstevel@tonic-gate #include <netinet/ip_icmp.h>
457c478bd9Sstevel@tonic-gate #include <netinet/icmp6.h>
467c478bd9Sstevel@tonic-gate #include <net/pppoe.h>
47c7e4935fSss #include <libdlpi.h>
48*741913f0SGordon Ross #include <note.h>
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #ifdef __cplusplus
517c478bd9Sstevel@tonic-gate extern "C" {
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Flags to control packet info display
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate #define	F_NOW		0x00000001	/* display in realtime */
587c478bd9Sstevel@tonic-gate #define	F_SUM		0x00000002	/* display summary line */
597c478bd9Sstevel@tonic-gate #define	F_ALLSUM	0x00000004	/* display all summary lines */
607c478bd9Sstevel@tonic-gate #define	F_DTAIL		0x00000008	/* display detail lines */
617c478bd9Sstevel@tonic-gate #define	F_TIME		0x00000010	/* display time */
627c478bd9Sstevel@tonic-gate #define	F_ATIME		0x00000020	/* display absolute time */
637c478bd9Sstevel@tonic-gate #define	F_RTIME		0x00000040	/* display relative time */
647c478bd9Sstevel@tonic-gate #define	F_DROPS		0x00000080	/* display drops */
657c478bd9Sstevel@tonic-gate #define	F_LEN		0x00000100	/* display pkt length */
667c478bd9Sstevel@tonic-gate #define	F_NUM		0x00000200	/* display pkt number */
677c478bd9Sstevel@tonic-gate #define	F_WHO		0x00000400	/* display src/dst */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	MAXLINE		(1088)		/* max len of detail line */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * The RPC XID cache structure.
737c478bd9Sstevel@tonic-gate  * When analyzing RPC protocols we
747c478bd9Sstevel@tonic-gate  * have to cache the xid of the RPC
757c478bd9Sstevel@tonic-gate  * request together with the program
767c478bd9Sstevel@tonic-gate  * number, proc, version etc since this
777c478bd9Sstevel@tonic-gate  * information is missing in the reply
787c478bd9Sstevel@tonic-gate  * packet.  Using the xid in the reply
797c478bd9Sstevel@tonic-gate  * we can lookup this previously stashed
807c478bd9Sstevel@tonic-gate  * information in the cache.
817c478bd9Sstevel@tonic-gate  *
827c478bd9Sstevel@tonic-gate  * For RPCSEC_GSS flavor, some special processing is
837c478bd9Sstevel@tonic-gate  * needed for the argument interpretation based on its
847c478bd9Sstevel@tonic-gate  * control procedure and service type.  This information
857c478bd9Sstevel@tonic-gate  * is stored in the cache table during interpretation of
867c478bd9Sstevel@tonic-gate  * the rpc header and will be referenced later when the rpc
877c478bd9Sstevel@tonic-gate  * argument is interpreted.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	XID_CACHE_SIZE 256
907c478bd9Sstevel@tonic-gate struct cache_struct {
917c478bd9Sstevel@tonic-gate 	int xid_num;	/* RPC transaction id */
927c478bd9Sstevel@tonic-gate 	int xid_frame;	/* Packet number */
937c478bd9Sstevel@tonic-gate 	int xid_prog;	/* RPC program number */
947c478bd9Sstevel@tonic-gate 	int xid_vers;	/* RPC version number */
957c478bd9Sstevel@tonic-gate 	int xid_proc;	/* RPC procedure number */
967c478bd9Sstevel@tonic-gate 	unsigned int xid_gss_proc; /* control procedure */
977c478bd9Sstevel@tonic-gate 	int xid_gss_service; /* none, integ, priv */
987c478bd9Sstevel@tonic-gate } xid_cache[XID_CACHE_SIZE];
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * The following macros advance the pointer passed to them.  They
1037c478bd9Sstevel@tonic-gate  * assume they are given a char *.
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate #define	GETINT8(v, ptr) { \
1067c478bd9Sstevel@tonic-gate 	(v) = (*(ptr)++); \
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #define	GETINT16(v, ptr) { \
1107c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1117c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #define	GETINT32(v, ptr) { \
1157c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1167c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1177c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1187c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1197c478bd9Sstevel@tonic-gate }
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Used to print nested protocol layers.  For example, an ip datagram included
1237c478bd9Sstevel@tonic-gate  * in an icmp error, or a PPP packet included in an LCP protocol reject..
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate extern char *prot_nest_prefix;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate extern char *get_sum_line(void);
1287c478bd9Sstevel@tonic-gate extern char *get_detail_line(int, int);
1292b24ab6bSSebastien Roy extern int want_packet(uchar_t *, int, int);
130605445d5Sdg extern void set_vlan_id(int);
1317c478bd9Sstevel@tonic-gate extern struct timeval prev_time;
13245916cd2Sjpk extern void process_pkt(struct sb_hdr *, char *, int, int);
1337c478bd9Sstevel@tonic-gate extern char *getflag(int, int, char *, char *);
1347c478bd9Sstevel@tonic-gate extern void show_header(char *, char *, int);
1352b24ab6bSSebastien Roy extern void show_count(void);
1367c478bd9Sstevel@tonic-gate extern void xdr_init(char *, int);
1377c478bd9Sstevel@tonic-gate extern char *get_line(int, int);
1387c478bd9Sstevel@tonic-gate extern int get_line_remain(void);
1397c478bd9Sstevel@tonic-gate extern char getxdr_char(void);
1407c478bd9Sstevel@tonic-gate extern char showxdr_char(char *);
1417c478bd9Sstevel@tonic-gate extern uchar_t getxdr_u_char(void);
1427c478bd9Sstevel@tonic-gate extern uchar_t showxdr_u_char(char *);
1437c478bd9Sstevel@tonic-gate extern short getxdr_short(void);
1447c478bd9Sstevel@tonic-gate extern short showxdr_short(char *);
1457c478bd9Sstevel@tonic-gate extern ushort_t getxdr_u_short(void);
1467c478bd9Sstevel@tonic-gate extern ushort_t showxdr_u_short(char *);
1477c478bd9Sstevel@tonic-gate extern long getxdr_long(void);
1487c478bd9Sstevel@tonic-gate extern long showxdr_long(char *);
1497c478bd9Sstevel@tonic-gate extern ulong_t getxdr_u_long(void);
1507c478bd9Sstevel@tonic-gate extern ulong_t showxdr_u_long(char *);
1517c478bd9Sstevel@tonic-gate extern longlong_t getxdr_longlong(void);
1527c478bd9Sstevel@tonic-gate extern longlong_t showxdr_longlong(char *);
15361961e0fSrobinson extern u_longlong_t getxdr_u_longlong(void);
15461961e0fSrobinson extern u_longlong_t showxdr_u_longlong(char *);
1557c478bd9Sstevel@tonic-gate extern char *getxdr_opaque(char *, int);
1567c478bd9Sstevel@tonic-gate extern char *getxdr_string(char *, int);
1577c478bd9Sstevel@tonic-gate extern char *showxdr_string(int, char *);
1587c478bd9Sstevel@tonic-gate extern char *getxdr_bytes(uint_t *);
1597c478bd9Sstevel@tonic-gate extern void xdr_skip(int);
1607c478bd9Sstevel@tonic-gate extern int getxdr_pos(void);
1617c478bd9Sstevel@tonic-gate extern void setxdr_pos(int);
1627c478bd9Sstevel@tonic-gate extern char *getxdr_context(char *, int);
1637c478bd9Sstevel@tonic-gate extern char *showxdr_context(char *);
1647c478bd9Sstevel@tonic-gate extern enum_t getxdr_enum(void);
1657c478bd9Sstevel@tonic-gate extern void show_space(void);
1667c478bd9Sstevel@tonic-gate extern void show_trailer(void);
1677c478bd9Sstevel@tonic-gate extern char *getxdr_date(void);
1687c478bd9Sstevel@tonic-gate extern char *showxdr_date(char *);
1697c478bd9Sstevel@tonic-gate extern char *getxdr_date_ns(void);
1707c478bd9Sstevel@tonic-gate char *format_time(int64_t sec, uint32_t nsec);
1717c478bd9Sstevel@tonic-gate extern char *showxdr_date_ns(char *);
1727c478bd9Sstevel@tonic-gate extern char *getxdr_hex(int);
1737c478bd9Sstevel@tonic-gate extern char *showxdr_hex(int, char *);
1747c478bd9Sstevel@tonic-gate extern bool_t getxdr_bool(void);
1757c478bd9Sstevel@tonic-gate extern bool_t showxdr_bool(char *);
1767c478bd9Sstevel@tonic-gate extern char *concat_args(char **, int);
1777c478bd9Sstevel@tonic-gate extern int pf_compile(char *, int);
1787c478bd9Sstevel@tonic-gate extern void compile(char *, int);
1797c478bd9Sstevel@tonic-gate extern void load_names(char *);
18045916cd2Sjpk extern void cap_write(struct sb_hdr *, char *, int, int);
181c7e4935fSss extern void cap_open_read(const char *);
182c7e4935fSss extern void cap_open_write(const char *);
1837c478bd9Sstevel@tonic-gate extern void cap_read(int, int, int, void (*)(), int);
1847c478bd9Sstevel@tonic-gate extern void cap_close(void);
185b78ff649Smeem extern boolean_t open_datalink(dlpi_handle_t *, const char *);
186b78ff649Smeem extern void init_datalink(dlpi_handle_t, ulong_t, ulong_t, struct timeval *,
187c7e4935fSss     struct Pf_ext_packetfilt *);
188c7e4935fSss extern void net_read(dlpi_handle_t, size_t, int, void (*)(), int);
1897c478bd9Sstevel@tonic-gate extern void click(int);
1907c478bd9Sstevel@tonic-gate extern void show_pktinfo(int, int, char *, char *, struct timeval *,
1917c478bd9Sstevel@tonic-gate 		struct timeval *, int, int);
1927c478bd9Sstevel@tonic-gate extern void show_line(char *);
193*741913f0SGordon Ross /*PRINTFLIKE1*/
194*741913f0SGordon Ross extern void show_printf(char *fmt, ...)
195*741913f0SGordon Ross     __PRINTFLIKE(1);
1967c478bd9Sstevel@tonic-gate extern char *getxdr_time(void);
1977c478bd9Sstevel@tonic-gate extern char *showxdr_time(char *);
19845916cd2Sjpk extern char *addrtoname(int, const void *);
1997c478bd9Sstevel@tonic-gate extern char *show_string(const char *, int, int);
20045916cd2Sjpk extern void pr_err(const char *, ...);
201c7e4935fSss extern void pr_errdlpi(dlpi_handle_t, const char *, int);
2027c478bd9Sstevel@tonic-gate extern void check_retransmit(char *, ulong_t);
2037c478bd9Sstevel@tonic-gate extern char *nameof_prog(int);
2047c478bd9Sstevel@tonic-gate extern char *getproto(int);
2057c478bd9Sstevel@tonic-gate extern uint8_t print_ipv6_extensions(int, uint8_t **, uint8_t *, int *, int *);
2067c478bd9Sstevel@tonic-gate extern void protoprint(int, int, ulong_t, int, int, int, char *, int);
2077c478bd9Sstevel@tonic-gate extern char *getportname(int, in_port_t);
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate extern void interpret_arp(int, struct arphdr *, int);
2107c478bd9Sstevel@tonic-gate extern void interpret_bparam(int, int, int, int, int, char *, int);
2114b22b933Srs extern void interpret_dns(int, int, const uchar_t *, int, int);
2127c478bd9Sstevel@tonic-gate extern void interpret_mount(int, int, int, int, int, char *, int);
2137c478bd9Sstevel@tonic-gate extern void interpret_nfs(int, int, int, int, int, char *, int);
2147c478bd9Sstevel@tonic-gate extern void interpret_nfs3(int, int, int, int, int, char *, int);
2157c478bd9Sstevel@tonic-gate extern void interpret_nfs4(int, int, int, int, int, char *, int);
2167c478bd9Sstevel@tonic-gate extern void interpret_nfs4_cb(int, int, int, int, int, char *, int);
2177c478bd9Sstevel@tonic-gate extern void interpret_nfs_acl(int, int, int, int, int, char *, int);
2187c478bd9Sstevel@tonic-gate extern void interpret_nis(int, int, int, int, int, char *, int);
2197c478bd9Sstevel@tonic-gate extern void interpret_nisbind(int, int, int, int, int, char *, int);
2207c478bd9Sstevel@tonic-gate extern void interpret_nlm(int, int, int, int, int, char *, int);
2217c478bd9Sstevel@tonic-gate extern void interpret_pmap(int, int, int, int, int, char *, int);
2227c478bd9Sstevel@tonic-gate extern int interpret_reserved(int, int, in_port_t, in_port_t, char *, int);
2237c478bd9Sstevel@tonic-gate extern void interpret_rquota(int, int, int, int, int, char *, int);
2247c478bd9Sstevel@tonic-gate extern void interpret_rstat(int, int, int, int, int, char *, int);
2257c478bd9Sstevel@tonic-gate extern void interpret_solarnet_fw(int, int, int, int, int, char *, int);
2267c478bd9Sstevel@tonic-gate extern void interpret_ldap(int, char *, int, int, int);
2277c478bd9Sstevel@tonic-gate extern void interpret_icmp(int, struct icmp *, int, int);
2287c478bd9Sstevel@tonic-gate extern void interpret_icmpv6(int, icmp6_t *, int, int);
22945916cd2Sjpk extern int interpret_ip(int, const struct ip *, int);
23045916cd2Sjpk extern int interpret_ipv6(int, const ip6_t *, int);
2317c478bd9Sstevel@tonic-gate extern int interpret_ppp(int, uchar_t *, int);
2327c478bd9Sstevel@tonic-gate extern int interpret_pppoe(int, poep_t *, int);
23345916cd2Sjpk struct tcphdr;
23445916cd2Sjpk extern int interpret_tcp(int, struct tcphdr *, int, int);
23545916cd2Sjpk struct udphdr;
23645916cd2Sjpk extern int interpret_udp(int, struct udphdr *, int, int);
23745916cd2Sjpk extern int interpret_esp(int, uint8_t *, int, int);
23845916cd2Sjpk extern int interpret_ah(int, uint8_t *, int, int);
23945916cd2Sjpk struct sctp_hdr;
24045916cd2Sjpk extern void interpret_sctp(int, struct sctp_hdr *, int, int);
24145916cd2Sjpk extern void interpret_mip_cntrlmsg(int, uchar_t *, int);
24245916cd2Sjpk struct dhcp;
24345916cd2Sjpk extern int interpret_dhcp(int, struct dhcp *, int);
244d04ccbb3Scarlsonj extern int interpret_dhcpv6(int, const uint8_t *, int);
24545916cd2Sjpk struct tftphdr;
24645916cd2Sjpk extern int interpret_tftp(int, struct tftphdr *, int);
24745916cd2Sjpk extern int interpret_http(int, char *, int);
24845916cd2Sjpk struct ntpdata;
24945916cd2Sjpk extern int interpret_ntp(int, struct ntpdata *, int);
25045916cd2Sjpk extern void interpret_netbios_ns(int, uchar_t *, int);
25145916cd2Sjpk extern void interpret_netbios_datagram(int, uchar_t *, int);
25245916cd2Sjpk extern void interpret_netbios_ses(int, uchar_t *, int);
25345916cd2Sjpk extern void interpret_slp(int, char *, int);
25445916cd2Sjpk struct rip;
25545916cd2Sjpk extern int interpret_rip(int, struct rip *, int);
25645916cd2Sjpk struct rip6;
25745916cd2Sjpk extern int interpret_rip6(int, struct rip6 *, int);
25845916cd2Sjpk extern int interpret_socks_call(int, char *, int);
25945916cd2Sjpk extern int interpret_socks_reply(int, char *, int);
2604eaa4710SRishi Srivatsavai extern int interpret_trill(int, struct ether_header **, char *, int *);
2614eaa4710SRishi Srivatsavai extern int interpret_isis(int, char *, int, boolean_t);
2624eaa4710SRishi Srivatsavai extern int interpret_bpdu(int, char *, int);
2637c478bd9Sstevel@tonic-gate extern void init_ldap(void);
2647c478bd9Sstevel@tonic-gate extern boolean_t arp_for_ether(char *, struct ether_addr *);
2657c478bd9Sstevel@tonic-gate extern char *ether_ouiname(uint32_t);
26645916cd2Sjpk extern char *tohex(char *p, int len);
2677c478bd9Sstevel@tonic-gate extern char *printether(struct ether_addr *);
2687c478bd9Sstevel@tonic-gate extern char *print_ethertype(int);
269d04ccbb3Scarlsonj extern const char *arp_htype(int);
2702b24ab6bSSebastien Roy extern int valid_rpc(char *, int);
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * Describes characteristics of the Media Access Layer.
2747c478bd9Sstevel@tonic-gate  * The mac_type is one of the supported DLPI media
2757c478bd9Sstevel@tonic-gate  * types (see <sys/dlpi.h>).
2767c478bd9Sstevel@tonic-gate  * The mtu_size is the size of the largest frame.
277605445d5Sdg  * network_type_offset is where the network type
278605445d5Sdg  * is located in the link layer header.
2797c478bd9Sstevel@tonic-gate  * The header length is returned by a function to
2807c478bd9Sstevel@tonic-gate  * allow for variable header size - for ethernet it's
2817c478bd9Sstevel@tonic-gate  * just a constant 14 octets.
2827c478bd9Sstevel@tonic-gate  * The interpreter is the function that "knows" how
2837c478bd9Sstevel@tonic-gate  * to interpret the frame.
284605445d5Sdg  * try_kernel_filter tells snoop to first try a kernel
285605445d5Sdg  * filter (because the header size is fixed, or if it could
286605445d5Sdg  * be of variable size where the variable size is easy for a kernel
287605445d5Sdg  * filter to handle, for example, Ethernet and VLAN tags)
288605445d5Sdg  * and only use a user space filter if the filter expression
289605445d5Sdg  * cannot be expressed in kernel space.
2907c478bd9Sstevel@tonic-gate  */
2912b24ab6bSSebastien Roy typedef uint_t (interpreter_fn_t)(int, char *, int, int);
2922b24ab6bSSebastien Roy typedef uint_t (headerlen_fn_t)(char *, size_t);
2937c478bd9Sstevel@tonic-gate typedef struct interface {
294b127ac41SPhilip Kirk 	uint_t		mac_type;
295b127ac41SPhilip Kirk 	uint_t		mtu_size;
296b127ac41SPhilip Kirk 	uint_t  	network_type_offset;
297b127ac41SPhilip Kirk 	size_t		network_type_len;
298b127ac41SPhilip Kirk 	uint_t		network_type_ip;
299b127ac41SPhilip Kirk 	uint_t		network_type_ipv6;
3002b24ab6bSSebastien Roy 	headerlen_fn_t	*header_len;
3012b24ab6bSSebastien Roy 	interpreter_fn_t *interpreter;
302b127ac41SPhilip Kirk 	boolean_t	try_kernel_filter;
3037c478bd9Sstevel@tonic-gate } interface_t;
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate extern interface_t INTERFACES[], *interface;
3067c478bd9Sstevel@tonic-gate extern char *dlc_header;
30745916cd2Sjpk extern char *src_name, *dst_name;
30845916cd2Sjpk extern char *prot_prefix;
30945916cd2Sjpk extern char *prot_nest_prefix;
31045916cd2Sjpk extern char *prot_title;
31145916cd2Sjpk 
31245916cd2Sjpk /* Keep track of how many nested IP headers we have. */
31345916cd2Sjpk extern unsigned int encap_levels, total_encap_levels;
31445916cd2Sjpk 
31545916cd2Sjpk extern int quitting;
316b127ac41SPhilip Kirk extern boolean_t Iflg, Pflg, rflg;
31745916cd2Sjpk 
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  * Global error recovery routine: used to reset snoop variables after
3207c478bd9Sstevel@tonic-gate  * catastrophic failure.
3217c478bd9Sstevel@tonic-gate  */
3227c478bd9Sstevel@tonic-gate void snoop_recover(void);
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate /*
3257c478bd9Sstevel@tonic-gate  * Global alarm handler structure for managing multiple alarms within
3267c478bd9Sstevel@tonic-gate  * snoop.
3277c478bd9Sstevel@tonic-gate  */
3287c478bd9Sstevel@tonic-gate typedef struct snoop_handler {
3297c478bd9Sstevel@tonic-gate 	struct snoop_handler *s_next;		/* next alarm handler */
3307c478bd9Sstevel@tonic-gate 	time_t s_time;				/* time to fire */
3317c478bd9Sstevel@tonic-gate 	void (*s_handler)();			/* alarm handler */
3327c478bd9Sstevel@tonic-gate } snoop_handler_t;
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate #define	SNOOP_MAXRECOVER	20	/* maxium number of recoveries */
3357c478bd9Sstevel@tonic-gate #define	SNOOP_ALARM_GRAN	3	/* alarm() timeout multiplier */
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate  * Global alarm handler management routine.
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate extern int snoop_alarm(int s_sec, void (*s_handler)());
3417c478bd9Sstevel@tonic-gate 
3420990bc30Sdg /*
3430990bc30Sdg  * The next two definitions do not take into account the length
3440990bc30Sdg  * of the underlying link header.  In order to use them, you must
3450990bc30Sdg  * add link_header_len to them.  The reason it is not done here is
3460990bc30Sdg  * that later these macros are used to initialize a table.
3470990bc30Sdg  */
3480990bc30Sdg #define	IPV4_TYPE_HEADER_OFFSET 9
3490990bc30Sdg #define	IPV6_TYPE_HEADER_OFFSET 6
3500990bc30Sdg 
3517c478bd9Sstevel@tonic-gate #ifdef __cplusplus
3527c478bd9Sstevel@tonic-gate }
3537c478bd9Sstevel@tonic-gate #endif
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate #endif	/* _SNOOP_H */
356