Commit | Line | Data |
---|---|---|
15637ed4 RG |
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 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | |
18 | * 3. All advertising materials mentioning features or use of this software | |
19 | * must display the following acknowledgement: | |
20 | * This product includes software developed by the University of | |
21 | * California, Berkeley and its contributors. | |
22 | * 4. Neither the name of the University nor the names of its contributors | |
23 | * may be used to endorse or promote products derived from this software | |
24 | * without specific prior written permission. | |
25 | * | |
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
36 | * SUCH DAMAGE. | |
37 | * | |
1cdffd64 RG |
38 | * from: @(#)pk.h 7.8 (Berkeley) 4/30/91 |
39 | * $Id$ | |
15637ed4 RG |
40 | */ |
41 | ||
42 | /* | |
43 | * | |
44 | * X.25 Packet Level Definitions: | |
45 | * | |
46 | */ | |
47 | ||
48 | /* Packet type identifier field defintions. */ | |
49 | ||
50 | #define X25_CALL 11 | |
51 | #define X25_CALL_ACCEPTED 15 | |
52 | #define X25_CLEAR 19 | |
53 | #define X25_CLEAR_CONFIRM 23 | |
54 | #define X25_DATA 0 | |
55 | #define X25_INTERRUPT 35 | |
56 | #define X25_INTERRUPT_CONFIRM 39 | |
57 | ||
58 | #define X25_RR 1 | |
59 | #define X25_RNR 5 | |
60 | #define X25_REJECT 9 | |
61 | #define X25_RESET 27 | |
62 | #define X25_RESET_CONFIRM 31 | |
63 | #define X25_DIAGNOSTIC 241 | |
64 | ||
65 | #define X25_RESTART 251 | |
66 | #define X25_RESTART_CONFIRM 255 | |
67 | ||
68 | /* Restart cause field definitions. */ | |
69 | ||
70 | #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1 | |
71 | #define X25_RESTART_NETWORK_CONGESTION 3 | |
72 | #define X25_RESTART_NETWORK_OPERATIONAL 7 | |
73 | ||
74 | /* Miscellaneous definitions. */ | |
75 | ||
76 | #define DATA_PACKET_DESIGNATOR 0x01 | |
77 | #define RR_OR_RNR_PACKET_DESIGNATOR 0x02 | |
78 | #define RR_PACKET_DESIGNATOR 0x04 | |
79 | ||
80 | #define DEFAULT_WINDOW_SIZE 2 | |
81 | #define MODULUS 8 | |
82 | ||
83 | #define ADDRLN 1 | |
84 | #define MAXADDRLN 15 | |
85 | #define FACILITIESLN 1 | |
86 | #define MAXFACILITIESLN 10 | |
87 | #define MAXUSERDATA 16 | |
88 | #define MAXCALLINFOLN 1+15+1+10+16 | |
89 | ||
90 | #define PACKET_OK 0 | |
91 | #define IGNORE_PACKET 1 | |
92 | #define ERROR_PACKET 2 | |
93 | ||
94 | typedef char bool; | |
95 | #define FALSE 0 | |
96 | #define TRUE 1 | |
97 | ||
98 | /* | |
99 | * X.25 Packet format definitions | |
100 | * This will eventually have to be rewritten without reference | |
101 | * to bit fields, to be ansi C compliant and allignment safe. | |
102 | */ | |
103 | ||
104 | #if BYTE_ORDER == BIG_ENDIAN | |
105 | #define ORDER2(a, b) a , b | |
106 | #define ORDER4(a, b, c, d) a , b , c , d | |
107 | #endif | |
108 | ||
109 | #if BYTE_ORDER == LITTLE_ENDIAN | |
110 | #define ORDER2(a, b) b , a | |
111 | #define ORDER4(a, b, c, d) d , c , b , a | |
112 | #endif | |
113 | ||
114 | typedef u_char octet; | |
115 | ||
116 | struct x25_calladdr { | |
117 | octet ORDER2(calling_addrlen:4, called_addrlen:4); | |
118 | octet address_field[MAXADDRLN]; | |
119 | }; | |
120 | ||
121 | struct x25_packet { | |
122 | octet ORDER4(q_bit:1, d_bit:1, fmt_identifier:2, lc_group_number:4); | |
123 | octet logical_channel_number; | |
124 | octet packet_type; | |
125 | octet packet_data; | |
126 | }; | |
127 | ||
128 | struct data_packet { | |
129 | octet ORDER4(pr:3, m_bit:1, ps:3, z:1); | |
130 | }; | |
131 | ||
132 | #define FACILITIES_REVERSE_CHARGE 0x1 | |
133 | #define FACILITIES_THROUGHPUT 0x2 | |
134 | #define FACILITIES_PACKETSIZE 0x42 | |
135 | #define FACILITIES_WINDOWSIZE 0x43 | |
136 | ||
137 | #define PKHEADERLN 3 | |
138 | ||
139 | ||
140 | #define PR(xp) (((struct data_packet *)&xp -> packet_type)->pr) | |
141 | #define PS(xp) (((struct data_packet *)&xp -> packet_type)->ps) | |
142 | #define MBIT(xp) (((struct data_packet *)&xp -> packet_type)->m_bit) | |
143 | #define LCN(xp) (xp -> logical_channel_number + \ | |
144 | (xp -> lc_group_number ? (xp -> lc_group_number >> 8) : 0)) | |
145 | #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \ | |
146 | (xp -> lc_group_number = lcn > 255 ? lcn >> 8 : 0)) | |
147 | ||
148 | struct mbuf *pk_template (); | |
149 | ||
150 | /* Define X.25 packet level states. */ | |
151 | ||
152 | /* Call setup and clearing substates. */ | |
153 | ||
154 | #define LISTEN 0 | |
155 | #define READY 1 | |
156 | #define RECEIVED_CALL 2 | |
157 | #define SENT_CALL 3 | |
158 | #define DATA_TRANSFER 4 | |
159 | #define RECEIVED_CLEAR 5 | |
160 | #define SENT_CLEAR 6 | |
161 | ||
162 | /* DTE states. */ | |
163 | ||
164 | #define DTE_WAITING 7 | |
165 | #define DTE_RECEIVED_RESTART 8 | |
166 | #define DTE_SENT_RESTART 9 | |
167 | #define DTE_READY 0 | |
168 | ||
169 | #define MAXSTATES 10 | |
170 | ||
171 | /* | |
172 | * The following definitions are used in a switch statement after | |
173 | * determining the packet type. These values are returned by the | |
174 | * pk_decode procedure. | |
175 | */ | |
176 | ||
177 | #define CALL 0 * MAXSTATES | |
178 | #define CALL_ACCEPTED 1 * MAXSTATES | |
179 | #define CLEAR 2 * MAXSTATES | |
180 | #define CLEAR_CONF 3 * MAXSTATES | |
181 | #define DATA 4 * MAXSTATES | |
182 | #define INTERRUPT 5 * MAXSTATES | |
183 | #define INTERRUPT_CONF 6 * MAXSTATES | |
184 | #define RR 7 * MAXSTATES | |
185 | #define RNR 8 * MAXSTATES | |
186 | #define RESET 9 * MAXSTATES | |
187 | #define RESET_CONF 10 * MAXSTATES | |
188 | #define RESTART 11 * MAXSTATES | |
189 | #define RESTART_CONF 12 * MAXSTATES | |
190 | #define REJECT 13 * MAXSTATES | |
191 | #define DIAG_TYPE 14 * MAXSTATES | |
192 | #define INVALID_PACKET 15 * MAXSTATES | |
193 | #define DELETE_PACKET INVALID_PACKET |