]> git.saurik.com Git - apple/xnu.git/blob - bsd/netiso/tp_tpdu.h
a94ea8fbca697d2a4322a7f5d4bb85693ae326f6
[apple/xnu.git] / bsd / netiso / tp_tpdu.h
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) 1991, 1993
24 * The Regents of the University of California. All rights reserved.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. All advertising materials mentioning features or use of this software
35 * must display the following acknowledgement:
36 * This product includes software developed by the University of
37 * California, Berkeley and its contributors.
38 * 4. Neither the name of the University nor the names of its contributors
39 * may be used to endorse or promote products derived from this software
40 * without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 *
54 * @(#)tp_tpdu.h 8.1 (Berkeley) 6/10/93
55 */
56
57 /***********************************************************
58 Copyright IBM Corporation 1987
59
60 All Rights Reserved
61
62 Permission to use, copy, modify, and distribute this software and its
63 documentation for any purpose and without fee is hereby granted,
64 provided that the above copyright notice appear in all copies and that
65 both that copyright notice and this permission notice appear in
66 supporting documentation, and that the name of IBM not be
67 used in advertising or publicity pertaining to distribution of the
68 software without specific, written prior permission.
69
70 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
71 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
72 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
73 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
74 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
75 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
76 SOFTWARE.
77
78 ******************************************************************/
79
80 /*
81 * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
82 */
83 /*
84 * ARGO TP
85 *
86 * This ghastly set of macros makes it possible to
87 * refer to tpdu structures without going mad.
88 */
89
90 #ifndef __TP_TPDU__
91 #define __TP_TPDU__
92
93 #ifndef BYTE_ORDER
94 /*
95 * Definitions for byte order,
96 * according to byte significance from low address to high.
97 */
98 #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
99 #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
100 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
101
102 #ifdef vax
103 #define BYTE_ORDER LITTLE_ENDIAN
104 #else
105 #define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */
106 #endif
107 #endif /* BYTE_ORDER */
108
109 /* This much of a tpdu is the same for all types of tpdus (except
110 * DT tpdus in class 0; their exceptions are handled by the data
111 * structure below
112 */
113 struct tpdu_fixed {
114 u_char _tpduf_li:8, /* length indicator */
115 #if BYTE_ORDER == LITTLE_ENDIAN
116 _tpduf_cdt: 4, /* credit */
117 _tpduf_type: 4; /* type of tpdu (DT, CR, etc.) */
118 #endif
119 #if BYTE_ORDER == BIG_ENDIAN
120 _tpduf_type: 4, /* type of tpdu (DT, CR, etc.) */
121 _tpduf_cdt: 4; /* credit */
122 #endif
123 u_short _tpduf_dref; /* destination ref; not in DT in class 0 */
124 };
125
126 #define tpdu_li _tpduf._tpduf_li
127 #define tpdu_type _tpduf._tpduf_type
128 #define tpdu_cdt _tpduf._tpduf_cdt
129 #define tpdu_dref _tpduf._tpduf_dref
130
131 struct tp0du {
132 u_char _tp0_li,
133 _tp0_cdt_type, /* same as in tpdu_fixed */
134 #if BYTE_ORDER == BIG_ENDIAN
135 _tp0_eot: 1, /* eot */
136 _tp0_mbz: 7, /* must be zero */
137 #endif
138 #if BYTE_ORDER == LITTLE_ENDIAN
139 _tp0_mbz: 7, /* must be zero */
140 _tp0_eot: 1, /* eot */
141 #endif
142 _tp0_notused: 8; /* data begins on this octet */
143 };
144
145 #define tp0du_eot _tp0_eot
146 #define tp0du_mbz _tp0_mbz
147
148 /*
149 * This is used when the extended format seqence numbers are
150 * being sent and received.
151 */
152 /*
153 * the seqeot field is an int that overlays the seq
154 * and eot fields, this allows the htonl operation
155 * to be applied to the entire 32 bit quantity, and
156 * simplifies the structure definitions.
157 */
158 union seq_type {
159 struct {
160 #if BYTE_ORDER == BIG_ENDIAN
161 unsigned int st_eot:1, /* end-of-tsdu */
162 st_seq:31; /* 31 bit sequence number */
163 #endif
164 #if BYTE_ORDER == LITTLE_ENDIAN
165 unsigned int st_seq:31, /* 31 bit sequence number */
166 st_eot:1; /* end-of-tsdu */
167 #endif
168 } st;
169 unsigned int s_seqeot;
170 #define s_eot st.st_eot
171 #define s_seq st.st_seq
172 };
173
174 /* Then most tpdu types have a portion that is always present but
175 * differs among the tpdu types :
176 */
177 union tpdu_fixed_rest {
178
179 struct {
180 u_short _tpdufr_sref, /* source reference */
181 #if BYTE_ORDER == BIG_ENDIAN
182 _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */
183 _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */
184 #endif
185 #if BYTE_ORDER == LITTLE_ENDIAN
186 _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */
187 _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */
188 #endif
189 _tpdufr_xx: 8; /* unused */
190 } CRCC;
191
192 #define tpdu_CRli _tpduf._tpduf_li
193 #define tpdu_CRtype _tpduf._tpduf_type
194 #define tpdu_CRcdt _tpduf._tpduf_cdt
195 #define tpdu_CRdref_0 _tpduf._tpduf_dref
196 #define tpdu_CRsref _tpdufr.CRCC._tpdufr_sref
197 #define tpdu_sref _tpdufr.CRCC._tpdufr_sref
198 #define tpdu_CRclass _tpdufr.CRCC._tpdufr_class
199 #define tpdu_CRoptions _tpdufr.CRCC._tpdufr_opt
200
201 #define tpdu_CCli _tpduf._tpduf_li
202 #define tpdu_CCtype _tpduf._tpduf_type
203 #define tpdu_CCcdt _tpduf._tpduf_cdt
204 #define tpdu_CCdref _tpduf._tpduf_dref
205 #define tpdu_CCsref _tpdufr.CRCC._tpdufr_sref
206 #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class
207 #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt
208
209 /* OPTIONS and ADDL OPTIONS bits */
210 #define TPO_USE_EFC 0x1
211 #define TPO_XTD_FMT 0x2
212 #define TPAO_USE_TXPD 0x1
213 #define TPAO_NO_CSUM 0x2
214 #define TPAO_USE_RCC 0x4
215 #define TPAO_USE_NXPD 0x8
216
217 struct {
218 unsigned short _tpdufr_sref; /* source reference */
219 unsigned char _tpdufr_reason; /* [ ISO 8073 13.5.3.d ] */
220 } DR;
221 #define tpdu_DRli _tpduf._tpduf_li
222 #define tpdu_DRtype _tpduf._tpduf_type
223 #define tpdu_DRdref _tpduf._tpduf_dref
224 #define tpdu_DRsref _tpdufr.DR._tpdufr_sref
225 #define tpdu_DRreason _tpdufr.DR._tpdufr_reason
226
227 unsigned short _tpdufr_sref; /* source reference */
228
229 #define tpdu_DCli _tpduf._tpduf_li
230 #define tpdu_DCtype _tpduf._tpduf_type
231 #define tpdu_DCdref _tpduf._tpduf_dref
232 #define tpdu_DCsref _tpdufr._tpdufr_sref
233
234 struct {
235 #if BYTE_ORDER == BIG_ENDIAN
236 unsigned char _tpdufr_eot:1, /* end-of-tsdu */
237 _tpdufr_seq:7; /* 7 bit sequence number */
238 #endif
239 #if BYTE_ORDER == LITTLE_ENDIAN
240 unsigned char _tpdufr_seq:7, /* 7 bit sequence number */
241 _tpdufr_eot:1; /* end-of-tsdu */
242 #endif
243 }SEQEOT;
244 struct {
245 #if BYTE_ORDER == BIG_ENDIAN
246 unsigned int _tpdufr_Xeot:1, /* end-of-tsdu */
247 _tpdufr_Xseq:31; /* 31 bit sequence number */
248 #endif
249 #if BYTE_ORDER == LITTLE_ENDIAN
250 unsigned int _tpdufr_Xseq:31, /* 31 bit sequence number */
251 _tpdufr_Xeot:1; /* end-of-tsdu */
252 #endif
253 }SEQEOT31;
254 unsigned int _tpdufr_Xseqeot;
255 #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot
256
257 #define tpdu_DTli _tpduf._tpduf_li
258 #define tpdu_DTtype _tpduf._tpduf_type
259 #define tpdu_DTdref _tpduf._tpduf_dref
260 #define tpdu_DTseq _tpdufr.SEQEOT._tpdufr_seq
261 #define tpdu_DTeot _tpdufr.SEQEOT._tpdufr_eot
262 #define tpdu_DTseqX _tpdufr.SEQEOT31._tpdufr_Xseq
263 #define tpdu_DTeotX _tpdufr.SEQEOT31._tpdufr_Xeot
264
265 #define tpdu_XPDli _tpduf._tpduf_li
266 #define tpdu_XPDtype _tpduf._tpduf_type
267 #define tpdu_XPDdref _tpduf._tpduf_dref
268 #define tpdu_XPDseq _tpdufr.SEQEOT._tpdufr_seq
269 #define tpdu_XPDeot _tpdufr.SEQEOT._tpdufr_eot
270 #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq
271 #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot
272
273 struct {
274 #if BYTE_ORDER == BIG_ENDIAN
275 unsigned _tpdufr_yrseq0:1, /* always zero */
276 _tpdufr_yrseq:31; /* [ ISO 8073 13.9.3.d ] */
277 #endif
278 #if BYTE_ORDER == LITTLE_ENDIAN
279 unsigned _tpdufr_yrseq:31, /* [ ISO 8073 13.9.3.d ] */
280 _tpdufr_yrseq0:1; /* always zero */
281 #endif
282 unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */
283 } AK31;
284
285 #define tpdu_AKli _tpduf._tpduf_li
286 #define tpdu_AKtype _tpduf._tpduf_type
287 #define tpdu_AKdref _tpduf._tpduf_dref
288 #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq
289 #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq
290 /* location of cdt depends on size of seq. numbers */
291 #define tpdu_AKcdt _tpduf._tpduf_cdt
292 #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt
293
294 #define tpdu_XAKli _tpduf._tpduf_li
295 #define tpdu_XAKtype _tpduf._tpduf_type
296 #define tpdu_XAKdref _tpduf._tpduf_dref
297 #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq
298 #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq
299
300 unsigned char _tpdu_ERreason; /* [ ISO 8073 13.12.3.c ] */
301
302 #define tpdu_ERli _tpduf._tpduf_li
303 #define tpdu_ERtype _tpduf._tpduf_type
304 #define tpdu_ERdref _tpduf._tpduf_dref
305 #define tpdu_ERreason _tpdufr._tpdu_ERreason
306
307 };
308
309 struct tpdu {
310 struct tpdu_fixed _tpduf;
311 union tpdu_fixed_rest _tpdufr;
312 };
313
314 #endif /* __TP_TPDU__ */