1 /* $KAME: sctp_header.h,v 1.13 2004/08/17 04:06:16 itojun Exp $ */
2 /* $DragonFly: src/sys/netinet/sctp_header.h,v 1.1 2005/07/15 14:46:16 eirikn Exp $ */
4 #ifndef __sctp_header_h__
5 #define __sctp_header_h__
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
40 #include <netinet/sctp.h>
41 #include <netinet/sctp_constants.h>
44 * Parameter structures
46 struct sctp_ipv4addr_param {
47 struct sctp_paramhdr ph; /* type=SCTP_IPV4_PARAM_TYPE, len=8 */
48 u_int32_t addr; /* IPV4 address */
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 */
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 */
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 */
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 */
75 struct sctp_ecn_supported_param {
76 struct sctp_paramhdr ph; /* type=SCTP_ECN_CAPABLE */
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;
90 char address[SCTP_ADDRMAX];
94 /* draft-ietf-tsvwg-prsctp */
95 /* PR-SCTP supported parameter */
96 struct sctp_prsctp_supported_param {
97 struct sctp_paramhdr ph;
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 */
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 */
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 */
118 /* ECN Nonce: draft-ladha-sctp-ecn-nonce */
119 struct sctp_ecn_nonce_supported_param {
120 struct sctp_paramhdr ph; /* type = 0x8001 len = 4 */
123 struct sctp_supported_chunk_types_param {
124 struct sctp_paramhdr ph; /* type = 0x8002 len = x */
125 u_int8_t chunk_types[0];
129 * Structures for DATA chunks
134 u_int16_t stream_sequence;
135 u_int32_t protocol_id;
136 /* user data follows */
139 struct sctp_data_chunk {
140 struct sctp_chunkhdr ch;
145 * Structures for the control chunks
148 /* Initiate (INIT)/Initiate Ack (INIT ACK) */
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 */
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 */
182 * at the end is tacked on the INIT chunk and the
183 * INIT-ACK chunk (minus the cookie).
187 struct sctp_inv_mandatory_param {
193 * We include this to 0 it since only a missing cookie
194 * will cause this error.
199 struct sctp_unresolv_addr {
203 u_int16_t reserved; /* Only one invalid addr type */
206 /* state cookie parameter */
207 struct sctp_state_cookie_param {
208 struct sctp_paramhdr ph;
209 struct sctp_state_cookie cookie;
212 struct sctp_init_chunk {
213 struct sctp_chunkhdr ch;
214 struct sctp_init init;
217 struct sctp_init_msg {
219 struct sctp_init_chunk msg;
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
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 */
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 */
242 struct sctp_sack_chunk {
243 struct sctp_chunkhdr ch;
244 struct sctp_sack sack;
248 /* Heartbeat Request (HEARTBEAT) */
249 struct sctp_heartbeat {
250 struct sctp_heartbeat_info_param hb_info;
253 struct sctp_heartbeat_chunk {
254 struct sctp_chunkhdr ch;
255 struct sctp_heartbeat heartbeat;
257 /* ... used for Heartbeat Ack (HEARTBEAT ACK) */
258 #define sctp_heartbeat_ack sctp_heartbeat
259 #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
262 /* Abort Asssociation (ABORT) */
263 struct sctp_abort_chunk {
264 struct sctp_chunkhdr ch;
265 /* optional error cause may follow */
268 struct sctp_abort_msg {
270 struct sctp_abort_chunk msg;
274 /* Shutdown Association (SHUTDOWN) */
275 struct sctp_shutdown_chunk {
276 struct sctp_chunkhdr ch;
277 u_int32_t cumulative_tsn_ack;
281 /* Shutdown Acknowledgment (SHUTDOWN ACK) */
282 struct sctp_shutdown_ack_chunk {
283 struct sctp_chunkhdr ch;
287 /* Operation Error (ERROR) */
288 struct sctp_error_chunk {
289 struct sctp_chunkhdr ch;
290 /* optional error causes follow */
294 /* Cookie Echo (COOKIE ECHO) */
295 struct sctp_cookie_echo_chunk {
296 struct sctp_chunkhdr ch;
297 struct sctp_state_cookie cookie;
300 /* Cookie Acknowledgment (COOKIE ACK) */
301 struct sctp_cookie_ack_chunk {
302 struct sctp_chunkhdr ch;
305 /* Explicit Congestion Notification Echo (ECNE) */
306 struct sctp_ecne_chunk {
307 struct sctp_chunkhdr ch;
311 /* Congestion Window Reduced (CWR) */
312 struct sctp_cwr_chunk {
313 struct sctp_chunkhdr ch;
317 /* Shutdown Complete (SHUTDOWN COMPLETE) */
318 struct sctp_shutdown_complete_chunk {
319 struct sctp_chunkhdr ch;
322 /* Oper error holding a stale cookie */
323 struct sctp_stale_cookie_msg {
324 struct sctp_paramhdr ph; /* really an error cause */
328 struct sctp_adaption_layer_indication {
329 struct sctp_paramhdr ph;
330 u_int32_t indication;
333 struct sctp_cookie_while_shutting_down {
335 struct sctp_chunkhdr ch;
336 struct sctp_paramhdr ph; /* really an error cause */
339 struct sctp_shutdown_complete_msg {
341 struct sctp_shutdown_complete_chunk shut_cmp;
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 */
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 */
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 */
373 struct sctp_forward_tsn_msg {
375 struct sctp_forward_tsn_chunk msg;
378 /* should be a multiple of 4 - 1 aka 3/7/11 etc. */
380 #define SCTP_NUM_DB_TO_VERIFY 3
382 struct sctp_chunk_desc {
384 u_int8_t data_bytes[SCTP_NUM_DB_TO_VERIFY];
389 struct sctp_pktdrop_chunk {
390 struct sctp_chunkhdr ch;
392 u_int32_t current_onq;
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 */
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 */
410 #define SCTP_RESET_PERFORMED 0x01 /* Peers sending str was reset */
411 #define SCTP_RESET_DENIED 0x02 /* Asked for but refused */
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 */
423 /* convience structures, note that if you
424 * are making a request for specific streams
425 * then the request will need to be an overlay
429 struct sctp_stream_reset_req {
430 struct sctp_chunkhdr ch;
431 struct sctp_stream_reset_request sr_req;
434 struct sctp_stream_reset_resp {
435 struct sctp_chunkhdr ch;
436 struct sctp_stream_reset_response sr_resp;
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.
448 #ifndef SCTP_MAX_OVERHEAD
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))
456 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
457 sizeof(struct sctphdr) + \
458 sizeof(struct ip6_hdr))
461 #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
462 sizeof(struct sctphdr))
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) + \
471 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
472 sizeof(struct sctphdr) + \
476 #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
477 sizeof(struct sctphdr))
479 #endif /* AF_INET6 */
480 #endif /* !SCTP_MAX_OVERHEAD */
482 #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
483 sizeof(struct sctphdr) + \
486 #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
487 sizeof(struct sctphdr))
489 #endif /* !__sctp_header_h__ */