1f8829a4aSRandall Stewart /*- 2b1006367SRandall Stewart * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 35d40cf5dSRandall Stewart * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved. 45d40cf5dSRandall Stewart * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved. 5f8829a4aSRandall Stewart * 6f8829a4aSRandall Stewart * Redistribution and use in source and binary forms, with or without 7f8829a4aSRandall Stewart * modification, are permitted provided that the following conditions are met: 8f8829a4aSRandall Stewart * 9f8829a4aSRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 10f8829a4aSRandall Stewart * this list of conditions and the following disclaimer. 11f8829a4aSRandall Stewart * 12f8829a4aSRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 13f8829a4aSRandall Stewart * notice, this list of conditions and the following disclaimer in 14f8829a4aSRandall Stewart * the documentation and/or other materials provided with the distribution. 15f8829a4aSRandall Stewart * 16f8829a4aSRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 17f8829a4aSRandall Stewart * contributors may be used to endorse or promote products derived 18f8829a4aSRandall Stewart * from this software without specific prior written permission. 19f8829a4aSRandall Stewart * 20f8829a4aSRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21f8829a4aSRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22f8829a4aSRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23f8829a4aSRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24f8829a4aSRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25f8829a4aSRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26f8829a4aSRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27f8829a4aSRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28f8829a4aSRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29f8829a4aSRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30f8829a4aSRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 31f8829a4aSRandall Stewart */ 32f8829a4aSRandall Stewart 33f8829a4aSRandall Stewart /* $KAME: sctp_header.h,v 1.14 2005/03/06 16:04:17 itojun Exp $ */ 34f8829a4aSRandall Stewart 35f8829a4aSRandall Stewart #include <sys/cdefs.h> 36f8829a4aSRandall Stewart __FBSDID("$FreeBSD$"); 37f8829a4aSRandall Stewart 38f8829a4aSRandall Stewart #ifndef __sctp_header_h__ 39f8829a4aSRandall Stewart #define __sctp_header_h__ 40f8829a4aSRandall Stewart 41f8829a4aSRandall Stewart #include <sys/time.h> 42f8829a4aSRandall Stewart #include <netinet/sctp.h> 43f8829a4aSRandall Stewart #include <netinet/sctp_constants.h> 44f8829a4aSRandall Stewart 45b3f1ea41SRandall Stewart #define SCTP_PACKED __attribute__((packed)) 4635918f85SRandall Stewart 47f8829a4aSRandall Stewart /* 48f8829a4aSRandall Stewart * Parameter structures 49f8829a4aSRandall Stewart */ 50f8829a4aSRandall Stewart struct sctp_ipv4addr_param { 51f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_IPV4_PARAM_TYPE, len=8 */ 52f8829a4aSRandall Stewart uint32_t addr; /* IPV4 address */ 5335918f85SRandall Stewart } SCTP_PACKED; 54f8829a4aSRandall Stewart 5542551e99SRandall Stewart #define SCTP_V6_ADDR_BYTES 16 5642551e99SRandall Stewart 5742551e99SRandall Stewart 58f8829a4aSRandall Stewart struct sctp_ipv6addr_param { 59f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */ 6042551e99SRandall Stewart uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */ 6135918f85SRandall Stewart } SCTP_PACKED; 62f8829a4aSRandall Stewart 63f8829a4aSRandall Stewart /* Cookie Preservative */ 64f8829a4aSRandall Stewart struct sctp_cookie_perserve_param { 65f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_COOKIE_PRESERVE, len=8 */ 66f8829a4aSRandall Stewart uint32_t time; /* time in ms to extend cookie */ 678d9d0613SMichael Tuexen } SCTP_PACKED; 68f8829a4aSRandall Stewart 6942551e99SRandall Stewart #define SCTP_ARRAY_MIN_LEN 1 70f8829a4aSRandall Stewart /* Host Name Address */ 71f8829a4aSRandall Stewart struct sctp_host_name_param { 72f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_HOSTNAME_ADDRESS */ 7342551e99SRandall Stewart char name[SCTP_ARRAY_MIN_LEN]; /* host name */ 7435918f85SRandall Stewart } SCTP_PACKED; 75f8829a4aSRandall Stewart 76d06c82f1SRandall Stewart /* 77d06c82f1SRandall Stewart * This is the maximum padded size of a s-a-p 78d06c82f1SRandall Stewart * so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12 79d06c82f1SRandall Stewart */ 80d06c82f1SRandall Stewart #define SCTP_MAX_ADDR_PARAMS_SIZE 12 81f8829a4aSRandall Stewart /* supported address type */ 82f8829a4aSRandall Stewart struct sctp_supported_addr_param { 83f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_SUPPORTED_ADDRTYPE */ 84*70acddf1SMichael Tuexen uint16_t addr_type[2]; /* array of supported address types */ 8535918f85SRandall Stewart } SCTP_PACKED; 86f8829a4aSRandall Stewart 87f8829a4aSRandall Stewart /* ECN parameter */ 88f8829a4aSRandall Stewart struct sctp_ecn_supported_param { 89f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_ECN_CAPABLE */ 9035918f85SRandall Stewart } SCTP_PACKED; 91f8829a4aSRandall Stewart 92f8829a4aSRandall Stewart 93f8829a4aSRandall Stewart /* heartbeat info parameter */ 94f8829a4aSRandall Stewart struct sctp_heartbeat_info_param { 95f8829a4aSRandall Stewart struct sctp_paramhdr ph; 96f8829a4aSRandall Stewart uint32_t time_value_1; 97f8829a4aSRandall Stewart uint32_t time_value_2; 98f8829a4aSRandall Stewart uint32_t random_value1; 99f8829a4aSRandall Stewart uint32_t random_value2; 100f8829a4aSRandall Stewart uint8_t addr_family; 101f8829a4aSRandall Stewart uint8_t addr_len; 102ca85e948SMichael Tuexen /* make sure that this structure is 4 byte aligned */ 103ca85e948SMichael Tuexen uint8_t padding[2]; 104f8829a4aSRandall Stewart char address[SCTP_ADDRMAX]; 10535918f85SRandall Stewart } SCTP_PACKED; 106f8829a4aSRandall Stewart 107f8829a4aSRandall Stewart 108f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 109f8829a4aSRandall Stewart /* PR-SCTP supported parameter */ 110f8829a4aSRandall Stewart struct sctp_prsctp_supported_param { 111f8829a4aSRandall Stewart struct sctp_paramhdr ph; 11235918f85SRandall Stewart } SCTP_PACKED; 113f8829a4aSRandall Stewart 114f8829a4aSRandall Stewart 115f8829a4aSRandall Stewart /* draft-ietf-tsvwg-addip-sctp */ 116f8829a4aSRandall Stewart struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */ 117f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* a SCTP parameter header */ 118f8829a4aSRandall Stewart uint32_t correlation_id;/* correlation id for this param */ 11935918f85SRandall Stewart } SCTP_PACKED; 120f8829a4aSRandall Stewart 121f8829a4aSRandall Stewart struct sctp_asconf_addr_param { /* an ASCONF address parameter */ 122f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 123f8829a4aSRandall Stewart struct sctp_ipv6addr_param addrp; /* max storage size */ 12435918f85SRandall Stewart } SCTP_PACKED; 125f8829a4aSRandall Stewart 126830d754dSRandall Stewart 127830d754dSRandall Stewart struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */ 128830d754dSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 129830d754dSRandall Stewart uint32_t local_vtag; 130830d754dSRandall Stewart uint32_t remote_vtag; 131830d754dSRandall Stewart } SCTP_PACKED; 132830d754dSRandall Stewart 133830d754dSRandall Stewart 134f8829a4aSRandall Stewart struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */ 135f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 136f8829a4aSRandall Stewart struct sctp_ipv4addr_param addrp; /* max storage size */ 13735918f85SRandall Stewart } SCTP_PACKED; 138f8829a4aSRandall Stewart 139d06c82f1SRandall Stewart #define SCTP_MAX_SUPPORTED_EXT 256 140d06c82f1SRandall Stewart 141f8829a4aSRandall Stewart struct sctp_supported_chunk_types_param { 142f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8008 len = x */ 143663fdad8SMichael Tuexen uint8_t chunk_types[]; 14435918f85SRandall Stewart } SCTP_PACKED; 145f8829a4aSRandall Stewart 146f8829a4aSRandall Stewart 147f8829a4aSRandall Stewart /* 148f8829a4aSRandall Stewart * Structures for DATA chunks 149f8829a4aSRandall Stewart */ 150f8829a4aSRandall Stewart struct sctp_data { 151f8829a4aSRandall Stewart uint32_t tsn; 152f8829a4aSRandall Stewart uint16_t stream_id; 153f8829a4aSRandall Stewart uint16_t stream_sequence; 154f8829a4aSRandall Stewart uint32_t protocol_id; 155f8829a4aSRandall Stewart /* user data follows */ 15635918f85SRandall Stewart } SCTP_PACKED; 157f8829a4aSRandall Stewart 158f8829a4aSRandall Stewart struct sctp_data_chunk { 159f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 160f8829a4aSRandall Stewart struct sctp_data dp; 16135918f85SRandall Stewart } SCTP_PACKED; 162f8829a4aSRandall Stewart 163f8829a4aSRandall Stewart /* 164f8829a4aSRandall Stewart * Structures for the control chunks 165f8829a4aSRandall Stewart */ 166f8829a4aSRandall Stewart 167f8829a4aSRandall Stewart /* Initiate (INIT)/Initiate Ack (INIT ACK) */ 168f8829a4aSRandall Stewart struct sctp_init { 169f8829a4aSRandall Stewart uint32_t initiate_tag; /* initiate tag */ 170f8829a4aSRandall Stewart uint32_t a_rwnd; /* a_rwnd */ 171f8829a4aSRandall Stewart uint16_t num_outbound_streams; /* OS */ 172f8829a4aSRandall Stewart uint16_t num_inbound_streams; /* MIS */ 173f8829a4aSRandall Stewart uint32_t initial_tsn; /* I-TSN */ 174f8829a4aSRandall Stewart /* optional param's follow */ 17535918f85SRandall Stewart } SCTP_PACKED; 176f8829a4aSRandall Stewart 17742551e99SRandall Stewart #define SCTP_IDENTIFICATION_SIZE 16 17842551e99SRandall Stewart #define SCTP_ADDRESS_SIZE 4 17935918f85SRandall Stewart #define SCTP_RESERVE_SPACE 6 180f8829a4aSRandall Stewart /* state cookie header */ 181f8829a4aSRandall Stewart struct sctp_state_cookie { /* this is our definition... */ 18242551e99SRandall Stewart uint8_t identification[SCTP_IDENTIFICATION_SIZE]; /* id of who we are */ 18335918f85SRandall Stewart struct timeval time_entered; /* the time I built cookie */ 184f8829a4aSRandall Stewart uint32_t cookie_life; /* life I will award this cookie */ 185f8829a4aSRandall Stewart uint32_t tie_tag_my_vtag; /* my tag in old association */ 18635918f85SRandall Stewart 187f8829a4aSRandall Stewart uint32_t tie_tag_peer_vtag; /* peers tag in old association */ 188f8829a4aSRandall Stewart uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */ 18935918f85SRandall Stewart 190f8829a4aSRandall Stewart uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */ 19142551e99SRandall Stewart uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */ 192f8829a4aSRandall Stewart uint32_t addr_type; /* address type */ 19342551e99SRandall Stewart uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */ 194f8829a4aSRandall Stewart uint32_t laddr_type; /* my local from address type */ 195f8829a4aSRandall Stewart uint32_t scope_id; /* v6 scope id for link-locals */ 19635918f85SRandall Stewart 197f8829a4aSRandall Stewart uint16_t peerport; /* port address of the peer in the INIT */ 198f8829a4aSRandall Stewart uint16_t myport; /* my port address used in the INIT */ 199f8829a4aSRandall Stewart uint8_t ipv4_addr_legal;/* Are V4 addr legal? */ 200f8829a4aSRandall Stewart uint8_t ipv6_addr_legal;/* Are V6 addr legal? */ 201f8829a4aSRandall Stewart uint8_t local_scope; /* IPv6 local scope flag */ 202f8829a4aSRandall Stewart uint8_t site_scope; /* IPv6 site scope flag */ 20335918f85SRandall Stewart 204f8829a4aSRandall Stewart uint8_t ipv4_scope; /* IPv4 private addr scope */ 205f8829a4aSRandall Stewart uint8_t loopback_scope; /* loopback scope information */ 20635918f85SRandall Stewart uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */ 207f8829a4aSRandall Stewart /* 208f8829a4aSRandall Stewart * at the end is tacked on the INIT chunk and the INIT-ACK chunk 209f8829a4aSRandall Stewart * (minus the cookie). 210f8829a4aSRandall Stewart */ 21135918f85SRandall Stewart } SCTP_PACKED; 212f8829a4aSRandall Stewart 213830d754dSRandall Stewart 214830d754dSRandall Stewart /* Used for NAT state error cause */ 215830d754dSRandall Stewart struct sctp_missing_nat_state { 216830d754dSRandall Stewart uint16_t cause; 217830d754dSRandall Stewart uint16_t length; 218663fdad8SMichael Tuexen uint8_t data[]; 219830d754dSRandall Stewart } SCTP_PACKED; 220830d754dSRandall Stewart 221830d754dSRandall Stewart 222f8829a4aSRandall Stewart struct sctp_inv_mandatory_param { 223f8829a4aSRandall Stewart uint16_t cause; 224f8829a4aSRandall Stewart uint16_t length; 225f8829a4aSRandall Stewart uint32_t num_param; 226f8829a4aSRandall Stewart uint16_t param; 227f8829a4aSRandall Stewart /* 228f8829a4aSRandall Stewart * We include this to 0 it since only a missing cookie will cause 229f8829a4aSRandall Stewart * this error. 230f8829a4aSRandall Stewart */ 231f8829a4aSRandall Stewart uint16_t resv; 23235918f85SRandall Stewart } SCTP_PACKED; 233f8829a4aSRandall Stewart 234f8829a4aSRandall Stewart struct sctp_unresolv_addr { 235f8829a4aSRandall Stewart uint16_t cause; 236f8829a4aSRandall Stewart uint16_t length; 237f8829a4aSRandall Stewart uint16_t addr_type; 238f8829a4aSRandall Stewart uint16_t reserved; /* Only one invalid addr type */ 23935918f85SRandall Stewart } SCTP_PACKED; 240f8829a4aSRandall Stewart 241f8829a4aSRandall Stewart /* state cookie parameter */ 242f8829a4aSRandall Stewart struct sctp_state_cookie_param { 243f8829a4aSRandall Stewart struct sctp_paramhdr ph; 244f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 24535918f85SRandall Stewart } SCTP_PACKED; 246f8829a4aSRandall Stewart 247f8829a4aSRandall Stewart struct sctp_init_chunk { 248f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 249f8829a4aSRandall Stewart struct sctp_init init; 25035918f85SRandall Stewart } SCTP_PACKED; 251f8829a4aSRandall Stewart 252f8829a4aSRandall Stewart struct sctp_init_msg { 253f8829a4aSRandall Stewart struct sctphdr sh; 254f8829a4aSRandall Stewart struct sctp_init_chunk msg; 25535918f85SRandall Stewart } SCTP_PACKED; 256f8829a4aSRandall Stewart 257f8829a4aSRandall Stewart /* ... used for both INIT and INIT ACK */ 258f8829a4aSRandall Stewart #define sctp_init_ack sctp_init 259f8829a4aSRandall Stewart #define sctp_init_ack_chunk sctp_init_chunk 260f8829a4aSRandall Stewart #define sctp_init_ack_msg sctp_init_msg 261f8829a4aSRandall Stewart 262f8829a4aSRandall Stewart 263f8829a4aSRandall Stewart /* Selective Ack (SACK) */ 264f8829a4aSRandall Stewart struct sctp_gap_ack_block { 265f8829a4aSRandall Stewart uint16_t start; /* Gap Ack block start */ 266f8829a4aSRandall Stewart uint16_t end; /* Gap Ack block end */ 26735918f85SRandall Stewart } SCTP_PACKED; 268f8829a4aSRandall Stewart 269f8829a4aSRandall Stewart struct sctp_sack { 270f8829a4aSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 271f8829a4aSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 272f8829a4aSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 273f8829a4aSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 274f8829a4aSRandall Stewart /* struct sctp_gap_ack_block's follow */ 275f8829a4aSRandall Stewart /* uint32_t duplicate_tsn's follow */ 27635918f85SRandall Stewart } SCTP_PACKED; 277f8829a4aSRandall Stewart 278f8829a4aSRandall Stewart struct sctp_sack_chunk { 279f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 280f8829a4aSRandall Stewart struct sctp_sack sack; 28135918f85SRandall Stewart } SCTP_PACKED; 282f8829a4aSRandall Stewart 283830d754dSRandall Stewart struct sctp_nr_sack { 284830d754dSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 285830d754dSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 286830d754dSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 287830d754dSRandall Stewart uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */ 288830d754dSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 289830d754dSRandall Stewart uint16_t reserved; /* not currently used */ 290830d754dSRandall Stewart /* struct sctp_gap_ack_block's follow */ 291830d754dSRandall Stewart /* uint32_t duplicate_tsn's follow */ 292830d754dSRandall Stewart } SCTP_PACKED; 293830d754dSRandall Stewart 294830d754dSRandall Stewart struct sctp_nr_sack_chunk { 295830d754dSRandall Stewart struct sctp_chunkhdr ch; 296830d754dSRandall Stewart struct sctp_nr_sack nr_sack; 297830d754dSRandall Stewart } SCTP_PACKED; 298830d754dSRandall Stewart 299830d754dSRandall Stewart 300f8829a4aSRandall Stewart /* Heartbeat Request (HEARTBEAT) */ 301f8829a4aSRandall Stewart struct sctp_heartbeat { 302f8829a4aSRandall Stewart struct sctp_heartbeat_info_param hb_info; 30335918f85SRandall Stewart } SCTP_PACKED; 304f8829a4aSRandall Stewart 305f8829a4aSRandall Stewart struct sctp_heartbeat_chunk { 306f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 307f8829a4aSRandall Stewart struct sctp_heartbeat heartbeat; 30835918f85SRandall Stewart } SCTP_PACKED; 309f8829a4aSRandall Stewart 310f8829a4aSRandall Stewart /* ... used for Heartbeat Ack (HEARTBEAT ACK) */ 311f8829a4aSRandall Stewart #define sctp_heartbeat_ack sctp_heartbeat 312f8829a4aSRandall Stewart #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk 313f8829a4aSRandall Stewart 314f8829a4aSRandall Stewart 315f8829a4aSRandall Stewart /* Abort Asssociation (ABORT) */ 316f8829a4aSRandall Stewart struct sctp_abort_chunk { 317f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 318f8829a4aSRandall Stewart /* optional error cause may follow */ 31935918f85SRandall Stewart } SCTP_PACKED; 320f8829a4aSRandall Stewart 321f8829a4aSRandall Stewart struct sctp_abort_msg { 322f8829a4aSRandall Stewart struct sctphdr sh; 323f8829a4aSRandall Stewart struct sctp_abort_chunk msg; 32435918f85SRandall Stewart } SCTP_PACKED; 325f8829a4aSRandall Stewart 326f8829a4aSRandall Stewart 327f8829a4aSRandall Stewart /* Shutdown Association (SHUTDOWN) */ 328f8829a4aSRandall Stewart struct sctp_shutdown_chunk { 329f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 330f8829a4aSRandall Stewart uint32_t cumulative_tsn_ack; 33135918f85SRandall Stewart } SCTP_PACKED; 332f8829a4aSRandall Stewart 333f8829a4aSRandall Stewart 334f8829a4aSRandall Stewart /* Shutdown Acknowledgment (SHUTDOWN ACK) */ 335f8829a4aSRandall Stewart struct sctp_shutdown_ack_chunk { 336f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 33735918f85SRandall Stewart } SCTP_PACKED; 338f8829a4aSRandall Stewart 339f8829a4aSRandall Stewart 340f8829a4aSRandall Stewart /* Operation Error (ERROR) */ 341f8829a4aSRandall Stewart struct sctp_error_chunk { 342f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 343f8829a4aSRandall Stewart /* optional error causes follow */ 34435918f85SRandall Stewart } SCTP_PACKED; 345f8829a4aSRandall Stewart 346f8829a4aSRandall Stewart 347f8829a4aSRandall Stewart /* Cookie Echo (COOKIE ECHO) */ 348f8829a4aSRandall Stewart struct sctp_cookie_echo_chunk { 349f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 350f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 35135918f85SRandall Stewart } SCTP_PACKED; 352f8829a4aSRandall Stewart 353f8829a4aSRandall Stewart /* Cookie Acknowledgment (COOKIE ACK) */ 354f8829a4aSRandall Stewart struct sctp_cookie_ack_chunk { 355f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 35635918f85SRandall Stewart } SCTP_PACKED; 357f8829a4aSRandall Stewart 358f8829a4aSRandall Stewart /* Explicit Congestion Notification Echo (ECNE) */ 359a21779f0SRandall Stewart struct old_sctp_ecne_chunk { 360a21779f0SRandall Stewart struct sctp_chunkhdr ch; 361a21779f0SRandall Stewart uint32_t tsn; 362a21779f0SRandall Stewart } SCTP_PACKED; 363a21779f0SRandall Stewart 364f8829a4aSRandall Stewart struct sctp_ecne_chunk { 365f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 366f8829a4aSRandall Stewart uint32_t tsn; 367a21779f0SRandall Stewart uint32_t num_pkts_since_cwr; 36835918f85SRandall Stewart } SCTP_PACKED; 369f8829a4aSRandall Stewart 370f8829a4aSRandall Stewart /* Congestion Window Reduced (CWR) */ 371f8829a4aSRandall Stewart struct sctp_cwr_chunk { 372f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 373f8829a4aSRandall Stewart uint32_t tsn; 37435918f85SRandall Stewart } SCTP_PACKED; 375f8829a4aSRandall Stewart 376f8829a4aSRandall Stewart /* Shutdown Complete (SHUTDOWN COMPLETE) */ 377f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk { 378f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 37935918f85SRandall Stewart } SCTP_PACKED; 380f8829a4aSRandall Stewart 381f8829a4aSRandall Stewart /* Oper error holding a stale cookie */ 382f8829a4aSRandall Stewart struct sctp_stale_cookie_msg { 383f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* really an error cause */ 384f8829a4aSRandall Stewart uint32_t time_usec; 38535918f85SRandall Stewart } SCTP_PACKED; 386f8829a4aSRandall Stewart 387f8829a4aSRandall Stewart struct sctp_adaptation_layer_indication { 388f8829a4aSRandall Stewart struct sctp_paramhdr ph; 389f8829a4aSRandall Stewart uint32_t indication; 39035918f85SRandall Stewart } SCTP_PACKED; 391f8829a4aSRandall Stewart 392f8829a4aSRandall Stewart struct sctp_cookie_while_shutting_down { 393f8829a4aSRandall Stewart struct sctphdr sh; 394f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 395f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* really an error cause */ 39635918f85SRandall Stewart } SCTP_PACKED; 397f8829a4aSRandall Stewart 398f8829a4aSRandall Stewart struct sctp_shutdown_complete_msg { 399f8829a4aSRandall Stewart struct sctphdr sh; 400f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk shut_cmp; 40135918f85SRandall Stewart } SCTP_PACKED; 402f8829a4aSRandall Stewart 403f8829a4aSRandall Stewart /* 404f8829a4aSRandall Stewart * draft-ietf-tsvwg-addip-sctp 405f8829a4aSRandall Stewart */ 406f8829a4aSRandall Stewart /* Address/Stream Configuration Change (ASCONF) */ 407f8829a4aSRandall Stewart struct sctp_asconf_chunk { 408f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 409f8829a4aSRandall Stewart uint32_t serial_number; 410f8829a4aSRandall Stewart /* lookup address parameter (mandatory) */ 411f8829a4aSRandall Stewart /* asconf parameters follow */ 41235918f85SRandall Stewart } SCTP_PACKED; 413f8829a4aSRandall Stewart 414f8829a4aSRandall Stewart /* Address/Stream Configuration Acknowledge (ASCONF ACK) */ 415f8829a4aSRandall Stewart struct sctp_asconf_ack_chunk { 416f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 417f8829a4aSRandall Stewart uint32_t serial_number; 418f8829a4aSRandall Stewart /* asconf parameters follow */ 41935918f85SRandall Stewart } SCTP_PACKED; 420f8829a4aSRandall Stewart 421f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 422f8829a4aSRandall Stewart /* Forward Cumulative TSN (FORWARD TSN) */ 423f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk { 424f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 425f8829a4aSRandall Stewart uint32_t new_cumulative_tsn; 426f8829a4aSRandall Stewart /* stream/sequence pairs (sctp_strseq) follow */ 42735918f85SRandall Stewart } SCTP_PACKED; 428f8829a4aSRandall Stewart 429f8829a4aSRandall Stewart struct sctp_strseq { 430f8829a4aSRandall Stewart uint16_t stream; 431f8829a4aSRandall Stewart uint16_t sequence; 43235918f85SRandall Stewart } SCTP_PACKED; 433f8829a4aSRandall Stewart 434f8829a4aSRandall Stewart struct sctp_forward_tsn_msg { 435f8829a4aSRandall Stewart struct sctphdr sh; 436f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk msg; 43735918f85SRandall Stewart } SCTP_PACKED; 438f8829a4aSRandall Stewart 439f8829a4aSRandall Stewart /* should be a multiple of 4 - 1 aka 3/7/11 etc. */ 440f8829a4aSRandall Stewart 441f8829a4aSRandall Stewart #define SCTP_NUM_DB_TO_VERIFY 31 442f8829a4aSRandall Stewart 443f8829a4aSRandall Stewart struct sctp_chunk_desc { 444f8829a4aSRandall Stewart uint8_t chunk_type; 445f8829a4aSRandall Stewart uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY]; 446f8829a4aSRandall Stewart uint32_t tsn_ifany; 44735918f85SRandall Stewart } SCTP_PACKED; 448f8829a4aSRandall Stewart 449f8829a4aSRandall Stewart 450f8829a4aSRandall Stewart struct sctp_pktdrop_chunk { 451f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 452f8829a4aSRandall Stewart uint32_t bottle_bw; 453f8829a4aSRandall Stewart uint32_t current_onq; 454f8829a4aSRandall Stewart uint16_t trunc_len; 455f8829a4aSRandall Stewart uint16_t reserved; 456663fdad8SMichael Tuexen uint8_t data[]; 45735918f85SRandall Stewart } SCTP_PACKED; 458f8829a4aSRandall Stewart 459f8829a4aSRandall Stewart /**********STREAM RESET STUFF ******************/ 460f8829a4aSRandall Stewart 461f8829a4aSRandall Stewart struct sctp_stream_reset_out_request { 462f8829a4aSRandall Stewart struct sctp_paramhdr ph; 463f8829a4aSRandall Stewart uint32_t request_seq; /* monotonically increasing seq no */ 464f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 465f8829a4aSRandall Stewart uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */ 466663fdad8SMichael Tuexen uint16_t list_of_streams[]; /* if not all list of streams */ 46735918f85SRandall Stewart } SCTP_PACKED; 468f8829a4aSRandall Stewart 469f8829a4aSRandall Stewart struct sctp_stream_reset_in_request { 470f8829a4aSRandall Stewart struct sctp_paramhdr ph; 471f8829a4aSRandall Stewart uint32_t request_seq; 472663fdad8SMichael Tuexen uint16_t list_of_streams[]; /* if not all list of streams */ 47335918f85SRandall Stewart } SCTP_PACKED; 474f8829a4aSRandall Stewart 475f8829a4aSRandall Stewart 476f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request { 477f8829a4aSRandall Stewart struct sctp_paramhdr ph; 478f8829a4aSRandall Stewart uint32_t request_seq; 47935918f85SRandall Stewart } SCTP_PACKED; 480f8829a4aSRandall Stewart 481f8829a4aSRandall Stewart struct sctp_stream_reset_response { 482f8829a4aSRandall Stewart struct sctp_paramhdr ph; 483f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 484f8829a4aSRandall Stewart uint32_t result; 48535918f85SRandall Stewart } SCTP_PACKED; 486f8829a4aSRandall Stewart 487f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn { 488f8829a4aSRandall Stewart struct sctp_paramhdr ph; 489f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 490f8829a4aSRandall Stewart uint32_t result; 491f8829a4aSRandall Stewart uint32_t senders_next_tsn; 492f8829a4aSRandall Stewart uint32_t receivers_next_tsn; 49335918f85SRandall Stewart } SCTP_PACKED; 494f8829a4aSRandall Stewart 495ea44232bSRandall Stewart struct sctp_stream_reset_add_strm { 496ea44232bSRandall Stewart struct sctp_paramhdr ph; 497ea44232bSRandall Stewart uint32_t request_seq; 498ea44232bSRandall Stewart uint16_t number_of_streams; 499ea44232bSRandall Stewart uint16_t reserved; 5008d9d0613SMichael Tuexen } SCTP_PACKED; 501f8829a4aSRandall Stewart 502f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ 503f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ 504f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_DENIED 0x00000002 /* refused to do it */ 505f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ 506f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ 507f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ 508f8829a4aSRandall Stewart 509f8829a4aSRandall Stewart /* 510f8829a4aSRandall Stewart * convience structures, note that if you are making a request for specific 511f8829a4aSRandall Stewart * streams then the request will need to be an overlay structure. 512f8829a4aSRandall Stewart */ 513f8829a4aSRandall Stewart 514f8829a4aSRandall Stewart struct sctp_stream_reset_out_req { 515f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 516f8829a4aSRandall Stewart struct sctp_stream_reset_out_request sr_req; 51735918f85SRandall Stewart } SCTP_PACKED; 518f8829a4aSRandall Stewart 519f8829a4aSRandall Stewart struct sctp_stream_reset_in_req { 520f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 521f8829a4aSRandall Stewart struct sctp_stream_reset_in_request sr_req; 52235918f85SRandall Stewart } SCTP_PACKED; 523f8829a4aSRandall Stewart 524f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_req { 525f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 526f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request sr_req; 52735918f85SRandall Stewart } SCTP_PACKED; 528f8829a4aSRandall Stewart 529f8829a4aSRandall Stewart struct sctp_stream_reset_resp { 530f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 531f8829a4aSRandall Stewart struct sctp_stream_reset_response sr_resp; 53235918f85SRandall Stewart } SCTP_PACKED; 533f8829a4aSRandall Stewart 534f8829a4aSRandall Stewart /* respone only valid with a TSN request */ 535f8829a4aSRandall Stewart struct sctp_stream_reset_resp_tsn { 536f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 537f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn sr_resp; 53835918f85SRandall Stewart } SCTP_PACKED; 539f8829a4aSRandall Stewart 540f8829a4aSRandall Stewart /****************************************************/ 541f8829a4aSRandall Stewart 542f8829a4aSRandall Stewart /* 543f8829a4aSRandall Stewart * Authenticated chunks support draft-ietf-tsvwg-sctp-auth 544f8829a4aSRandall Stewart */ 545d06c82f1SRandall Stewart 546d06c82f1SRandall Stewart /* Should we make the max be 32? */ 547d06c82f1SRandall Stewart #define SCTP_RANDOM_MAX_SIZE 256 548f8829a4aSRandall Stewart struct sctp_auth_random { 549f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8002 */ 550663fdad8SMichael Tuexen uint8_t random_data[]; 55135918f85SRandall Stewart } SCTP_PACKED; 552f8829a4aSRandall Stewart 553f8829a4aSRandall Stewart struct sctp_auth_chunk_list { 554f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8003 */ 555663fdad8SMichael Tuexen uint8_t chunk_types[]; 55635918f85SRandall Stewart } SCTP_PACKED; 557f8829a4aSRandall Stewart 558f8829a4aSRandall Stewart struct sctp_auth_hmac_algo { 559f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8004 */ 560663fdad8SMichael Tuexen uint16_t hmac_ids[]; 56135918f85SRandall Stewart } SCTP_PACKED; 562f8829a4aSRandall Stewart 563f8829a4aSRandall Stewart struct sctp_auth_chunk { 564f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 565f8829a4aSRandall Stewart uint16_t shared_key_id; 566f8829a4aSRandall Stewart uint16_t hmac_id; 567663fdad8SMichael Tuexen uint8_t hmac[]; 56835918f85SRandall Stewart } SCTP_PACKED; 569f8829a4aSRandall Stewart 570f8829a4aSRandall Stewart struct sctp_auth_invalid_hmac { 571f8829a4aSRandall Stewart struct sctp_paramhdr ph; 572f8829a4aSRandall Stewart uint16_t hmac_id; 573f8829a4aSRandall Stewart uint16_t padding; 57435918f85SRandall Stewart } SCTP_PACKED; 575f8829a4aSRandall Stewart 576f8829a4aSRandall Stewart /* 577f8829a4aSRandall Stewart * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing 578f8829a4aSRandall Stewart * pieces. If ENCE is missing we could have a couple of blocks. This way we 579f8829a4aSRandall Stewart * optimize so we MOST likely can bundle a SACK/ECN with the smallest size 580f8829a4aSRandall Stewart * data chunk I will split into. We could increase throughput slightly by 581f8829a4aSRandall Stewart * taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I 582f8829a4aSRandall Stewart * feel is worth it for now. 583f8829a4aSRandall Stewart */ 584f8829a4aSRandall Stewart #ifndef SCTP_MAX_OVERHEAD 58542551e99SRandall Stewart #ifdef INET6 586f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 587f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 588f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 589f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 590f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 591f8829a4aSRandall Stewart 592f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 593f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 594f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 595f8829a4aSRandall Stewart 596f8829a4aSRandall Stewart 597f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \ 598f8829a4aSRandall Stewart sizeof(struct sctphdr)) 599f8829a4aSRandall Stewart 600f8829a4aSRandall Stewart #else 601f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 602f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 603f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 604f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 605f8829a4aSRandall Stewart sizeof(struct ip)) 606f8829a4aSRandall Stewart 607f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 608f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 609f8829a4aSRandall Stewart sizeof(struct ip)) 610f8829a4aSRandall Stewart 611f8829a4aSRandall Stewart 612f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \ 613f8829a4aSRandall Stewart sizeof(struct sctphdr)) 614f8829a4aSRandall Stewart 61542551e99SRandall Stewart #endif /* INET6 */ 616f8829a4aSRandall Stewart #endif /* !SCTP_MAX_OVERHEAD */ 617f8829a4aSRandall Stewart 618f8829a4aSRandall Stewart #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 619f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 620f8829a4aSRandall Stewart sizeof(struct ip)) 621f8829a4aSRandall Stewart 622f8829a4aSRandall Stewart #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ 623f8829a4aSRandall Stewart sizeof(struct sctphdr)) 624f8829a4aSRandall Stewart 625b3f1ea41SRandall Stewart #undef SCTP_PACKED 626f8829a4aSRandall Stewart #endif /* !__sctp_header_h__ */ 627