xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h (revision d6913e077df3706d8fe5649c00430704087fc6a2)
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.
25741913f0SGordon Ross  *
26741913f0SGordon 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>
48741913f0SGordon 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 
715b8f338eSToomas Soome /*
725b8f338eSToomas Soome  * Transient port structure. See TFTP interpreter.
735b8f338eSToomas Soome  */
745b8f338eSToomas Soome struct ttable {
755b8f338eSToomas Soome 	int t_port;
765b8f338eSToomas Soome 	int blksize;
775b8f338eSToomas Soome 	int (*t_proc)(int, void *, int);
785b8f338eSToomas Soome };
795b8f338eSToomas Soome 
805b8f338eSToomas Soome extern int add_transient(int port, int (*proc)(int, void *, int));
815b8f338eSToomas Soome extern struct ttable *is_transient(int port);
825b8f338eSToomas Soome extern void del_transient(int port);
835b8f338eSToomas Soome 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * The RPC XID cache structure.
867c478bd9Sstevel@tonic-gate  * When analyzing RPC protocols we
877c478bd9Sstevel@tonic-gate  * have to cache the xid of the RPC
887c478bd9Sstevel@tonic-gate  * request together with the program
897c478bd9Sstevel@tonic-gate  * number, proc, version etc since this
907c478bd9Sstevel@tonic-gate  * information is missing in the reply
917c478bd9Sstevel@tonic-gate  * packet.  Using the xid in the reply
927c478bd9Sstevel@tonic-gate  * we can lookup this previously stashed
937c478bd9Sstevel@tonic-gate  * information in the cache.
947c478bd9Sstevel@tonic-gate  *
957c478bd9Sstevel@tonic-gate  * For RPCSEC_GSS flavor, some special processing is
967c478bd9Sstevel@tonic-gate  * needed for the argument interpretation based on its
977c478bd9Sstevel@tonic-gate  * control procedure and service type.  This information
987c478bd9Sstevel@tonic-gate  * is stored in the cache table during interpretation of
997c478bd9Sstevel@tonic-gate  * the rpc header and will be referenced later when the rpc
1007c478bd9Sstevel@tonic-gate  * argument is interpreted.
1017c478bd9Sstevel@tonic-gate  */
1027c478bd9Sstevel@tonic-gate #define	XID_CACHE_SIZE 256
1037c478bd9Sstevel@tonic-gate struct cache_struct {
1047c478bd9Sstevel@tonic-gate 	int xid_num;	/* RPC transaction id */
1057c478bd9Sstevel@tonic-gate 	int xid_frame;	/* Packet number */
1067c478bd9Sstevel@tonic-gate 	int xid_prog;	/* RPC program number */
1077c478bd9Sstevel@tonic-gate 	int xid_vers;	/* RPC version number */
1087c478bd9Sstevel@tonic-gate 	int xid_proc;	/* RPC procedure number */
1097c478bd9Sstevel@tonic-gate 	unsigned int xid_gss_proc; /* control procedure */
1107c478bd9Sstevel@tonic-gate 	int xid_gss_service; /* none, integ, priv */
1117c478bd9Sstevel@tonic-gate } xid_cache[XID_CACHE_SIZE];
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * The following macros advance the pointer passed to them.  They
1167c478bd9Sstevel@tonic-gate  * assume they are given a char *.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	GETINT8(v, ptr) { \
1197c478bd9Sstevel@tonic-gate 	(v) = (*(ptr)++); \
1207c478bd9Sstevel@tonic-gate }
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	GETINT16(v, ptr) { \
1237c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1247c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #define	GETINT32(v, ptr) { \
1287c478bd9Sstevel@tonic-gate 	(v) = *(ptr)++ << 8; \
1297c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1307c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; (v) <<= 8; \
1317c478bd9Sstevel@tonic-gate 	(v) |= *(ptr)++; \
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  * Used to print nested protocol layers.  For example, an ip datagram included
1367c478bd9Sstevel@tonic-gate  * in an icmp error, or a PPP packet included in an LCP protocol reject..
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate extern char *prot_nest_prefix;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate extern char *get_sum_line(void);
1417c478bd9Sstevel@tonic-gate extern char *get_detail_line(int, int);
1422b24ab6bSSebastien Roy extern int want_packet(uchar_t *, int, int);
143605445d5Sdg extern void set_vlan_id(int);
1447c478bd9Sstevel@tonic-gate extern struct timeval prev_time;
14545916cd2Sjpk extern void process_pkt(struct sb_hdr *, char *, int, int);
1467c478bd9Sstevel@tonic-gate extern char *getflag(int, int, char *, char *);
1477c478bd9Sstevel@tonic-gate extern void show_header(char *, char *, int);
1482b24ab6bSSebastien Roy extern void show_count(void);
1497c478bd9Sstevel@tonic-gate extern void xdr_init(char *, int);
1507c478bd9Sstevel@tonic-gate extern char *get_line(int, int);
1517c478bd9Sstevel@tonic-gate extern int get_line_remain(void);
1527c478bd9Sstevel@tonic-gate extern char getxdr_char(void);
1537c478bd9Sstevel@tonic-gate extern char showxdr_char(char *);
1547c478bd9Sstevel@tonic-gate extern uchar_t getxdr_u_char(void);
1557c478bd9Sstevel@tonic-gate extern uchar_t showxdr_u_char(char *);
1567c478bd9Sstevel@tonic-gate extern short getxdr_short(void);
1577c478bd9Sstevel@tonic-gate extern short showxdr_short(char *);
1587c478bd9Sstevel@tonic-gate extern ushort_t getxdr_u_short(void);
1597c478bd9Sstevel@tonic-gate extern ushort_t showxdr_u_short(char *);
1607c478bd9Sstevel@tonic-gate extern long getxdr_long(void);
1617c478bd9Sstevel@tonic-gate extern long showxdr_long(char *);
1627c478bd9Sstevel@tonic-gate extern ulong_t getxdr_u_long(void);
1637c478bd9Sstevel@tonic-gate extern ulong_t showxdr_u_long(char *);
1647c478bd9Sstevel@tonic-gate extern longlong_t getxdr_longlong(void);
1657c478bd9Sstevel@tonic-gate extern longlong_t showxdr_longlong(char *);
16661961e0fSrobinson extern u_longlong_t getxdr_u_longlong(void);
16761961e0fSrobinson extern u_longlong_t showxdr_u_longlong(char *);
1687c478bd9Sstevel@tonic-gate extern char *getxdr_opaque(char *, int);
1697c478bd9Sstevel@tonic-gate extern char *getxdr_string(char *, int);
1707c478bd9Sstevel@tonic-gate extern char *showxdr_string(int, char *);
1717c478bd9Sstevel@tonic-gate extern char *getxdr_bytes(uint_t *);
1727c478bd9Sstevel@tonic-gate extern void xdr_skip(int);
1737c478bd9Sstevel@tonic-gate extern int getxdr_pos(void);
1747c478bd9Sstevel@tonic-gate extern void setxdr_pos(int);
1757c478bd9Sstevel@tonic-gate extern char *getxdr_context(char *, int);
1767c478bd9Sstevel@tonic-gate extern char *showxdr_context(char *);
1777c478bd9Sstevel@tonic-gate extern enum_t getxdr_enum(void);
1787c478bd9Sstevel@tonic-gate extern void show_space(void);
1797c478bd9Sstevel@tonic-gate extern void show_trailer(void);
1807c478bd9Sstevel@tonic-gate extern char *getxdr_date(void);
1817c478bd9Sstevel@tonic-gate extern char *showxdr_date(char *);
1827c478bd9Sstevel@tonic-gate extern char *getxdr_date_ns(void);
1837c478bd9Sstevel@tonic-gate char *format_time(int64_t sec, uint32_t nsec);
1847c478bd9Sstevel@tonic-gate extern char *showxdr_date_ns(char *);
1857c478bd9Sstevel@tonic-gate extern char *getxdr_hex(int);
1867c478bd9Sstevel@tonic-gate extern char *showxdr_hex(int, char *);
1877c478bd9Sstevel@tonic-gate extern bool_t getxdr_bool(void);
1887c478bd9Sstevel@tonic-gate extern bool_t showxdr_bool(char *);
1897c478bd9Sstevel@tonic-gate extern char *concat_args(char **, int);
1907c478bd9Sstevel@tonic-gate extern int pf_compile(char *, int);
1917c478bd9Sstevel@tonic-gate extern void compile(char *, int);
1927c478bd9Sstevel@tonic-gate extern void load_names(char *);
19345916cd2Sjpk extern void cap_write(struct sb_hdr *, char *, int, int);
194c7e4935fSss extern void cap_open_read(const char *);
195c7e4935fSss extern void cap_open_write(const char *);
1967c478bd9Sstevel@tonic-gate extern void cap_read(int, int, int, void (*)(), int);
1977c478bd9Sstevel@tonic-gate extern void cap_close(void);
198b78ff649Smeem extern boolean_t open_datalink(dlpi_handle_t *, const char *);
199b78ff649Smeem extern void init_datalink(dlpi_handle_t, ulong_t, ulong_t, struct timeval *,
200c7e4935fSss     struct Pf_ext_packetfilt *);
201c7e4935fSss extern void net_read(dlpi_handle_t, size_t, int, void (*)(), int);
2027c478bd9Sstevel@tonic-gate extern void click(int);
2037c478bd9Sstevel@tonic-gate extern void show_pktinfo(int, int, char *, char *, struct timeval *,
2047c478bd9Sstevel@tonic-gate 		struct timeval *, int, int);
2057c478bd9Sstevel@tonic-gate extern void show_line(char *);
206741913f0SGordon Ross /*PRINTFLIKE1*/
207741913f0SGordon Ross extern void show_printf(char *fmt, ...)
208741913f0SGordon Ross     __PRINTFLIKE(1);
2097c478bd9Sstevel@tonic-gate extern char *getxdr_time(void);
2107c478bd9Sstevel@tonic-gate extern char *showxdr_time(char *);
21145916cd2Sjpk extern char *addrtoname(int, const void *);
2127c478bd9Sstevel@tonic-gate extern char *show_string(const char *, int, int);
21345916cd2Sjpk extern void pr_err(const char *, ...);
214c7e4935fSss extern void pr_errdlpi(dlpi_handle_t, const char *, int);
2157c478bd9Sstevel@tonic-gate extern void check_retransmit(char *, ulong_t);
2167c478bd9Sstevel@tonic-gate extern char *nameof_prog(int);
2177c478bd9Sstevel@tonic-gate extern char *getproto(int);
2187c478bd9Sstevel@tonic-gate extern uint8_t print_ipv6_extensions(int, uint8_t **, uint8_t *, int *, int *);
2197c478bd9Sstevel@tonic-gate extern void protoprint(int, int, ulong_t, int, int, int, char *, int);
2207c478bd9Sstevel@tonic-gate extern char *getportname(int, in_port_t);
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate extern void interpret_arp(int, struct arphdr *, int);
2237c478bd9Sstevel@tonic-gate extern void interpret_bparam(int, int, int, int, int, char *, int);
2244b22b933Srs extern void interpret_dns(int, int, const uchar_t *, int, int);
2257c478bd9Sstevel@tonic-gate extern void interpret_mount(int, int, int, int, int, char *, int);
2267c478bd9Sstevel@tonic-gate extern void interpret_nfs(int, int, int, int, int, char *, int);
2277c478bd9Sstevel@tonic-gate extern void interpret_nfs3(int, int, int, int, int, char *, int);
2287c478bd9Sstevel@tonic-gate extern void interpret_nfs4(int, int, int, int, int, char *, int);
2297c478bd9Sstevel@tonic-gate extern void interpret_nfs4_cb(int, int, int, int, int, char *, int);
2307c478bd9Sstevel@tonic-gate extern void interpret_nfs_acl(int, int, int, int, int, char *, int);
2317c478bd9Sstevel@tonic-gate extern void interpret_nis(int, int, int, int, int, char *, int);
2327c478bd9Sstevel@tonic-gate extern void interpret_nisbind(int, int, int, int, int, char *, int);
2337c478bd9Sstevel@tonic-gate extern void interpret_nlm(int, int, int, int, int, char *, int);
2347c478bd9Sstevel@tonic-gate extern void interpret_pmap(int, int, int, int, int, char *, int);
2357c478bd9Sstevel@tonic-gate extern int interpret_reserved(int, int, in_port_t, in_port_t, char *, int);
2367c478bd9Sstevel@tonic-gate extern void interpret_rquota(int, int, int, int, int, char *, int);
2377c478bd9Sstevel@tonic-gate extern void interpret_rstat(int, int, int, int, int, char *, int);
2387c478bd9Sstevel@tonic-gate extern void interpret_solarnet_fw(int, int, int, int, int, char *, int);
2397c478bd9Sstevel@tonic-gate extern void interpret_ldap(int, char *, int, int, int);
2407c478bd9Sstevel@tonic-gate extern void interpret_icmp(int, struct icmp *, int, int);
2417c478bd9Sstevel@tonic-gate extern void interpret_icmpv6(int, icmp6_t *, int, int);
24245916cd2Sjpk extern int interpret_ip(int, const struct ip *, int);
24345916cd2Sjpk extern int interpret_ipv6(int, const ip6_t *, int);
2447c478bd9Sstevel@tonic-gate extern int interpret_ppp(int, uchar_t *, int);
2457c478bd9Sstevel@tonic-gate extern int interpret_pppoe(int, poep_t *, int);
24645916cd2Sjpk struct tcphdr;
24745916cd2Sjpk extern int interpret_tcp(int, struct tcphdr *, int, int);
24845916cd2Sjpk struct udphdr;
24945916cd2Sjpk extern int interpret_udp(int, struct udphdr *, int, int);
25045916cd2Sjpk extern int interpret_esp(int, uint8_t *, int, int);
25145916cd2Sjpk extern int interpret_ah(int, uint8_t *, int, int);
25245916cd2Sjpk struct sctp_hdr;
25345916cd2Sjpk extern void interpret_sctp(int, struct sctp_hdr *, int, int);
25445916cd2Sjpk extern void interpret_mip_cntrlmsg(int, uchar_t *, int);
25545916cd2Sjpk struct dhcp;
25645916cd2Sjpk extern int interpret_dhcp(int, struct dhcp *, int);
257d04ccbb3Scarlsonj extern int interpret_dhcpv6(int, const uint8_t *, int);
25845916cd2Sjpk struct tftphdr;
2595b8f338eSToomas Soome extern int interpret_tftp(int, void *, int);
26045916cd2Sjpk extern int interpret_http(int, char *, int);
26145916cd2Sjpk struct ntpdata;
26245916cd2Sjpk extern int interpret_ntp(int, struct ntpdata *, int);
26345916cd2Sjpk extern void interpret_netbios_ns(int, uchar_t *, int);
26445916cd2Sjpk extern void interpret_netbios_datagram(int, uchar_t *, int);
26545916cd2Sjpk extern void interpret_netbios_ses(int, uchar_t *, int);
266*d6913e07SToomas Soome extern int interpret_slp(int, void *, int);
26745916cd2Sjpk struct rip;
26845916cd2Sjpk extern int interpret_rip(int, struct rip *, int);
26945916cd2Sjpk struct rip6;
27045916cd2Sjpk extern int interpret_rip6(int, struct rip6 *, int);
27145916cd2Sjpk extern int interpret_socks_call(int, char *, int);
27245916cd2Sjpk extern int interpret_socks_reply(int, char *, int);
2734eaa4710SRishi Srivatsavai extern int interpret_trill(int, struct ether_header **, char *, int *);
2744eaa4710SRishi Srivatsavai extern int interpret_isis(int, char *, int, boolean_t);
2754eaa4710SRishi Srivatsavai extern int interpret_bpdu(int, char *, int);
2767c478bd9Sstevel@tonic-gate extern void init_ldap(void);
2777c478bd9Sstevel@tonic-gate extern boolean_t arp_for_ether(char *, struct ether_addr *);
2787c478bd9Sstevel@tonic-gate extern char *ether_ouiname(uint32_t);
27945916cd2Sjpk extern char *tohex(char *p, int len);
2807c478bd9Sstevel@tonic-gate extern char *printether(struct ether_addr *);
2817c478bd9Sstevel@tonic-gate extern char *print_ethertype(int);
282d04ccbb3Scarlsonj extern const char *arp_htype(int);
2832b24ab6bSSebastien Roy extern int valid_rpc(char *, int);
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate /*
2867c478bd9Sstevel@tonic-gate  * Describes characteristics of the Media Access Layer.
2877c478bd9Sstevel@tonic-gate  * The mac_type is one of the supported DLPI media
2887c478bd9Sstevel@tonic-gate  * types (see <sys/dlpi.h>).
2897c478bd9Sstevel@tonic-gate  * The mtu_size is the size of the largest frame.
290605445d5Sdg  * network_type_offset is where the network type
291605445d5Sdg  * is located in the link layer header.
2927c478bd9Sstevel@tonic-gate  * The header length is returned by a function to
2937c478bd9Sstevel@tonic-gate  * allow for variable header size - for ethernet it's
2947c478bd9Sstevel@tonic-gate  * just a constant 14 octets.
2957c478bd9Sstevel@tonic-gate  * The interpreter is the function that "knows" how
2967c478bd9Sstevel@tonic-gate  * to interpret the frame.
297605445d5Sdg  * try_kernel_filter tells snoop to first try a kernel
298605445d5Sdg  * filter (because the header size is fixed, or if it could
299605445d5Sdg  * be of variable size where the variable size is easy for a kernel
300605445d5Sdg  * filter to handle, for example, Ethernet and VLAN tags)
301605445d5Sdg  * and only use a user space filter if the filter expression
302605445d5Sdg  * cannot be expressed in kernel space.
3037c478bd9Sstevel@tonic-gate  */
3042b24ab6bSSebastien Roy typedef uint_t (interpreter_fn_t)(int, char *, int, int);
3052b24ab6bSSebastien Roy typedef uint_t (headerlen_fn_t)(char *, size_t);
3067c478bd9Sstevel@tonic-gate typedef struct interface {
307b127ac41SPhilip Kirk 	uint_t		mac_type;
308b127ac41SPhilip Kirk 	uint_t		mtu_size;
3095b8f338eSToomas Soome 	uint_t		network_type_offset;
310b127ac41SPhilip Kirk 	size_t		network_type_len;
311b127ac41SPhilip Kirk 	uint_t		network_type_ip;
312b127ac41SPhilip Kirk 	uint_t		network_type_ipv6;
3132b24ab6bSSebastien Roy 	headerlen_fn_t	*header_len;
3142b24ab6bSSebastien Roy 	interpreter_fn_t *interpreter;
315b127ac41SPhilip Kirk 	boolean_t	try_kernel_filter;
3167c478bd9Sstevel@tonic-gate } interface_t;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate extern interface_t INTERFACES[], *interface;
3197c478bd9Sstevel@tonic-gate extern char *dlc_header;
32045916cd2Sjpk extern char *src_name, *dst_name;
32145916cd2Sjpk extern char *prot_prefix;
32245916cd2Sjpk extern char *prot_nest_prefix;
32345916cd2Sjpk extern char *prot_title;
32445916cd2Sjpk 
32545916cd2Sjpk /* Keep track of how many nested IP headers we have. */
32645916cd2Sjpk extern unsigned int encap_levels, total_encap_levels;
32745916cd2Sjpk 
32845916cd2Sjpk extern int quitting;
329b127ac41SPhilip Kirk extern boolean_t Iflg, Pflg, rflg;
33045916cd2Sjpk 
3317c478bd9Sstevel@tonic-gate /*
3327c478bd9Sstevel@tonic-gate  * Global error recovery routine: used to reset snoop variables after
3337c478bd9Sstevel@tonic-gate  * catastrophic failure.
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate void snoop_recover(void);
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate  * Global alarm handler structure for managing multiple alarms within
3397c478bd9Sstevel@tonic-gate  * snoop.
3407c478bd9Sstevel@tonic-gate  */
3417c478bd9Sstevel@tonic-gate typedef struct snoop_handler {
3427c478bd9Sstevel@tonic-gate 	struct snoop_handler *s_next;		/* next alarm handler */
3437c478bd9Sstevel@tonic-gate 	time_t s_time;				/* time to fire */
3447c478bd9Sstevel@tonic-gate 	void (*s_handler)();			/* alarm handler */
3457c478bd9Sstevel@tonic-gate } snoop_handler_t;
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate #define	SNOOP_MAXRECOVER	20	/* maxium number of recoveries */
3487c478bd9Sstevel@tonic-gate #define	SNOOP_ALARM_GRAN	3	/* alarm() timeout multiplier */
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate /*
3517c478bd9Sstevel@tonic-gate  * Global alarm handler management routine.
3527c478bd9Sstevel@tonic-gate  */
3537c478bd9Sstevel@tonic-gate extern int snoop_alarm(int s_sec, void (*s_handler)());
3547c478bd9Sstevel@tonic-gate 
3550990bc30Sdg /*
3560990bc30Sdg  * The next two definitions do not take into account the length
3570990bc30Sdg  * of the underlying link header.  In order to use them, you must
3580990bc30Sdg  * add link_header_len to them.  The reason it is not done here is
3590990bc30Sdg  * that later these macros are used to initialize a table.
3600990bc30Sdg  */
3610990bc30Sdg #define	IPV4_TYPE_HEADER_OFFSET 9
3620990bc30Sdg #define	IPV6_TYPE_HEADER_OFFSET 6
3630990bc30Sdg 
3647c478bd9Sstevel@tonic-gate #ifdef __cplusplus
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate #endif
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate #endif	/* _SNOOP_H */
369