1 /* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002/12/11 07:14:11 guy Exp $ (LBL) */ 2 3 /* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola 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 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 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 * 16 * 4. Neither the name of Cisco nor of Motorola may be used 17 * to endorse or promote products derived from this software without 18 * specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * This file is part of the SCTP reference Implementation 33 * 34 * 35 * Please send any bug reports or fixes you make to one of the following email 36 * addresses: 37 * 38 * rstewar1 (at) email.mot.com 39 * kmorneau (at) cisco.com 40 * qxie1 (at) email.mot.com 41 * 42 * Any bugs reported given to us we will try to fix... any fixes shared will 43 * be incorperated into the next SCTP release. 44 */ 45 46 47 #ifndef __sctpHeader_h__ 48 #define __sctpHeader_h__ 49 50 #include <sctpConstants.h> 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 /* the sctp common header */ 57 58 #ifdef TRU64 59 #define _64BITS 1 60 #endif 61 62 struct sctpHeader{ 63 u_int16_t source; 64 u_int16_t destination; 65 u_int32_t verificationTag; 66 u_int32_t adler32; 67 }; 68 69 /* various descriptor parsers */ 70 71 struct sctpChunkDesc{ 72 u_int8_t chunkID; 73 u_int8_t chunkFlg; 74 u_int16_t chunkLength; 75 }; 76 77 struct sctpParamDesc{ 78 u_int16_t paramType; 79 u_int16_t paramLength; 80 }; 81 82 83 struct sctpRelChunkDesc{ 84 struct sctpChunkDesc chk; 85 u_int32_t serialNumber; 86 }; 87 88 struct sctpVendorSpecificParam { 89 struct sctpParamDesc p; /* type must be 0xfffe */ 90 u_int32_t vendorId; /* vendor ID from RFC 1700 */ 91 u_int16_t vendorSpecificType; 92 u_int16_t vendorSpecificLen; 93 }; 94 95 96 /* Structures for the control parts */ 97 98 99 100 /* Sctp association init request/ack */ 101 102 /* this is used for init ack, too */ 103 struct sctpInitiation{ 104 u_int32_t initTag; /* tag of mine */ 105 u_int32_t rcvWindowCredit; /* rwnd */ 106 u_int16_t NumPreopenStreams; /* OS */ 107 u_int16_t MaxInboundStreams; /* MIS */ 108 u_int32_t initialTSN; 109 /* optional param's follow in sctpParamDesc form */ 110 }; 111 112 struct sctpV4IpAddress{ 113 struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */ 114 u_int32_t ipAddress; 115 }; 116 117 118 struct sctpV6IpAddress{ 119 struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */ 120 u_int8_t ipAddress[16]; 121 }; 122 123 struct sctpDNSName{ 124 struct sctpParamDesc param; 125 u_int8_t name[1]; 126 }; 127 128 129 struct sctpCookiePreserve{ 130 struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */ 131 u_int32_t extraTime; 132 }; 133 134 135 struct sctpTimeStamp{ 136 u_int32_t ts_sec; 137 u_int32_t ts_usec; 138 }; 139 140 /* wire structure of my cookie */ 141 struct cookieMessage{ 142 u_int32_t TieTag_curTag; /* copied from assoc if present */ 143 u_int32_t TieTag_hisTag; /* copied from assoc if present */ 144 int32_t cookieLife; /* life I will award this cookie */ 145 struct sctpTimeStamp timeEnteringState; /* the time I built cookie */ 146 struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */ 147 u_int32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */ 148 int32_t addrtype; /* address type */ 149 u_int16_t locScope; /* V6 local scope flag */ 150 u_int16_t siteScope; /* V6 site scope flag */ 151 /* at the end is tacked on the INIT chunk sent in 152 * its entirety and of course our 153 * signature. 154 */ 155 }; 156 157 158 /* this guy is for use when 159 * I have a initiate message gloming the 160 * things together. 161 162 */ 163 struct sctpUnifiedInit{ 164 struct sctpChunkDesc uh; 165 struct sctpInitiation initm; 166 }; 167 168 struct sctpSendableInit{ 169 struct sctpHeader mh; 170 struct sctpUnifiedInit msg; 171 }; 172 173 174 /* Selective Acknowledgement 175 * has the following structure with 176 * a optional ammount of trailing int's 177 * on the last part (based on the numberOfDesc 178 * field). 179 */ 180 181 struct sctpSelectiveAck{ 182 u_int32_t highestConseqTSN; 183 u_int32_t updatedRwnd; 184 u_int16_t numberOfdesc; 185 u_int16_t numDupTsns; 186 }; 187 188 struct sctpSelectiveFrag{ 189 u_int16_t fragmentStart; 190 u_int16_t fragmentEnd; 191 }; 192 193 194 struct sctpUnifiedSack{ 195 struct sctpChunkDesc uh; 196 struct sctpSelectiveAck sack; 197 }; 198 199 /* for both RTT request/response the 200 * following is sent 201 */ 202 203 struct sctpHBrequest { 204 u_int32_t time_value_1; 205 u_int32_t time_value_2; 206 }; 207 208 /* here is what I read and respond with to. */ 209 struct sctpHBunified{ 210 struct sctpChunkDesc hdr; 211 struct sctpParamDesc hb; 212 }; 213 214 215 /* here is what I send */ 216 struct sctpHBsender{ 217 struct sctpChunkDesc hdr; 218 struct sctpParamDesc hb; 219 struct sctpHBrequest rtt; 220 int8_t addrFmt[SCTP_ADDRMAX]; 221 u_int16_t userreq; 222 }; 223 224 225 226 /* for the abort and shutdown ACK 227 * we must carry the init tag in the common header. Just the 228 * common header is all that is needed with a chunk descriptor. 229 */ 230 struct sctpUnifiedAbort{ 231 struct sctpChunkDesc uh; 232 }; 233 234 struct sctpUnifiedAbortLight{ 235 struct sctpHeader mh; 236 struct sctpChunkDesc uh; 237 }; 238 239 struct sctpUnifiedAbortHeavy{ 240 struct sctpHeader mh; 241 struct sctpChunkDesc uh; 242 u_int16_t causeCode; 243 u_int16_t causeLen; 244 }; 245 246 /* For the graceful shutdown we must carry 247 * the tag (in common header) and the highest consequitive acking value 248 */ 249 struct sctpShutdown { 250 u_int32_t TSN_Seen; 251 }; 252 253 struct sctpUnifiedShutdown{ 254 struct sctpChunkDesc uh; 255 struct sctpShutdown shut; 256 }; 257 258 /* in the unified message we add the trailing 259 * stream id since it is the only message 260 * that is defined as a operation error. 261 */ 262 struct sctpOpErrorCause{ 263 u_int16_t cause; 264 u_int16_t causeLen; 265 }; 266 267 struct sctpUnifiedOpError{ 268 struct sctpChunkDesc uh; 269 struct sctpOpErrorCause c; 270 }; 271 272 struct sctpUnifiedStreamError{ 273 struct sctpHeader mh; 274 struct sctpChunkDesc uh; 275 struct sctpOpErrorCause c; 276 u_int16_t strmNum; 277 u_int16_t reserved; 278 }; 279 280 struct staleCookieMsg{ 281 struct sctpHeader mh; 282 struct sctpChunkDesc uh; 283 struct sctpOpErrorCause c; 284 u_int32_t moretime; 285 }; 286 287 /* the following is used in all sends 288 * where nothing is needed except the 289 * chunk/type i.e. shutdownAck Abort */ 290 291 struct sctpUnifiedSingleMsg{ 292 struct sctpHeader mh; 293 struct sctpChunkDesc uh; 294 }; 295 296 struct sctpDataPart{ 297 u_int32_t TSN; 298 u_int16_t streamId; 299 u_int16_t sequence; 300 u_int32_t payloadtype; 301 }; 302 303 struct sctpUnifiedDatagram{ 304 struct sctpChunkDesc uh; 305 struct sctpDataPart dp; 306 }; 307 308 struct sctpECN_echo{ 309 struct sctpChunkDesc uh; 310 u_int32_t Lowest_TSN; 311 }; 312 313 314 struct sctpCWR{ 315 struct sctpChunkDesc uh; 316 u_int32_t TSN_reduced_at; 317 }; 318 319 #ifdef __cplusplus 320 } 321 #endif 322 323 #endif 324