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