xref: /original-bsd/sys/netccitt/pk.h (revision 35274bea)
1 /*
2  * Copyright (c) University of British Columbia, 1984
3  * Copyright (c) 1990, 1992, 1993
4  *	The Regents of the University of California.  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.h	8.1 (Berkeley) 06/10/93
13  */
14 
15 /*
16  *
17  *  X.25 Packet Level Definitions:
18  *
19  */
20 
21 /* Packet type identifier field defintions. */
22 
23 #define X25_CALL                         11
24 #define X25_CALL_ACCEPTED                15
25 #define X25_CLEAR                        19
26 #define X25_CLEAR_CONFIRM                23
27 #define X25_DATA                          0
28 #define X25_INTERRUPT                    35
29 #define X25_INTERRUPT_CONFIRM            39
30 
31 #define X25_RR                            1
32 #define X25_RNR                           5
33 #define X25_REJECT			  9
34 #define X25_RESET                        27
35 #define X25_RESET_CONFIRM                31
36 #define X25_DIAGNOSTIC			241
37 
38 #define X25_RESTART                     251
39 #define X25_RESTART_CONFIRM		255
40 
41 /* Restart cause field definitions. */
42 
43 #define X25_RESTART_DTE_ORIGINATED	  0
44 #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1
45 #define X25_RESTART_NETWORK_CONGESTION	  3
46 #define X25_RESTART_NETWORK_OPERATIONAL	  7
47 #define X25_RESTART_DTE_ORIGINATED2	  128
48 
49 
50 /* Miscellaneous definitions. */
51 
52 #define DATA_PACKET_DESIGNATOR		0x01
53 #define RR_OR_RNR_PACKET_DESIGNATOR	0x02
54 #define RR_PACKET_DESIGNATOR		0x04
55 
56 #define DEFAULT_WINDOW_SIZE		2
57 #define MODULUS				8
58 
59 #define ADDRLN				1
60 #define MAXADDRLN			15
61 #define FACILITIESLN			1
62 #define MAXFACILITIESLN			10
63 #define MAXUSERDATA			16
64 #define MAXCALLINFOLN			1+15+1+10+16
65 
66 #define PACKET_OK			0
67 #define IGNORE_PACKET			1
68 #define ERROR_PACKET			2
69 
70 typedef char    bool;
71 #define FALSE	0
72 #define TRUE	1
73 
74 /*
75  *  X.25 Packet format definitions
76  *  This will eventually have to be rewritten without reference
77  *  to bit fields, to be ansi C compliant and allignment safe.
78  */
79 
80 typedef u_char octet;
81 
82 struct x25_calladdr {
83 	octet addrlens;
84 	octet address_field[MAXADDRLN];
85 };
86 
87 struct x25_packet {
88 	octet bits;
89 	octet logical_channel_number;
90 	octet packet_type;
91 	octet packet_data;
92 };
93 #define packet_cause packet_data
94 
95 struct data_packet {
96 	octet bits;
97 };
98 
99 #define FACILITIES_REVERSE_CHARGE	0x1
100 #define FACILITIES_THROUGHPUT		0x2
101 #define FACILITIES_PACKETSIZE		0x42
102 #define FACILITIES_WINDOWSIZE		0x43
103 
104 #define PKHEADERLN	3
105 
106 #define DP(xp)          (((struct data_packet *)&(xp) -> packet_type) -> bits)
107 #define PS(xp)           X25GBITS(DP(xp), p_s)
108 #define PR(xp)           X25GBITS(DP(xp), p_r)
109 #define MBIT(xp)         X25GBITS(DP(xp), m_bit)
110 #define SPR(xp, v)       X25SBITS(DP(xp), p_r, (v))
111 #define SPS(xp, v)       X25SBITS(DP(xp), p_s, (v))
112 #define SMBIT(xp, v)     X25SBITS(DP(xp), m_bit, (v))
113 
114 #define LCN(xp)		(xp -> logical_channel_number + \
115 	(X25GBITS(xp -> bits, lc_group_number) ? (X25GBITS(xp -> bits, lc_group_number) << 8) : 0))
116 #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \
117 	(X25SBITS(xp -> bits, lc_group_number, lcn > 255 ? lcn >> 8 : 0)))
118 
119 struct mbuf *pk_template ();
120 
121 /* Define X.25 packet level states. */
122 
123 /* Call setup and clearing substates.  */
124 
125 #define LISTEN           0
126 #define READY            1
127 #define RECEIVED_CALL    2
128 #define SENT_CALL        3
129 #define DATA_TRANSFER    4
130 #define RECEIVED_CLEAR   5
131 #define SENT_CLEAR       6
132 
133 /* DTE states. */
134 
135 #define DTE_WAITING		7
136 #define DTE_RECEIVED_RESTART	8
137 #define DTE_SENT_RESTART	9
138 #define DTE_READY		0
139 
140 /* Cleaning out ... */
141 
142 #define LCN_ZOMBIE 		10
143 
144 #define MAXSTATES		11
145 
146 /*
147  *  The following definitions are used in a switch statement after
148  *  determining the packet type.  These values are returned by the
149  *  pk_decode procedure.
150  */
151 
152 #define CALL             0 * MAXSTATES
153 #define CALL_ACCEPTED    1 * MAXSTATES
154 #define CLEAR            2 * MAXSTATES
155 #define CLEAR_CONF       3 * MAXSTATES
156 #define DATA             4 * MAXSTATES
157 #define INTERRUPT        5 * MAXSTATES
158 #define INTERRUPT_CONF   6 * MAXSTATES
159 #define RR               7 * MAXSTATES
160 #define RNR              8 * MAXSTATES
161 #define RESET            9 * MAXSTATES
162 #define RESET_CONF      10 * MAXSTATES
163 #define RESTART         11 * MAXSTATES
164 #define RESTART_CONF    12 * MAXSTATES
165 #define REJECT          13 * MAXSTATES
166 #define DIAG_TYPE       14 * MAXSTATES
167 #define INVALID_PACKET  15 * MAXSTATES
168 #define DELETE_PACKET	INVALID_PACKET
169 
170 /*
171  * The following definitions are used by the restart procedures
172  * for noting wether the PLE is supposed to behave as DTE or DCE
173  * (essentially necessary for operation over LLC2)
174  */
175 #define	DTE_DXERESOLVING	0x0001
176 #define	DTE_PLAYDTE		0x0002
177 #define	DTE_PLAYDCE		0x0004
178 #define DTE_CONNECTPENDING	0x0010
179 #define	DTE_PRETENDDTE		0x0020
180 
181 #define MAXRESTARTCOLLISIONS	10
182