xref: /original-bsd/sys/netccitt/pk_var.h (revision 89a39cb6)
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.5 (Berkeley) 06/21/90
13  */
14 
15 
16 /*
17  *
18  *  X.25 Logical Channel Descriptor
19  *
20  */
21 
22 struct pklcd {
23 	int	(*lcd_send)();		/* if X.25 front end, direct connect */
24 	int	(*lcd_upper)();		/* switch to socket vs datagram vs ...*/
25 	caddr_t	lcd_upnext;		/* reference for lcd_upper() */
26 	short   lcd_lcn;		/* Logical channel number */
27 	short   lcd_state;		/* Logical Channel state */
28         bool	lcd_intrconf_pending;	/* Interrupt confirmation pending */
29 	octet	lcd_intrdata;		/* Octet of incoming intr data */
30 	short   lcd_timer;		/* Various timer values */
31 	short   lcd_dg_timer;		/* to reclaim idle datagram circuits */
32 	char	lcd_retry;		/* Timer retry count */
33 	char	lcd_rsn;		/* Seq no of last received packet */
34 	char	lcd_ssn;		/* Seq no of next packet to send */
35 	char	lcd_output_window;	/* Output flow control window */
36 	char	lcd_input_window;	/* Input flow control window */
37 	char	lcd_last_transmitted_pr;/* Last Pr value transmitted */
38         bool	lcd_rnr_condition;	/* Remote in busy condition */
39         bool	lcd_window_condition;	/* Output window size exceeded */
40         bool	lcd_reset_condition;	/* True, if waiting reset confirm */
41 	char	lcd_packetsize;		/* Maximum packet size */
42 	char	lcd_windowsize;		/* Window size - both directions */
43         octet	lcd_closed_user_group;	/* Closed user group specification */
44 	char	lcd_flags;		/* copy of sockaddr_x25 op_flags */
45 	struct	x25_packet *lcd_template;/* Address of current packet */
46 	struct	socket *lcd_so;		/* Socket addr for connection */
47 	struct	sockaddr_x25 *lcd_craddr;/* Calling address pointer */
48 	struct	sockaddr_x25 *lcd_ceaddr;/* Called address pointer */
49 	time_t	lcd_stime;		/* time circuit established */
50 	long    lcd_txcnt;		/* Data packet transmit count */
51 	long    lcd_rxcnt;		/* Data packet receive count */
52 	short   lcd_intrcnt;		/* Interrupt packet transmit count */
53 	struct	pklcd *lcd_listen;	/* Next lcd on listen queue */
54 	struct	pkcb *lcd_pkp;		/* Network this lcd is attached to */
55 	struct	sockaddr_x25 lcd_faddr	/* Remote Address (Calling) */
56 	struct	sockaddr_x25 lcd_laddr	/* Local Address (Called) */
57 	struct	sockbuf lcd_sb;		/* alternate for datagram service */
58 };
59 
60 #define X25_DG_CIRCUIT	0x10		/* lcd_flag: used for datagrams */
61 #define X25_DG_ROUTING	0x20		/* lcd_flag: peer addr not yet known */
62 
63 /*
64  * Per network information, allocated dynamically
65  * when a new network is configured.
66  */
67 
68 struct	pkcb {
69 	struct	pkcb *pk_next;
70 	struct	x25_ifaddr *pk_ia;	/* backpointer to ifaddr */
71 	int	(*pk_lloutput) ();	/* link level output procedure */
72 	caddr_t pk_llnext;		/* handle for next level down */
73 	int	(*pk_start) ();		/* connect, confirm method */
74 	struct	x25config *pk_xcp;	/* network specific configuration */
75 	short	pk_state;		/* packet level status */
76 	struct	x25config pk_xc;	/* network specific configuration */
77 	struct	pklcd **pk_chan;	/* actual size == xc_maxlcn+1 */
78 #define	pk_maxlcn pk_xc.xc_maxlcn	/* local copy of xc_maxlcn */
79 };
80 /*
81  *	Interface address, x25 version. Exactly one of these structures is
82  *	allocated for each interface with an x25 address.
83  *
84  *	The ifaddr structure conatins the protocol-independent part
85  *	of the structure, and is assumed to be first.
86  */
87 struct x25_ifaddr {
88 	struct	ifaddr ia_ifa;		/* protocol-independent info */
89 #define ia_ifp		ia_ifa.ifa_ifp
90 #define	ia_flags	ia_ifa.ifa_flags
91 	struct	pkcb	ia_pkcb;	/* per network information */
92 #define ia_maxlcn	ia_pkcb.pk_maxlcn
93 #define ia_chan		ia_pkcb.pk_chan
94 #define	ia_addr		ia_pkcb.pk_xc.xc_addr
95 	struct	sockaddr_x25 ia_sockmask; /* reserve space for netmask */
96 };
97 
98 /*
99  * ``Link-Level'' extension to Routing Entry for upper level
100  * packet switching via X.25 virtual circuits.
101  */
102 struct rtextension_x25 {
103 	struct	pklcd *rtx_lcd;		/* local connection block */
104 	struct	rtentry *rtx_rt;	/* back pointer to route */
105 	struct	x25_ifaddr *rtx_ia;	/* may not be same as rt_ifa */
106 	int	rtx_state;		/* can't trust lcd->lcd_state */
107 	int	rtx_flags;
108 	int	rtx_timer;		/* for idle timeout */
109 };
110 
111 /* States for rtx_state */
112 #define XRS_NEWBORN		0
113 #define XRS_RESOLVING		1
114 #define XRS_FREE		2
115 #define XRS_CONNECTED		3
116 #define XRS_CONNECTING		4
117 #define XRS_DISCONNECTING 	5
118 
119 /* flags */
120 #define XRF_VALID	0x1		/* Circuit is live, etc. */
121 #define XRF_RTHELD	0x2		/* this lcb references rtentry */
122 
123 #ifdef KERNEL
124 struct	pkcb *pkcbhead;		/* head of linked list of networks */
125 struct	pklcd *pk_listenhead;
126 struct	pklcd *pk_attach();
127 
128 char	*pk_name[], *pk_state[];
129 int	pk_t20, pk_t21, pk_t22, pk_t23;
130 #endif
131