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