xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h (revision 4b22b9337f359bfd063322244f5336cc7c6ffcfa)
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 /*
23d04ccbb3Scarlsonj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SNOOP_H
287c478bd9Sstevel@tonic-gate #define	_SNOOP_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS	*/
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>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #ifdef __cplusplus
507c478bd9Sstevel@tonic-gate extern "C" {
517c478bd9Sstevel@tonic-gate #endif
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * Flags to control packet info display
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate #define	F_NOW		0x00000001	/* display in realtime */
577c478bd9Sstevel@tonic-gate #define	F_SUM		0x00000002	/* display summary line */
587c478bd9Sstevel@tonic-gate #define	F_ALLSUM	0x00000004	/* display all summary lines */
597c478bd9Sstevel@tonic-gate #define	F_DTAIL		0x00000008	/* display detail lines */
607c478bd9Sstevel@tonic-gate #define	F_TIME		0x00000010	/* display time */
617c478bd9Sstevel@tonic-gate #define	F_ATIME		0x00000020	/* display absolute time */
627c478bd9Sstevel@tonic-gate #define	F_RTIME		0x00000040	/* display relative time */
637c478bd9Sstevel@tonic-gate #define	F_DROPS		0x00000080	/* display drops */
647c478bd9Sstevel@tonic-gate #define	F_LEN		0x00000100	/* display pkt length */
657c478bd9Sstevel@tonic-gate #define	F_NUM		0x00000200	/* display pkt number */
667c478bd9Sstevel@tonic-gate #define	F_WHO		0x00000400	/* display src/dst */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	MAXLINE		(1088)		/* max len of detail line */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #define	MAX_HDRTRAILER	(64)		/* max hdr/trailer packet slack */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * The RPC XID cache structure.
747c478bd9Sstevel@tonic-gate  * When analyzing RPC protocols we
757c478bd9Sstevel@tonic-gate  * have to cache the xid of the RPC
767c478bd9Sstevel@tonic-gate  * request together with the program
777c478bd9Sstevel@tonic-gate  * number, proc, version etc since this
787c478bd9Sstevel@tonic-gate  * information is missing in the reply
797c478bd9Sstevel@tonic-gate  * packet.  Using the xid in the reply
807c478bd9Sstevel@tonic-gate  * we can lookup this previously stashed
817c478bd9Sstevel@tonic-gate  * information in the cache.
827c478bd9Sstevel@tonic-gate  *
837c478bd9Sstevel@tonic-gate  * For RPCSEC_GSS flavor, some special processing is
847c478bd9Sstevel@tonic-gate  * needed for the argument interpretation based on its
857c478bd9Sstevel@tonic-gate  * control procedure and service type.  This information
867c478bd9Sstevel@tonic-gate  * is stored in the cache table during interpretation of
877c478bd9Sstevel@tonic-gate  * the rpc header and will be referenced later when the rpc
887c478bd9Sstevel@tonic-gate  * argument is interpreted.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	XID_CACHE_SIZE 256
917c478bd9Sstevel@tonic-gate struct cache_struct {
927c478bd9Sstevel@tonic-gate 	int xid_num;	/* RPC transaction id */
937c478bd9Sstevel@tonic-gate 	int xid_frame;	/* Packet number */
947c478bd9Sstevel@tonic-gate 	int xid_prog;	/* RPC program number */
957c478bd9Sstevel@tonic-gate 	int xid_vers;	/* RPC version number */
967c478bd9Sstevel@tonic-gate 	int xid_proc;	/* RPC procedure number */
977c478bd9Sstevel@tonic-gate 	unsigned int xid_gss_proc; /* control procedure */
987c478bd9Sstevel@tonic-gate 	int xid_gss_service; /* none, integ, priv */
997c478bd9Sstevel@tonic-gate } xid_cache[XID_CACHE_SIZE];
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * The following macros advance the pointer passed to them.  They
1047c478bd9Sstevel@tonic-gate  * assume they are given a char *.
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate #define	GETINT8(v, ptr) { \
1077c478bd9Sstevel@tonic-gate 	(v) = (*(ptr)++); \
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #define	GETINT16(v, ptr) { \
1117c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1127c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	GETINT32(v, ptr) { \
1167c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1177c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1187c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1197c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1207c478bd9Sstevel@tonic-gate }
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * Used to print nested protocol layers.  For example, an ip datagram included
1247c478bd9Sstevel@tonic-gate  * in an icmp error, or a PPP packet included in an LCP protocol reject..
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate extern char *prot_nest_prefix;
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate extern char *get_sum_line(void);
1297c478bd9Sstevel@tonic-gate extern char *get_detail_line(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);
1357c478bd9Sstevel@tonic-gate extern void xdr_init(char *, int);
1367c478bd9Sstevel@tonic-gate extern char *get_line(int, int);
1377c478bd9Sstevel@tonic-gate extern int get_line_remain(void);
1387c478bd9Sstevel@tonic-gate extern char getxdr_char(void);
1397c478bd9Sstevel@tonic-gate extern char showxdr_char(char *);
1407c478bd9Sstevel@tonic-gate extern uchar_t getxdr_u_char(void);
1417c478bd9Sstevel@tonic-gate extern uchar_t showxdr_u_char(char *);
1427c478bd9Sstevel@tonic-gate extern short getxdr_short(void);
1437c478bd9Sstevel@tonic-gate extern short showxdr_short(char *);
1447c478bd9Sstevel@tonic-gate extern ushort_t getxdr_u_short(void);
1457c478bd9Sstevel@tonic-gate extern ushort_t showxdr_u_short(char *);
1467c478bd9Sstevel@tonic-gate extern long getxdr_long(void);
1477c478bd9Sstevel@tonic-gate extern long showxdr_long(char *);
1487c478bd9Sstevel@tonic-gate extern ulong_t getxdr_u_long(void);
1497c478bd9Sstevel@tonic-gate extern ulong_t showxdr_u_long(char *);
1507c478bd9Sstevel@tonic-gate extern longlong_t getxdr_longlong(void);
1517c478bd9Sstevel@tonic-gate extern longlong_t showxdr_longlong(char *);
15261961e0fSrobinson extern u_longlong_t getxdr_u_longlong(void);
15361961e0fSrobinson extern u_longlong_t showxdr_u_longlong(char *);
1547c478bd9Sstevel@tonic-gate extern char *getxdr_opaque(char *, int);
1557c478bd9Sstevel@tonic-gate extern char *getxdr_string(char *, int);
1567c478bd9Sstevel@tonic-gate extern char *showxdr_string(int, char *);
1577c478bd9Sstevel@tonic-gate extern char *getxdr_bytes(uint_t *);
1587c478bd9Sstevel@tonic-gate extern void xdr_skip(int);
1597c478bd9Sstevel@tonic-gate extern int getxdr_pos(void);
1607c478bd9Sstevel@tonic-gate extern void setxdr_pos(int);
1617c478bd9Sstevel@tonic-gate extern char *getxdr_context(char *, int);
1627c478bd9Sstevel@tonic-gate extern char *showxdr_context(char *);
1637c478bd9Sstevel@tonic-gate extern enum_t getxdr_enum(void);
1647c478bd9Sstevel@tonic-gate extern void show_space(void);
1657c478bd9Sstevel@tonic-gate extern void show_trailer(void);
1667c478bd9Sstevel@tonic-gate extern char *getxdr_date(void);
1677c478bd9Sstevel@tonic-gate extern char *showxdr_date(char *);
1687c478bd9Sstevel@tonic-gate extern char *getxdr_date_ns(void);
1697c478bd9Sstevel@tonic-gate char *format_time(int64_t sec, uint32_t nsec);
1707c478bd9Sstevel@tonic-gate extern char *showxdr_date_ns(char *);
1717c478bd9Sstevel@tonic-gate extern char *getxdr_hex(int);
1727c478bd9Sstevel@tonic-gate extern char *showxdr_hex(int, char *);
1737c478bd9Sstevel@tonic-gate extern bool_t getxdr_bool(void);
1747c478bd9Sstevel@tonic-gate extern bool_t showxdr_bool(char *);
1757c478bd9Sstevel@tonic-gate extern char *concat_args(char **, int);
1767c478bd9Sstevel@tonic-gate extern int pf_compile(char *, int);
1777c478bd9Sstevel@tonic-gate extern void compile(char *, int);
1787c478bd9Sstevel@tonic-gate extern void load_names(char *);
17945916cd2Sjpk extern void cap_write(struct sb_hdr *, char *, int, int);
180c7e4935fSss extern void cap_open_read(const char *);
181c7e4935fSss extern void cap_open_write(const char *);
1827c478bd9Sstevel@tonic-gate extern void cap_read(int, int, int, void (*)(), int);
1837c478bd9Sstevel@tonic-gate extern void cap_close(void);
184c7e4935fSss extern boolean_t check_device(dlpi_handle_t *, char **);
185c7e4935fSss extern void initdevice(dlpi_handle_t, ulong_t, ulong_t, struct timeval *,
186c7e4935fSss     struct Pf_ext_packetfilt *);
187c7e4935fSss extern void net_read(dlpi_handle_t, size_t, int, void (*)(), int);
1887c478bd9Sstevel@tonic-gate extern void click(int);
1897c478bd9Sstevel@tonic-gate extern void show_pktinfo(int, int, char *, char *, struct timeval *,
1907c478bd9Sstevel@tonic-gate 		struct timeval *, int, int);
1917c478bd9Sstevel@tonic-gate extern void show_line(char *);
1927c478bd9Sstevel@tonic-gate extern char *getxdr_time(void);
1937c478bd9Sstevel@tonic-gate extern char *showxdr_time(char *);
19445916cd2Sjpk extern char *addrtoname(int, const void *);
1957c478bd9Sstevel@tonic-gate extern char *show_string(const char *, int, int);
19645916cd2Sjpk extern void pr_err(const char *, ...);
197c7e4935fSss extern void pr_errdlpi(dlpi_handle_t, const char *, int);
1987c478bd9Sstevel@tonic-gate extern void check_retransmit(char *, ulong_t);
1997c478bd9Sstevel@tonic-gate extern char *nameof_prog(int);
2007c478bd9Sstevel@tonic-gate extern char *getproto(int);
2017c478bd9Sstevel@tonic-gate extern uint8_t print_ipv6_extensions(int, uint8_t **, uint8_t *, int *, int *);
2027c478bd9Sstevel@tonic-gate extern void protoprint(int, int, ulong_t, int, int, int, char *, int);
2037c478bd9Sstevel@tonic-gate extern char *getportname(int, in_port_t);
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate extern void interpret_arp(int, struct arphdr *, int);
2067c478bd9Sstevel@tonic-gate extern void interpret_bparam(int, int, int, int, int, char *, int);
207*4b22b933Srs extern void interpret_dns(int, int, const uchar_t *, int, int);
2087c478bd9Sstevel@tonic-gate extern void interpret_mount(int, int, int, int, int, char *, int);
2097c478bd9Sstevel@tonic-gate extern void interpret_nfs(int, int, int, int, int, char *, int);
2107c478bd9Sstevel@tonic-gate extern void interpret_nfs3(int, int, int, int, int, char *, int);
2117c478bd9Sstevel@tonic-gate extern void interpret_nfs4(int, int, int, int, int, char *, int);
2127c478bd9Sstevel@tonic-gate extern void interpret_nfs4_cb(int, int, int, int, int, char *, int);
2137c478bd9Sstevel@tonic-gate extern void interpret_nfs_acl(int, int, int, int, int, char *, int);
2147c478bd9Sstevel@tonic-gate extern void interpret_nis(int, int, int, int, int, char *, int);
2157c478bd9Sstevel@tonic-gate extern void interpret_nisbind(int, int, int, int, int, char *, int);
2167c478bd9Sstevel@tonic-gate extern void interpret_nisp_cb(int, int, int, int, int, char *, int);
2177c478bd9Sstevel@tonic-gate extern void interpret_nisplus(int, int, int, int, int, char *, int);
2187c478bd9Sstevel@tonic-gate extern void interpret_nlm(int, int, int, int, int, char *, int);
2197c478bd9Sstevel@tonic-gate extern void interpret_pmap(int, int, int, int, int, char *, int);
2207c478bd9Sstevel@tonic-gate extern int interpret_reserved(int, int, in_port_t, in_port_t, char *, int);
2217c478bd9Sstevel@tonic-gate extern void interpret_rquota(int, int, int, int, int, char *, int);
2227c478bd9Sstevel@tonic-gate extern void interpret_rstat(int, int, int, int, int, char *, int);
2237c478bd9Sstevel@tonic-gate extern void interpret_solarnet_fw(int, int, int, int, int, char *, int);
2247c478bd9Sstevel@tonic-gate extern void interpret_ldap(int, char *, int, int, int);
2257c478bd9Sstevel@tonic-gate extern void interpret_icmp(int, struct icmp *, int, int);
2267c478bd9Sstevel@tonic-gate extern void interpret_icmpv6(int, icmp6_t *, int, int);
22745916cd2Sjpk extern int interpret_ip(int, const struct ip *, int);
22845916cd2Sjpk extern int interpret_ipv6(int, const ip6_t *, int);
2297c478bd9Sstevel@tonic-gate extern int interpret_ppp(int, uchar_t *, int);
2307c478bd9Sstevel@tonic-gate extern int interpret_pppoe(int, poep_t *, int);
23145916cd2Sjpk struct tcphdr;
23245916cd2Sjpk extern int interpret_tcp(int, struct tcphdr *, int, int);
23345916cd2Sjpk struct udphdr;
23445916cd2Sjpk extern int interpret_udp(int, struct udphdr *, int, int);
23545916cd2Sjpk extern int interpret_esp(int, uint8_t *, int, int);
23645916cd2Sjpk extern int interpret_ah(int, uint8_t *, int, int);
23745916cd2Sjpk struct sctp_hdr;
23845916cd2Sjpk extern void interpret_sctp(int, struct sctp_hdr *, int, int);
23945916cd2Sjpk extern void interpret_mip_cntrlmsg(int, uchar_t *, int);
24045916cd2Sjpk struct dhcp;
24145916cd2Sjpk extern int interpret_dhcp(int, struct dhcp *, int);
242d04ccbb3Scarlsonj extern int interpret_dhcpv6(int, const uint8_t *, int);
24345916cd2Sjpk struct tftphdr;
24445916cd2Sjpk extern int interpret_tftp(int, struct tftphdr *, int);
24545916cd2Sjpk extern int interpret_http(int, char *, int);
24645916cd2Sjpk struct ntpdata;
24745916cd2Sjpk extern int interpret_ntp(int, struct ntpdata *, int);
24845916cd2Sjpk extern void interpret_netbios_ns(int, uchar_t *, int);
24945916cd2Sjpk extern void interpret_netbios_datagram(int, uchar_t *, int);
25045916cd2Sjpk extern void interpret_netbios_ses(int, uchar_t *, int);
25145916cd2Sjpk extern void interpret_slp(int, char *, int);
25245916cd2Sjpk struct rip;
25345916cd2Sjpk extern int interpret_rip(int, struct rip *, int);
25445916cd2Sjpk struct rip6;
25545916cd2Sjpk extern int interpret_rip6(int, struct rip6 *, int);
25645916cd2Sjpk extern int interpret_socks_call(int, char *, int);
25745916cd2Sjpk extern int interpret_socks_reply(int, char *, int);
2587c478bd9Sstevel@tonic-gate extern void init_ldap(void);
2597c478bd9Sstevel@tonic-gate extern boolean_t arp_for_ether(char *, struct ether_addr *);
2607c478bd9Sstevel@tonic-gate extern char *ether_ouiname(uint32_t);
26145916cd2Sjpk extern char *tohex(char *p, int len);
2627c478bd9Sstevel@tonic-gate extern char *printether(struct ether_addr *);
2637c478bd9Sstevel@tonic-gate extern char *print_ethertype(int);
264d04ccbb3Scarlsonj extern const char *arp_htype(int);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate  * Describes characteristics of the Media Access Layer.
2687c478bd9Sstevel@tonic-gate  * The mac_type is one of the supported DLPI media
2697c478bd9Sstevel@tonic-gate  * types (see <sys/dlpi.h>).
2707c478bd9Sstevel@tonic-gate  * The mtu_size is the size of the largest frame.
271605445d5Sdg  * network_type_offset is where the network type
272605445d5Sdg  * is located in the link layer header.
2737c478bd9Sstevel@tonic-gate  * The header length is returned by a function to
2747c478bd9Sstevel@tonic-gate  * allow for variable header size - for ethernet it's
2757c478bd9Sstevel@tonic-gate  * just a constant 14 octets.
2767c478bd9Sstevel@tonic-gate  * The interpreter is the function that "knows" how
2777c478bd9Sstevel@tonic-gate  * to interpret the frame.
278605445d5Sdg  * try_kernel_filter tells snoop to first try a kernel
279605445d5Sdg  * filter (because the header size is fixed, or if it could
280605445d5Sdg  * be of variable size where the variable size is easy for a kernel
281605445d5Sdg  * filter to handle, for example, Ethernet and VLAN tags)
282605445d5Sdg  * and only use a user space filter if the filter expression
283605445d5Sdg  * cannot be expressed in kernel space.
2847c478bd9Sstevel@tonic-gate  */
2857c478bd9Sstevel@tonic-gate typedef struct interface {
2867c478bd9Sstevel@tonic-gate 	uint_t	mac_type;
2877c478bd9Sstevel@tonic-gate 	uint_t	mtu_size;
288605445d5Sdg 	uint_t  network_type_offset;
2897c478bd9Sstevel@tonic-gate 	uint_t	(*header_len)(char *);
2907c478bd9Sstevel@tonic-gate 	uint_t 	(*interpreter)(int, char *, int, int);
291605445d5Sdg 	uint_t	try_kernel_filter;
2927c478bd9Sstevel@tonic-gate } interface_t;
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate extern interface_t INTERFACES[], *interface;
2957c478bd9Sstevel@tonic-gate extern char *device;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate extern char *dlc_header;
2987c478bd9Sstevel@tonic-gate 
29945916cd2Sjpk extern char *src_name, *dst_name;
30045916cd2Sjpk 
30145916cd2Sjpk extern char *prot_prefix;
30245916cd2Sjpk extern char *prot_nest_prefix;
30345916cd2Sjpk extern char *prot_title;
30445916cd2Sjpk 
30545916cd2Sjpk /* Keep track of how many nested IP headers we have. */
30645916cd2Sjpk extern unsigned int encap_levels, total_encap_levels;
30745916cd2Sjpk 
30845916cd2Sjpk extern int quitting;
30945916cd2Sjpk 
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate  * Global error recovery routine: used to reset snoop variables after
3127c478bd9Sstevel@tonic-gate  * catastrophic failure.
3137c478bd9Sstevel@tonic-gate  */
3147c478bd9Sstevel@tonic-gate void snoop_recover(void);
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Global alarm handler structure for managing multiple alarms within
3187c478bd9Sstevel@tonic-gate  * snoop.
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate typedef struct snoop_handler {
3217c478bd9Sstevel@tonic-gate 	struct snoop_handler *s_next;		/* next alarm handler */
3227c478bd9Sstevel@tonic-gate 	time_t s_time;				/* time to fire */
3237c478bd9Sstevel@tonic-gate 	void (*s_handler)();			/* alarm handler */
3247c478bd9Sstevel@tonic-gate } snoop_handler_t;
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate #define	SNOOP_MAXRECOVER	20	/* maxium number of recoveries */
3277c478bd9Sstevel@tonic-gate #define	SNOOP_ALARM_GRAN	3	/* alarm() timeout multiplier */
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate  * Global alarm handler management routine.
3317c478bd9Sstevel@tonic-gate  */
3327c478bd9Sstevel@tonic-gate extern int snoop_alarm(int s_sec, void (*s_handler)());
3337c478bd9Sstevel@tonic-gate 
3340990bc30Sdg /*
3350990bc30Sdg  * The next two definitions do not take into account the length
3360990bc30Sdg  * of the underlying link header.  In order to use them, you must
3370990bc30Sdg  * add link_header_len to them.  The reason it is not done here is
3380990bc30Sdg  * that later these macros are used to initialize a table.
3390990bc30Sdg  */
3400990bc30Sdg #define	IPV4_TYPE_HEADER_OFFSET 9
3410990bc30Sdg #define	IPV6_TYPE_HEADER_OFFSET 6
3420990bc30Sdg 
3437c478bd9Sstevel@tonic-gate #ifdef __cplusplus
3447c478bd9Sstevel@tonic-gate }
3457c478bd9Sstevel@tonic-gate #endif
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate #endif	/* _SNOOP_H */
348