xref: /original-bsd/sys/netccitt/pk_var.h (revision 963f8367)
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.10 (Berkeley) 05/09/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 	struct	x25_ifaddr *pk_ia;	/* backpointer to ifaddr */
77 	int	(*pk_lloutput) ();	/* link level output procedure */
78 	caddr_t pk_llnext;		/* handle for next level down */
79 	int	(*pk_start) ();		/* connect, confirm method */
80 	struct	x25config *pk_xcp;	/* network specific configuration */
81 	short	pk_state;		/* packet level status */
82 	struct	x25config pk_xc;	/* network specific configuration */
83 	struct	pklcd **pk_chan;	/* actual size == xc_maxlcn+1 */
84 #define	pk_maxlcn pk_xc.xc_maxlcn	/* local copy of xc_maxlcn */
85 };
86 /*
87  *	Interface address, x25 version. Exactly one of these structures is
88  *	allocated for each interface with an x25 address.
89  *
90  *	The ifaddr structure conatins the protocol-independent part
91  *	of the structure, and is assumed to be first.
92  */
93 struct x25_ifaddr {
94 	struct	ifaddr ia_ifa;		/* protocol-independent info */
95 #define ia_ifp		ia_ifa.ifa_ifp
96 #define	ia_flags	ia_ifa.ifa_flags
97 	struct	pkcb	ia_pkcb;	/* per network information */
98 #define ia_maxlcn	ia_pkcb.pk_maxlcn
99 #define ia_chan		ia_pkcb.pk_chan
100 #define ia_xc		ia_pkcb.pk_xc
101 #define ia_xcp		ia_pkcb.pk_xcp
102 	struct	sockaddr_x25 ia_sockmask; /* reserve space for netmask */
103 };
104 
105 /*
106  * ``Link-Level'' extension to Routing Entry for upper level
107  * packet switching via X.25 virtual circuits.
108  */
109 struct llinfo_x25 {
110 	struct	llinfo_x25 *lx_next;	/* chain together in linked list */
111 	struct	llinfo_x25 *lx_prev;	/* chain together in linked list */
112 	struct	rtentry *lx_rt;		/* back pointer to route */
113 	struct	pklcd *lx_lcd;		/* local connection block */
114 	struct	x25_ifaddr *lx_ia;	/* may not be same as rt_ifa */
115 	int	lx_state;		/* can't trust lcd->lcd_state */
116 	int	lx_flags;
117 	int	lx_timer;		/* for idle timeout */
118 	int	lx_family;		/* for dispatch */
119 };
120 
121 /* States for lx_state */
122 #define LXS_NEWBORN		0
123 #define LXS_RESOLVING		1
124 #define LXS_FREE		2
125 #define LXS_CONNECTED		3
126 #define LXS_CONNECTING		4
127 #define LXS_DISCONNECTING 	5
128 #define LXS_LISTENING 		6
129 
130 /* flags */
131 #define LXF_VALID	0x1		/* Circuit is live, etc. */
132 #define LXF_RTHELD	0x2		/* this lcb references rtentry */
133 #define LXF_LISTEN	0x4		/* accepting incoming calls */
134 
135 /*
136  * miscellenous debugging info
137  */
138 struct mbuf_cache {
139 	int	mbc_size;
140 	int	mbc_num;
141 	int	mbc_oldsize;
142 	struct	mbuf **mbc_cache;
143 };
144 
145 #if defined(KERNEL) && defined(CCITT)
146 struct	pkcb *pkcbhead;		/* head of linked list of networks */
147 struct	pklcd *pk_listenhead;
148 struct	pklcd *pk_attach();
149 
150 extern char	*pk_name[], *pk_state[];
151 int	pk_t20, pk_t21, pk_t22, pk_t23;
152 #endif
153