| 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 | * @(#)tp_tpdu.h 7.3 (Berkeley) %G% * |
| 33 | * |
| 34 | * This ghastly set of macros makes it possible to |
| 35 | * refer to tpdu structures without going mad. |
| 36 | */ |
| 37 | |
| 38 | #ifndef __TP_TPDU__ |
| 39 | #define __TP_TPDU__ |
| 40 | |
| 41 | #ifndef BYTE_ORDER |
| 42 | /* |
| 43 | * Definitions for byte order, |
| 44 | * according to byte significance from low address to high. |
| 45 | */ |
| 46 | #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ |
| 47 | #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ |
| 48 | #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ |
| 49 | |
| 50 | #ifdef vax |
| 51 | #define BYTE_ORDER LITTLE_ENDIAN |
| 52 | #else |
| 53 | #define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */ |
| 54 | #endif |
| 55 | #endif BYTE_ORDER |
| 56 | |
| 57 | /* This much of a tpdu is the same for all types of tpdus (except |
| 58 | * DT tpdus in class 0; their exceptions are handled by the data |
| 59 | * structure below |
| 60 | */ |
| 61 | struct tpdu_fixed { |
| 62 | u_char _tpduf_li:8, /* length indicator */ |
| 63 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 64 | _tpduf_cdt: 4, /* credit */ |
| 65 | _tpduf_type: 4; /* type of tpdu (DT, CR, etc.) */ |
| 66 | #endif |
| 67 | #if BYTE_ORDER == BIG_ENDIAN |
| 68 | _tpduf_type: 4, /* type of tpdu (DT, CR, etc.) */ |
| 69 | _tpduf_cdt: 4; /* credit */ |
| 70 | #endif |
| 71 | u_short _tpduf_dref; /* destination ref; not in DT in class 0 */ |
| 72 | }; |
| 73 | |
| 74 | #define tpdu_li _tpduf._tpduf_li |
| 75 | #define tpdu_type _tpduf._tpduf_type |
| 76 | #define tpdu_cdt _tpduf._tpduf_cdt |
| 77 | #define tpdu_dref _tpduf._tpduf_dref |
| 78 | |
| 79 | struct tp0du { |
| 80 | u_char _tp0_li, |
| 81 | _tp0_cdt_type, /* same as in tpdu_fixed */ |
| 82 | #if BYTE_ORDER == BIG_ENDIAN |
| 83 | _tp0_eot: 1, /* eot */ |
| 84 | _tp0_mbz: 7, /* must be zero */ |
| 85 | #endif |
| 86 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 87 | _tp0_mbz: 7, /* must be zero */ |
| 88 | _tp0_eot: 1, /* eot */ |
| 89 | #endif |
| 90 | _tp0_notused: 8; /* data begins on this octet */ |
| 91 | }; |
| 92 | |
| 93 | #define tp0du_eot _tp0_eot |
| 94 | #define tp0du_mbz _tp0_mbz |
| 95 | |
| 96 | /* |
| 97 | * This is used when the extended format seqence numbers are |
| 98 | * being sent and received. |
| 99 | */ |
| 100 | /* |
| 101 | * the seqeot field is an int that overlays the seq |
| 102 | * and eot fields, this allows the htonl operation |
| 103 | * to be applied to the entire 32 bit quantity, and |
| 104 | * simplifies the structure definitions. |
| 105 | */ |
| 106 | union seq_type { |
| 107 | struct { |
| 108 | #if BYTE_ORDER == BIG_ENDIAN |
| 109 | unsigned int st_eot:1, /* end-of-tsdu */ |
| 110 | st_seq:31; /* 31 bit sequence number */ |
| 111 | #endif |
| 112 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 113 | unsigned int st_seq:31, /* 31 bit sequence number */ |
| 114 | st_eot:1; /* end-of-tsdu */ |
| 115 | #endif |
| 116 | } st; |
| 117 | unsigned int s_seqeot; |
| 118 | #define s_eot st.st_eot |
| 119 | #define s_seq st.st_seq |
| 120 | }; |
| 121 | |
| 122 | /* Then most tpdu types have a portion that is always present but |
| 123 | * differs among the tpdu types : |
| 124 | */ |
| 125 | union tpdu_fixed_rest { |
| 126 | |
| 127 | struct { |
| 128 | u_short _tpdufr_sref, /* source reference */ |
| 129 | #if BYTE_ORDER == BIG_ENDIAN |
| 130 | _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */ |
| 131 | _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */ |
| 132 | #endif |
| 133 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 134 | _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */ |
| 135 | _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */ |
| 136 | #endif |
| 137 | _tpdufr_xx: 8; /* unused */ |
| 138 | } CRCC; |
| 139 | |
| 140 | #define tpdu_CRli _tpduf._tpduf_li |
| 141 | #define tpdu_CRtype _tpduf._tpduf_type |
| 142 | #define tpdu_CRcdt _tpduf._tpduf_cdt |
| 143 | #define tpdu_CRdref_0 _tpduf._tpduf_dref |
| 144 | #define tpdu_CRsref _tpdufr.CRCC._tpdufr_sref |
| 145 | #define tpdu_sref _tpdufr.CRCC._tpdufr_sref |
| 146 | #define tpdu_CRclass _tpdufr.CRCC._tpdufr_class |
| 147 | #define tpdu_CRoptions _tpdufr.CRCC._tpdufr_opt |
| 148 | |
| 149 | #define tpdu_CCli _tpduf._tpduf_li |
| 150 | #define tpdu_CCtype _tpduf._tpduf_type |
| 151 | #define tpdu_CCcdt _tpduf._tpduf_cdt |
| 152 | #define tpdu_CCdref _tpduf._tpduf_dref |
| 153 | #define tpdu_CCsref _tpdufr.CRCC._tpdufr_sref |
| 154 | #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class |
| 155 | #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt |
| 156 | |
| 157 | /* OPTIONS and ADDL OPTIONS bits */ |
| 158 | #define TPO_USE_EFC 0x1 |
| 159 | #define TPO_XTD_FMT 0x2 |
| 160 | #define TPAO_USE_TXPD 0x1 |
| 161 | #define TPAO_NO_CSUM 0x2 |
| 162 | #define TPAO_USE_RCC 0x4 |
| 163 | #define TPAO_USE_NXPD 0x8 |
| 164 | |
| 165 | struct { |
| 166 | unsigned short _tpdufr_sref; /* source reference */ |
| 167 | unsigned char _tpdufr_reason; /* [ ISO 8073 13.5.3.d ] */ |
| 168 | } DR; |
| 169 | #define tpdu_DRli _tpduf._tpduf_li |
| 170 | #define tpdu_DRtype _tpduf._tpduf_type |
| 171 | #define tpdu_DRdref _tpduf._tpduf_dref |
| 172 | #define tpdu_DRsref _tpdufr.DR._tpdufr_sref |
| 173 | #define tpdu_DRreason _tpdufr.DR._tpdufr_reason |
| 174 | |
| 175 | unsigned short _tpdufr_sref; /* source reference */ |
| 176 | |
| 177 | #define tpdu_DCli _tpduf._tpduf_li |
| 178 | #define tpdu_DCtype _tpduf._tpduf_type |
| 179 | #define tpdu_DCdref _tpduf._tpduf_dref |
| 180 | #define tpdu_DCsref _tpdufr._tpdufr_sref |
| 181 | |
| 182 | struct { |
| 183 | #if BYTE_ORDER == BIG_ENDIAN |
| 184 | unsigned char _tpdufr_eot:1, /* end-of-tsdu */ |
| 185 | _tpdufr_seq:7; /* 7 bit sequence number */ |
| 186 | #endif |
| 187 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 188 | unsigned char _tpdufr_seq:7, /* 7 bit sequence number */ |
| 189 | _tpdufr_eot:1; /* end-of-tsdu */ |
| 190 | #endif |
| 191 | }SEQEOT; |
| 192 | struct { |
| 193 | #if BYTE_ORDER == BIG_ENDIAN |
| 194 | unsigned int _tpdufr_Xeot:1, /* end-of-tsdu */ |
| 195 | _tpdufr_Xseq:31; /* 31 bit sequence number */ |
| 196 | #endif |
| 197 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 198 | unsigned int _tpdufr_Xseq:31, /* 31 bit sequence number */ |
| 199 | _tpdufr_Xeot:1; /* end-of-tsdu */ |
| 200 | #endif |
| 201 | }SEQEOT31; |
| 202 | unsigned int _tpdufr_Xseqeot; |
| 203 | #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot |
| 204 | |
| 205 | #define tpdu_DTli _tpduf._tpduf_li |
| 206 | #define tpdu_DTtype _tpduf._tpduf_type |
| 207 | #define tpdu_DTdref _tpduf._tpduf_dref |
| 208 | #define tpdu_DTseq _tpdufr.SEQEOT._tpdufr_seq |
| 209 | #define tpdu_DTeot _tpdufr.SEQEOT._tpdufr_eot |
| 210 | #define tpdu_DTseqX _tpdufr.SEQEOT31._tpdufr_Xseq |
| 211 | #define tpdu_DTeotX _tpdufr.SEQEOT31._tpdufr_Xeot |
| 212 | |
| 213 | #define tpdu_XPDli _tpduf._tpduf_li |
| 214 | #define tpdu_XPDtype _tpduf._tpduf_type |
| 215 | #define tpdu_XPDdref _tpduf._tpduf_dref |
| 216 | #define tpdu_XPDseq _tpdufr.SEQEOT._tpdufr_seq |
| 217 | #define tpdu_XPDeot _tpdufr.SEQEOT._tpdufr_eot |
| 218 | #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq |
| 219 | #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot |
| 220 | |
| 221 | struct { |
| 222 | #if BYTE_ORDER == BIG_ENDIAN |
| 223 | unsigned _tpdufr_yrseq0:1, /* always zero */ |
| 224 | _tpdufr_yrseq:31; /* [ ISO 8073 13.9.3.d ] */ |
| 225 | #endif |
| 226 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 227 | unsigned _tpdufr_yrseq:31, /* [ ISO 8073 13.9.3.d ] */ |
| 228 | _tpdufr_yrseq0:1; /* always zero */ |
| 229 | #endif |
| 230 | unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */ |
| 231 | } AK31; |
| 232 | |
| 233 | #define tpdu_AKli _tpduf._tpduf_li |
| 234 | #define tpdu_AKtype _tpduf._tpduf_type |
| 235 | #define tpdu_AKdref _tpduf._tpduf_dref |
| 236 | #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq |
| 237 | #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq |
| 238 | /* location of cdt depends on size of seq. numbers */ |
| 239 | #define tpdu_AKcdt _tpduf._tpduf_cdt |
| 240 | #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt |
| 241 | |
| 242 | #define tpdu_XAKli _tpduf._tpduf_li |
| 243 | #define tpdu_XAKtype _tpduf._tpduf_type |
| 244 | #define tpdu_XAKdref _tpduf._tpduf_dref |
| 245 | #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq |
| 246 | #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq |
| 247 | |
| 248 | unsigned char _tpdu_ERreason; /* [ ISO 8073 13.12.3.c ] */ |
| 249 | |
| 250 | #define tpdu_ERli _tpduf._tpduf_li |
| 251 | #define tpdu_ERtype _tpduf._tpduf_type |
| 252 | #define tpdu_ERdref _tpduf._tpduf_dref |
| 253 | #define tpdu_ERreason _tpdufr._tpdu_ERreason |
| 254 | |
| 255 | }; |
| 256 | |
| 257 | struct tpdu { |
| 258 | struct tpdu_fixed _tpduf; |
| 259 | union tpdu_fixed_rest _tpdufr; |
| 260 | }; |
| 261 | |
| 262 | #endif __TP_TPDU__ |