1f8829a4aSRandall Stewart /*- 2b1006367SRandall Stewart * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 3f8829a4aSRandall Stewart * 4f8829a4aSRandall Stewart * Redistribution and use in source and binary forms, with or without 5f8829a4aSRandall Stewart * modification, are permitted provided that the following conditions are met: 6f8829a4aSRandall Stewart * 7f8829a4aSRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 8f8829a4aSRandall Stewart * this list of conditions and the following disclaimer. 9f8829a4aSRandall Stewart * 10f8829a4aSRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 11f8829a4aSRandall Stewart * notice, this list of conditions and the following disclaimer in 12f8829a4aSRandall Stewart * the documentation and/or other materials provided with the distribution. 13f8829a4aSRandall Stewart * 14f8829a4aSRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 15f8829a4aSRandall Stewart * contributors may be used to endorse or promote products derived 16f8829a4aSRandall Stewart * from this software without specific prior written permission. 17f8829a4aSRandall Stewart * 18f8829a4aSRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19f8829a4aSRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20f8829a4aSRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21f8829a4aSRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22f8829a4aSRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23f8829a4aSRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24f8829a4aSRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25f8829a4aSRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26f8829a4aSRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27f8829a4aSRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28f8829a4aSRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 29f8829a4aSRandall Stewart */ 30f8829a4aSRandall Stewart 31f8829a4aSRandall Stewart /* $KAME: sctp_header.h,v 1.14 2005/03/06 16:04:17 itojun Exp $ */ 32f8829a4aSRandall Stewart 33f8829a4aSRandall Stewart #include <sys/cdefs.h> 34f8829a4aSRandall Stewart __FBSDID("$FreeBSD$"); 35f8829a4aSRandall Stewart 36f8829a4aSRandall Stewart #ifndef __sctp_header_h__ 37f8829a4aSRandall Stewart #define __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 */ 65f8829a4aSRandall Stewart }; 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 */ 8242551e99SRandall Stewart uint16_t addr_type[SCTP_ARRAY_MIN_LEN]; /* array of supported address 8342551e99SRandall Stewart * types */ 8435918f85SRandall Stewart } SCTP_PACKED; 85f8829a4aSRandall Stewart 86f8829a4aSRandall Stewart /* ECN parameter */ 87f8829a4aSRandall Stewart struct sctp_ecn_supported_param { 88f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type=SCTP_ECN_CAPABLE */ 8935918f85SRandall Stewart } SCTP_PACKED; 90f8829a4aSRandall Stewart 91f8829a4aSRandall Stewart 92f8829a4aSRandall Stewart /* heartbeat info parameter */ 93f8829a4aSRandall Stewart struct sctp_heartbeat_info_param { 94f8829a4aSRandall Stewart struct sctp_paramhdr ph; 95f8829a4aSRandall Stewart uint32_t time_value_1; 96f8829a4aSRandall Stewart uint32_t time_value_2; 97f8829a4aSRandall Stewart uint32_t random_value1; 98f8829a4aSRandall Stewart uint32_t random_value2; 99f8829a4aSRandall Stewart uint16_t user_req; 100f8829a4aSRandall Stewart uint8_t addr_family; 101f8829a4aSRandall Stewart uint8_t addr_len; 102f8829a4aSRandall Stewart char address[SCTP_ADDRMAX]; 10335918f85SRandall Stewart } SCTP_PACKED; 104f8829a4aSRandall Stewart 105f8829a4aSRandall Stewart 106f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 107f8829a4aSRandall Stewart /* PR-SCTP supported parameter */ 108f8829a4aSRandall Stewart struct sctp_prsctp_supported_param { 109f8829a4aSRandall Stewart struct sctp_paramhdr ph; 11035918f85SRandall Stewart } SCTP_PACKED; 111f8829a4aSRandall Stewart 112f8829a4aSRandall Stewart 113f8829a4aSRandall Stewart /* draft-ietf-tsvwg-addip-sctp */ 114f8829a4aSRandall Stewart struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */ 115f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* a SCTP parameter header */ 116f8829a4aSRandall Stewart uint32_t correlation_id;/* correlation id for this param */ 11735918f85SRandall Stewart } SCTP_PACKED; 118f8829a4aSRandall Stewart 119f8829a4aSRandall Stewart struct sctp_asconf_addr_param { /* an ASCONF address parameter */ 120f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 121f8829a4aSRandall Stewart struct sctp_ipv6addr_param addrp; /* max storage size */ 12235918f85SRandall Stewart } SCTP_PACKED; 123f8829a4aSRandall Stewart 124830d754dSRandall Stewart 125830d754dSRandall Stewart struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */ 126830d754dSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 127830d754dSRandall Stewart uint32_t local_vtag; 128830d754dSRandall Stewart uint32_t remote_vtag; 129830d754dSRandall Stewart } SCTP_PACKED; 130830d754dSRandall Stewart 131830d754dSRandall Stewart 132f8829a4aSRandall Stewart struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */ 133f8829a4aSRandall Stewart struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ 134f8829a4aSRandall Stewart struct sctp_ipv4addr_param addrp; /* max storage size */ 13535918f85SRandall Stewart } SCTP_PACKED; 136f8829a4aSRandall Stewart 137d06c82f1SRandall Stewart #define SCTP_MAX_SUPPORTED_EXT 256 138d06c82f1SRandall Stewart 139f8829a4aSRandall Stewart struct sctp_supported_chunk_types_param { 140f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8008 len = x */ 141f8829a4aSRandall Stewart uint8_t chunk_types[0]; 14235918f85SRandall Stewart } SCTP_PACKED; 143f8829a4aSRandall Stewart 144f8829a4aSRandall Stewart 145f8829a4aSRandall Stewart /* ECN Nonce: draft-ladha-sctp-ecn-nonce */ 146f8829a4aSRandall Stewart struct sctp_ecn_nonce_supported_param { 147f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8001 len = 4 */ 14835918f85SRandall Stewart } SCTP_PACKED; 149f8829a4aSRandall Stewart 150f8829a4aSRandall Stewart 151f8829a4aSRandall Stewart /* 152f8829a4aSRandall Stewart * Structures for DATA chunks 153f8829a4aSRandall Stewart */ 154f8829a4aSRandall Stewart struct sctp_data { 155f8829a4aSRandall Stewart uint32_t tsn; 156f8829a4aSRandall Stewart uint16_t stream_id; 157f8829a4aSRandall Stewart uint16_t stream_sequence; 158f8829a4aSRandall Stewart uint32_t protocol_id; 159f8829a4aSRandall Stewart /* user data follows */ 16035918f85SRandall Stewart } SCTP_PACKED; 161f8829a4aSRandall Stewart 162f8829a4aSRandall Stewart struct sctp_data_chunk { 163f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 164f8829a4aSRandall Stewart struct sctp_data dp; 16535918f85SRandall Stewart } SCTP_PACKED; 166f8829a4aSRandall Stewart 167f8829a4aSRandall Stewart /* 168f8829a4aSRandall Stewart * Structures for the control chunks 169f8829a4aSRandall Stewart */ 170f8829a4aSRandall Stewart 171f8829a4aSRandall Stewart /* Initiate (INIT)/Initiate Ack (INIT ACK) */ 172f8829a4aSRandall Stewart struct sctp_init { 173f8829a4aSRandall Stewart uint32_t initiate_tag; /* initiate tag */ 174f8829a4aSRandall Stewart uint32_t a_rwnd; /* a_rwnd */ 175f8829a4aSRandall Stewart uint16_t num_outbound_streams; /* OS */ 176f8829a4aSRandall Stewart uint16_t num_inbound_streams; /* MIS */ 177f8829a4aSRandall Stewart uint32_t initial_tsn; /* I-TSN */ 178f8829a4aSRandall Stewart /* optional param's follow */ 17935918f85SRandall Stewart } SCTP_PACKED; 180f8829a4aSRandall Stewart 18142551e99SRandall Stewart #define SCTP_IDENTIFICATION_SIZE 16 18242551e99SRandall Stewart #define SCTP_ADDRESS_SIZE 4 18335918f85SRandall Stewart #define SCTP_RESERVE_SPACE 6 184f8829a4aSRandall Stewart /* state cookie header */ 185f8829a4aSRandall Stewart struct sctp_state_cookie { /* this is our definition... */ 18642551e99SRandall Stewart uint8_t identification[SCTP_IDENTIFICATION_SIZE]; /* id of who we are */ 18735918f85SRandall Stewart struct timeval time_entered; /* the time I built cookie */ 188f8829a4aSRandall Stewart uint32_t cookie_life; /* life I will award this cookie */ 189f8829a4aSRandall Stewart uint32_t tie_tag_my_vtag; /* my tag in old association */ 19035918f85SRandall Stewart 191f8829a4aSRandall Stewart uint32_t tie_tag_peer_vtag; /* peers tag in old association */ 192f8829a4aSRandall Stewart uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */ 19335918f85SRandall Stewart 194f8829a4aSRandall Stewart uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */ 19542551e99SRandall Stewart uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */ 196f8829a4aSRandall Stewart uint32_t addr_type; /* address type */ 19742551e99SRandall Stewart uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */ 198f8829a4aSRandall Stewart uint32_t laddr_type; /* my local from address type */ 199f8829a4aSRandall Stewart uint32_t scope_id; /* v6 scope id for link-locals */ 20035918f85SRandall Stewart 201f8829a4aSRandall Stewart uint16_t peerport; /* port address of the peer in the INIT */ 202f8829a4aSRandall Stewart uint16_t myport; /* my port address used in the INIT */ 203f8829a4aSRandall Stewart uint8_t ipv4_addr_legal;/* Are V4 addr legal? */ 204f8829a4aSRandall Stewart uint8_t ipv6_addr_legal;/* Are V6 addr legal? */ 205f8829a4aSRandall Stewart uint8_t local_scope; /* IPv6 local scope flag */ 206f8829a4aSRandall Stewart uint8_t site_scope; /* IPv6 site scope flag */ 20735918f85SRandall Stewart 208f8829a4aSRandall Stewart uint8_t ipv4_scope; /* IPv4 private addr scope */ 209f8829a4aSRandall Stewart uint8_t loopback_scope; /* loopback scope information */ 21035918f85SRandall Stewart uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */ 211f8829a4aSRandall Stewart /* 212f8829a4aSRandall Stewart * at the end is tacked on the INIT chunk and the INIT-ACK chunk 213f8829a4aSRandall Stewart * (minus the cookie). 214f8829a4aSRandall Stewart */ 21535918f85SRandall Stewart } SCTP_PACKED; 216f8829a4aSRandall Stewart 217830d754dSRandall Stewart 218830d754dSRandall Stewart /* Used for NAT state error cause */ 219830d754dSRandall Stewart struct sctp_missing_nat_state { 220830d754dSRandall Stewart uint16_t cause; 221830d754dSRandall Stewart uint16_t length; 222830d754dSRandall Stewart uint8_t data[0]; 223830d754dSRandall Stewart } SCTP_PACKED; 224830d754dSRandall Stewart 225830d754dSRandall Stewart 226f8829a4aSRandall Stewart struct sctp_inv_mandatory_param { 227f8829a4aSRandall Stewart uint16_t cause; 228f8829a4aSRandall Stewart uint16_t length; 229f8829a4aSRandall Stewart uint32_t num_param; 230f8829a4aSRandall Stewart uint16_t param; 231f8829a4aSRandall Stewart /* 232f8829a4aSRandall Stewart * We include this to 0 it since only a missing cookie will cause 233f8829a4aSRandall Stewart * this error. 234f8829a4aSRandall Stewart */ 235f8829a4aSRandall Stewart uint16_t resv; 23635918f85SRandall Stewart } SCTP_PACKED; 237f8829a4aSRandall Stewart 238f8829a4aSRandall Stewart struct sctp_unresolv_addr { 239f8829a4aSRandall Stewart uint16_t cause; 240f8829a4aSRandall Stewart uint16_t length; 241f8829a4aSRandall Stewart uint16_t addr_type; 242f8829a4aSRandall Stewart uint16_t reserved; /* Only one invalid addr type */ 24335918f85SRandall Stewart } SCTP_PACKED; 244f8829a4aSRandall Stewart 245f8829a4aSRandall Stewart /* state cookie parameter */ 246f8829a4aSRandall Stewart struct sctp_state_cookie_param { 247f8829a4aSRandall Stewart struct sctp_paramhdr ph; 248f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 24935918f85SRandall Stewart } SCTP_PACKED; 250f8829a4aSRandall Stewart 251f8829a4aSRandall Stewart struct sctp_init_chunk { 252f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 253f8829a4aSRandall Stewart struct sctp_init init; 25435918f85SRandall Stewart } SCTP_PACKED; 255f8829a4aSRandall Stewart 256f8829a4aSRandall Stewart struct sctp_init_msg { 257f8829a4aSRandall Stewart struct sctphdr sh; 258f8829a4aSRandall Stewart struct sctp_init_chunk msg; 25935918f85SRandall Stewart } SCTP_PACKED; 260f8829a4aSRandall Stewart 261f8829a4aSRandall Stewart /* ... used for both INIT and INIT ACK */ 262f8829a4aSRandall Stewart #define sctp_init_ack sctp_init 263f8829a4aSRandall Stewart #define sctp_init_ack_chunk sctp_init_chunk 264f8829a4aSRandall Stewart #define sctp_init_ack_msg sctp_init_msg 265f8829a4aSRandall Stewart 266f8829a4aSRandall Stewart 267f8829a4aSRandall Stewart /* Selective Ack (SACK) */ 268f8829a4aSRandall Stewart struct sctp_gap_ack_block { 269f8829a4aSRandall Stewart uint16_t start; /* Gap Ack block start */ 270f8829a4aSRandall Stewart uint16_t end; /* Gap Ack block end */ 27135918f85SRandall Stewart } SCTP_PACKED; 272f8829a4aSRandall Stewart 273f8829a4aSRandall Stewart struct sctp_sack { 274f8829a4aSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 275f8829a4aSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 276f8829a4aSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 277f8829a4aSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 278f8829a4aSRandall Stewart /* struct sctp_gap_ack_block's follow */ 279f8829a4aSRandall Stewart /* uint32_t duplicate_tsn's follow */ 28035918f85SRandall Stewart } SCTP_PACKED; 281f8829a4aSRandall Stewart 282f8829a4aSRandall Stewart struct sctp_sack_chunk { 283f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 284f8829a4aSRandall Stewart struct sctp_sack sack; 28535918f85SRandall Stewart } SCTP_PACKED; 286f8829a4aSRandall Stewart 287f8829a4aSRandall Stewart 288830d754dSRandall Stewart /* EY Following 3 structs define NR Selective Ack (NR_SACK) chunk */ 289830d754dSRandall Stewart struct sctp_nr_gap_ack_block { 290830d754dSRandall Stewart uint16_t start; /* NR Gap Ack block start */ 291830d754dSRandall Stewart uint16_t end; /* NR Gap Ack block end */ 292830d754dSRandall Stewart } SCTP_PACKED; 293830d754dSRandall Stewart 294830d754dSRandall Stewart struct sctp_nr_sack { 295830d754dSRandall Stewart uint32_t cum_tsn_ack; /* cumulative TSN Ack */ 296830d754dSRandall Stewart uint32_t a_rwnd; /* updated a_rwnd of sender */ 297830d754dSRandall Stewart uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ 298830d754dSRandall Stewart uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */ 299830d754dSRandall Stewart uint16_t num_dup_tsns; /* number of duplicate TSNs */ 300830d754dSRandall Stewart uint16_t reserved; /* not currently used */ 301830d754dSRandall Stewart /* struct sctp_gap_ack_block's follow */ 302830d754dSRandall Stewart /* struct sctp_nr_gap_ack_block's follow */ 303830d754dSRandall Stewart /* uint32_t duplicate_tsn's follow */ 304830d754dSRandall Stewart } SCTP_PACKED; 305830d754dSRandall Stewart 306830d754dSRandall Stewart struct sctp_nr_sack_chunk { 307830d754dSRandall Stewart struct sctp_chunkhdr ch; 308830d754dSRandall Stewart struct sctp_nr_sack nr_sack; 309830d754dSRandall Stewart } SCTP_PACKED; 310830d754dSRandall Stewart 311830d754dSRandall Stewart 312f8829a4aSRandall Stewart /* Heartbeat Request (HEARTBEAT) */ 313f8829a4aSRandall Stewart struct sctp_heartbeat { 314f8829a4aSRandall Stewart struct sctp_heartbeat_info_param hb_info; 31535918f85SRandall Stewart } SCTP_PACKED; 316f8829a4aSRandall Stewart 317f8829a4aSRandall Stewart struct sctp_heartbeat_chunk { 318f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 319f8829a4aSRandall Stewart struct sctp_heartbeat heartbeat; 32035918f85SRandall Stewart } SCTP_PACKED; 321f8829a4aSRandall Stewart 322f8829a4aSRandall Stewart /* ... used for Heartbeat Ack (HEARTBEAT ACK) */ 323f8829a4aSRandall Stewart #define sctp_heartbeat_ack sctp_heartbeat 324f8829a4aSRandall Stewart #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk 325f8829a4aSRandall Stewart 326f8829a4aSRandall Stewart 327f8829a4aSRandall Stewart /* Abort Asssociation (ABORT) */ 328f8829a4aSRandall Stewart struct sctp_abort_chunk { 329f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 330f8829a4aSRandall Stewart /* optional error cause may follow */ 33135918f85SRandall Stewart } SCTP_PACKED; 332f8829a4aSRandall Stewart 333f8829a4aSRandall Stewart struct sctp_abort_msg { 334f8829a4aSRandall Stewart struct sctphdr sh; 335f8829a4aSRandall Stewart struct sctp_abort_chunk msg; 33635918f85SRandall Stewart } SCTP_PACKED; 337f8829a4aSRandall Stewart 338f8829a4aSRandall Stewart 339f8829a4aSRandall Stewart /* Shutdown Association (SHUTDOWN) */ 340f8829a4aSRandall Stewart struct sctp_shutdown_chunk { 341f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 342f8829a4aSRandall Stewart uint32_t cumulative_tsn_ack; 34335918f85SRandall Stewart } SCTP_PACKED; 344f8829a4aSRandall Stewart 345f8829a4aSRandall Stewart 346f8829a4aSRandall Stewart /* Shutdown Acknowledgment (SHUTDOWN ACK) */ 347f8829a4aSRandall Stewart struct sctp_shutdown_ack_chunk { 348f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 34935918f85SRandall Stewart } SCTP_PACKED; 350f8829a4aSRandall Stewart 351f8829a4aSRandall Stewart 352f8829a4aSRandall Stewart /* Operation Error (ERROR) */ 353f8829a4aSRandall Stewart struct sctp_error_chunk { 354f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 355f8829a4aSRandall Stewart /* optional error causes follow */ 35635918f85SRandall Stewart } SCTP_PACKED; 357f8829a4aSRandall Stewart 358f8829a4aSRandall Stewart 359f8829a4aSRandall Stewart /* Cookie Echo (COOKIE ECHO) */ 360f8829a4aSRandall Stewart struct sctp_cookie_echo_chunk { 361f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 362f8829a4aSRandall Stewart struct sctp_state_cookie cookie; 36335918f85SRandall Stewart } SCTP_PACKED; 364f8829a4aSRandall Stewart 365f8829a4aSRandall Stewart /* Cookie Acknowledgment (COOKIE ACK) */ 366f8829a4aSRandall Stewart struct sctp_cookie_ack_chunk { 367f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 36835918f85SRandall Stewart } SCTP_PACKED; 369f8829a4aSRandall Stewart 370f8829a4aSRandall Stewart /* Explicit Congestion Notification Echo (ECNE) */ 371f8829a4aSRandall Stewart struct sctp_ecne_chunk { 372f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 373f8829a4aSRandall Stewart uint32_t tsn; 37435918f85SRandall Stewart } SCTP_PACKED; 375f8829a4aSRandall Stewart 376f8829a4aSRandall Stewart /* Congestion Window Reduced (CWR) */ 377f8829a4aSRandall Stewart struct sctp_cwr_chunk { 378f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 379f8829a4aSRandall Stewart uint32_t tsn; 38035918f85SRandall Stewart } SCTP_PACKED; 381f8829a4aSRandall Stewart 382f8829a4aSRandall Stewart /* Shutdown Complete (SHUTDOWN COMPLETE) */ 383f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk { 384f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 38535918f85SRandall Stewart } SCTP_PACKED; 386f8829a4aSRandall Stewart 387f8829a4aSRandall Stewart /* Oper error holding a stale cookie */ 388f8829a4aSRandall Stewart struct sctp_stale_cookie_msg { 389f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* really an error cause */ 390f8829a4aSRandall Stewart uint32_t time_usec; 39135918f85SRandall Stewart } SCTP_PACKED; 392f8829a4aSRandall Stewart 393f8829a4aSRandall Stewart struct sctp_adaptation_layer_indication { 394f8829a4aSRandall Stewart struct sctp_paramhdr ph; 395f8829a4aSRandall Stewart uint32_t indication; 39635918f85SRandall Stewart } SCTP_PACKED; 397f8829a4aSRandall Stewart 398f8829a4aSRandall Stewart struct sctp_cookie_while_shutting_down { 399f8829a4aSRandall Stewart struct sctphdr sh; 400f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 401f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* really an error cause */ 40235918f85SRandall Stewart } SCTP_PACKED; 403f8829a4aSRandall Stewart 404f8829a4aSRandall Stewart struct sctp_shutdown_complete_msg { 405f8829a4aSRandall Stewart struct sctphdr sh; 406f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk shut_cmp; 40735918f85SRandall Stewart } SCTP_PACKED; 408f8829a4aSRandall Stewart 409f8829a4aSRandall Stewart /* 410f8829a4aSRandall Stewart * draft-ietf-tsvwg-addip-sctp 411f8829a4aSRandall Stewart */ 412f8829a4aSRandall Stewart /* Address/Stream Configuration Change (ASCONF) */ 413f8829a4aSRandall Stewart struct sctp_asconf_chunk { 414f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 415f8829a4aSRandall Stewart uint32_t serial_number; 416f8829a4aSRandall Stewart /* lookup address parameter (mandatory) */ 417f8829a4aSRandall Stewart /* asconf parameters follow */ 41835918f85SRandall Stewart } SCTP_PACKED; 419f8829a4aSRandall Stewart 420f8829a4aSRandall Stewart /* Address/Stream Configuration Acknowledge (ASCONF ACK) */ 421f8829a4aSRandall Stewart struct sctp_asconf_ack_chunk { 422f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 423f8829a4aSRandall Stewart uint32_t serial_number; 424f8829a4aSRandall Stewart /* asconf parameters follow */ 42535918f85SRandall Stewart } SCTP_PACKED; 426f8829a4aSRandall Stewart 427f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */ 428f8829a4aSRandall Stewart /* Forward Cumulative TSN (FORWARD TSN) */ 429f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk { 430f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 431f8829a4aSRandall Stewart uint32_t new_cumulative_tsn; 432f8829a4aSRandall Stewart /* stream/sequence pairs (sctp_strseq) follow */ 43335918f85SRandall Stewart } SCTP_PACKED; 434f8829a4aSRandall Stewart 435f8829a4aSRandall Stewart struct sctp_strseq { 436f8829a4aSRandall Stewart uint16_t stream; 437f8829a4aSRandall Stewart uint16_t sequence; 43835918f85SRandall Stewart } SCTP_PACKED; 439f8829a4aSRandall Stewart 440f8829a4aSRandall Stewart struct sctp_forward_tsn_msg { 441f8829a4aSRandall Stewart struct sctphdr sh; 442f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk msg; 44335918f85SRandall Stewart } SCTP_PACKED; 444f8829a4aSRandall Stewart 445f8829a4aSRandall Stewart /* should be a multiple of 4 - 1 aka 3/7/11 etc. */ 446f8829a4aSRandall Stewart 447f8829a4aSRandall Stewart #define SCTP_NUM_DB_TO_VERIFY 31 448f8829a4aSRandall Stewart 449f8829a4aSRandall Stewart struct sctp_chunk_desc { 450f8829a4aSRandall Stewart uint8_t chunk_type; 451f8829a4aSRandall Stewart uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY]; 452f8829a4aSRandall Stewart uint32_t tsn_ifany; 45335918f85SRandall Stewart } SCTP_PACKED; 454f8829a4aSRandall Stewart 455f8829a4aSRandall Stewart 456f8829a4aSRandall Stewart struct sctp_pktdrop_chunk { 457f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 458f8829a4aSRandall Stewart uint32_t bottle_bw; 459f8829a4aSRandall Stewart uint32_t current_onq; 460f8829a4aSRandall Stewart uint16_t trunc_len; 461f8829a4aSRandall Stewart uint16_t reserved; 462f8829a4aSRandall Stewart uint8_t data[0]; 46335918f85SRandall Stewart } SCTP_PACKED; 464f8829a4aSRandall Stewart 465f8829a4aSRandall Stewart /**********STREAM RESET STUFF ******************/ 466f8829a4aSRandall Stewart 467f8829a4aSRandall Stewart struct sctp_stream_reset_out_request { 468f8829a4aSRandall Stewart struct sctp_paramhdr ph; 469f8829a4aSRandall Stewart uint32_t request_seq; /* monotonically increasing seq no */ 470f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 471f8829a4aSRandall Stewart uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */ 472f8829a4aSRandall Stewart uint16_t list_of_streams[0]; /* if not all list of streams */ 47335918f85SRandall Stewart } SCTP_PACKED; 474f8829a4aSRandall Stewart 475f8829a4aSRandall Stewart struct sctp_stream_reset_in_request { 476f8829a4aSRandall Stewart struct sctp_paramhdr ph; 477f8829a4aSRandall Stewart uint32_t request_seq; 478f8829a4aSRandall Stewart uint16_t list_of_streams[0]; /* if not all list of streams */ 47935918f85SRandall Stewart } SCTP_PACKED; 480f8829a4aSRandall Stewart 481f8829a4aSRandall Stewart 482f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request { 483f8829a4aSRandall Stewart struct sctp_paramhdr ph; 484f8829a4aSRandall Stewart uint32_t request_seq; 48535918f85SRandall Stewart } SCTP_PACKED; 486f8829a4aSRandall Stewart 487f8829a4aSRandall Stewart struct sctp_stream_reset_response { 488f8829a4aSRandall Stewart struct sctp_paramhdr ph; 489f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 490f8829a4aSRandall Stewart uint32_t result; 49135918f85SRandall Stewart } SCTP_PACKED; 492f8829a4aSRandall Stewart 493f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn { 494f8829a4aSRandall Stewart struct sctp_paramhdr ph; 495f8829a4aSRandall Stewart uint32_t response_seq; /* if a response, the resp seq no */ 496f8829a4aSRandall Stewart uint32_t result; 497f8829a4aSRandall Stewart uint32_t senders_next_tsn; 498f8829a4aSRandall Stewart uint32_t receivers_next_tsn; 49935918f85SRandall Stewart } SCTP_PACKED; 500f8829a4aSRandall Stewart 501f8829a4aSRandall Stewart 502f8829a4aSRandall Stewart 503f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ 504f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ 505f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_DENIED 0x00000002 /* refused to do it */ 506f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ 507f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ 508f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ 509f8829a4aSRandall Stewart 510f8829a4aSRandall Stewart /* 511f8829a4aSRandall Stewart * convience structures, note that if you are making a request for specific 512f8829a4aSRandall Stewart * streams then the request will need to be an overlay structure. 513f8829a4aSRandall Stewart */ 514f8829a4aSRandall Stewart 515f8829a4aSRandall Stewart struct sctp_stream_reset_out_req { 516f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 517f8829a4aSRandall Stewart struct sctp_stream_reset_out_request sr_req; 51835918f85SRandall Stewart } SCTP_PACKED; 519f8829a4aSRandall Stewart 520f8829a4aSRandall Stewart struct sctp_stream_reset_in_req { 521f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 522f8829a4aSRandall Stewart struct sctp_stream_reset_in_request sr_req; 52335918f85SRandall Stewart } SCTP_PACKED; 524f8829a4aSRandall Stewart 525f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_req { 526f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 527f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request sr_req; 52835918f85SRandall Stewart } SCTP_PACKED; 529f8829a4aSRandall Stewart 530f8829a4aSRandall Stewart struct sctp_stream_reset_resp { 531f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 532f8829a4aSRandall Stewart struct sctp_stream_reset_response sr_resp; 53335918f85SRandall Stewart } SCTP_PACKED; 534f8829a4aSRandall Stewart 535f8829a4aSRandall Stewart /* respone only valid with a TSN request */ 536f8829a4aSRandall Stewart struct sctp_stream_reset_resp_tsn { 537f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 538f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn sr_resp; 53935918f85SRandall Stewart } SCTP_PACKED; 540f8829a4aSRandall Stewart 541f8829a4aSRandall Stewart /****************************************************/ 542f8829a4aSRandall Stewart 543f8829a4aSRandall Stewart /* 544f8829a4aSRandall Stewart * Authenticated chunks support draft-ietf-tsvwg-sctp-auth 545f8829a4aSRandall Stewart */ 546d06c82f1SRandall Stewart 547d06c82f1SRandall Stewart /* Should we make the max be 32? */ 548d06c82f1SRandall Stewart #define SCTP_RANDOM_MAX_SIZE 256 549f8829a4aSRandall Stewart struct sctp_auth_random { 550f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8002 */ 551f8829a4aSRandall Stewart uint8_t random_data[0]; 55235918f85SRandall Stewart } SCTP_PACKED; 553f8829a4aSRandall Stewart 554f8829a4aSRandall Stewart struct sctp_auth_chunk_list { 555f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8003 */ 556f8829a4aSRandall Stewart uint8_t chunk_types[0]; 55735918f85SRandall Stewart } SCTP_PACKED; 558f8829a4aSRandall Stewart 559f8829a4aSRandall Stewart struct sctp_auth_hmac_algo { 560f8829a4aSRandall Stewart struct sctp_paramhdr ph;/* type = 0x8004 */ 561f8829a4aSRandall Stewart uint16_t hmac_ids[0]; 56235918f85SRandall Stewart } SCTP_PACKED; 563f8829a4aSRandall Stewart 564f8829a4aSRandall Stewart struct sctp_auth_chunk { 565f8829a4aSRandall Stewart struct sctp_chunkhdr ch; 566f8829a4aSRandall Stewart uint16_t shared_key_id; 567f8829a4aSRandall Stewart uint16_t hmac_id; 568f8829a4aSRandall Stewart uint8_t hmac[0]; 56935918f85SRandall Stewart } SCTP_PACKED; 570f8829a4aSRandall Stewart 571f8829a4aSRandall Stewart struct sctp_auth_invalid_hmac { 572f8829a4aSRandall Stewart struct sctp_paramhdr ph; 573f8829a4aSRandall Stewart uint16_t hmac_id; 574f8829a4aSRandall Stewart uint16_t padding; 57535918f85SRandall Stewart } SCTP_PACKED; 576f8829a4aSRandall Stewart 577f8829a4aSRandall Stewart /* 578f8829a4aSRandall Stewart * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing 579f8829a4aSRandall Stewart * pieces. If ENCE is missing we could have a couple of blocks. This way we 580f8829a4aSRandall Stewart * optimize so we MOST likely can bundle a SACK/ECN with the smallest size 581f8829a4aSRandall Stewart * data chunk I will split into. We could increase throughput slightly by 582f8829a4aSRandall Stewart * taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I 583f8829a4aSRandall Stewart * feel is worth it for now. 584f8829a4aSRandall Stewart */ 585f8829a4aSRandall Stewart #ifndef SCTP_MAX_OVERHEAD 58642551e99SRandall Stewart #ifdef INET6 587f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 588f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 589f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 590f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 591f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 592f8829a4aSRandall Stewart 593f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 594f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 595f8829a4aSRandall Stewart sizeof(struct ip6_hdr)) 596f8829a4aSRandall Stewart 597f8829a4aSRandall Stewart 598f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \ 599f8829a4aSRandall Stewart sizeof(struct sctphdr)) 600f8829a4aSRandall Stewart 601f8829a4aSRandall Stewart #else 602f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 603f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 604f8829a4aSRandall Stewart sizeof(struct sctp_ecne_chunk) + \ 605f8829a4aSRandall Stewart sizeof(struct sctp_sack_chunk) + \ 606f8829a4aSRandall Stewart sizeof(struct ip)) 607f8829a4aSRandall Stewart 608f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 609f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 610f8829a4aSRandall Stewart sizeof(struct ip)) 611f8829a4aSRandall Stewart 612f8829a4aSRandall Stewart 613f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \ 614f8829a4aSRandall Stewart sizeof(struct sctphdr)) 615f8829a4aSRandall Stewart 61642551e99SRandall Stewart #endif /* INET6 */ 617f8829a4aSRandall Stewart #endif /* !SCTP_MAX_OVERHEAD */ 618f8829a4aSRandall Stewart 619f8829a4aSRandall Stewart #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \ 620f8829a4aSRandall Stewart sizeof(struct sctphdr) + \ 621f8829a4aSRandall Stewart sizeof(struct ip)) 622f8829a4aSRandall Stewart 623f8829a4aSRandall Stewart #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ 624f8829a4aSRandall Stewart sizeof(struct sctphdr)) 625f8829a4aSRandall Stewart 626b3f1ea41SRandall Stewart #undef SCTP_PACKED 627f8829a4aSRandall Stewart #endif /* !__sctp_header_h__ */ 628