1261639Sbr/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */
2261639Sbr
3261639Sbr/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
4261639Sbr *
5261639Sbr * Redistribution and use in source and binary forms, with or without
6261639Sbr * modification, are permitted provided that the following conditions
7261639Sbr * are met:
8261639Sbr *
9261639Sbr * 1. Redistributions of source code must retain the above copyright
10261639Sbr *    notice, this list of conditions and the following disclaimer.
11261639Sbr *
12261639Sbr * 2. Redistributions in binary form must reproduce the above copyright
13261639Sbr *    notice, this list of conditions and the following disclaimer in the
14261639Sbr *    documentation and/or other materials provided with the distribution.
15261639Sbr *
16261639Sbr * 4. Neither the name of Cisco nor of Motorola may be used
17261639Sbr *    to endorse or promote products derived from this software without
18261639Sbr *    specific prior written permission.
19261639Sbr *
20261639Sbr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21261639Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22261639Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23261639Sbr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24261639Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25261639Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26261639Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27261639Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28261639Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29261639Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30261639Sbr * SUCH DAMAGE.
31261639Sbr *
32261639Sbr * This file is part of the SCTP reference Implementation
33261639Sbr *
34261639Sbr *
35261639Sbr * Please send any bug reports or fixes you make to one of the following email
36261639Sbr * addresses:
37261639Sbr *
38261639Sbr * rstewar1@email.mot.com
39261639Sbr * kmorneau@cisco.com
40261639Sbr * qxie1@email.mot.com
41261639Sbr *
42261639Sbr * Any bugs reported given to us we will try to fix... any fixes shared will
43261639Sbr * be incorperated into the next SCTP release.
44261639Sbr */
45261639Sbr
46261639Sbr
47261639Sbr#ifndef __sctpHeader_h__
48261639Sbr#define __sctpHeader_h__
49261639Sbr
50261639Sbr#include <sctpConstants.h>
51261639Sbr
52261639Sbr#ifdef	__cplusplus
53261639Sbrextern "C" {
54261639Sbr#endif
55261639Sbr
56261639Sbr/* the sctp common header */
57261639Sbr
58261639Sbr#ifdef TRU64
59261639Sbr #define _64BITS 1
60261639Sbr#endif
61261639Sbr
62261639Sbrstruct sctpHeader{
63261639Sbr  u_int16_t source;
64261639Sbr  u_int16_t destination;
65261639Sbr  u_int32_t verificationTag;
66261639Sbr  u_int32_t adler32;
67261639Sbr};
68261639Sbr
69261639Sbr/* various descriptor parsers */
70261639Sbr
71261639Sbrstruct sctpChunkDesc{
72261639Sbr  u_int8_t chunkID;
73261639Sbr  u_int8_t chunkFlg;
74261639Sbr  u_int16_t chunkLength;
75261639Sbr};
76261639Sbr
77261639Sbrstruct sctpParamDesc{
78261639Sbr  u_int16_t paramType;
79261639Sbr  u_int16_t paramLength;
80261639Sbr};
81261639Sbr
82261639Sbr
83261639Sbrstruct sctpRelChunkDesc{
84261639Sbr  struct sctpChunkDesc chk;
85261639Sbr  u_int32_t serialNumber;
86261639Sbr};
87261639Sbr
88261639Sbrstruct sctpVendorSpecificParam {
89261639Sbr  struct sctpParamDesc p;  /* type must be 0xfffe */
90261639Sbr  u_int32_t vendorId;	   /* vendor ID from RFC 1700 */
91261639Sbr  u_int16_t vendorSpecificType;
92261639Sbr  u_int16_t vendorSpecificLen;
93261639Sbr};
94261639Sbr
95261639Sbr
96261639Sbr/* Structures for the control parts */
97261639Sbr
98261639Sbr
99261639Sbr
100261639Sbr/* Sctp association init request/ack */
101261639Sbr
102261639Sbr/* this is used for init ack, too */
103261639Sbrstruct sctpInitiation{
104261639Sbr  u_int32_t initTag;		/* tag of mine */
105261639Sbr  u_int32_t rcvWindowCredit;	/* rwnd */
106261639Sbr  u_int16_t NumPreopenStreams;	/* OS */
107261639Sbr  u_int16_t MaxInboundStreams;     /* MIS */
108261639Sbr  u_int32_t initialTSN;
109261639Sbr  /* optional param's follow in sctpParamDesc form */
110261639Sbr};
111261639Sbr
112261639Sbrstruct sctpV4IpAddress{
113261639Sbr  struct sctpParamDesc p;	/* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
114261639Sbr  u_int32_t  ipAddress;
115261639Sbr};
116261639Sbr
117261639Sbr
118261639Sbrstruct sctpV6IpAddress{
119261639Sbr  struct sctpParamDesc p;	/* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
120261639Sbr  u_int8_t  ipAddress[16];
121261639Sbr};
122261639Sbr
123261639Sbrstruct sctpDNSName{
124261639Sbr  struct sctpParamDesc param;
125261639Sbr  u_int8_t name[1];
126261639Sbr};
127261639Sbr
128261639Sbr
129261639Sbrstruct sctpCookiePreserve{
130261639Sbr  struct sctpParamDesc p;	/* type is set to SCTP_COOKIE_PRESERVE, len=8 */
131261639Sbr  u_int32_t extraTime;
132261639Sbr};
133261639Sbr
134261639Sbr
135261639Sbrstruct sctpTimeStamp{
136261639Sbr  u_int32_t ts_sec;
137261639Sbr  u_int32_t ts_usec;
138261639Sbr};
139261639Sbr
140261639Sbr/* wire structure of my cookie */
141261639Sbrstruct cookieMessage{
142261639Sbr  u_int32_t TieTag_curTag;		/* copied from assoc if present */
143261639Sbr  u_int32_t TieTag_hisTag; 		/* copied from assoc if present */
144261639Sbr  int32_t cookieLife;			/* life I will award this cookie */
145261639Sbr  struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
146261639Sbr  struct sctpInitiation initAckISent;	/* the INIT-ACK that I sent to my peer */
147261639Sbr  u_int32_t addressWhereISent[4];	/* I make this 4 ints so I get 128bits for future */
148261639Sbr  int32_t addrtype;			/* address type */
149261639Sbr  u_int16_t locScope;			/* V6 local scope flag */
150261639Sbr  u_int16_t siteScope;			/* V6 site scope flag */
151261639Sbr  /* at the end is tacked on the INIT chunk sent in
152261639Sbr   * its entirety and of course our
153261639Sbr   * signature.
154261639Sbr   */
155261639Sbr};
156
157
158/* this guy is for use when
159 * I have a initiate message gloming the
160 * things together.
161
162 */
163struct sctpUnifiedInit{
164  struct sctpChunkDesc uh;
165  struct sctpInitiation initm;
166};
167
168struct 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
181struct sctpSelectiveAck{
182  u_int32_t highestConseqTSN;
183  u_int32_t updatedRwnd;
184  u_int16_t numberOfdesc;
185  u_int16_t numDupTsns;
186};
187
188struct sctpSelectiveFrag{
189  u_int16_t fragmentStart;
190  u_int16_t fragmentEnd;
191};
192
193
194struct sctpUnifiedSack{
195  struct sctpChunkDesc uh;
196  struct sctpSelectiveAck sack;
197};
198
199/* for both RTT request/response the
200 * following is sent
201 */
202
203struct 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. */
209struct sctpHBunified{
210  struct sctpChunkDesc hdr;
211  struct sctpParamDesc hb;
212};
213
214
215/* here is what I send */
216struct 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 */
230struct sctpUnifiedAbort{
231  struct sctpChunkDesc uh;
232};
233
234struct sctpUnifiedAbortLight{
235  struct sctpHeader mh;
236  struct sctpChunkDesc uh;
237};
238
239struct 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 */
249struct sctpShutdown {
250  u_int32_t TSN_Seen;
251};
252
253struct 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 */
262struct sctpOpErrorCause{
263  u_int16_t cause;
264  u_int16_t causeLen;
265};
266
267struct sctpUnifiedOpError{
268  struct sctpChunkDesc uh;
269  struct sctpOpErrorCause c;
270};
271
272struct 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
280struct 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
291struct sctpUnifiedSingleMsg{
292  struct sctpHeader mh;
293  struct sctpChunkDesc uh;
294};
295
296struct sctpDataPart{
297  u_int32_t TSN;
298  u_int16_t streamId;
299  u_int16_t sequence;
300  u_int32_t payloadtype;
301};
302
303struct sctpUnifiedDatagram{
304  struct sctpChunkDesc uh;
305  struct sctpDataPart dp;
306};
307
308struct sctpECN_echo{
309  struct sctpChunkDesc uh;
310  u_int32_t Lowest_TSN;
311};
312
313
314struct sctpCWR{
315  struct sctpChunkDesc uh;
316  u_int32_t TSN_reduced_at;
317};
318
319#ifdef	__cplusplus
320}
321#endif
322
323#endif
324