2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
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.
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.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
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.
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
59 * @(#)pk.h 8.1 (Berkeley) 6/10/93
64 * X.25 Packet Level Definitions:
68 /* Packet type identifier field defintions. */
71 #define X25_CALL_ACCEPTED 15
73 #define X25_CLEAR_CONFIRM 23
75 #define X25_INTERRUPT 35
76 #define X25_INTERRUPT_CONFIRM 39
82 #define X25_RESET_CONFIRM 31
83 #define X25_DIAGNOSTIC 241
85 #define X25_RESTART 251
86 #define X25_RESTART_CONFIRM 255
88 /* Restart cause field definitions. */
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
97 /* Miscellaneous definitions. */
99 #define DATA_PACKET_DESIGNATOR 0x01
100 #define RR_OR_RNR_PACKET_DESIGNATOR 0x02
101 #define RR_PACKET_DESIGNATOR 0x04
103 #define DEFAULT_WINDOW_SIZE 2
108 #define FACILITIESLN 1
109 #define MAXFACILITIESLN 10
110 #define MAXUSERDATA 16
111 #define MAXCALLINFOLN 1+15+1+10+16
114 #define IGNORE_PACKET 1
115 #define ERROR_PACKET 2
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.
127 typedef u_char octet
;
129 struct x25_calladdr
{
131 octet address_field
[MAXADDRLN
];
136 octet logical_channel_number
;
140 #define packet_cause packet_data
146 #define FACILITIES_REVERSE_CHARGE 0x1
147 #define FACILITIES_THROUGHPUT 0x2
148 #define FACILITIES_PACKETSIZE 0x42
149 #define FACILITIES_WINDOWSIZE 0x43
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))
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)))
166 struct mbuf
*pk_template ();
168 /* Define X.25 packet level states. */
170 /* Call setup and clearing substates. */
174 #define RECEIVED_CALL 2
176 #define DATA_TRANSFER 4
177 #define RECEIVED_CLEAR 5
182 #define DTE_WAITING 7
183 #define DTE_RECEIVED_RESTART 8
184 #define DTE_SENT_RESTART 9
187 /* Cleaning out ... */
189 #define LCN_ZOMBIE 10
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.
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
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)
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
228 #define MAXRESTARTCOLLISIONS 10