1f8829a4aSRandall Stewart /*- 2b1006367SRandall Stewart * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 3807aad63SMichael Tuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 4807aad63SMichael Tuexen * Copyright (c) 2008-2012, 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 #include <sys/cdefs.h> 34f8829a4aSRandall Stewart __FBSDID("$FreeBSD$"); 35f8829a4aSRandall Stewart 36807aad63SMichael Tuexen #ifndef _NETINET_SCTP_HEADER_H_ 37807aad63SMichael Tuexen #define _NETINET_SCTP_HEADER_H_ 38f8829a4aSRandall Stewart 39f8829a4aSRandall Stewart #include <sys/time.h> 40f8829a4aSRandall Stewart #include <netinet/sctp.h> 41f8829a4aSRandall Stewart #include <netinet/sctp_constants.h> 42f8829a4aSRandall Stewart 43b3f1ea41SRandall Stewart #define SCTP_PACKED __attribute__((packed)) 4435918f85SRandall Stewart 45f8829a4aSRandall Stewart /* 46f8829a4aSRandall Stewart * Parameter structures 47f8829a4aSRandall Stewart */ 48f8829a4aSRandall Stewart struct sctp_ipv4addr_param { 49f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_IPV4_PARAM_TYPE, len=8 */ 50f8829a4aSRandall Stewart uint32_t addr; /* IPV4 address */ 5135918f85SRandall Stewart } SCTP_PACKED; 52f8829a4aSRandall Stewart 5342551e99SRandall Stewart #define SCTP_V6_ADDR_BYTES 16 5442551e99SRandall Stewart 5542551e99SRandall Stewart 56f8829a4aSRandall Stewart struct sctp_ipv6addr_param { 57f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */ 5842551e99SRandall Stewart uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */ 5935918f85SRandall Stewart } SCTP_PACKED; 60f8829a4aSRandall Stewart 61f8829a4aSRandall Stewart /* Cookie Preservative */ 62f8829a4aSRandall Stewart struct sctp_cookie_perserve_param { 63f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_COOKIE_PRESERVE, len=8 */ 64f8829a4aSRandall Stewart uint32_t time; /* time in ms to extend cookie */ 658d9d0613SMichael Tuexen } SCTP_PACKED; 66f8829a4aSRandall Stewart 6742551e99SRandall Stewart #define SCTP_ARRAY_MIN_LEN 1 68f8829a4aSRandall Stewart /* Host Name Address */ 69f8829a4aSRandall Stewart struct sctp_host_name_param { 70f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_HOSTNAME_ADDRESS */ 7142551e99SRandall Stewart char name[SCTP_ARRAY_MIN_LEN]; /* host name */ 7235918f85SRandall Stewart } SCTP_PACKED; 73f8829a4aSRandall Stewart 74d06c82f1SRandall Stewart /* 75d06c82f1SRandall Stewart * This is the maximum padded size of a s-a-p 76d06c82f1SRandall Stewart * so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12 77d06c82f1SRandall Stewart */ 78d06c82f1SRandall Stewart #define SCTP_MAX_ADDR_PARAMS_SIZE 12 79f8829a4aSRandall Stewart /* supported address type */ 80f8829a4aSRandall Stewart struct sctp_supported_addr_param { 81f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_SUPPORTED_ADDRTYPE */ 8270acddf1SMichael Tuexen uint16_t addr_type[2]; /* array of supported address types */ 8335918f85SRandall Stewart } SCTP_PACKED; 84f8829a4aSRandall Stewart 85f8829a4aSRandall Stewart /* heartbeat info parameter */ 86f8829a4aSRandall Stewart struct sctp_heartbeat_info_param { 87f8829a4aSRandall Stewart struct sctp_paramhdr ph; 88f8829a4aSRandall Stewart uint32_t time_value_1; 89f8829a4aSRandall Stewart uint32_t time_value_2; 90f8829a4aSRandall Stewart uint32_t random_value1; 91f8829a4aSRandall Stewart uint32_t random_value2; 92f8829a4aSRandall Stewart uint8_t addr_family; 93f8829a4aSRandall Stewart uint8_t addr_len; 94ca85e948SMichael Tuexen /* make sure that this structure is 4 byte aligned */ 95ca85e948SMichael Tuexen uint8_t padding[2]; 96f8829a4aSRandall Stewart char address[SCTP_ADDRMAX]; 9735918f85SRandall Stewart } SCTP_PACKED; 98f8829a4aSRandall Stewart 99f8829a4aSRandall Stewart 100f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 101f8829a4aSRandall Stewart /* PR-SCTP supported parameter */ 102f8829a4aSRandall Stewart struct sctp_prsctp_supported_param { 103f8829a4aSRandall Stewart struct sctp_paramhdr ph; 10435918f85SRandall Stewart } SCTP_PACKED; 105f8829a4aSRandall Stewart 106f8829a4aSRandall Stewart 107f8829a4aSRandall Stewart /* draft-ietf-tsvwg-addip-sctp */ 108f8829a4aSRandall Stewart struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */ 109f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* a SCTP parameter header */ 110f8829a4aSRandall Stewart uint32_t correlation_id;/* correlation id for this param */ 11135918f85SRandall Stewart } SCTP_PACKED; 112f8829a4aSRandall Stewart 113f8829a4aSRandall Stewart struct sctp_asconf_addr_param { /* an ASCONF address parameter */ 114f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 115f8829a4aSRandall Stewart struct sctp_ipv6addr_param addrp; /* max storage size */ 11635918f85SRandall Stewart } SCTP_PACKED; 117f8829a4aSRandall Stewart 118830d754dSRandall Stewart 119830d754dSRandall Stewart struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */ 120830d754dSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 121830d754dSRandall Stewart uint32_t local_vtag; 122830d754dSRandall Stewart uint32_t remote_vtag; 123830d754dSRandall Stewart } SCTP_PACKED; 124830d754dSRandall Stewart 125830d754dSRandall Stewart 126f8829a4aSRandall Stewart struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */ 127f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 128f8829a4aSRandall Stewart struct sctp_ipv4addr_param addrp; /* max storage size */ 12935918f85SRandall Stewart } SCTP_PACKED; 130f8829a4aSRandall Stewart 131d06c82f1SRandall Stewart #define SCTP_MAX_SUPPORTED_EXT 256 132d06c82f1SRandall Stewart 133f8829a4aSRandall Stewart struct sctp_supported_chunk_types_param { 134f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8008 len = x */ 135663fdad8SMichael Tuexen uint8_t chunk_types[]; 13635918f85SRandall Stewart } SCTP_PACKED; 137f8829a4aSRandall Stewart 138f8829a4aSRandall Stewart 139f8829a4aSRandall Stewart /* 140f8829a4aSRandall Stewart * Structures for DATA chunks 141f8829a4aSRandall Stewart */ 142f8829a4aSRandall Stewart struct sctp_data { 143f8829a4aSRandall Stewart uint32_t tsn; 144*49656eefSMichael Tuexen uint16_t sid; 145*49656eefSMichael Tuexen uint16_t ssn; 146*49656eefSMichael Tuexen uint32_t ppid; 147f8829a4aSRandall Stewart /* user data follows */ 14835918f85SRandall Stewart } SCTP_PACKED; 149f8829a4aSRandall Stewart 150f8829a4aSRandall Stewart struct sctp_data_chunk { 151f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 152f8829a4aSRandall Stewart struct sctp_data dp; 15335918f85SRandall Stewart } SCTP_PACKED; 154f8829a4aSRandall Stewart 15544249214SRandall Stewart struct sctp_idata { 15644249214SRandall Stewart uint32_t tsn; 157*49656eefSMichael Tuexen uint16_t sid; 15844249214SRandall Stewart uint16_t reserved; /* Where does the SSN go? */ 159*49656eefSMichael Tuexen uint32_t mid; 16044249214SRandall Stewart union { 161*49656eefSMichael Tuexen uint32_t ppid; 16244249214SRandall Stewart uint32_t fsn; /* Fragment Sequence Number */ 163e187bac2SMichael Tuexen } ppid_fsn; 16444249214SRandall Stewart /* user data follows */ 16544249214SRandall Stewart } SCTP_PACKED; 16644249214SRandall Stewart 16744249214SRandall Stewart struct sctp_idata_chunk { 16844249214SRandall Stewart struct sctp_chunkhdr ch; 16944249214SRandall Stewart struct sctp_idata dp; 17044249214SRandall Stewart } SCTP_PACKED; 17144249214SRandall Stewart 172f8829a4aSRandall Stewart /* 173f8829a4aSRandall Stewart * Structures for the control chunks 174f8829a4aSRandall Stewart */ 175f8829a4aSRandall Stewart 176f8829a4aSRandall Stewart /* Initiate (INIT)/Initiate Ack (INIT ACK) */ 177f8829a4aSRandall Stewart struct sctp_init { 178f8829a4aSRandall Stewart uint32_t initiate_tag; /* initiate tag */ 179f8829a4aSRandall Stewart uint32_t a_rwnd; /* a_rwnd */ 180f8829a4aSRandall Stewart uint16_t num_outbound_streams; /* OS */ 181f8829a4aSRandall Stewart uint16_t num_inbound_streams; /* MIS */ 182f8829a4aSRandall Stewart uint32_t initial_tsn; /* I-TSN */ 183f8829a4aSRandall Stewart /* optional param's follow */ 18435918f85SRandall Stewart } SCTP_PACKED; 18542551e99SRandall Stewart #define SCTP_IDENTIFICATION_SIZE 16 18642551e99SRandall Stewart #define SCTP_ADDRESS_SIZE 4 18735918f85SRandall Stewart #define SCTP_RESERVE_SPACE 6 188f8829a4aSRandall Stewart /* state cookie header */ 189f8829a4aSRandall Stewart struct sctp_state_cookie { /* this is our definition... */ 19042551e99SRandall Stewart uint8_t identification[SCTP_IDENTIFICATION_SIZE]; /* id of who we are */ 19135918f85SRandall Stewart struct timeval time_entered; /* the time I built cookie */ 192f8829a4aSRandall Stewart uint32_t cookie_life; /* life I will award this cookie */ 193f8829a4aSRandall Stewart uint32_t tie_tag_my_vtag; /* my tag in old association */ 19435918f85SRandall Stewart 195f8829a4aSRandall Stewart uint32_t tie_tag_peer_vtag; /* peers tag in old association */ 196f8829a4aSRandall Stewart uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */ 19735918f85SRandall Stewart 198f8829a4aSRandall Stewart uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */ 19942551e99SRandall Stewart uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */ 200f8829a4aSRandall Stewart uint32_t addr_type; /* address type */ 20142551e99SRandall Stewart uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */ 202f8829a4aSRandall Stewart uint32_t laddr_type; /* my local from address type */ 203f8829a4aSRandall Stewart uint32_t scope_id; /* v6 scope id for link-locals */ 20435918f85SRandall Stewart 205f8829a4aSRandall Stewart uint16_t peerport; /* port address of the peer in the INIT */ 206f8829a4aSRandall Stewart uint16_t myport; /* my port address used in the INIT */ 207f8829a4aSRandall Stewart uint8_t ipv4_addr_legal;/* Are V4 addr legal? */ 208f8829a4aSRandall Stewart uint8_t ipv6_addr_legal;/* Are V6 addr legal? */ 209f8829a4aSRandall Stewart uint8_t local_scope; /* IPv6 local scope flag */ 210f8829a4aSRandall Stewart uint8_t site_scope; /* IPv6 site scope flag */ 21135918f85SRandall Stewart 212f8829a4aSRandall Stewart uint8_t ipv4_scope; /* IPv4 private addr scope */ 213f8829a4aSRandall Stewart uint8_t loopback_scope; /* loopback scope information */ 21435918f85SRandall Stewart uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */ 215f8829a4aSRandall Stewart /* 216f8829a4aSRandall Stewart * at the end is tacked on the INIT chunk and the INIT-ACK chunk 217f8829a4aSRandall Stewart * (minus the cookie). 218f8829a4aSRandall Stewart */ 21935918f85SRandall Stewart } SCTP_PACKED; 220f8829a4aSRandall Stewart 221f8829a4aSRandall Stewart /* state cookie parameter */ 222f8829a4aSRandall Stewart struct sctp_state_cookie_param { 223f8829a4aSRandall Stewart struct sctp_paramhdr ph; 224f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 22535918f85SRandall Stewart } SCTP_PACKED; 226f8829a4aSRandall Stewart 227f8829a4aSRandall Stewart struct sctp_init_chunk { 228f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 229f8829a4aSRandall Stewart struct sctp_init init; 23035918f85SRandall Stewart } SCTP_PACKED; 231f8829a4aSRandall Stewart 232f8829a4aSRandall Stewart struct sctp_init_msg { 233f8829a4aSRandall Stewart struct sctphdr sh; 234f8829a4aSRandall Stewart struct sctp_init_chunk msg; 23535918f85SRandall Stewart } SCTP_PACKED; 236f8829a4aSRandall Stewart 237f8829a4aSRandall Stewart /* ... used for both INIT and INIT ACK */ 238f8829a4aSRandall Stewart #define sctp_init_ack sctp_init 239f8829a4aSRandall Stewart #define sctp_init_ack_chunk sctp_init_chunk 240f8829a4aSRandall Stewart #define sctp_init_ack_msg sctp_init_msg 241f8829a4aSRandall Stewart 242f8829a4aSRandall Stewart 243f8829a4aSRandall Stewart /* Selective Ack (SACK) */ 244f8829a4aSRandall Stewart struct sctp_gap_ack_block { 245f8829a4aSRandall Stewart uint16_t start; /* Gap Ack block start */ 246f8829a4aSRandall Stewart uint16_t end; /* Gap Ack block end */ 24735918f85SRandall Stewart } SCTP_PACKED; 248f8829a4aSRandall Stewart 249f8829a4aSRandall Stewart struct sctp_sack { 250f8829a4aSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 251f8829a4aSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 252f8829a4aSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 253f8829a4aSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 254f8829a4aSRandall Stewart /* struct sctp_gap_ack_block's follow */ 255f8829a4aSRandall Stewart /* uint32_t duplicate_tsn's follow */ 25635918f85SRandall Stewart } SCTP_PACKED; 257f8829a4aSRandall Stewart 258f8829a4aSRandall Stewart struct sctp_sack_chunk { 259f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 260f8829a4aSRandall Stewart struct sctp_sack sack; 26135918f85SRandall Stewart } SCTP_PACKED; 262f8829a4aSRandall Stewart 263830d754dSRandall Stewart struct sctp_nr_sack { 264830d754dSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 265830d754dSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 266830d754dSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 267830d754dSRandall Stewart uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */ 268830d754dSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 269830d754dSRandall Stewart uint16_t reserved; /* not currently used */ 270830d754dSRandall Stewart /* struct sctp_gap_ack_block's follow */ 271830d754dSRandall Stewart /* uint32_t duplicate_tsn's follow */ 272830d754dSRandall Stewart } SCTP_PACKED; 273830d754dSRandall Stewart 274830d754dSRandall Stewart struct sctp_nr_sack_chunk { 275830d754dSRandall Stewart struct sctp_chunkhdr ch; 276830d754dSRandall Stewart struct sctp_nr_sack nr_sack; 277830d754dSRandall Stewart } SCTP_PACKED; 278830d754dSRandall Stewart 279830d754dSRandall Stewart 280f8829a4aSRandall Stewart /* Heartbeat Request (HEARTBEAT) */ 281f8829a4aSRandall Stewart struct sctp_heartbeat { 282f8829a4aSRandall Stewart struct sctp_heartbeat_info_param hb_info; 28335918f85SRandall Stewart } SCTP_PACKED; 284f8829a4aSRandall Stewart 285f8829a4aSRandall Stewart struct sctp_heartbeat_chunk { 286f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 287f8829a4aSRandall Stewart struct sctp_heartbeat heartbeat; 28835918f85SRandall Stewart } SCTP_PACKED; 289f8829a4aSRandall Stewart 290f8829a4aSRandall Stewart /* ... used for Heartbeat Ack (HEARTBEAT ACK) */ 291f8829a4aSRandall Stewart #define sctp_heartbeat_ack sctp_heartbeat 292f8829a4aSRandall Stewart #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk 293f8829a4aSRandall Stewart 294f8829a4aSRandall Stewart 295f8829a4aSRandall Stewart /* Abort Asssociation (ABORT) */ 296f8829a4aSRandall Stewart struct sctp_abort_chunk { 297f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 298f8829a4aSRandall Stewart /* optional error cause may follow */ 29935918f85SRandall Stewart } SCTP_PACKED; 300f8829a4aSRandall Stewart 301f8829a4aSRandall Stewart struct sctp_abort_msg { 302f8829a4aSRandall Stewart struct sctphdr sh; 303f8829a4aSRandall Stewart struct sctp_abort_chunk msg; 30435918f85SRandall Stewart } SCTP_PACKED; 305f8829a4aSRandall Stewart 306f8829a4aSRandall Stewart 307f8829a4aSRandall Stewart /* Shutdown Association (SHUTDOWN) */ 308f8829a4aSRandall Stewart struct sctp_shutdown_chunk { 309f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 310f8829a4aSRandall Stewart uint32_t cumulative_tsn_ack; 31135918f85SRandall Stewart } SCTP_PACKED; 312f8829a4aSRandall Stewart 313f8829a4aSRandall Stewart 314f8829a4aSRandall Stewart /* Shutdown Acknowledgment (SHUTDOWN ACK) */ 315f8829a4aSRandall Stewart struct sctp_shutdown_ack_chunk { 316f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 31735918f85SRandall Stewart } SCTP_PACKED; 318f8829a4aSRandall Stewart 319f8829a4aSRandall Stewart 320f8829a4aSRandall Stewart /* Operation Error (ERROR) */ 321f8829a4aSRandall Stewart struct sctp_error_chunk { 322f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 323f8829a4aSRandall Stewart /* optional error causes follow */ 32435918f85SRandall Stewart } SCTP_PACKED; 325f8829a4aSRandall Stewart 326f8829a4aSRandall Stewart 327f8829a4aSRandall Stewart /* Cookie Echo (COOKIE ECHO) */ 328f8829a4aSRandall Stewart struct sctp_cookie_echo_chunk { 329f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 330f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 33135918f85SRandall Stewart } SCTP_PACKED; 332f8829a4aSRandall Stewart 333f8829a4aSRandall Stewart /* Cookie Acknowledgment (COOKIE ACK) */ 334f8829a4aSRandall Stewart struct sctp_cookie_ack_chunk { 335f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 33635918f85SRandall Stewart } SCTP_PACKED; 337f8829a4aSRandall Stewart 338f8829a4aSRandall Stewart /* Explicit Congestion Notification Echo (ECNE) */ 339a21779f0SRandall Stewart struct old_sctp_ecne_chunk { 340a21779f0SRandall Stewart struct sctp_chunkhdr ch; 341a21779f0SRandall Stewart uint32_t tsn; 342a21779f0SRandall Stewart } SCTP_PACKED; 343a21779f0SRandall Stewart 344f8829a4aSRandall Stewart struct sctp_ecne_chunk { 345f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 346f8829a4aSRandall Stewart uint32_t tsn; 347a21779f0SRandall Stewart uint32_t num_pkts_since_cwr; 34835918f85SRandall Stewart } SCTP_PACKED; 349f8829a4aSRandall Stewart 350f8829a4aSRandall Stewart /* Congestion Window Reduced (CWR) */ 351f8829a4aSRandall Stewart struct sctp_cwr_chunk { 352f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 353f8829a4aSRandall Stewart uint32_t tsn; 35435918f85SRandall Stewart } SCTP_PACKED; 355f8829a4aSRandall Stewart 356f8829a4aSRandall Stewart /* Shutdown Complete (SHUTDOWN COMPLETE) */ 357f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk { 358f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 35935918f85SRandall Stewart } SCTP_PACKED; 360f8829a4aSRandall Stewart 361f8829a4aSRandall Stewart struct sctp_adaptation_layer_indication { 362f8829a4aSRandall Stewart struct sctp_paramhdr ph; 363f8829a4aSRandall Stewart uint32_t indication; 36435918f85SRandall Stewart } SCTP_PACKED; 365f8829a4aSRandall Stewart 366f8829a4aSRandall Stewart /* 367f8829a4aSRandall Stewart * draft-ietf-tsvwg-addip-sctp 368f8829a4aSRandall Stewart */ 369f8829a4aSRandall Stewart /* Address/Stream Configuration Change (ASCONF) */ 370f8829a4aSRandall Stewart struct sctp_asconf_chunk { 371f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 372f8829a4aSRandall Stewart uint32_t serial_number; 373f8829a4aSRandall Stewart /* lookup address parameter (mandatory) */ 374f8829a4aSRandall Stewart /* asconf parameters follow */ 37535918f85SRandall Stewart } SCTP_PACKED; 376f8829a4aSRandall Stewart 377f8829a4aSRandall Stewart /* Address/Stream Configuration Acknowledge (ASCONF ACK) */ 378f8829a4aSRandall Stewart struct sctp_asconf_ack_chunk { 379f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 380f8829a4aSRandall Stewart uint32_t serial_number; 381f8829a4aSRandall Stewart /* asconf parameters follow */ 38235918f85SRandall Stewart } SCTP_PACKED; 383f8829a4aSRandall Stewart 384f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 385f8829a4aSRandall Stewart /* Forward Cumulative TSN (FORWARD TSN) */ 386f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk { 387f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 388f8829a4aSRandall Stewart uint32_t new_cumulative_tsn; 389f8829a4aSRandall Stewart /* stream/sequence pairs (sctp_strseq) follow */ 39035918f85SRandall Stewart } SCTP_PACKED; 391f8829a4aSRandall Stewart 392f8829a4aSRandall Stewart struct sctp_strseq { 393*49656eefSMichael Tuexen uint16_t sid; 394*49656eefSMichael Tuexen uint16_t ssn; 39535918f85SRandall Stewart } SCTP_PACKED; 396f8829a4aSRandall Stewart 39744249214SRandall Stewart struct sctp_strseq_mid { 398*49656eefSMichael Tuexen uint16_t sid; 3998e1b295fSMichael Tuexen uint16_t flags; 400*49656eefSMichael Tuexen uint32_t mid; 40144249214SRandall Stewart }; 40244249214SRandall Stewart 403f8829a4aSRandall Stewart struct sctp_forward_tsn_msg { 404f8829a4aSRandall Stewart struct sctphdr sh; 405f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk msg; 40635918f85SRandall Stewart } SCTP_PACKED; 407f8829a4aSRandall Stewart 408f8829a4aSRandall Stewart /* should be a multiple of 4 - 1 aka 3/7/11 etc. */ 409f8829a4aSRandall Stewart 410f8829a4aSRandall Stewart #define SCTP_NUM_DB_TO_VERIFY 31 411f8829a4aSRandall Stewart 412f8829a4aSRandall Stewart struct sctp_chunk_desc { 413f8829a4aSRandall Stewart uint8_t chunk_type; 414f8829a4aSRandall Stewart uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY]; 415f8829a4aSRandall Stewart uint32_t tsn_ifany; 41635918f85SRandall Stewart } SCTP_PACKED; 417f8829a4aSRandall Stewart 418f8829a4aSRandall Stewart 419f8829a4aSRandall Stewart struct sctp_pktdrop_chunk { 420f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 421f8829a4aSRandall Stewart uint32_t bottle_bw; 422f8829a4aSRandall Stewart uint32_t current_onq; 423f8829a4aSRandall Stewart uint16_t trunc_len; 424f8829a4aSRandall Stewart uint16_t reserved; 425663fdad8SMichael Tuexen uint8_t data[]; 42635918f85SRandall Stewart } SCTP_PACKED; 427f8829a4aSRandall Stewart 428f8829a4aSRandall Stewart /**********STREAM RESET STUFF ******************/ 429f8829a4aSRandall Stewart 43084f3b49aSMichael Tuexen struct sctp_stream_reset_request { 43184f3b49aSMichael Tuexen struct sctp_paramhdr ph; 43284f3b49aSMichael Tuexen uint32_t request_seq; 43384f3b49aSMichael Tuexen } SCTP_PACKED; 43484f3b49aSMichael Tuexen 435f8829a4aSRandall Stewart struct sctp_stream_reset_out_request { 436f8829a4aSRandall Stewart struct sctp_paramhdr ph; 437f8829a4aSRandall Stewart uint32_t request_seq; /* monotonically increasing seq no */ 438f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 439f8829a4aSRandall Stewart uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */ 440663fdad8SMichael Tuexen uint16_t list_of_streams[]; /* if not all list of streams */ 44135918f85SRandall Stewart } SCTP_PACKED; 442f8829a4aSRandall Stewart 443f8829a4aSRandall Stewart struct sctp_stream_reset_in_request { 444f8829a4aSRandall Stewart struct sctp_paramhdr ph; 445f8829a4aSRandall Stewart uint32_t request_seq; 446663fdad8SMichael Tuexen uint16_t list_of_streams[]; /* if not all list of streams */ 44735918f85SRandall Stewart } SCTP_PACKED; 448f8829a4aSRandall Stewart 449f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request { 450f8829a4aSRandall Stewart struct sctp_paramhdr ph; 451f8829a4aSRandall Stewart uint32_t request_seq; 45235918f85SRandall Stewart } SCTP_PACKED; 453f8829a4aSRandall Stewart 454f8829a4aSRandall Stewart struct sctp_stream_reset_response { 455f8829a4aSRandall Stewart struct sctp_paramhdr ph; 456f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 457f8829a4aSRandall Stewart uint32_t result; 45835918f85SRandall Stewart } SCTP_PACKED; 459f8829a4aSRandall Stewart 460f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn { 461f8829a4aSRandall Stewart struct sctp_paramhdr ph; 462f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 463f8829a4aSRandall Stewart uint32_t result; 464f8829a4aSRandall Stewart uint32_t senders_next_tsn; 465f8829a4aSRandall Stewart uint32_t receivers_next_tsn; 46635918f85SRandall Stewart } SCTP_PACKED; 467f8829a4aSRandall Stewart 468ea44232bSRandall Stewart struct sctp_stream_reset_add_strm { 469ea44232bSRandall Stewart struct sctp_paramhdr ph; 470ea44232bSRandall Stewart uint32_t request_seq; 471ea44232bSRandall Stewart uint16_t number_of_streams; 472ea44232bSRandall Stewart uint16_t reserved; 4738d9d0613SMichael Tuexen } SCTP_PACKED; 474f8829a4aSRandall Stewart 475f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */ 476f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001 477f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002 478f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */ 479f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004 480f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005 481f3ebe64cSMichael Tuexen #define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */ 482f8829a4aSRandall Stewart 483f8829a4aSRandall Stewart /* 484f8829a4aSRandall Stewart * convience structures, note that if you are making a request for specific 485f8829a4aSRandall Stewart * streams then the request will need to be an overlay structure. 486f8829a4aSRandall Stewart */ 487f8829a4aSRandall Stewart 488f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_req { 489f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 490f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request sr_req; 49135918f85SRandall Stewart } SCTP_PACKED; 492f8829a4aSRandall Stewart 493f8829a4aSRandall Stewart struct sctp_stream_reset_resp { 494f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 495f8829a4aSRandall Stewart struct sctp_stream_reset_response sr_resp; 49635918f85SRandall Stewart } SCTP_PACKED; 497f8829a4aSRandall Stewart 498f8829a4aSRandall Stewart /* respone only valid with a TSN request */ 499f8829a4aSRandall Stewart struct sctp_stream_reset_resp_tsn { 500f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 501f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn sr_resp; 50235918f85SRandall Stewart } SCTP_PACKED; 503f8829a4aSRandall Stewart 504f8829a4aSRandall Stewart /****************************************************/ 505f8829a4aSRandall Stewart 506f8829a4aSRandall Stewart /* 507f8829a4aSRandall Stewart * Authenticated chunks support draft-ietf-tsvwg-sctp-auth 508f8829a4aSRandall Stewart */ 509d06c82f1SRandall Stewart 510d06c82f1SRandall Stewart /* Should we make the max be 32? */ 511d06c82f1SRandall Stewart #define SCTP_RANDOM_MAX_SIZE 256 512f8829a4aSRandall Stewart struct sctp_auth_random { 513f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8002 */ 514663fdad8SMichael Tuexen uint8_t random_data[]; 51535918f85SRandall Stewart } SCTP_PACKED; 516f8829a4aSRandall Stewart 517f8829a4aSRandall Stewart struct sctp_auth_chunk_list { 518f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8003 */ 519663fdad8SMichael Tuexen uint8_t chunk_types[]; 52035918f85SRandall Stewart } SCTP_PACKED; 521f8829a4aSRandall Stewart 522f8829a4aSRandall Stewart struct sctp_auth_hmac_algo { 523f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8004 */ 524663fdad8SMichael Tuexen uint16_t hmac_ids[]; 52535918f85SRandall Stewart } SCTP_PACKED; 526f8829a4aSRandall Stewart 527f8829a4aSRandall Stewart struct sctp_auth_chunk { 528f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 529f8829a4aSRandall Stewart uint16_t shared_key_id; 530f8829a4aSRandall Stewart uint16_t hmac_id; 531663fdad8SMichael Tuexen uint8_t hmac[]; 53235918f85SRandall Stewart } SCTP_PACKED; 533f8829a4aSRandall Stewart 534f8829a4aSRandall Stewart /* 535f8829a4aSRandall Stewart * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing 536f8829a4aSRandall Stewart * pieces. If ENCE is missing we could have a couple of blocks. This way we 537f8829a4aSRandall Stewart * optimize so we MOST likely can bundle a SACK/ECN with the smallest size 538f8829a4aSRandall Stewart * data chunk I will split into. We could increase throughput slightly by 539f8829a4aSRandall Stewart * taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I 540f8829a4aSRandall Stewart * feel is worth it for now. 541f8829a4aSRandall Stewart */ 542f8829a4aSRandall Stewart #ifndef SCTP_MAX_OVERHEAD 54342551e99SRandall Stewart #ifdef INET6 544f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 545f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 546f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 547f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 548f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 549f8829a4aSRandall Stewart 550f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 551f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 552f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 553f8829a4aSRandall Stewart 554f8829a4aSRandall Stewart 555f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \ 556f8829a4aSRandall Stewart sizeof(struct sctphdr)) 557f8829a4aSRandall Stewart 558f8829a4aSRandall Stewart #else 559f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 560f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 561f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 562f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 563f8829a4aSRandall Stewart sizeof(struct ip)) 564f8829a4aSRandall Stewart 565f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 566f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 567f8829a4aSRandall Stewart sizeof(struct ip)) 568f8829a4aSRandall Stewart 569f8829a4aSRandall Stewart 570f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \ 571f8829a4aSRandall Stewart sizeof(struct sctphdr)) 572f8829a4aSRandall Stewart 57342551e99SRandall Stewart #endif /* INET6 */ 574f8829a4aSRandall Stewart #endif /* !SCTP_MAX_OVERHEAD */ 575f8829a4aSRandall Stewart 576f8829a4aSRandall Stewart #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 577f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 578f8829a4aSRandall Stewart sizeof(struct ip)) 579f8829a4aSRandall Stewart 580f8829a4aSRandall Stewart #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ 581f8829a4aSRandall Stewart sizeof(struct sctphdr)) 582f8829a4aSRandall Stewart 583b3f1ea41SRandall Stewart #undef SCTP_PACKED 584f8829a4aSRandall Stewart #endif /* !__sctp_header_h__ */ 585