xref: /original-bsd/sys/netccitt/pk_var.h (revision 403c148d)
1 /*
2  * Copyright (c) University of British Columbia, 1984
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Laboratory for Computation Vision and the Computer Science Department
8  * of the University of British Columbia.
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)pk_var.h	7.11 (Berkeley) 05/29/91
13  */
14 
15 
16 /*
17  *
18  *  X.25 Logical Channel Descriptor
19  *
20  */
21 
22 struct pklcd {
23 	struct 	pklcd_q {
24 		struct	pklcd_q *q_forw;	/* debugging chain */
25 		struct	pklcd_q *q_back;	/* debugging chain */
26 	} lcd_q;
27 	int	(*lcd_upper)();		/* switch to socket vs datagram vs ...*/
28 	caddr_t	lcd_upnext;		/* reference for lcd_upper() */
29 	int	(*lcd_send)();		/* if X.25 front end, direct connect */
30 	caddr_t lcd_downnext;		/* reference for lcd_send() */
31 	short   lcd_lcn;		/* Logical channel number */
32 	short   lcd_state;		/* Logical Channel state */
33 	short   lcd_timer;		/* Various timer values */
34 	short   lcd_dg_timer;		/* to reclaim idle datagram circuits */
35         bool	lcd_intrconf_pending;	/* Interrupt confirmation pending */
36 	octet	lcd_intrdata;		/* Octet of incoming intr data */
37 	char	lcd_retry;		/* Timer retry count */
38 	char	lcd_rsn;		/* Seq no of last received packet */
39 	char	lcd_ssn;		/* Seq no of next packet to send */
40 	char	lcd_output_window;	/* Output flow control window */
41 	char	lcd_input_window;	/* Input flow control window */
42 	char	lcd_last_transmitted_pr;/* Last Pr value transmitted */
43         bool	lcd_rnr_condition;	/* Remote in busy condition */
44         bool	lcd_window_condition;	/* Output window size exceeded */
45         bool	lcd_reset_condition;	/* True, if waiting reset confirm */
46 	bool	lcd_rxrnr_condition;	/* True, if we have sent rnr */
47 	char	lcd_packetsize;		/* Maximum packet size */
48 	char	lcd_windowsize;		/* Window size - both directions */
49         octet	lcd_closed_user_group;	/* Closed user group specification */
50 	char	lcd_flags;		/* copy of sockaddr_x25 op_flags */
51 	struct	mbuf *lcd_facilities;	/* user supplied facilities for cr */
52 	struct	mbuf *lcd_template;	/* Address of response packet */
53 	struct	socket *lcd_so;		/* Socket addr for connection */
54 	struct	sockaddr_x25 *lcd_craddr;/* Calling address pointer */
55 	struct	sockaddr_x25 *lcd_ceaddr;/* Called address pointer */
56 	time_t	lcd_stime;		/* time circuit established */
57 	long    lcd_txcnt;		/* Data packet transmit count */
58 	long    lcd_rxcnt;		/* Data packet receive count */
59 	short   lcd_intrcnt;		/* Interrupt packet transmit count */
60 	struct	pklcd *lcd_listen;	/* Next lcd on listen queue */
61 	struct	pkcb *lcd_pkp;		/* Network this lcd is attached to */
62 	struct	mbuf *lcd_cps;		/* Complete Packet Sequence reassembly*/
63 	long	lcd_cpsmax;		/* Max length for CPS */
64 	struct	sockaddr_x25 lcd_faddr;	/* Remote Address (Calling) */
65 	struct	sockaddr_x25 lcd_laddr;	/* Local Address (Called) */
66 	struct	sockbuf lcd_sb;		/* alternate for datagram service */
67 };
68 
69 /*
70  * Per network information, allocated dynamically
71  * when a new network is configured.
72  */
73 
74 struct	pkcb {
75 	struct	pkcb *pk_next;
76 	short	pk_state;		/* packet level status */
77 	short	pk_maxlcn;		/* local copy of xc_maxlcn */
78 	int	(*pk_lloutput) ();	/* link level output procedure */
79 	caddr_t pk_llnext;		/* handle for next level down */
80 	struct	x25config *pk_xcp;	/* network specific configuration */
81 	struct	x25_ifaddr *pk_ia;	/* backpointer to ifaddr */
82 	struct	pklcd **pk_chan;	/* actual size == xc_maxlcn+1 */
83 };
84 /*
85  *	Interface address, x25 version. Exactly one of these structures is
86  *	allocated for each interface with an x25 address.
87  *
88  *	The ifaddr structure conatins the protocol-independent part
89  *	of the structure, and is assumed to be first.
90  */
91 struct x25_ifaddr {
92 	struct	ifaddr ia_ifa;		/* protocol-independent info */
93 #define ia_ifp	ia_ifa.ifa_ifp
94 #define	ia_flags ia_ifa.ifa_flags
95 	struct	x25config ia_xc;	/* network specific configuration */
96 #define ia_maxlcn ia_xc.xc_maxlcn
97 	int	(*ia_start) ();		/* connect, confirm method */
98 	struct	sockaddr_x25 ia_dstaddr; /* reserve space for route dst */
99 };
100 
101 /*
102  * ``Link-Level'' extension to Routing Entry for upper level
103  * packet switching via X.25 virtual circuits.
104  */
105 struct llinfo_x25 {
106 	struct	llinfo_x25 *lx_next;	/* chain together in linked list */
107 	struct	llinfo_x25 *lx_prev;	/* chain together in linked list */
108 	struct	rtentry *lx_rt;		/* back pointer to route */
109 	struct	pklcd *lx_lcd;		/* local connection block */
110 	struct	x25_ifaddr *lx_ia;	/* may not be same as rt_ifa */
111 	int	lx_state;		/* can't trust lcd->lcd_state */
112 	int	lx_flags;
113 	int	lx_timer;		/* for idle timeout */
114 	int	lx_family;		/* for dispatch */
115 };
116 
117 /* States for lx_state */
118 #define LXS_NEWBORN		0
119 #define LXS_RESOLVING		1
120 #define LXS_FREE		2
121 #define LXS_CONNECTING		3
122 #define LXS_CONNECTED		4
123 #define LXS_DISCONNECTING 	5
124 #define LXS_LISTENING 		6
125 
126 /* flags */
127 #define LXF_VALID	0x1		/* Circuit is live, etc. */
128 #define LXF_RTHELD	0x2		/* this lcb references rtentry */
129 #define LXF_LISTEN	0x4		/* accepting incoming calls */
130 
131 /*
132  * miscellenous debugging info
133  */
134 struct mbuf_cache {
135 	int	mbc_size;
136 	int	mbc_num;
137 	int	mbc_oldsize;
138 	struct	mbuf **mbc_cache;
139 };
140 
141 #if defined(KERNEL) && defined(CCITT)
142 struct	pkcb *pkcbhead;		/* head of linked list of networks */
143 struct	pklcd *pk_listenhead;
144 struct	pklcd *pk_attach();
145 
146 extern char	*pk_name[], *pk_state[];
147 int	pk_t20, pk_t21, pk_t22, pk_t23;
148 #endif
149