1 /* $KAME: sctp_header.h,v 1.14 2005/03/06 16:04:17 itojun Exp $ */
2 /* $NetBSD: sctp_header.h,v 1.3 2021/12/05 04:28:53 msaitoh Exp $ */
3
4 #ifndef __SCTP_HEADER_H__
5 #define __SCTP_HEADER_H__
6
7 /*
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Cisco Systems, Inc.
22 * 4. Neither the name of the project nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39 #include <sys/time.h>
40 #include <netinet/sctp.h>
41 #include <netinet/sctp_constants.h>
42
43 /*
44 * Parameter structures
45 */
46 struct sctp_ipv4addr_param {
47 struct sctp_paramhdr ph; /* type=SCTP_IPV4_PARAM_TYPE, len=8 */
48 u_int32_t addr; /* IPV4 address */
49 } __packed;
50
51 struct sctp_ipv6addr_param {
52 struct sctp_paramhdr ph; /* type=SCTP_IPV6_PARAM_TYPE, len=20 */
53 u_int8_t addr[16]; /* IPV6 address */
54 } __packed;
55
56 /* Cookie Preservative */
57 struct sctp_cookie_perserve_param {
58 struct sctp_paramhdr ph; /* type=SCTP_COOKIE_PRESERVE, len=8 */
59 u_int32_t time; /* time in ms to extend cookie */
60 } __packed;
61
62 /* Host Name Address */
63 struct sctp_host_name_param {
64 struct sctp_paramhdr ph; /* type=SCTP_HOSTNAME_ADDRESS */
65 char name[1]; /* host name */
66 } __packed;
67
68 /* supported address type */
69 struct sctp_supported_addr_param {
70 struct sctp_paramhdr ph; /* type=SCTP_SUPPORTED_ADDRTYPE */
71 u_int16_t addr_type[1]; /* array of supported address types */
72 } __packed;
73
74 /* ECN parameter */
75 struct sctp_ecn_supported_param {
76 struct sctp_paramhdr ph; /* type=SCTP_ECN_CAPABLE */
77 } __packed;
78
79
80 /* heartbeat info parameter */
81 struct sctp_heartbeat_info_param {
82 struct sctp_paramhdr ph;
83 u_int32_t time_value_1;
84 u_int32_t time_value_2;
85 u_int32_t random_value1;
86 u_int32_t random_value2;
87 u_int16_t user_req;
88 u_int8_t addr_family;
89 u_int8_t addr_len;
90 char address[SCTP_ADDRMAX];
91 } __packed;
92
93
94 /* draft-ietf-tsvwg-prsctp */
95 /* PR-SCTP supported parameter */
96 struct sctp_prsctp_supported_param {
97 struct sctp_paramhdr ph;
98 } __packed;
99
100
101 /* draft-ietf-tsvwg-addip-sctp */
102 struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
103 struct sctp_paramhdr ph; /* a SCTP parameter header */
104 u_int32_t correlation_id; /* correlation id for this param */
105 } __packed;
106
107 struct sctp_asconf_addr_param { /* an ASCONF address parameter */
108 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
109 struct sctp_ipv6addr_param addrp; /* max storage size */
110 } __packed;
111
112 struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
113 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
114 struct sctp_ipv4addr_param addrp; /* max storage size */
115 } __packed;
116
117
118 /* ECN Nonce: draft-ladha-sctp-ecn-nonce */
119 struct sctp_ecn_nonce_supported_param {
120 struct sctp_paramhdr ph; /* type = 0x8001 len = 4 */
121 } __packed;
122
123 struct sctp_supported_chunk_types_param {
124 struct sctp_paramhdr ph; /* type = 0x8002 len = x */
125 u_int8_t chunk_types[0];
126 } __packed;
127
128 /*
129 * Structures for DATA chunks
130 */
131 struct sctp_data {
132 u_int32_t tsn;
133 u_int16_t stream_id;
134 u_int16_t stream_sequence;
135 u_int32_t protocol_id;
136 /* user data follows */
137 } __packed;
138
139 struct sctp_data_chunk {
140 struct sctp_chunkhdr ch;
141 struct sctp_data dp;
142 } __packed;
143
144 /*
145 * Structures for the control chunks
146 */
147
148 /* Initiate (INIT)/Initiate Ack (INIT ACK) */
149 struct sctp_init {
150 u_int32_t initiate_tag; /* initiate tag */
151 u_int32_t a_rwnd; /* a_rwnd */
152 u_int16_t num_outbound_streams; /* OS */
153 u_int16_t num_inbound_streams; /* MIS */
154 u_int32_t initial_tsn; /* I-TSN */
155 /* optional param's follow */
156 } __packed;
157
158 /* state cookie header */
159 struct sctp_state_cookie { /* this is our definition... */
160 u_int8_t identification[16]; /* id of who we are */
161 u_int32_t cookie_life; /* life I will award this cookie */
162 u_int32_t tie_tag_my_vtag; /* my tag in old association */
163 u_int32_t tie_tag_peer_vtag; /* peers tag in old association */
164 u_int32_t peers_vtag; /* peers tag in INIT (for quick ref) */
165 u_int32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */
166 struct timeval time_entered; /* the time I built cookie */
167 u_int32_t address[4]; /* 4 ints/128 bits */
168 u_int32_t addr_type; /* address type */
169 u_int32_t laddress[4]; /* my local from address */
170 u_int32_t laddr_type; /* my local from address type */
171 u_int32_t scope_id; /* v6 scope id for link-locals */
172 u_int16_t peerport; /* port address of the peer in the INIT */
173 u_int16_t myport; /* my port address used in the INIT */
174 u_int8_t ipv4_addr_legal; /* Are V4 addr legal? */
175 u_int8_t ipv6_addr_legal; /* Are V6 addr legal? */
176 u_int8_t local_scope; /* IPv6 local scope flag */
177 u_int8_t site_scope; /* IPv6 site scope flag */
178 u_int8_t ipv4_scope; /* IPv4 private addr scope */
179 u_int8_t loopback_scope; /* loopback scope information */
180 u_int16_t reserved;
181 /*
182 * at the end is tacked on the INIT chunk and the
183 * INIT-ACK chunk (minus the cookie).
184 */
185 } __packed;
186
187 struct sctp_inv_mandatory_param {
188 u_int16_t cause;
189 u_int16_t length;
190 u_int32_t num_param;
191 u_int16_t param;
192 /*
193 * We include this to 0 it since only a missing cookie
194 * will cause this error.
195 */
196 u_int16_t resv;
197 } __packed;
198
199 struct sctp_unresolv_addr {
200 u_int16_t cause;
201 u_int16_t length;
202 u_int16_t addr_type;
203 u_int16_t reserved; /* Only one invalid addr type */
204 } __packed;
205
206 /* state cookie parameter */
207 struct sctp_state_cookie_param {
208 struct sctp_paramhdr ph;
209 struct sctp_state_cookie cookie;
210 } __packed;
211
212 struct sctp_init_chunk {
213 struct sctp_chunkhdr ch;
214 struct sctp_init init;
215 } __packed;
216
217 struct sctp_init_msg {
218 struct sctphdr sh;
219 struct sctp_init_chunk msg;
220 } __packed;
221 /* ... used for both INIT and INIT ACK */
222 #define sctp_init_ack sctp_init
223 #define sctp_init_ack_chunk sctp_init_chunk
224 #define sctp_init_ack_msg sctp_init_msg
225
226
227 /* Selective Ack (SACK) */
228 struct sctp_gap_ack_block {
229 u_int16_t start; /* Gap Ack block start */
230 u_int16_t end; /* Gap Ack block end */
231 } __packed;
232
233 struct sctp_sack {
234 u_int32_t cum_tsn_ack; /* cumulative TSN Ack */
235 u_int32_t a_rwnd; /* updated a_rwnd of sender */
236 u_int16_t num_gap_ack_blks; /* number of Gap Ack blocks */
237 u_int16_t num_dup_tsns; /* number of duplicate TSNs */
238 /* struct sctp_gap_ack_block's follow */
239 /* u_int32_t duplicate_tsn's follow */
240 } __packed;
241
242 struct sctp_sack_chunk {
243 struct sctp_chunkhdr ch;
244 struct sctp_sack sack;
245 } __packed;
246
247
248 /* Heartbeat Request (HEARTBEAT) */
249 struct sctp_heartbeat {
250 struct sctp_heartbeat_info_param hb_info;
251 } __packed;
252
253 struct sctp_heartbeat_chunk {
254 struct sctp_chunkhdr ch;
255 struct sctp_heartbeat heartbeat;
256 } __packed;
257 /* ... used for Heartbeat Ack (HEARTBEAT ACK) */
258 #define sctp_heartbeat_ack sctp_heartbeat
259 #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
260
261
262 /* Abort Asssociation (ABORT) */
263 struct sctp_abort_chunk {
264 struct sctp_chunkhdr ch;
265 /* optional error cause may follow */
266 } __packed;
267
268 struct sctp_abort_msg {
269 struct sctphdr sh;
270 struct sctp_abort_chunk msg;
271 } __packed;
272
273
274 /* Shutdown Association (SHUTDOWN) */
275 struct sctp_shutdown_chunk {
276 struct sctp_chunkhdr ch;
277 u_int32_t cumulative_tsn_ack;
278 } __packed;
279
280
281 /* Shutdown Acknowledgment (SHUTDOWN ACK) */
282 struct sctp_shutdown_ack_chunk {
283 struct sctp_chunkhdr ch;
284 } __packed;
285
286
287 /* Operation Error (ERROR) */
288 struct sctp_error_chunk {
289 struct sctp_chunkhdr ch;
290 /* optional error causes follow */
291 } __packed;
292
293
294 /* Cookie Echo (COOKIE ECHO) */
295 struct sctp_cookie_echo_chunk {
296 struct sctp_chunkhdr ch;
297 struct sctp_state_cookie cookie;
298 } __packed;
299
300 /* Cookie Acknowledgment (COOKIE ACK) */
301 struct sctp_cookie_ack_chunk {
302 struct sctp_chunkhdr ch;
303 } __packed;
304
305 /* Explicit Congestion Notification Echo (ECNE) */
306 struct sctp_ecne_chunk {
307 struct sctp_chunkhdr ch;
308 u_int32_t tsn;
309 } __packed;
310
311 /* Congestion Window Reduced (CWR) */
312 struct sctp_cwr_chunk {
313 struct sctp_chunkhdr ch;
314 u_int32_t tsn;
315 } __packed;
316
317 /* Shutdown Complete (SHUTDOWN COMPLETE) */
318 struct sctp_shutdown_complete_chunk {
319 struct sctp_chunkhdr ch;
320 } __packed;
321
322 /* Oper error holding a stale cookie */
323 struct sctp_stale_cookie_msg {
324 struct sctp_paramhdr ph; /* really an error cause */
325 u_int32_t time_usec;
326 } __packed;
327
328 struct sctp_adaption_layer_indication {
329 struct sctp_paramhdr ph;
330 u_int32_t indication;
331 } __packed;
332
333 struct sctp_cookie_while_shutting_down {
334 struct sctphdr sh;
335 struct sctp_chunkhdr ch;
336 struct sctp_paramhdr ph; /* really an error cause */
337 } __packed;
338
339 struct sctp_shutdown_complete_msg {
340 struct sctphdr sh;
341 struct sctp_shutdown_complete_chunk shut_cmp;
342 } __packed;
343
344 /* draft-ietf-tsvwg-addip-sctp */
345 /* Address/Stream Configuration Change (ASCONF) */
346 struct sctp_asconf_chunk {
347 struct sctp_chunkhdr ch;
348 u_int32_t serial_number;
349 /* lookup address parameter (mandatory) */
350 /* asconf parameters follow */
351 } __packed;
352
353 /* Address/Stream Configuration Acknowledge (ASCONF ACK) */
354 struct sctp_asconf_ack_chunk {
355 struct sctp_chunkhdr ch;
356 u_int32_t serial_number;
357 /* asconf parameters follow */
358 } __packed;
359
360 /* draft-ietf-tsvwg-prsctp */
361 /* Forward Cumulative TSN (FORWARD TSN) */
362 struct sctp_forward_tsn_chunk {
363 struct sctp_chunkhdr ch;
364 u_int32_t new_cumulative_tsn;
365 /* stream/sequence pairs (sctp_strseq) follow */
366 } __packed;
367
368 struct sctp_strseq {
369 u_int16_t stream;
370 u_int16_t sequence;
371 } __packed;
372
373 struct sctp_forward_tsn_msg {
374 struct sctphdr sh;
375 struct sctp_forward_tsn_chunk msg;
376 } __packed;
377
378 /* should be a multiple of 4 - 1 aka 3/7/11 etc. */
379
380 #define SCTP_NUM_DB_TO_VERIFY 3
381
382 struct sctp_chunk_desc {
383 u_int8_t chunk_type;
384 u_int8_t data_bytes[SCTP_NUM_DB_TO_VERIFY];
385 u_int32_t tsn_ifany;
386 } __packed;
387
388
389 struct sctp_pktdrop_chunk {
390 struct sctp_chunkhdr ch;
391 u_int32_t bottle_bw;
392 u_int32_t current_onq;
393 u_int16_t trunc_len;
394 u_int16_t reserved;
395 u_int8_t data[0];
396 } __packed;
397
398 #define SCTP_RESET_YOUR 0x01 /* reset your streams and send response */
399 #define SCTP_RESET_ALL 0x02 /* reset all of your streams */
400 #define SCTP_RECIPRICAL 0x04 /* reset my streams too */
401
402 struct sctp_stream_reset_request {
403 struct sctp_paramhdr ph;
404 u_int8_t reset_flags; /* actual request */
405 u_int8_t reset_pad[3];
406 u_int32_t reset_req_seq; /* monotonically increasing seq no */
407 u_int16_t list_of_streams[0]; /* if not all list of streams */
408 } __packed;
409
410 #define SCTP_RESET_PERFORMED 0x01 /* Peers sending str was reset */
411 #define SCTP_RESET_DENIED 0x02 /* Asked for but refused */
412
413 struct sctp_stream_reset_response {
414 struct sctp_paramhdr ph;
415 u_int8_t reset_flags; /* actual request */
416 u_int8_t reset_pad[3];
417 u_int32_t reset_req_seq_resp; /* copied from reset_req reset_req_seq */
418 u_int32_t reset_at_tsn; /* resetters next TSN to be assigned send wise */
419 u_int32_t cumulative_tsn; /* resetters cum-ack point receive wise */
420 u_int16_t list_of_streams[0]; /* if not all list of streams */
421 } __packed;
422
423 /* convenience structures, note that if you
424 * are making a request for specific streams
425 * then the request will need to be an overlay
426 * structure.
427 */
428
429 struct sctp_stream_reset_req {
430 struct sctp_chunkhdr ch;
431 struct sctp_stream_reset_request sr_req;
432 } __packed;
433
434 struct sctp_stream_reset_resp {
435 struct sctp_chunkhdr ch;
436 struct sctp_stream_reset_response sr_resp;
437 } __packed;
438
439
440 /*
441 * we pre-reserve enough room for a ECNE or CWR AND a SACK with no
442 * missing pieces. If ENCE is missing we could have a couple of blocks.
443 * This way we optimize so we MOST likely can bundle a SACK/ECN with
444 * the smallest size data chunk I will split into. We could increase
445 * throughput slightly by taking out these two but the 24-sack/8-CWR
446 * i.e. 32 bytes I pre-reserve I feel is worth it for now.
447 */
448 #ifndef SCTP_MAX_OVERHEAD
449 #ifdef AF_INET6
450 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
451 sizeof(struct sctphdr) + \
452 sizeof(struct sctp_ecne_chunk) + \
453 sizeof(struct sctp_sack_chunk) + \
454 sizeof(struct ip6_hdr))
455
456 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
457 sizeof(struct sctphdr) + \
458 sizeof(struct ip6_hdr))
459
460
461 #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
462 sizeof(struct sctphdr))
463
464 #else
465 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
466 sizeof(struct sctphdr) + \
467 sizeof(struct sctp_ecne_chunk) + \
468 sizeof(struct sctp_sack_chunk) + \
469 sizeof(struct ip))
470
471 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
472 sizeof(struct sctphdr) + \
473 sizeof(struct ip))
474
475
476 #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
477 sizeof(struct sctphdr))
478
479 #endif /* AF_INET6 */
480 #endif /* !SCTP_MAX_OVERHEAD */
481
482 #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
483 sizeof(struct sctphdr) + \
484 sizeof(struct ip))
485
486 #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
487 sizeof(struct sctphdr))
488
489 #endif /* !__SCTP_HEADER_H__ */
Cache object: 2429cdca41ff5a91cf384fbc317eabc8
|