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