/*
 *	Copyright (c) 1995, 1996, Sun Microsystems, Inc.
 *
 * This software is provided by Sun ``AS IS'' and any express or implied
 * warranties, including, but not limited to, the implied warranties of
 * merchantability and fitness for a particular purpose are disclaimed.
 * In no event shall Sun Microsystems be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages.
 *
 * This software is not a product, and is provided for evaluation purposes
 * only.
 *
 * This software may not be resold without the express permission of
 * Sun Microsystems.
 *
 * Feedback on this tool may be sent to packet-shell-owner@sunroof.eng.sun.com.
 */

#ifndef	_SNOOP_H
#define	_SNOOP_H

#pragma ident	"@(#)snoop.h	1.3	98/11/12 SMI"

#include <sys/pfmod.h>
#include <sys/time.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Flags to control packet info display
 */
#define	F_NOW		0x00000001	/* display in realtime */
#define	F_SUM		0x00000002	/* display summary line */
#define	F_ALLSUM	0x00000004	/* display all summary lines */
#define	F_DTAIL		0x00000008	/* display detail lines */
#define	F_TIME		0x00000010	/* display time */
#define	F_ATIME		0x00000020	/* display absolute time */
#define	F_RTIME		0x00000040	/* display relative time */
#define	F_DROPS		0x00000080	/* display drops */
#define	F_LEN		0x00000100	/* display pkt length */
#define	F_NUM		0x00000200	/* display pkt number */
#define	F_WHO		0x00000400	/* display src/dst */

#define	MAXLINE		(160)		/* max len of detail line */

#if defined(__STDC__)
extern char *get_sum_line(void);
extern char *get_detail_line(int, int);
extern struct timeval prev_time;
extern char *getflag(int, int, char *, char *);
extern void show_header(char *, char *, int);
extern void xdr_init(char *, int);
extern char *get_line(int, int);
extern char getxdr_char(void);
extern char showxdr_char(char *);
extern uchar_t getxdr_u_char(void);
extern uchar_t showxdr_u_char(char *);
extern short getxdr_short(void);
extern short showxdr_short(char *);
extern ushort_t getxdr_u_short(void);
extern ushort_t showxdr_u_short(char *);
extern long getxdr_long(void);
extern long showxdr_long(char *);
extern ulong_t getxdr_u_long(void);
extern ulong_t showxdr_u_long(char *);
extern longlong_t getxdr_longlong(void);
extern longlong_t showxdr_longlong(char *);
extern unsigned long long getxdr_u_longlong(void);
extern unsigned long long showxdr_u_longlong(char *);
extern char *getxdr_opaque(char *, int);
extern char *getxdr_string(char *, int);
extern char *showxdr_string(int, char *);
extern char *getxdr_bytes(uint_t *);
extern void xdr_skip(int);
extern int getxdr_pos(void);
extern void show_space(void);
extern void show_trailer(void);
extern char *getxdr_date(void);
extern char *showxdr_date(char *);
extern char *showxdr_date_ns(char *);
extern char *getxdr_hex(int);
extern char *showxdr_hex(int, char *);
extern bool_t getxdr_bool(void);
extern bool_t showxdr_bool(char *);
extern char *concat_args(char **, int);
extern int pf_install(char *e, int fd);
extern int pf_compile(char *, int);
extern void compile(char *, int);
extern void load_names(char *);
extern void cap_open(char *);
extern void cap_read(int, int, char *, int, void (*)(), int);
extern void initdevice(char *, ulong_t, ulong_t, struct timeval *,
		struct packetfilt *, int);
extern void net_read(int, int, void (*)(), int);
extern void click(int);
extern void show_pktinfo(int, int, char *, char *, struct timeval *,
		struct timeval *, int, int);
extern void show_line(char *);
extern char *getxdr_time(void);
extern char *showxdr_time(char *);
#else
extern char *get_sum_line();
extern char *get_detail_line();
extern struct timeval prev_time;
extern char *getflag();
extern void show_header();
extern void xdr_init();
extern char *get_line();
extern char getxdr_char();
extern char showxdr_char();
extern uchar_t getxdr_u_char();
extern uchar_t showxdr_u_char();
extern short getxdr_short();
extern short showxdr_short();
extern ushort_t getxdr_u_short();
extern ushort_t showxdr_u_short();
extern long getxdr_long();
extern long showxdr_long();
extern ulong_t getxdr_u_long();
extern ulong_t showxdr_u_long();
extern longlong_t getxdr_longlong();
extern longlong_t showxdr_longlong();
extern unsigned long long getxdr_u_longlong();
extern unsigned long long showxdr_u_longlong();
extern char *getxdr_opaque();
extern char *getxdr_string();
extern char *showxdr_string();
extern char *getxdr_bytes();
extern void xdr_skip();
extern int getxdr_pos();
extern void show_space();
extern void show_trailer();
extern char *getxdr_date();
extern char *showxdr_date();
extern char *showxdr_date_ns();
extern char *getxdr_hex();
extern char *showxdr_hex();
extern bool_t getxdr_bool();
extern bool_t showxdr_bool();
extern char *concat_args();
extern int pf_install();
extern int pf_compile();
extern void compile();
extern void load_names();
extern void cap_open();
extern void cap_read();
extern void initdevice();
extern void net_read();
extern void click();
extern void show_pktinfo();
extern void show_line();
extern char *getxdr_time();
extern char *showxdr_time();
#endif

/*
 * Describes characteristics of the Media Access Layer.
 * The mac_type is one of the supported DLPI media
 * types (see <sys/dlpi.h>).
 * The mtu_size is the size of the largest frame.
 * The header length is returned by a function to
 * allow for variable header size - for ethernet it's
 * just a constant 14 octets.
 * The interpreter is the function that "knows" how
 * to interpret the frame.
 */
typedef struct interface {
	uint_t	mac_type;
	uint_t	mtu_size;
	uint_t	(*header_len)(char *);
	uint_t 	(*interpreter)(int, char *, int, int);
	uint_t	mac_hdr_fixed_size;
} interface_t;

#define	IF_HDR_FIXED	0
#define	IF_HDR_VAR	1

extern interface_t INTERFACES[], *interface;

#ifdef __cplusplus
}
#endif

#endif	/* _SNOOP_H */
