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