HAMMER 60I/Many: Mirroring
[dragonfly.git] / sys / netinet / sctp_header.h
blob77928e295101e7cf7677f02d2cb583d18a3e372c
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.2 2006/05/20 02:42:12 dillon Exp $ */
4 #ifndef _NETINET_SCTP_HEADER_H_
5 #define _NETINET_SCTP_HEADER_H_
7 /*
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
9 * All rights reserved.
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.
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.
39 #ifndef _SYS_TYPES_H_
40 #include <sys/types.h>
41 #endif
42 #ifndef _SYS_TIME_H_
43 #include <sys/time.h>
44 #endif
45 #ifndef _NETINET_SCTP_H_
46 #include <netinet/sctp.h>
47 #endif
48 #ifndef _NETINET_SCTP_CONSTANTS_H_
49 #include <netinet/sctp_constants.h>
50 #endif
53 * Parameter structures
55 struct sctp_ipv4addr_param {
56 struct sctp_paramhdr ph; /* type=SCTP_IPV4_PARAM_TYPE, len=8 */
57 u_int32_t addr; /* IPV4 address */
60 struct sctp_ipv6addr_param {
61 struct sctp_paramhdr ph; /* type=SCTP_IPV6_PARAM_TYPE, len=20 */
62 u_int8_t addr[16]; /* IPV6 address */
65 /* Cookie Preservative */
66 struct sctp_cookie_perserve_param {
67 struct sctp_paramhdr ph; /* type=SCTP_COOKIE_PRESERVE, len=8 */
68 u_int32_t time; /* time in ms to extend cookie */
71 /* Host Name Address */
72 struct sctp_host_name_param {
73 struct sctp_paramhdr ph; /* type=SCTP_HOSTNAME_ADDRESS */
74 char name[1]; /* host name */
77 /* supported address type */
78 struct sctp_supported_addr_param {
79 struct sctp_paramhdr ph; /* type=SCTP_SUPPORTED_ADDRTYPE */
80 u_int16_t addr_type[1]; /* array of supported address types */
83 /* ECN parameter */
84 struct sctp_ecn_supported_param {
85 struct sctp_paramhdr ph; /* type=SCTP_ECN_CAPABLE */
89 /* heartbeat info parameter */
90 struct sctp_heartbeat_info_param {
91 struct sctp_paramhdr ph;
92 u_int32_t time_value_1;
93 u_int32_t time_value_2;
94 u_int32_t random_value1;
95 u_int32_t random_value2;
96 u_int16_t user_req;
97 u_int8_t addr_family;
98 u_int8_t addr_len;
99 char address[SCTP_ADDRMAX];
103 /* draft-ietf-tsvwg-prsctp */
104 /* PR-SCTP supported parameter */
105 struct sctp_prsctp_supported_param {
106 struct sctp_paramhdr ph;
110 /* draft-ietf-tsvwg-addip-sctp */
111 struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
112 struct sctp_paramhdr ph; /* a SCTP parameter header */
113 u_int32_t correlation_id; /* correlation id for this param */
116 struct sctp_asconf_addr_param { /* an ASCONF address parameter */
117 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
118 struct sctp_ipv6addr_param addrp; /* max storage size */
121 struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
122 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
123 struct sctp_ipv4addr_param addrp; /* max storage size */
127 /* ECN Nonce: draft-ladha-sctp-ecn-nonce */
128 struct sctp_ecn_nonce_supported_param {
129 struct sctp_paramhdr ph; /* type = 0x8001 len = 4 */
132 struct sctp_supported_chunk_types_param {
133 struct sctp_paramhdr ph; /* type = 0x8002 len = x */
134 u_int8_t chunk_types[0];
138 * Structures for DATA chunks
140 struct sctp_data {
141 u_int32_t tsn;
142 u_int16_t stream_id;
143 u_int16_t stream_sequence;
144 u_int32_t protocol_id;
145 /* user data follows */
148 struct sctp_data_chunk {
149 struct sctp_chunkhdr ch;
150 struct sctp_data dp;
154 * Structures for the control chunks
157 /* Initiate (INIT)/Initiate Ack (INIT ACK) */
158 struct sctp_init {
159 u_int32_t initiate_tag; /* initiate tag */
160 u_int32_t a_rwnd; /* a_rwnd */
161 u_int16_t num_outbound_streams; /* OS */
162 u_int16_t num_inbound_streams; /* MIS */
163 u_int32_t initial_tsn; /* I-TSN */
164 /* optional param's follow */
167 /* state cookie header */
168 struct sctp_state_cookie { /* this is our definition... */
169 u_int8_t identification[16]; /* id of who we are */
170 u_int32_t cookie_life; /* life I will award this cookie */
171 u_int32_t tie_tag_my_vtag; /* my tag in old association */
172 u_int32_t tie_tag_peer_vtag; /* peers tag in old association */
173 u_int32_t peers_vtag; /* peers tag in INIT (for quick ref) */
174 u_int32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */
175 struct timeval time_entered; /* the time I built cookie */
176 u_int32_t address[4]; /* 4 ints/128 bits */
177 u_int32_t addr_type; /* address type */
178 u_int32_t laddress[4]; /* my local from address */
179 u_int32_t laddr_type; /* my local from address type */
180 u_int32_t scope_id; /* v6 scope id for link-locals */
181 u_int16_t peerport; /* port address of the peer in the INIT */
182 u_int16_t myport; /* my port address used in the INIT */
183 u_int8_t ipv4_addr_legal; /* Are V4 addr legal? */
184 u_int8_t ipv6_addr_legal; /* Are V6 addr legal? */
185 u_int8_t local_scope; /* IPv6 local scope flag */
186 u_int8_t site_scope; /* IPv6 site scope flag */
187 u_int8_t ipv4_scope; /* IPv4 private addr scope */
188 u_int8_t loopback_scope; /* loopback scope information */
189 u_int16_t reserved;
191 * at the end is tacked on the INIT chunk and the
192 * INIT-ACK chunk (minus the cookie).
196 struct sctp_inv_mandatory_param {
197 u_int16_t cause;
198 u_int16_t length;
199 u_int32_t num_param;
200 u_int16_t param;
202 * We include this to 0 it since only a missing cookie
203 * will cause this error.
205 u_int16_t resv;
208 struct sctp_unresolv_addr {
209 u_int16_t cause;
210 u_int16_t length;
211 u_int16_t addr_type;
212 u_int16_t reserved; /* Only one invalid addr type */
215 /* state cookie parameter */
216 struct sctp_state_cookie_param {
217 struct sctp_paramhdr ph;
218 struct sctp_state_cookie cookie;
221 struct sctp_init_chunk {
222 struct sctp_chunkhdr ch;
223 struct sctp_init init;
226 struct sctp_init_msg {
227 struct sctphdr sh;
228 struct sctp_init_chunk msg;
230 /* ... used for both INIT and INIT ACK */
231 #define sctp_init_ack sctp_init
232 #define sctp_init_ack_chunk sctp_init_chunk
233 #define sctp_init_ack_msg sctp_init_msg
236 /* Selective Ack (SACK) */
237 struct sctp_gap_ack_block {
238 u_int16_t start; /* Gap Ack block start */
239 u_int16_t end; /* Gap Ack block end */
242 struct sctp_sack {
243 u_int32_t cum_tsn_ack; /* cumulative TSN Ack */
244 u_int32_t a_rwnd; /* updated a_rwnd of sender */
245 u_int16_t num_gap_ack_blks; /* number of Gap Ack blocks */
246 u_int16_t num_dup_tsns; /* number of duplicate TSNs */
247 /* struct sctp_gap_ack_block's follow */
248 /* u_int32_t duplicate_tsn's follow */
251 struct sctp_sack_chunk {
252 struct sctp_chunkhdr ch;
253 struct sctp_sack sack;
257 /* Heartbeat Request (HEARTBEAT) */
258 struct sctp_heartbeat {
259 struct sctp_heartbeat_info_param hb_info;
262 struct sctp_heartbeat_chunk {
263 struct sctp_chunkhdr ch;
264 struct sctp_heartbeat heartbeat;
266 /* ... used for Heartbeat Ack (HEARTBEAT ACK) */
267 #define sctp_heartbeat_ack sctp_heartbeat
268 #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
271 /* Abort Asssociation (ABORT) */
272 struct sctp_abort_chunk {
273 struct sctp_chunkhdr ch;
274 /* optional error cause may follow */
277 struct sctp_abort_msg {
278 struct sctphdr sh;
279 struct sctp_abort_chunk msg;
283 /* Shutdown Association (SHUTDOWN) */
284 struct sctp_shutdown_chunk {
285 struct sctp_chunkhdr ch;
286 u_int32_t cumulative_tsn_ack;
290 /* Shutdown Acknowledgment (SHUTDOWN ACK) */
291 struct sctp_shutdown_ack_chunk {
292 struct sctp_chunkhdr ch;
296 /* Operation Error (ERROR) */
297 struct sctp_error_chunk {
298 struct sctp_chunkhdr ch;
299 /* optional error causes follow */
303 /* Cookie Echo (COOKIE ECHO) */
304 struct sctp_cookie_echo_chunk {
305 struct sctp_chunkhdr ch;
306 struct sctp_state_cookie cookie;
309 /* Cookie Acknowledgment (COOKIE ACK) */
310 struct sctp_cookie_ack_chunk {
311 struct sctp_chunkhdr ch;
314 /* Explicit Congestion Notification Echo (ECNE) */
315 struct sctp_ecne_chunk {
316 struct sctp_chunkhdr ch;
317 u_int32_t tsn;
320 /* Congestion Window Reduced (CWR) */
321 struct sctp_cwr_chunk {
322 struct sctp_chunkhdr ch;
323 u_int32_t tsn;
326 /* Shutdown Complete (SHUTDOWN COMPLETE) */
327 struct sctp_shutdown_complete_chunk {
328 struct sctp_chunkhdr ch;
331 /* Oper error holding a stale cookie */
332 struct sctp_stale_cookie_msg {
333 struct sctp_paramhdr ph; /* really an error cause */
334 u_int32_t time_usec;
337 struct sctp_adaption_layer_indication {
338 struct sctp_paramhdr ph;
339 u_int32_t indication;
342 struct sctp_cookie_while_shutting_down {
343 struct sctphdr sh;
344 struct sctp_chunkhdr ch;
345 struct sctp_paramhdr ph; /* really an error cause */
348 struct sctp_shutdown_complete_msg {
349 struct sctphdr sh;
350 struct sctp_shutdown_complete_chunk shut_cmp;
353 /* draft-ietf-tsvwg-addip-sctp */
354 /* Address/Stream Configuration Change (ASCONF) */
355 struct sctp_asconf_chunk {
356 struct sctp_chunkhdr ch;
357 u_int32_t serial_number;
358 /* lookup address parameter (mandatory) */
359 /* asconf parameters follow */
362 /* Address/Stream Configuration Acknowledge (ASCONF ACK) */
363 struct sctp_asconf_ack_chunk {
364 struct sctp_chunkhdr ch;
365 u_int32_t serial_number;
366 /* asconf parameters follow */
369 /* draft-ietf-tsvwg-prsctp */
370 /* Forward Cumulative TSN (FORWARD TSN) */
371 struct sctp_forward_tsn_chunk {
372 struct sctp_chunkhdr ch;
373 u_int32_t new_cumulative_tsn;
374 /* stream/sequence pairs (sctp_strseq) follow */
377 struct sctp_strseq {
378 u_int16_t stream;
379 u_int16_t sequence;
382 struct sctp_forward_tsn_msg {
383 struct sctphdr sh;
384 struct sctp_forward_tsn_chunk msg;
387 /* should be a multiple of 4 - 1 aka 3/7/11 etc. */
389 #define SCTP_NUM_DB_TO_VERIFY 3
391 struct sctp_chunk_desc {
392 u_int8_t chunk_type;
393 u_int8_t data_bytes[SCTP_NUM_DB_TO_VERIFY];
394 u_int32_t tsn_ifany;
398 struct sctp_pktdrop_chunk {
399 struct sctp_chunkhdr ch;
400 u_int32_t bottle_bw;
401 u_int32_t current_onq;
402 u_int16_t trunc_len;
403 u_int16_t reserved;
404 u_int8_t data[0];
407 #define SCTP_RESET_YOUR 0x01 /* reset your streams and send response */
408 #define SCTP_RESET_ALL 0x02 /* reset all of your streams */
409 #define SCTP_RECIPRICAL 0x04 /* reset my streams too */
411 struct sctp_stream_reset_request {
412 struct sctp_paramhdr ph;
413 u_int8_t reset_flags; /* actual request */
414 u_int8_t reset_pad[3];
415 u_int32_t reset_req_seq; /* monotonically increasing seq no */
416 u_int16_t list_of_streams[0]; /* if not all list of streams */
419 #define SCTP_RESET_PERFORMED 0x01 /* Peers sending str was reset */
420 #define SCTP_RESET_DENIED 0x02 /* Asked for but refused */
422 struct sctp_stream_reset_response {
423 struct sctp_paramhdr ph;
424 u_int8_t reset_flags; /* actual request */
425 u_int8_t reset_pad[3];
426 u_int32_t reset_req_seq_resp; /* copied from reset_req reset_req_seq */
427 u_int32_t reset_at_tsn; /* resetters next TSN to be assigned send wise */
428 u_int32_t cumulative_tsn; /* resetters cum-ack point receive wise */
429 u_int16_t list_of_streams[0]; /* if not all list of streams */
432 /* convience structures, note that if you
433 * are making a request for specific streams
434 * then the request will need to be an overlay
435 * structure.
438 struct sctp_stream_reset_req {
439 struct sctp_chunkhdr ch;
440 struct sctp_stream_reset_request sr_req;
443 struct sctp_stream_reset_resp {
444 struct sctp_chunkhdr ch;
445 struct sctp_stream_reset_response sr_resp;
450 * we pre-reserve enough room for a ECNE or CWR AND a SACK with no
451 * missing pieces. If ENCE is missing we could have a couple of blocks.
452 * This way we optimize so we MOST likely can bundle a SACK/ECN with
453 * the smallest size data chunk I will split into. We could increase
454 * throughput slightly by taking out these two but the 24-sack/8-CWR
455 * i.e. 32 bytes I pre-reserve I feel is worth it for now.
457 #ifndef SCTP_MAX_OVERHEAD
458 #ifdef AF_INET6
459 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
460 sizeof(struct sctphdr) + \
461 sizeof(struct sctp_ecne_chunk) + \
462 sizeof(struct sctp_sack_chunk) + \
463 sizeof(struct ip6_hdr))
465 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
466 sizeof(struct sctphdr) + \
467 sizeof(struct ip6_hdr))
470 #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
471 sizeof(struct sctphdr))
473 #else
474 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
475 sizeof(struct sctphdr) + \
476 sizeof(struct sctp_ecne_chunk) + \
477 sizeof(struct sctp_sack_chunk) + \
478 sizeof(struct ip))
480 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
481 sizeof(struct sctphdr) + \
482 sizeof(struct ip))
485 #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
486 sizeof(struct sctphdr))
488 #endif /* AF_INET6 */
489 #endif /* !SCTP_MAX_OVERHEAD */
491 #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
492 sizeof(struct sctphdr) + \
493 sizeof(struct ip))
495 #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
496 sizeof(struct sctphdr))
498 #endif /* _NETINET_SCTP_HEADER_H_ */