snoop.h revision 12819
162587Sitojun/*
295023Ssuz * Copyright (c) 1995 Ugen J.S.Antsilevich
362587Sitojun *
4139823Simp * Redistribution and use in source forms, with and without modification,
554263Sshin * are permitted provided that this entire comment appears intact.
654263Sshin *
754263Sshin * Redistribution in binary form may occur without any restrictions.
854263Sshin * Obviously, it would be nice if you gave credit where credit is due
954263Sshin * but requiring it would be too onerous.
1054263Sshin *
1154263Sshin * This software is provided ``AS IS'' without any warranties of any kind.
1254263Sshin *
1354263Sshin * Snoop stuff.
1454263Sshin */
1554263Sshin
1654263Sshin#ifndef _SNOOP_H_
1754263Sshin#define	_SNOOP_H_
1854263Sshin
1954263Sshin#define SNOOP_MINLEN		(4*1024)	/* This should be power of 2.
2054263Sshin						 * 4K tested to be the minimum
2154263Sshin						 * for which on normal tty
2254263Sshin						 * usage there is no need to
2354263Sshin						 * allocate more.
2454263Sshin						 */
2554263Sshin#define SNOOP_MAXLEN		(64*1024)	/* This one also,64K enough
2654263Sshin						 * If we grow more,something
2754263Sshin						 * really bad in this world..
2854263Sshin						 */
2954263Sshin
3054263Sshin/*
3154263Sshin * This is the main snoop per-device
3254263Sshin * structure...
3354263Sshin */
3454263Sshin
35101739Srwatsonstruct snoop {
3654263Sshin	dev_t		snp_target;	/* major/minor number of device*/
3754263Sshin	struct tty	*snp_tty;	/* tty device pointer	       */
3854263Sshin	u_long 		snp_len;	/* buffer data length	       */
3954263Sshin	u_long		snp_base;	/* buffer data base	       */
4054263Sshin	u_long		snp_blen;	/* Overall buffer len	       */
4154263Sshin	caddr_t		snp_buf;	/* Data buffer		       */
42129880Sphk	int 		snp_flags;	/* Flags place		       */
4354263Sshin#define SNOOP_NBIO		0x0001
4454263Sshin#define SNOOP_ASYNC		0x0002
4554263Sshin#define SNOOP_OPEN		0x0004
4654263Sshin#define SNOOP_RWAIT		0x0008
4791270Sbrooks#define SNOOP_OFLOW		0x0010
4854263Sshin#define SNOOP_DOWN		0x0020
4962587Sitojun	struct selinfo	snp_sel;	/* Selection info	       */
5079106Sbrooks};
5154263Sshin
5254263Sshin/*
5354263Sshin * Theese are snoop io controls
54130933Sbrooks * SNPSTTY accepts 'struct snptty' as input.
5554263Sshin * If ever type or  unit set to -1,snoop device
5654263Sshin * detached from it's current tty.
5754263Sshin */
5854263Sshin
5954263Sshin#define SNPSTTY       _IOW('T', 90, dev_t)
6054263Sshin#define SNPGTTY       _IOR('T', 89, dev_t)
6154263Sshin
6278064Sume/*
6378064Sume * Theese values would be returned by FIONREAD ioctl
6454263Sshin * instead of number of characters in buffer in case
6554263Sshin * of specific errors.
6679106Sbrooks */
6754263Sshin#define SNP_OFLOW		-1
6854263Sshin#define SNP_TTYCLOSE		-2
6954263Sshin#define SNP_DETACH		-3
7054263Sshin
7154263Sshin#ifdef KERNEL
7254263Sshin/* XXX several wrong storage classes and types here. */
7354263Sshinint	snpdown __P((struct snoop *snp));
7454263Sshinint	snpin __P((struct snoop *snp, char *buf, int n));
7554263Sshinint	snpinc __P((struct snoop *snp, char c));
76148385Sume#endif /* KERNEL */
7754263Sshin
7862587Sitojun#endif /* _SNOOP_H_ */
7954263Sshin