17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
237c478bdstevel@tonic-gate * Copyright 1992 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
287c478bdstevel@tonic-gate/*	  All Rights Reserved  	*/
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bdstevel@tonic-gate
337c478bdstevel@tonic-gate#define OLDPACKSIZE	128
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#define	PACKSIZE	64
367c478bdstevel@tonic-gate#define MINPACKSIZE	32
377c478bdstevel@tonic-gate#define MAXPACKSIZE   4096
387c478bdstevel@tonic-gate
397c478bdstevel@tonic-gate#define	WINDOWS		7
407c478bdstevel@tonic-gate#define	MINWINDOWS	1
417c478bdstevel@tonic-gate#define	MAXWINDOWS	7
427c478bdstevel@tonic-gate
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gatestruct header {
457c478bdstevel@tonic-gate	char	sync;
467c478bdstevel@tonic-gate	char	ksize;
477c478bdstevel@tonic-gate	unsigned short sum;
487c478bdstevel@tonic-gate	char	cntl;
497c478bdstevel@tonic-gate	char	ccntl;
507c478bdstevel@tonic-gate};
517c478bdstevel@tonic-gate#define	HDRSIZ	6
527c478bdstevel@tonic-gate
537c478bdstevel@tonic-gatestruct pack {
547c478bdstevel@tonic-gate	short	p_state;	/* line state */
557c478bdstevel@tonic-gate	short	p_bits;		/* mask for getepack */
567c478bdstevel@tonic-gate	short	p_rsize;	/* input packet size */
577c478bdstevel@tonic-gate	short	p_xsize;	/* output packet size */
587c478bdstevel@tonic-gate	struct	header p_ihbuf;	/* input header */
597c478bdstevel@tonic-gate	struct	header p_ohbuf; /* output header */
607c478bdstevel@tonic-gate	char	*p_rptr;
617c478bdstevel@tonic-gate	char	**p_ipool;
627c478bdstevel@tonic-gate	char	p_xcount;	/* # active output buffers */
637c478bdstevel@tonic-gate	char	p_rcount;
647c478bdstevel@tonic-gate	char	p_nout,p_tout;
657c478bdstevel@tonic-gate	char	p_lpsize;	/* log(psize/32) */
667c478bdstevel@tonic-gate	char	p_timer;
677c478bdstevel@tonic-gate	char	p_obusy;
687c478bdstevel@tonic-gate	char	p_srxmit;
697c478bdstevel@tonic-gate	char	p_rwindow;	/* window size */
707c478bdstevel@tonic-gate	char	p_swindow;
717c478bdstevel@tonic-gate	char	p_msg;		/* control msg */
727c478bdstevel@tonic-gate	char	p_rmsg;		/* repeated control msg */
737c478bdstevel@tonic-gate	char	p_ps,p_pr;	/* last packet sent, recv'd */
747c478bdstevel@tonic-gate	char	p_rpr;
757c478bdstevel@tonic-gate	char	p_nxtps;	/* next output seq number */
767c478bdstevel@tonic-gate	char	p_imap;		/* bit map of input buffers */
777c478bdstevel@tonic-gate	char	p_pscopy;	/* newest output packet */
787c478bdstevel@tonic-gate	char	*p_ob[8];	/* output buffers */
797c478bdstevel@tonic-gate	char	*p_ib[8];	/* input buffers */
807c478bdstevel@tonic-gate	char	p_os[8];	/* output buffer status */
817c478bdstevel@tonic-gate	char	p_is[8];	/* input buffer status */
827c478bdstevel@tonic-gate	short	p_osum[8];	/* output checksums */
837c478bdstevel@tonic-gate	short	p_isum[8];	/* input checksums */
847c478bdstevel@tonic-gate	int	p_ifn, p_ofn;
857c478bdstevel@tonic-gate};
867c478bdstevel@tonic-gate#define	CHECK	0125252
877c478bdstevel@tonic-gate#define	SYN	020
887c478bdstevel@tonic-gate#define	MOD8	7
897c478bdstevel@tonic-gate#define	ISCNTL(a)	((a & 0300)==0)
907c478bdstevel@tonic-gate#ifndef MIN
917c478bdstevel@tonic-gate#define	MIN(a,b)	((a<b)? a:b)
927c478bdstevel@tonic-gate#endif
937c478bdstevel@tonic-gate
947c478bdstevel@tonic-gateextern char	next[8];
957c478bdstevel@tonic-gateextern char	mask[8];
967c478bdstevel@tonic-gateextern int	npbits;
977c478bdstevel@tonic-gateextern int	pkactive;
987c478bdstevel@tonic-gateextern int	pkdebug;
997c478bdstevel@tonic-gateextern int	pksizes[];
1007c478bdstevel@tonic-gateextern struct pack *Pk;
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate/*
1037c478bdstevel@tonic-gate * driver state
1047c478bdstevel@tonic-gate */
1057c478bdstevel@tonic-gate#define	DEAD	0
1067c478bdstevel@tonic-gate#define	INITa	1
1077c478bdstevel@tonic-gate#define	INITb	2
1087c478bdstevel@tonic-gate#define	INITab	3
1097c478bdstevel@tonic-gate#define	LIVE	010
1107c478bdstevel@tonic-gate#define	RXMIT	020
1117c478bdstevel@tonic-gate#define	RREJ	040
1127c478bdstevel@tonic-gate#define PDEBUG	0200
1137c478bdstevel@tonic-gate#define	DRAINO	0400
1147c478bdstevel@tonic-gate#define	WAITO	01000
1157c478bdstevel@tonic-gate#define	DOWN	02000
1167c478bdstevel@tonic-gate#define	RCLOSE	04000
1177c478bdstevel@tonic-gate#define	BADFRAME 020000
1187c478bdstevel@tonic-gate
1197c478bdstevel@tonic-gate/*
1207c478bdstevel@tonic-gate * io buffer states
1217c478bdstevel@tonic-gate */
1227c478bdstevel@tonic-gate#define	B_NULL	0
1237c478bdstevel@tonic-gate#define	B_READY	1
1247c478bdstevel@tonic-gate#define	B_SENT	2
1257c478bdstevel@tonic-gate#define	B_RESID	010
1267c478bdstevel@tonic-gate#define	B_COPY	020
1277c478bdstevel@tonic-gate#define	B_MARK	040
1287c478bdstevel@tonic-gate#define	B_SHORT	0100
1297c478bdstevel@tonic-gate
1307c478bdstevel@tonic-gate/*
1317c478bdstevel@tonic-gate * control messages
1327c478bdstevel@tonic-gate */
1337c478bdstevel@tonic-gate#define	CLOSE	1
1347c478bdstevel@tonic-gate#define	RJ	2
1357c478bdstevel@tonic-gate/* #define	SRJ	3 */	/* not supported */
1367c478bdstevel@tonic-gate#define	RR	4
1377c478bdstevel@tonic-gate#define	INITC	5
1387c478bdstevel@tonic-gate#define	INITB	6
1397c478bdstevel@tonic-gate#define	INITA	7
1407c478bdstevel@tonic-gate
1417c478bdstevel@tonic-gate#define	M_RJ	4
1427c478bdstevel@tonic-gate/* #define	M_SRJ	010 */	/* not used */
1437c478bdstevel@tonic-gate#define	M_RR	020
1447c478bdstevel@tonic-gate#define	M_INITC	040
1457c478bdstevel@tonic-gate#define	M_CLOSE	2
1467c478bdstevel@tonic-gate#define	M_INITA	0200
1477c478bdstevel@tonic-gate#define	M_INITB	0100
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gate/*
1507c478bdstevel@tonic-gate * packet ioctl buf
1517c478bdstevel@tonic-gate */
1527c478bdstevel@tonic-gatestruct	piocb {
1537c478bdstevel@tonic-gate	unsigned t;
1547c478bdstevel@tonic-gate	short	psize;
1557c478bdstevel@tonic-gate	short	mode;
1567c478bdstevel@tonic-gate	short	state;
1577c478bdstevel@tonic-gate	char	window;
1587c478bdstevel@tonic-gate};
159