]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) University of British Columbia, 1984 | |
24 | * Copyright (c) 1990, 1992, 1993 | |
25 | * The Regents of the University of California. All rights reserved. | |
26 | * | |
27 | * This code is derived from software contributed to Berkeley by | |
28 | * the Laboratory for Computation Vision and the Computer Science Department | |
29 | * of the University of British Columbia. | |
30 | * | |
31 | * Redistribution and use in source and binary forms, with or without | |
32 | * modification, are permitted provided that the following conditions | |
33 | * are met: | |
34 | * 1. Redistributions of source code must retain the above copyright | |
35 | * notice, this list of conditions and the following disclaimer. | |
36 | * 2. Redistributions in binary form must reproduce the above copyright | |
37 | * notice, this list of conditions and the following disclaimer in the | |
38 | * documentation and/or other materials provided with the distribution. | |
39 | * 3. All advertising materials mentioning features or use of this software | |
40 | * must display the following acknowledgement: | |
41 | * This product includes software developed by the University of | |
42 | * California, Berkeley and its contributors. | |
43 | * 4. Neither the name of the University nor the names of its contributors | |
44 | * may be used to endorse or promote products derived from this software | |
45 | * without specific prior written permission. | |
46 | * | |
47 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
48 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
50 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
53 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
55 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
56 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
57 | * SUCH DAMAGE. | |
58 | * | |
59 | * @(#)pk.h 8.1 (Berkeley) 6/10/93 | |
60 | */ | |
61 | ||
62 | /* | |
63 | * | |
64 | * X.25 Packet Level Definitions: | |
65 | * | |
66 | */ | |
67 | ||
68 | /* Packet type identifier field defintions. */ | |
69 | ||
70 | #define X25_CALL 11 | |
71 | #define X25_CALL_ACCEPTED 15 | |
72 | #define X25_CLEAR 19 | |
73 | #define X25_CLEAR_CONFIRM 23 | |
74 | #define X25_DATA 0 | |
75 | #define X25_INTERRUPT 35 | |
76 | #define X25_INTERRUPT_CONFIRM 39 | |
77 | ||
78 | #define X25_RR 1 | |
79 | #define X25_RNR 5 | |
80 | #define X25_REJECT 9 | |
81 | #define X25_RESET 27 | |
82 | #define X25_RESET_CONFIRM 31 | |
83 | #define X25_DIAGNOSTIC 241 | |
84 | ||
85 | #define X25_RESTART 251 | |
86 | #define X25_RESTART_CONFIRM 255 | |
87 | ||
88 | /* Restart cause field definitions. */ | |
89 | ||
90 | #define X25_RESTART_DTE_ORIGINATED 0 | |
91 | #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1 | |
92 | #define X25_RESTART_NETWORK_CONGESTION 3 | |
93 | #define X25_RESTART_NETWORK_OPERATIONAL 7 | |
94 | #define X25_RESTART_DTE_ORIGINATED2 128 | |
95 | ||
96 | ||
97 | /* Miscellaneous definitions. */ | |
98 | ||
99 | #define DATA_PACKET_DESIGNATOR 0x01 | |
100 | #define RR_OR_RNR_PACKET_DESIGNATOR 0x02 | |
101 | #define RR_PACKET_DESIGNATOR 0x04 | |
102 | ||
103 | #define DEFAULT_WINDOW_SIZE 2 | |
104 | #define MODULUS 8 | |
105 | ||
106 | #define ADDRLN 1 | |
107 | #define MAXADDRLN 15 | |
108 | #define FACILITIESLN 1 | |
109 | #define MAXFACILITIESLN 10 | |
110 | #define MAXUSERDATA 16 | |
111 | #define MAXCALLINFOLN 1+15+1+10+16 | |
112 | ||
113 | #define PACKET_OK 0 | |
114 | #define IGNORE_PACKET 1 | |
115 | #define ERROR_PACKET 2 | |
116 | ||
117 | typedef char bool; | |
118 | #define FALSE 0 | |
119 | #define TRUE 1 | |
120 | ||
121 | /* | |
122 | * X.25 Packet format definitions | |
123 | * This will eventually have to be rewritten without reference | |
124 | * to bit fields, to be ansi C compliant and allignment safe. | |
125 | */ | |
126 | ||
127 | typedef u_char octet; | |
128 | ||
129 | struct x25_calladdr { | |
130 | octet addrlens; | |
131 | octet address_field[MAXADDRLN]; | |
132 | }; | |
133 | ||
134 | struct x25_packet { | |
135 | octet bits; | |
136 | octet logical_channel_number; | |
137 | octet packet_type; | |
138 | octet packet_data; | |
139 | }; | |
140 | #define packet_cause packet_data | |
141 | ||
142 | struct data_packet { | |
143 | octet bits; | |
144 | }; | |
145 | ||
146 | #define FACILITIES_REVERSE_CHARGE 0x1 | |
147 | #define FACILITIES_THROUGHPUT 0x2 | |
148 | #define FACILITIES_PACKETSIZE 0x42 | |
149 | #define FACILITIES_WINDOWSIZE 0x43 | |
150 | ||
151 | #define PKHEADERLN 3 | |
152 | ||
153 | #define DP(xp) (((struct data_packet *)&(xp) -> packet_type) -> bits) | |
154 | #define PS(xp) X25GBITS(DP(xp), p_s) | |
155 | #define PR(xp) X25GBITS(DP(xp), p_r) | |
156 | #define MBIT(xp) X25GBITS(DP(xp), m_bit) | |
157 | #define SPR(xp, v) X25SBITS(DP(xp), p_r, (v)) | |
158 | #define SPS(xp, v) X25SBITS(DP(xp), p_s, (v)) | |
159 | #define SMBIT(xp, v) X25SBITS(DP(xp), m_bit, (v)) | |
160 | ||
161 | #define LCN(xp) (xp -> logical_channel_number + \ | |
162 | (X25GBITS(xp -> bits, lc_group_number) ? (X25GBITS(xp -> bits, lc_group_number) << 8) : 0)) | |
163 | #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \ | |
164 | (X25SBITS(xp -> bits, lc_group_number, lcn > 255 ? lcn >> 8 : 0))) | |
165 | ||
166 | struct mbuf *pk_template (); | |
167 | ||
168 | /* Define X.25 packet level states. */ | |
169 | ||
170 | /* Call setup and clearing substates. */ | |
171 | ||
172 | #define LISTEN 0 | |
173 | #define READY 1 | |
174 | #define RECEIVED_CALL 2 | |
175 | #define SENT_CALL 3 | |
176 | #define DATA_TRANSFER 4 | |
177 | #define RECEIVED_CLEAR 5 | |
178 | #define SENT_CLEAR 6 | |
179 | ||
180 | /* DTE states. */ | |
181 | ||
182 | #define DTE_WAITING 7 | |
183 | #define DTE_RECEIVED_RESTART 8 | |
184 | #define DTE_SENT_RESTART 9 | |
185 | #define DTE_READY 0 | |
186 | ||
187 | /* Cleaning out ... */ | |
188 | ||
189 | #define LCN_ZOMBIE 10 | |
190 | ||
191 | #define MAXSTATES 11 | |
192 | ||
193 | /* | |
194 | * The following definitions are used in a switch statement after | |
195 | * determining the packet type. These values are returned by the | |
196 | * pk_decode procedure. | |
197 | */ | |
198 | ||
199 | #define CALL 0 * MAXSTATES | |
200 | #define CALL_ACCEPTED 1 * MAXSTATES | |
201 | #define CLEAR 2 * MAXSTATES | |
202 | #define CLEAR_CONF 3 * MAXSTATES | |
203 | #define DATA 4 * MAXSTATES | |
204 | #define INTERRUPT 5 * MAXSTATES | |
205 | #define INTERRUPT_CONF 6 * MAXSTATES | |
206 | #define RR 7 * MAXSTATES | |
207 | #define RNR 8 * MAXSTATES | |
208 | #define RESET 9 * MAXSTATES | |
209 | #define RESET_CONF 10 * MAXSTATES | |
210 | #define RESTART 11 * MAXSTATES | |
211 | #define RESTART_CONF 12 * MAXSTATES | |
212 | #define REJECT 13 * MAXSTATES | |
213 | #define DIAG_TYPE 14 * MAXSTATES | |
214 | #define INVALID_PACKET 15 * MAXSTATES | |
215 | #define DELETE_PACKET INVALID_PACKET | |
216 | ||
217 | /* | |
218 | * The following definitions are used by the restart procedures | |
219 | * for noting wether the PLE is supposed to behave as DTE or DCE | |
220 | * (essentially necessary for operation over LLC2) | |
221 | */ | |
222 | #define DTE_DXERESOLVING 0x0001 | |
223 | #define DTE_PLAYDTE 0x0002 | |
224 | #define DTE_PLAYDCE 0x0004 | |
225 | #define DTE_CONNECTPENDING 0x0010 | |
226 | #define DTE_PRETENDDTE 0x0020 | |
227 | ||
228 | #define MAXRESTARTCOLLISIONS 10 |