xref: /original-bsd/sys/netiso/tp_tpdu.h (revision c73c5200)
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 	u_char			_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 	u_short			_tpduf_dref;		/* 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 	u_char		_tp0_li,
80 				_tp0_cdt_type,		/* same as in tpdu_fixed */
81 #if BYTE_ORDER == BIG_ENDIAN
82 				_tp0_eot: 1,		/* eot */
83 				_tp0_mbz: 7,		/* must be zero */
84 #endif
85 #if BYTE_ORDER == LITTLE_ENDIAN
86 				_tp0_mbz: 7,		/* must be zero */
87 				_tp0_eot: 1,		/* eot */
88 #endif
89 				_tp0_notused: 8;	/* data begins on this octet */
90 };
91 
92 #define tp0du_eot _tp0_eot
93 #define tp0du_mbz _tp0_mbz
94 
95 /*
96  * This is used when the extended format seqence numbers are
97  * being sent and received.
98  */
99 				/*
100 				 * the seqeot field is an int that overlays the seq
101 				 * and eot fields, this allows the htonl operation
102 				 * to be applied to the entire 32 bit quantity, and
103 				 * simplifies the structure definitions.
104 				 */
105 union seq_type {
106 	struct {
107 #if BYTE_ORDER == BIG_ENDIAN
108 		unsigned int	st_eot:1,		/* end-of-tsdu */
109 				 		st_seq:31;		/* 31 bit sequence number */
110 #endif
111 #if BYTE_ORDER == LITTLE_ENDIAN
112 		unsigned int	st_seq:31,		/* 31 bit sequence number */
113 						st_eot:1;		/* end-of-tsdu */
114 #endif
115 	} st;
116 	unsigned int s_seqeot;
117 #define s_eot	st.st_eot
118 #define s_seq	st.st_seq
119 };
120 
121 /* Then most tpdu types have a portion that is always present but
122  * differs among the tpdu types :
123  */
124 union  tpdu_fixed_rest {
125 
126 		struct {
127 			u_short		_tpdufr_sref, 		/* source reference */
128 #if BYTE_ORDER == BIG_ENDIAN
129 						_tpdufr_class: 4,	/* class [ ISO 8073 13.3.3.e ] */
130 						_tpdufr_opt: 4,		/* options [ ISO 8073 13.3.3.e ] */
131 #endif
132 #if BYTE_ORDER == LITTLE_ENDIAN
133 						_tpdufr_opt: 4,		/* options [ ISO 8073 13.3.3.e ] */
134 						_tpdufr_class: 4,	/* class [ ISO 8073 13.3.3.e ] */
135 #endif
136 						_tpdufr_xx: 8;		/* unused */
137 		} CRCC;
138 
139 #define tpdu_CRli _tpduf._tpduf_li
140 #define tpdu_CRtype _tpduf._tpduf_type
141 #define tpdu_CRcdt _tpduf._tpduf_cdt
142 #define tpdu_CRdref_0 _tpduf._tpduf_dref
143 #define tpdu_CRsref _tpdufr.CRCC._tpdufr_sref
144 #define tpdu_sref _tpdufr.CRCC._tpdufr_sref
145 #define tpdu_CRclass _tpdufr.CRCC._tpdufr_class
146 #define tpdu_CRoptions _tpdufr.CRCC._tpdufr_opt
147 
148 #define tpdu_CCli _tpduf._tpduf_li
149 #define tpdu_CCtype _tpduf._tpduf_type
150 #define tpdu_CCcdt _tpduf._tpduf_cdt
151 #define tpdu_CCdref _tpduf._tpduf_dref
152 #define tpdu_CCsref _tpdufr.CRCC._tpdufr_sref
153 #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class
154 #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt
155 
156 /* OPTIONS and ADDL OPTIONS bits */
157 #define TPO_USE_EFC	 			0x1
158 #define TPO_XTD_FMT	 			0x2
159 #define TPAO_USE_TXPD 			0x1
160 #define TPAO_NO_CSUM 			0x2
161 #define TPAO_USE_RCC 			0x4
162 #define TPAO_USE_NXPD 			0x8
163 
164 		struct {
165 			unsigned short _tpdufr_sref;	/* source reference */
166 			unsigned char  _tpdufr_reason;	/* [ ISO 8073 13.5.3.d ] */
167 		} DR;
168 #define tpdu_DRli _tpduf._tpduf_li
169 #define tpdu_DRtype _tpduf._tpduf_type
170 #define tpdu_DRdref _tpduf._tpduf_dref
171 #define tpdu_DRsref _tpdufr.DR._tpdufr_sref
172 #define tpdu_DRreason _tpdufr.DR._tpdufr_reason
173 
174 		unsigned short _tpdufr_sref;	/* source reference */
175 
176 #define tpdu_DCli _tpduf._tpduf_li
177 #define tpdu_DCtype _tpduf._tpduf_type
178 #define tpdu_DCdref _tpduf._tpduf_dref
179 #define tpdu_DCsref _tpdufr._tpdufr_sref
180 
181 		struct {
182 #if BYTE_ORDER == BIG_ENDIAN
183 			unsigned char _tpdufr_eot:1,	/* end-of-tsdu */
184 						  _tpdufr_seq:7; 	/* 7 bit sequence number */
185 #endif
186 #if BYTE_ORDER == LITTLE_ENDIAN
187 			unsigned char	_tpdufr_seq:7, 	/* 7 bit sequence number */
188 							_tpdufr_eot:1;	/* end-of-tsdu */
189 #endif
190 		}SEQEOT;
191 		struct {
192 #if BYTE_ORDER == BIG_ENDIAN
193 			unsigned int	_tpdufr_Xeot:1,		/* end-of-tsdu */
194 					 		_tpdufr_Xseq:31;	/* 31 bit sequence number */
195 #endif
196 #if BYTE_ORDER == LITTLE_ENDIAN
197 			unsigned int	_tpdufr_Xseq:31,	/* 31 bit sequence number */
198 							_tpdufr_Xeot:1;		/* end-of-tsdu */
199 #endif
200 		}SEQEOT31;
201 		unsigned int _tpdufr_Xseqeot;
202 #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot
203 
204 #define tpdu_DTli _tpduf._tpduf_li
205 #define tpdu_DTtype _tpduf._tpduf_type
206 #define tpdu_DTdref _tpduf._tpduf_dref
207 #define tpdu_DTseq _tpdufr.SEQEOT._tpdufr_seq
208 #define tpdu_DTeot _tpdufr.SEQEOT._tpdufr_eot
209 #define tpdu_DTseqX _tpdufr.SEQEOT31._tpdufr_Xseq
210 #define tpdu_DTeotX _tpdufr.SEQEOT31._tpdufr_Xeot
211 
212 #define tpdu_XPDli _tpduf._tpduf_li
213 #define tpdu_XPDtype _tpduf._tpduf_type
214 #define tpdu_XPDdref _tpduf._tpduf_dref
215 #define tpdu_XPDseq _tpdufr.SEQEOT._tpdufr_seq
216 #define tpdu_XPDeot _tpdufr.SEQEOT._tpdufr_eot
217 #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq
218 #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot
219 
220 		struct {
221 #if BYTE_ORDER == BIG_ENDIAN
222 			unsigned	_tpdufr_yrseq0:1,	/* always zero */
223 						_tpdufr_yrseq:31; 	/* [ ISO 8073 13.9.3.d ] */
224 #endif
225 #if BYTE_ORDER == LITTLE_ENDIAN
226 			unsigned	_tpdufr_yrseq:31, 	/* [ ISO 8073 13.9.3.d ] */
227 						_tpdufr_yrseq0:1;	/* always zero */
228 #endif
229 			unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */
230 		} AK31;
231 
232 #define tpdu_AKli _tpduf._tpduf_li
233 #define tpdu_AKtype _tpduf._tpduf_type
234 #define tpdu_AKdref _tpduf._tpduf_dref
235 #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq
236 #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq
237 /* location of cdt depends on size of seq. numbers */
238 #define tpdu_AKcdt _tpduf._tpduf_cdt
239 #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt
240 
241 #define tpdu_XAKli _tpduf._tpduf_li
242 #define tpdu_XAKtype _tpduf._tpduf_type
243 #define tpdu_XAKdref _tpduf._tpduf_dref
244 #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq
245 #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq
246 
247 		unsigned char _tpdu_ERreason;  	/* [ ISO 8073 13.12.3.c ] */
248 
249 #define tpdu_ERli _tpduf._tpduf_li
250 #define tpdu_ERtype _tpduf._tpduf_type
251 #define tpdu_ERdref _tpduf._tpduf_dref
252 #define tpdu_ERreason _tpdufr._tpdu_ERreason
253 
254 };
255 
256 struct tpdu {
257 	struct	tpdu_fixed 		_tpduf;
258 	union 	tpdu_fixed_rest _tpdufr;
259 };
260 
261 #endif __TP_TPDU__
262