1190207Srpaulo/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */ 298524Sfenner 398524Sfenner/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola 498524Sfenner * 598524Sfenner * Redistribution and use in source and binary forms, with or without 698524Sfenner * modification, are permitted provided that the following conditions 798524Sfenner * are met: 898524Sfenner * 998524Sfenner * 1. Redistributions of source code must retain the above copyright 1098524Sfenner * notice, this list of conditions and the following disclaimer. 1198524Sfenner * 1298524Sfenner * 2. Redistributions in binary form must reproduce the above copyright 1398524Sfenner * notice, this list of conditions and the following disclaimer in the 1498524Sfenner * documentation and/or other materials provided with the distribution. 1598524Sfenner * 1698524Sfenner * 4. Neither the name of Cisco nor of Motorola may be used 1798524Sfenner * to endorse or promote products derived from this software without 1898524Sfenner * specific prior written permission. 1998524Sfenner * 2098524Sfenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2198524Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2298524Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2398524Sfenner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2498524Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2598524Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2698524Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2798524Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2898524Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2998524Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3098524Sfenner * SUCH DAMAGE. 3198524Sfenner * 3298524Sfenner * This file is part of the SCTP reference Implementation 3398524Sfenner * 34127668Sbms * 3598524Sfenner * Please send any bug reports or fixes you make to one of the following email 3698524Sfenner * addresses: 37127668Sbms * 3898524Sfenner * rstewar1@email.mot.com 3998524Sfenner * kmorneau@cisco.com 4098524Sfenner * qxie1@email.mot.com 41127668Sbms * 4298524Sfenner * Any bugs reported given to us we will try to fix... any fixes shared will 4398524Sfenner * be incorperated into the next SCTP release. 4498524Sfenner */ 4598524Sfenner 4698524Sfenner 4798524Sfenner#ifndef __sctpHeader_h__ 4898524Sfenner#define __sctpHeader_h__ 4998524Sfenner 5098524Sfenner#include <sctpConstants.h> 5198524Sfenner 5298524Sfenner#ifdef __cplusplus 5398524Sfennerextern "C" { 5498524Sfenner#endif 5598524Sfenner 5698524Sfenner/* the sctp common header */ 5798524Sfenner 5898524Sfenner#ifdef TRU64 5998524Sfenner #define _64BITS 1 60127668Sbms#endif 6198524Sfenner 6298524Sfennerstruct sctpHeader{ 63127668Sbms u_int16_t source; 64127668Sbms u_int16_t destination; 65127668Sbms u_int32_t verificationTag; 66127668Sbms u_int32_t adler32; 6798524Sfenner}; 6898524Sfenner 6998524Sfenner/* various descriptor parsers */ 7098524Sfenner 7198524Sfennerstruct sctpChunkDesc{ 72127668Sbms u_int8_t chunkID; 73127668Sbms u_int8_t chunkFlg; 74127668Sbms u_int16_t chunkLength; 7598524Sfenner}; 7698524Sfenner 7798524Sfennerstruct sctpParamDesc{ 78127668Sbms u_int16_t paramType; 79127668Sbms u_int16_t paramLength; 8098524Sfenner}; 8198524Sfenner 8298524Sfenner 8398524Sfennerstruct sctpRelChunkDesc{ 8498524Sfenner struct sctpChunkDesc chk; 85127668Sbms u_int32_t serialNumber; 8698524Sfenner}; 8798524Sfenner 8898524Sfennerstruct sctpVendorSpecificParam { 8998524Sfenner struct sctpParamDesc p; /* type must be 0xfffe */ 90127668Sbms u_int32_t vendorId; /* vendor ID from RFC 1700 */ 91127668Sbms u_int16_t vendorSpecificType; 92127668Sbms u_int16_t vendorSpecificLen; 9398524Sfenner}; 9498524Sfenner 9598524Sfenner 9698524Sfenner/* Structures for the control parts */ 9798524Sfenner 9898524Sfenner 9998524Sfenner 10098524Sfenner/* Sctp association init request/ack */ 10198524Sfenner 10298524Sfenner/* this is used for init ack, too */ 10398524Sfennerstruct sctpInitiation{ 104127668Sbms u_int32_t initTag; /* tag of mine */ 105127668Sbms u_int32_t rcvWindowCredit; /* rwnd */ 106127668Sbms u_int16_t NumPreopenStreams; /* OS */ 107127668Sbms u_int16_t MaxInboundStreams; /* MIS */ 108127668Sbms u_int32_t initialTSN; 10998524Sfenner /* optional param's follow in sctpParamDesc form */ 11098524Sfenner}; 11198524Sfenner 11298524Sfennerstruct sctpV4IpAddress{ 11398524Sfenner struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */ 114127668Sbms u_int32_t ipAddress; 11598524Sfenner}; 11698524Sfenner 11798524Sfenner 11898524Sfennerstruct sctpV6IpAddress{ 11998524Sfenner struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */ 120127668Sbms u_int8_t ipAddress[16]; 12198524Sfenner}; 12298524Sfenner 12398524Sfennerstruct sctpDNSName{ 12498524Sfenner struct sctpParamDesc param; 125127668Sbms u_int8_t name[1]; 12698524Sfenner}; 12798524Sfenner 12898524Sfenner 12998524Sfennerstruct sctpCookiePreserve{ 13098524Sfenner struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */ 131127668Sbms u_int32_t extraTime; 13298524Sfenner}; 13398524Sfenner 13498524Sfenner 13598524Sfennerstruct sctpTimeStamp{ 136127668Sbms u_int32_t ts_sec; 137127668Sbms u_int32_t ts_usec; 13898524Sfenner}; 13998524Sfenner 14098524Sfenner/* wire structure of my cookie */ 14198524Sfennerstruct cookieMessage{ 142127668Sbms u_int32_t TieTag_curTag; /* copied from assoc if present */ 143127668Sbms u_int32_t TieTag_hisTag; /* copied from assoc if present */ 144127668Sbms int32_t cookieLife; /* life I will award this cookie */ 14598524Sfenner struct sctpTimeStamp timeEnteringState; /* the time I built cookie */ 14698524Sfenner struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */ 147127668Sbms u_int32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */ 148127668Sbms int32_t addrtype; /* address type */ 149127668Sbms u_int16_t locScope; /* V6 local scope flag */ 150127668Sbms u_int16_t siteScope; /* V6 site scope flag */ 15198524Sfenner /* at the end is tacked on the INIT chunk sent in 152127668Sbms * its entirety and of course our 15398524Sfenner * signature. 15498524Sfenner */ 15598524Sfenner}; 15698524Sfenner 15798524Sfenner 15898524Sfenner/* this guy is for use when 15998524Sfenner * I have a initiate message gloming the 16098524Sfenner * things together. 16198524Sfenner 16298524Sfenner */ 16398524Sfennerstruct sctpUnifiedInit{ 16498524Sfenner struct sctpChunkDesc uh; 16598524Sfenner struct sctpInitiation initm; 16698524Sfenner}; 16798524Sfenner 16898524Sfennerstruct sctpSendableInit{ 16998524Sfenner struct sctpHeader mh; 17098524Sfenner struct sctpUnifiedInit msg; 17198524Sfenner}; 17298524Sfenner 17398524Sfenner 174127668Sbms/* Selective Acknowledgement 17598524Sfenner * has the following structure with 17698524Sfenner * a optional ammount of trailing int's 177127668Sbms * on the last part (based on the numberOfDesc 17898524Sfenner * field). 17998524Sfenner */ 18098524Sfenner 18198524Sfennerstruct sctpSelectiveAck{ 182127668Sbms u_int32_t highestConseqTSN; 183127668Sbms u_int32_t updatedRwnd; 184127668Sbms u_int16_t numberOfdesc; 185127668Sbms u_int16_t numDupTsns; 18698524Sfenner}; 18798524Sfenner 18898524Sfennerstruct sctpSelectiveFrag{ 189127668Sbms u_int16_t fragmentStart; 190127668Sbms u_int16_t fragmentEnd; 19198524Sfenner}; 19298524Sfenner 19398524Sfenner 19498524Sfennerstruct sctpUnifiedSack{ 19598524Sfenner struct sctpChunkDesc uh; 19698524Sfenner struct sctpSelectiveAck sack; 19798524Sfenner}; 19898524Sfenner 19998524Sfenner/* for both RTT request/response the 200127668Sbms * following is sent 20198524Sfenner */ 20298524Sfenner 20398524Sfennerstruct sctpHBrequest { 204127668Sbms u_int32_t time_value_1; 205127668Sbms u_int32_t time_value_2; 20698524Sfenner}; 20798524Sfenner 20898524Sfenner/* here is what I read and respond with to. */ 20998524Sfennerstruct sctpHBunified{ 21098524Sfenner struct sctpChunkDesc hdr; 21198524Sfenner struct sctpParamDesc hb; 21298524Sfenner}; 21398524Sfenner 21498524Sfenner 21598524Sfenner/* here is what I send */ 21698524Sfennerstruct sctpHBsender{ 21798524Sfenner struct sctpChunkDesc hdr; 21898524Sfenner struct sctpParamDesc hb; 21998524Sfenner struct sctpHBrequest rtt; 220127668Sbms int8_t addrFmt[SCTP_ADDRMAX]; 221127668Sbms u_int16_t userreq; 22298524Sfenner}; 22398524Sfenner 22498524Sfenner 225127668Sbms 226127668Sbms/* for the abort and shutdown ACK 22798524Sfenner * we must carry the init tag in the common header. Just the 22898524Sfenner * common header is all that is needed with a chunk descriptor. 22998524Sfenner */ 23098524Sfennerstruct sctpUnifiedAbort{ 23198524Sfenner struct sctpChunkDesc uh; 23298524Sfenner}; 23398524Sfenner 23498524Sfennerstruct sctpUnifiedAbortLight{ 23598524Sfenner struct sctpHeader mh; 23698524Sfenner struct sctpChunkDesc uh; 23798524Sfenner}; 23898524Sfenner 23998524Sfennerstruct sctpUnifiedAbortHeavy{ 24098524Sfenner struct sctpHeader mh; 24198524Sfenner struct sctpChunkDesc uh; 242127668Sbms u_int16_t causeCode; 243127668Sbms u_int16_t causeLen; 24498524Sfenner}; 24598524Sfenner 24698524Sfenner/* For the graceful shutdown we must carry 24798524Sfenner * the tag (in common header) and the highest consequitive acking value 24898524Sfenner */ 24998524Sfennerstruct sctpShutdown { 250127668Sbms u_int32_t TSN_Seen; 25198524Sfenner}; 25298524Sfenner 25398524Sfennerstruct sctpUnifiedShutdown{ 25498524Sfenner struct sctpChunkDesc uh; 25598524Sfenner struct sctpShutdown shut; 25698524Sfenner}; 25798524Sfenner 25898524Sfenner/* in the unified message we add the trailing 25998524Sfenner * stream id since it is the only message 26098524Sfenner * that is defined as a operation error. 26198524Sfenner */ 26298524Sfennerstruct sctpOpErrorCause{ 263127668Sbms u_int16_t cause; 264127668Sbms u_int16_t causeLen; 26598524Sfenner}; 26698524Sfenner 26798524Sfennerstruct sctpUnifiedOpError{ 26898524Sfenner struct sctpChunkDesc uh; 26998524Sfenner struct sctpOpErrorCause c; 27098524Sfenner}; 27198524Sfenner 27298524Sfennerstruct sctpUnifiedStreamError{ 27398524Sfenner struct sctpHeader mh; 27498524Sfenner struct sctpChunkDesc uh; 27598524Sfenner struct sctpOpErrorCause c; 276127668Sbms u_int16_t strmNum; 277127668Sbms u_int16_t reserved; 27898524Sfenner}; 27998524Sfenner 28098524Sfennerstruct staleCookieMsg{ 28198524Sfenner struct sctpHeader mh; 28298524Sfenner struct sctpChunkDesc uh; 28398524Sfenner struct sctpOpErrorCause c; 284127668Sbms u_int32_t moretime; 28598524Sfenner}; 28698524Sfenner 28798524Sfenner/* the following is used in all sends 28898524Sfenner * where nothing is needed except the 28998524Sfenner * chunk/type i.e. shutdownAck Abort */ 29098524Sfenner 29198524Sfennerstruct sctpUnifiedSingleMsg{ 29298524Sfenner struct sctpHeader mh; 29398524Sfenner struct sctpChunkDesc uh; 29498524Sfenner}; 29598524Sfenner 29698524Sfennerstruct sctpDataPart{ 297127668Sbms u_int32_t TSN; 298127668Sbms u_int16_t streamId; 299127668Sbms u_int16_t sequence; 300127668Sbms u_int32_t payloadtype; 30198524Sfenner}; 30298524Sfenner 30398524Sfennerstruct sctpUnifiedDatagram{ 30498524Sfenner struct sctpChunkDesc uh; 30598524Sfenner struct sctpDataPart dp; 30698524Sfenner}; 30798524Sfenner 30898524Sfennerstruct sctpECN_echo{ 30998524Sfenner struct sctpChunkDesc uh; 310127668Sbms u_int32_t Lowest_TSN; 311127668Sbms}; 31298524Sfenner 31398524Sfenner 31498524Sfennerstruct sctpCWR{ 31598524Sfenner struct sctpChunkDesc uh; 316127668Sbms u_int32_t TSN_reduced_at; 317127668Sbms}; 31898524Sfenner 31998524Sfenner#ifdef __cplusplus 32098524Sfenner} 32198524Sfenner#endif 32298524Sfenner 32398524Sfenner#endif 324