1 /* $NetBSD: tp_tpdu.h,v 1.10 2005/02/26 22:39:49 perry Exp $ */
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)tp_tpdu.h 8.1 (Berkeley) 6/10/93
34 /***********************************************************
35 Copyright IBM Corporation 1987
39 Permission to use, copy, modify, and distribute this software and its
40 documentation for any purpose and without fee is hereby granted,
41 provided that the above copyright notice appear in all copies and that
42 both that copyright notice and this permission notice appear in
43 supporting documentation, and that the name of IBM not be
44 used in advertising or publicity pertaining to distribution of the
45 software without specific, written prior permission.
47 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
48 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
49 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
50 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
51 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
52 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
55 ******************************************************************/
58 * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
61 * This ghastly set of macros makes it possible to refer to tpdu structures
65 #ifndef _NETISO_TP_TPDU_H_
66 #define _NETISO_TP_TPDU_H_
68 #include <machine/endian.h> /* for BYTE_ORDER */
71 * This much of a tpdu is the same for all types of tpdus (except DT tpdus
72 * in class 0; their exceptions are handled by the data structure below
75 u_char _tpduf_li
:8, /* length indicator */
76 #if BYTE_ORDER == LITTLE_ENDIAN
77 _tpduf_cdt
:4, /* credit */
78 _tpduf_type
:4; /* type of tpdu (DT, CR, etc.) */
80 #if BYTE_ORDER == BIG_ENDIAN
81 _tpduf_type
:4, /* type of tpdu (DT, CR, etc.) */
82 _tpduf_cdt
:4; /* credit */
84 u_short _tpduf_dref
; /* destination ref; not in DT in
88 #define tpdu_li _tpduf._tpduf_li
89 #define tpdu_type _tpduf._tpduf_type
90 #define tpdu_cdt _tpduf._tpduf_cdt
91 #define tpdu_dref _tpduf._tpduf_dref
94 u_char _tp0_li
, _tp0_cdt_type
, /* same as in tpdu_fixed */
95 #if BYTE_ORDER == BIG_ENDIAN
97 _tp0_mbz
:7, /* must be zero */
99 #if BYTE_ORDER == LITTLE_ENDIAN
100 _tp0_mbz
:7, /* must be zero */
101 _tp0_eot
:1, /* eot */
103 _tp0_notused
:8; /* data begins on this octet */
106 #define tp0du_eot _tp0_eot
107 #define tp0du_mbz _tp0_mbz
110 * This is used when the extended format seqence numbers are
111 * being sent and received.
114 * the seqeot field is an int that overlays the seq
115 * and eot fields, this allows the htonl operation
116 * to be applied to the entire 32 bit quantity, and
117 * simplifies the structure definitions.
121 #if BYTE_ORDER == BIG_ENDIAN
122 unsigned int st_eot
:1, /* end-of-tsdu */
123 st_seq
:31; /* 31 bit sequence number */
125 #if BYTE_ORDER == LITTLE_ENDIAN
126 unsigned int st_seq
:31, /* 31 bit sequence number */
127 st_eot
:1; /* end-of-tsdu */
130 unsigned int s_seqeot
;
131 #define s_eot st.st_eot
132 #define s_seq st.st_seq
136 * Then most tpdu types have a portion that is always present but differs
137 * among the tpdu types :
139 union tpdu_fixed_rest
{
142 u_short _tpdufr_sref
, /* source reference */
143 #if BYTE_ORDER == BIG_ENDIAN
144 _tpdufr_class
:4, /* class [ISO 8073 13.3.3.e] */
145 _tpdufr_opt
:4, /* options [ISO 8073 13.3.3.e] */
147 #if BYTE_ORDER == LITTLE_ENDIAN
148 _tpdufr_opt
:4, /* options [ISO 8073 13.3.3.e] */
149 _tpdufr_class
:4, /* class [ISO 8073 13.3.3.e] */
151 _tpdufr_xx
:8; /* unused */
154 #define tpdu_CRli _tpduf._tpduf_li
155 #define tpdu_CRtype _tpduf._tpduf_type
156 #define tpdu_CRcdt _tpduf._tpduf_cdt
157 #define tpdu_CRdref_0 _tpduf._tpduf_dref
158 #define tpdu_CRsref _tpdufr.CRCC._tpdufr_sref
159 #define tpdu_sref _tpdufr.CRCC._tpdufr_sref
160 #define tpdu_CRclass _tpdufr.CRCC._tpdufr_class
161 #define tpdu_CRoptions _tpdufr.CRCC._tpdufr_opt
163 #define tpdu_CCli _tpduf._tpduf_li
164 #define tpdu_CCtype _tpduf._tpduf_type
165 #define tpdu_CCcdt _tpduf._tpduf_cdt
166 #define tpdu_CCdref _tpduf._tpduf_dref
167 #define tpdu_CCsref _tpdufr.CRCC._tpdufr_sref
168 #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class
169 #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt
171 /* OPTIONS and ADDL OPTIONS bits */
172 #define TPO_USE_EFC 0x1
173 #define TPO_XTD_FMT 0x2
174 #define TPAO_USE_TXPD 0x1
175 #define TPAO_NO_CSUM 0x2
176 #define TPAO_USE_RCC 0x4
177 #define TPAO_USE_NXPD 0x8
180 unsigned short _tpdufr_sref
; /* source reference */
181 unsigned char _tpdufr_reason
; /* [ ISO 8073 13.5.3.d ] */
183 #define tpdu_DRli _tpduf._tpduf_li
184 #define tpdu_DRtype _tpduf._tpduf_type
185 #define tpdu_DRdref _tpduf._tpduf_dref
186 #define tpdu_DRsref _tpdufr.DR._tpdufr_sref
187 #define tpdu_DRreason _tpdufr.DR._tpdufr_reason
189 unsigned short _tpdufr_sref
; /* source reference */
191 #define tpdu_DCli _tpduf._tpduf_li
192 #define tpdu_DCtype _tpduf._tpduf_type
193 #define tpdu_DCdref _tpduf._tpduf_dref
194 #define tpdu_DCsref _tpdufr._tpdufr_sref
197 #if BYTE_ORDER == BIG_ENDIAN
198 unsigned char _tpdufr_eot
:1, /* end-of-tsdu */
199 _tpdufr_seq
:7; /* 7 bit sequence number */
201 #if BYTE_ORDER == LITTLE_ENDIAN
202 unsigned char _tpdufr_seq
:7, /* 7 bit sequence number */
203 _tpdufr_eot
:1; /* end-of-tsdu */
207 #if BYTE_ORDER == BIG_ENDIAN
208 unsigned int _tpdufr_Xeot
:1, /* end-of-tsdu */
209 _tpdufr_Xseq
:31; /* 31 bit sequence
212 #if BYTE_ORDER == LITTLE_ENDIAN
213 unsigned int _tpdufr_Xseq
:31, /* 31 bit sequence
215 _tpdufr_Xeot
:1; /* end-of-tsdu */
218 unsigned int _tpdufr_Xseqeot
;
219 #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot
221 #define tpdu_DTli _tpduf._tpduf_li
222 #define tpdu_DTtype _tpduf._tpduf_type
223 #define tpdu_DTdref _tpduf._tpduf_dref
224 #define tpdu_DTseq _tpdufr.SEQEOT._tpdufr_seq
225 #define tpdu_DTeot _tpdufr.SEQEOT._tpdufr_eot
226 #define tpdu_DTseqX _tpdufr.SEQEOT31._tpdufr_Xseq
227 #define tpdu_DTeotX _tpdufr.SEQEOT31._tpdufr_Xeot
229 #define tpdu_XPDli _tpduf._tpduf_li
230 #define tpdu_XPDtype _tpduf._tpduf_type
231 #define tpdu_XPDdref _tpduf._tpduf_dref
232 #define tpdu_XPDseq _tpdufr.SEQEOT._tpdufr_seq
233 #define tpdu_XPDeot _tpdufr.SEQEOT._tpdufr_eot
234 #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq
235 #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot
238 #if BYTE_ORDER == BIG_ENDIAN
239 unsigned _tpdufr_yrseq0
:1, /* always zero */
240 _tpdufr_yrseq
:31; /* [ ISO 8073 13.9.3.d ] */
242 #if BYTE_ORDER == LITTLE_ENDIAN
243 unsigned _tpdufr_yrseq
:31, /* [ ISO 8073 13.9.3.d ] */
244 _tpdufr_yrseq0
:1; /* always zero */
246 unsigned short _tpdufr_cdt
; /* [ ISO 8073 13.9.3.b ] */
249 #define tpdu_AKli _tpduf._tpduf_li
250 #define tpdu_AKtype _tpduf._tpduf_type
251 #define tpdu_AKdref _tpduf._tpduf_dref
252 #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq
253 #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq
254 /* location of cdt depends on size of seq. numbers */
255 #define tpdu_AKcdt _tpduf._tpduf_cdt
256 #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt
258 #define tpdu_XAKli _tpduf._tpduf_li
259 #define tpdu_XAKtype _tpduf._tpduf_type
260 #define tpdu_XAKdref _tpduf._tpduf_dref
261 #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq
262 #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq
264 unsigned char _tpdu_ERreason
; /* [ ISO 8073 13.12.3.c ] */
266 #define tpdu_ERli _tpduf._tpduf_li
267 #define tpdu_ERtype _tpduf._tpduf_type
268 #define tpdu_ERdref _tpduf._tpduf_dref
269 #define tpdu_ERreason _tpdufr._tpdu_ERreason
274 struct tpdu_fixed _tpduf
;
275 union tpdu_fixed_rest _tpdufr
;
278 #endif /* !_NETISO_TP_TPDU_H_ */