Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /*- |
michael@0 | 2 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. |
michael@0 | 3 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. |
michael@0 | 4 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
michael@0 | 5 | * |
michael@0 | 6 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 7 | * modification, are permitted provided that the following conditions are met: |
michael@0 | 8 | * |
michael@0 | 9 | * a) Redistributions of source code must retain the above copyright notice, |
michael@0 | 10 | * this list of conditions and the following disclaimer. |
michael@0 | 11 | * |
michael@0 | 12 | * b) Redistributions in binary form must reproduce the above copyright |
michael@0 | 13 | * notice, this list of conditions and the following disclaimer in |
michael@0 | 14 | * the documentation and/or other materials provided with the distribution. |
michael@0 | 15 | * |
michael@0 | 16 | * c) Neither the name of Cisco Systems, Inc. nor the names of its |
michael@0 | 17 | * contributors may be used to endorse or promote products derived |
michael@0 | 18 | * from this software without specific prior written permission. |
michael@0 | 19 | * |
michael@0 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
michael@0 | 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
michael@0 | 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
michael@0 | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
michael@0 | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
michael@0 | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
michael@0 | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
michael@0 | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
michael@0 | 30 | * THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 31 | */ |
michael@0 | 32 | |
michael@0 | 33 | #ifdef __FreeBSD__ |
michael@0 | 34 | #include <sys/cdefs.h> |
michael@0 | 35 | __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 240198 2012-09-07 13:36:42Z tuexen $"); |
michael@0 | 36 | #endif |
michael@0 | 37 | |
michael@0 | 38 | #ifndef _NETINET_SCTP_HEADER_H_ |
michael@0 | 39 | #define _NETINET_SCTP_HEADER_H_ |
michael@0 | 40 | |
michael@0 | 41 | #if defined(__Windows__) && !defined(__Userspace_os_Windows) |
michael@0 | 42 | #include <packon.h> |
michael@0 | 43 | #endif |
michael@0 | 44 | #if !defined(__Userspace_os_Windows) |
michael@0 | 45 | #include <sys/time.h> |
michael@0 | 46 | #endif |
michael@0 | 47 | #include <netinet/sctp.h> |
michael@0 | 48 | #include <netinet/sctp_constants.h> |
michael@0 | 49 | |
michael@0 | 50 | #if !defined(__Userspace_os_Windows) |
michael@0 | 51 | #define SCTP_PACKED __attribute__((packed)) |
michael@0 | 52 | #else |
michael@0 | 53 | #pragma pack (push, 1) |
michael@0 | 54 | #define SCTP_PACKED |
michael@0 | 55 | #endif |
michael@0 | 56 | |
michael@0 | 57 | /* |
michael@0 | 58 | * Parameter structures |
michael@0 | 59 | */ |
michael@0 | 60 | struct sctp_ipv4addr_param { |
michael@0 | 61 | struct sctp_paramhdr ph;/* type=SCTP_IPV4_PARAM_TYPE, len=8 */ |
michael@0 | 62 | uint32_t addr; /* IPV4 address */ |
michael@0 | 63 | } SCTP_PACKED; |
michael@0 | 64 | |
michael@0 | 65 | #define SCTP_V6_ADDR_BYTES 16 |
michael@0 | 66 | |
michael@0 | 67 | |
michael@0 | 68 | struct sctp_ipv6addr_param { |
michael@0 | 69 | struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */ |
michael@0 | 70 | uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */ |
michael@0 | 71 | } SCTP_PACKED; |
michael@0 | 72 | |
michael@0 | 73 | /* Cookie Preservative */ |
michael@0 | 74 | struct sctp_cookie_perserve_param { |
michael@0 | 75 | struct sctp_paramhdr ph;/* type=SCTP_COOKIE_PRESERVE, len=8 */ |
michael@0 | 76 | uint32_t time; /* time in ms to extend cookie */ |
michael@0 | 77 | } SCTP_PACKED; |
michael@0 | 78 | |
michael@0 | 79 | #define SCTP_ARRAY_MIN_LEN 1 |
michael@0 | 80 | /* Host Name Address */ |
michael@0 | 81 | struct sctp_host_name_param { |
michael@0 | 82 | struct sctp_paramhdr ph;/* type=SCTP_HOSTNAME_ADDRESS */ |
michael@0 | 83 | char name[SCTP_ARRAY_MIN_LEN]; /* host name */ |
michael@0 | 84 | } SCTP_PACKED; |
michael@0 | 85 | |
michael@0 | 86 | /* |
michael@0 | 87 | * This is the maximum padded size of a s-a-p |
michael@0 | 88 | * so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12 |
michael@0 | 89 | */ |
michael@0 | 90 | #define SCTP_MAX_ADDR_PARAMS_SIZE 12 |
michael@0 | 91 | /* supported address type */ |
michael@0 | 92 | struct sctp_supported_addr_param { |
michael@0 | 93 | struct sctp_paramhdr ph;/* type=SCTP_SUPPORTED_ADDRTYPE */ |
michael@0 | 94 | uint16_t addr_type[2]; /* array of supported address types */ |
michael@0 | 95 | } SCTP_PACKED; |
michael@0 | 96 | |
michael@0 | 97 | /* ECN parameter */ |
michael@0 | 98 | struct sctp_ecn_supported_param { |
michael@0 | 99 | struct sctp_paramhdr ph;/* type=SCTP_ECN_CAPABLE */ |
michael@0 | 100 | } SCTP_PACKED; |
michael@0 | 101 | |
michael@0 | 102 | |
michael@0 | 103 | /* heartbeat info parameter */ |
michael@0 | 104 | struct sctp_heartbeat_info_param { |
michael@0 | 105 | struct sctp_paramhdr ph; |
michael@0 | 106 | uint32_t time_value_1; |
michael@0 | 107 | uint32_t time_value_2; |
michael@0 | 108 | uint32_t random_value1; |
michael@0 | 109 | uint32_t random_value2; |
michael@0 | 110 | uint8_t addr_family; |
michael@0 | 111 | uint8_t addr_len; |
michael@0 | 112 | /* make sure that this structure is 4 byte aligned */ |
michael@0 | 113 | uint8_t padding[2]; |
michael@0 | 114 | char address[SCTP_ADDRMAX]; |
michael@0 | 115 | } SCTP_PACKED; |
michael@0 | 116 | |
michael@0 | 117 | |
michael@0 | 118 | /* draft-ietf-tsvwg-prsctp */ |
michael@0 | 119 | /* PR-SCTP supported parameter */ |
michael@0 | 120 | struct sctp_prsctp_supported_param { |
michael@0 | 121 | struct sctp_paramhdr ph; |
michael@0 | 122 | } SCTP_PACKED; |
michael@0 | 123 | |
michael@0 | 124 | |
michael@0 | 125 | /* draft-ietf-tsvwg-addip-sctp */ |
michael@0 | 126 | struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */ |
michael@0 | 127 | struct sctp_paramhdr ph;/* a SCTP parameter header */ |
michael@0 | 128 | uint32_t correlation_id;/* correlation id for this param */ |
michael@0 | 129 | } SCTP_PACKED; |
michael@0 | 130 | |
michael@0 | 131 | struct sctp_asconf_addr_param { /* an ASCONF address parameter */ |
michael@0 | 132 | struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ |
michael@0 | 133 | struct sctp_ipv6addr_param addrp; /* max storage size */ |
michael@0 | 134 | } SCTP_PACKED; |
michael@0 | 135 | |
michael@0 | 136 | |
michael@0 | 137 | struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */ |
michael@0 | 138 | struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ |
michael@0 | 139 | uint32_t local_vtag; |
michael@0 | 140 | uint32_t remote_vtag; |
michael@0 | 141 | } SCTP_PACKED; |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */ |
michael@0 | 145 | struct sctp_asconf_paramhdr aph; /* asconf "parameter" */ |
michael@0 | 146 | struct sctp_ipv4addr_param addrp; /* max storage size */ |
michael@0 | 147 | } SCTP_PACKED; |
michael@0 | 148 | |
michael@0 | 149 | #define SCTP_MAX_SUPPORTED_EXT 256 |
michael@0 | 150 | |
michael@0 | 151 | struct sctp_supported_chunk_types_param { |
michael@0 | 152 | struct sctp_paramhdr ph;/* type = 0x8008 len = x */ |
michael@0 | 153 | uint8_t chunk_types[]; |
michael@0 | 154 | } SCTP_PACKED; |
michael@0 | 155 | |
michael@0 | 156 | |
michael@0 | 157 | /* |
michael@0 | 158 | * Structures for DATA chunks |
michael@0 | 159 | */ |
michael@0 | 160 | struct sctp_data { |
michael@0 | 161 | uint32_t tsn; |
michael@0 | 162 | uint16_t stream_id; |
michael@0 | 163 | uint16_t stream_sequence; |
michael@0 | 164 | uint32_t protocol_id; |
michael@0 | 165 | /* user data follows */ |
michael@0 | 166 | } SCTP_PACKED; |
michael@0 | 167 | |
michael@0 | 168 | struct sctp_data_chunk { |
michael@0 | 169 | struct sctp_chunkhdr ch; |
michael@0 | 170 | struct sctp_data dp; |
michael@0 | 171 | } SCTP_PACKED; |
michael@0 | 172 | |
michael@0 | 173 | /* |
michael@0 | 174 | * Structures for the control chunks |
michael@0 | 175 | */ |
michael@0 | 176 | |
michael@0 | 177 | /* Initiate (INIT)/Initiate Ack (INIT ACK) */ |
michael@0 | 178 | struct sctp_init { |
michael@0 | 179 | uint32_t initiate_tag; /* initiate tag */ |
michael@0 | 180 | uint32_t a_rwnd; /* a_rwnd */ |
michael@0 | 181 | uint16_t num_outbound_streams; /* OS */ |
michael@0 | 182 | uint16_t num_inbound_streams; /* MIS */ |
michael@0 | 183 | uint32_t initial_tsn; /* I-TSN */ |
michael@0 | 184 | /* optional param's follow */ |
michael@0 | 185 | } SCTP_PACKED; |
michael@0 | 186 | #define SCTP_IDENTIFICATION_SIZE 16 |
michael@0 | 187 | #define SCTP_ADDRESS_SIZE 4 |
michael@0 | 188 | #if defined(__Userspace__) |
michael@0 | 189 | #define SCTP_RESERVE_SPACE 5 |
michael@0 | 190 | #else |
michael@0 | 191 | #define SCTP_RESERVE_SPACE 6 |
michael@0 | 192 | #endif |
michael@0 | 193 | /* state cookie header */ |
michael@0 | 194 | struct sctp_state_cookie { /* this is our definition... */ |
michael@0 | 195 | uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */ |
michael@0 | 196 | struct timeval time_entered; /* the time I built cookie */ |
michael@0 | 197 | uint32_t cookie_life; /* life I will award this cookie */ |
michael@0 | 198 | uint32_t tie_tag_my_vtag; /* my tag in old association */ |
michael@0 | 199 | |
michael@0 | 200 | uint32_t tie_tag_peer_vtag; /* peers tag in old association */ |
michael@0 | 201 | uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */ |
michael@0 | 202 | |
michael@0 | 203 | uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */ |
michael@0 | 204 | uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */ |
michael@0 | 205 | uint32_t addr_type; /* address type */ |
michael@0 | 206 | uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */ |
michael@0 | 207 | uint32_t laddr_type; /* my local from address type */ |
michael@0 | 208 | uint32_t scope_id; /* v6 scope id for link-locals */ |
michael@0 | 209 | |
michael@0 | 210 | uint16_t peerport; /* port address of the peer in the INIT */ |
michael@0 | 211 | uint16_t myport; /* my port address used in the INIT */ |
michael@0 | 212 | uint8_t ipv4_addr_legal;/* Are V4 addr legal? */ |
michael@0 | 213 | uint8_t ipv6_addr_legal;/* Are V6 addr legal? */ |
michael@0 | 214 | #if defined(__Userspace__) |
michael@0 | 215 | uint8_t conn_addr_legal; |
michael@0 | 216 | #endif |
michael@0 | 217 | uint8_t local_scope; /* IPv6 local scope flag */ |
michael@0 | 218 | uint8_t site_scope; /* IPv6 site scope flag */ |
michael@0 | 219 | |
michael@0 | 220 | uint8_t ipv4_scope; /* IPv4 private addr scope */ |
michael@0 | 221 | uint8_t loopback_scope; /* loopback scope information */ |
michael@0 | 222 | uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */ |
michael@0 | 223 | /* |
michael@0 | 224 | * at the end is tacked on the INIT chunk and the INIT-ACK chunk |
michael@0 | 225 | * (minus the cookie). |
michael@0 | 226 | */ |
michael@0 | 227 | } SCTP_PACKED; |
michael@0 | 228 | |
michael@0 | 229 | |
michael@0 | 230 | /* Used for NAT state error cause */ |
michael@0 | 231 | struct sctp_missing_nat_state { |
michael@0 | 232 | uint16_t cause; |
michael@0 | 233 | uint16_t length; |
michael@0 | 234 | uint8_t data[]; |
michael@0 | 235 | } SCTP_PACKED; |
michael@0 | 236 | |
michael@0 | 237 | |
michael@0 | 238 | struct sctp_inv_mandatory_param { |
michael@0 | 239 | uint16_t cause; |
michael@0 | 240 | uint16_t length; |
michael@0 | 241 | uint32_t num_param; |
michael@0 | 242 | uint16_t param; |
michael@0 | 243 | /* |
michael@0 | 244 | * We include this to 0 it since only a missing cookie will cause |
michael@0 | 245 | * this error. |
michael@0 | 246 | */ |
michael@0 | 247 | uint16_t resv; |
michael@0 | 248 | } SCTP_PACKED; |
michael@0 | 249 | |
michael@0 | 250 | struct sctp_unresolv_addr { |
michael@0 | 251 | uint16_t cause; |
michael@0 | 252 | uint16_t length; |
michael@0 | 253 | uint16_t addr_type; |
michael@0 | 254 | uint16_t reserved; /* Only one invalid addr type */ |
michael@0 | 255 | } SCTP_PACKED; |
michael@0 | 256 | |
michael@0 | 257 | /* state cookie parameter */ |
michael@0 | 258 | struct sctp_state_cookie_param { |
michael@0 | 259 | struct sctp_paramhdr ph; |
michael@0 | 260 | struct sctp_state_cookie cookie; |
michael@0 | 261 | } SCTP_PACKED; |
michael@0 | 262 | |
michael@0 | 263 | struct sctp_init_chunk { |
michael@0 | 264 | struct sctp_chunkhdr ch; |
michael@0 | 265 | struct sctp_init init; |
michael@0 | 266 | } SCTP_PACKED; |
michael@0 | 267 | |
michael@0 | 268 | struct sctp_init_msg { |
michael@0 | 269 | struct sctphdr sh; |
michael@0 | 270 | struct sctp_init_chunk msg; |
michael@0 | 271 | } SCTP_PACKED; |
michael@0 | 272 | |
michael@0 | 273 | /* ... used for both INIT and INIT ACK */ |
michael@0 | 274 | #define sctp_init_ack sctp_init |
michael@0 | 275 | #define sctp_init_ack_chunk sctp_init_chunk |
michael@0 | 276 | #define sctp_init_ack_msg sctp_init_msg |
michael@0 | 277 | |
michael@0 | 278 | |
michael@0 | 279 | /* Selective Ack (SACK) */ |
michael@0 | 280 | struct sctp_gap_ack_block { |
michael@0 | 281 | uint16_t start; /* Gap Ack block start */ |
michael@0 | 282 | uint16_t end; /* Gap Ack block end */ |
michael@0 | 283 | } SCTP_PACKED; |
michael@0 | 284 | |
michael@0 | 285 | struct sctp_sack { |
michael@0 | 286 | uint32_t cum_tsn_ack; /* cumulative TSN Ack */ |
michael@0 | 287 | uint32_t a_rwnd; /* updated a_rwnd of sender */ |
michael@0 | 288 | uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ |
michael@0 | 289 | uint16_t num_dup_tsns; /* number of duplicate TSNs */ |
michael@0 | 290 | /* struct sctp_gap_ack_block's follow */ |
michael@0 | 291 | /* uint32_t duplicate_tsn's follow */ |
michael@0 | 292 | } SCTP_PACKED; |
michael@0 | 293 | |
michael@0 | 294 | struct sctp_sack_chunk { |
michael@0 | 295 | struct sctp_chunkhdr ch; |
michael@0 | 296 | struct sctp_sack sack; |
michael@0 | 297 | } SCTP_PACKED; |
michael@0 | 298 | |
michael@0 | 299 | struct sctp_nr_sack { |
michael@0 | 300 | uint32_t cum_tsn_ack; /* cumulative TSN Ack */ |
michael@0 | 301 | uint32_t a_rwnd; /* updated a_rwnd of sender */ |
michael@0 | 302 | uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */ |
michael@0 | 303 | uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */ |
michael@0 | 304 | uint16_t num_dup_tsns; /* number of duplicate TSNs */ |
michael@0 | 305 | uint16_t reserved; /* not currently used*/ |
michael@0 | 306 | /* struct sctp_gap_ack_block's follow */ |
michael@0 | 307 | /* uint32_t duplicate_tsn's follow */ |
michael@0 | 308 | } SCTP_PACKED; |
michael@0 | 309 | |
michael@0 | 310 | struct sctp_nr_sack_chunk { |
michael@0 | 311 | struct sctp_chunkhdr ch; |
michael@0 | 312 | struct sctp_nr_sack nr_sack; |
michael@0 | 313 | } SCTP_PACKED; |
michael@0 | 314 | |
michael@0 | 315 | |
michael@0 | 316 | /* Heartbeat Request (HEARTBEAT) */ |
michael@0 | 317 | struct sctp_heartbeat { |
michael@0 | 318 | struct sctp_heartbeat_info_param hb_info; |
michael@0 | 319 | } SCTP_PACKED; |
michael@0 | 320 | |
michael@0 | 321 | struct sctp_heartbeat_chunk { |
michael@0 | 322 | struct sctp_chunkhdr ch; |
michael@0 | 323 | struct sctp_heartbeat heartbeat; |
michael@0 | 324 | } SCTP_PACKED; |
michael@0 | 325 | |
michael@0 | 326 | /* ... used for Heartbeat Ack (HEARTBEAT ACK) */ |
michael@0 | 327 | #define sctp_heartbeat_ack sctp_heartbeat |
michael@0 | 328 | #define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk |
michael@0 | 329 | |
michael@0 | 330 | |
michael@0 | 331 | /* Abort Asssociation (ABORT) */ |
michael@0 | 332 | struct sctp_abort_chunk { |
michael@0 | 333 | struct sctp_chunkhdr ch; |
michael@0 | 334 | /* optional error cause may follow */ |
michael@0 | 335 | } SCTP_PACKED; |
michael@0 | 336 | |
michael@0 | 337 | struct sctp_abort_msg { |
michael@0 | 338 | struct sctphdr sh; |
michael@0 | 339 | struct sctp_abort_chunk msg; |
michael@0 | 340 | } SCTP_PACKED; |
michael@0 | 341 | |
michael@0 | 342 | |
michael@0 | 343 | /* Shutdown Association (SHUTDOWN) */ |
michael@0 | 344 | struct sctp_shutdown_chunk { |
michael@0 | 345 | struct sctp_chunkhdr ch; |
michael@0 | 346 | uint32_t cumulative_tsn_ack; |
michael@0 | 347 | } SCTP_PACKED; |
michael@0 | 348 | |
michael@0 | 349 | |
michael@0 | 350 | /* Shutdown Acknowledgment (SHUTDOWN ACK) */ |
michael@0 | 351 | struct sctp_shutdown_ack_chunk { |
michael@0 | 352 | struct sctp_chunkhdr ch; |
michael@0 | 353 | } SCTP_PACKED; |
michael@0 | 354 | |
michael@0 | 355 | |
michael@0 | 356 | /* Operation Error (ERROR) */ |
michael@0 | 357 | struct sctp_error_chunk { |
michael@0 | 358 | struct sctp_chunkhdr ch; |
michael@0 | 359 | /* optional error causes follow */ |
michael@0 | 360 | } SCTP_PACKED; |
michael@0 | 361 | |
michael@0 | 362 | |
michael@0 | 363 | /* Cookie Echo (COOKIE ECHO) */ |
michael@0 | 364 | struct sctp_cookie_echo_chunk { |
michael@0 | 365 | struct sctp_chunkhdr ch; |
michael@0 | 366 | struct sctp_state_cookie cookie; |
michael@0 | 367 | } SCTP_PACKED; |
michael@0 | 368 | |
michael@0 | 369 | /* Cookie Acknowledgment (COOKIE ACK) */ |
michael@0 | 370 | struct sctp_cookie_ack_chunk { |
michael@0 | 371 | struct sctp_chunkhdr ch; |
michael@0 | 372 | } SCTP_PACKED; |
michael@0 | 373 | |
michael@0 | 374 | /* Explicit Congestion Notification Echo (ECNE) */ |
michael@0 | 375 | struct old_sctp_ecne_chunk { |
michael@0 | 376 | struct sctp_chunkhdr ch; |
michael@0 | 377 | uint32_t tsn; |
michael@0 | 378 | } SCTP_PACKED; |
michael@0 | 379 | |
michael@0 | 380 | struct sctp_ecne_chunk { |
michael@0 | 381 | struct sctp_chunkhdr ch; |
michael@0 | 382 | uint32_t tsn; |
michael@0 | 383 | uint32_t num_pkts_since_cwr; |
michael@0 | 384 | } SCTP_PACKED; |
michael@0 | 385 | |
michael@0 | 386 | /* Congestion Window Reduced (CWR) */ |
michael@0 | 387 | struct sctp_cwr_chunk { |
michael@0 | 388 | struct sctp_chunkhdr ch; |
michael@0 | 389 | uint32_t tsn; |
michael@0 | 390 | } SCTP_PACKED; |
michael@0 | 391 | |
michael@0 | 392 | /* Shutdown Complete (SHUTDOWN COMPLETE) */ |
michael@0 | 393 | struct sctp_shutdown_complete_chunk { |
michael@0 | 394 | struct sctp_chunkhdr ch; |
michael@0 | 395 | } SCTP_PACKED; |
michael@0 | 396 | |
michael@0 | 397 | /* Oper error holding a stale cookie */ |
michael@0 | 398 | struct sctp_stale_cookie_msg { |
michael@0 | 399 | struct sctp_paramhdr ph;/* really an error cause */ |
michael@0 | 400 | uint32_t time_usec; |
michael@0 | 401 | } SCTP_PACKED; |
michael@0 | 402 | |
michael@0 | 403 | struct sctp_adaptation_layer_indication { |
michael@0 | 404 | struct sctp_paramhdr ph; |
michael@0 | 405 | uint32_t indication; |
michael@0 | 406 | } SCTP_PACKED; |
michael@0 | 407 | |
michael@0 | 408 | struct sctp_cookie_while_shutting_down { |
michael@0 | 409 | struct sctphdr sh; |
michael@0 | 410 | struct sctp_chunkhdr ch; |
michael@0 | 411 | struct sctp_paramhdr ph;/* really an error cause */ |
michael@0 | 412 | } SCTP_PACKED; |
michael@0 | 413 | |
michael@0 | 414 | struct sctp_shutdown_complete_msg { |
michael@0 | 415 | struct sctphdr sh; |
michael@0 | 416 | struct sctp_shutdown_complete_chunk shut_cmp; |
michael@0 | 417 | } SCTP_PACKED; |
michael@0 | 418 | |
michael@0 | 419 | /* |
michael@0 | 420 | * draft-ietf-tsvwg-addip-sctp |
michael@0 | 421 | */ |
michael@0 | 422 | /* Address/Stream Configuration Change (ASCONF) */ |
michael@0 | 423 | struct sctp_asconf_chunk { |
michael@0 | 424 | struct sctp_chunkhdr ch; |
michael@0 | 425 | uint32_t serial_number; |
michael@0 | 426 | /* lookup address parameter (mandatory) */ |
michael@0 | 427 | /* asconf parameters follow */ |
michael@0 | 428 | } SCTP_PACKED; |
michael@0 | 429 | |
michael@0 | 430 | /* Address/Stream Configuration Acknowledge (ASCONF ACK) */ |
michael@0 | 431 | struct sctp_asconf_ack_chunk { |
michael@0 | 432 | struct sctp_chunkhdr ch; |
michael@0 | 433 | uint32_t serial_number; |
michael@0 | 434 | /* asconf parameters follow */ |
michael@0 | 435 | } SCTP_PACKED; |
michael@0 | 436 | |
michael@0 | 437 | /* draft-ietf-tsvwg-prsctp */ |
michael@0 | 438 | /* Forward Cumulative TSN (FORWARD TSN) */ |
michael@0 | 439 | struct sctp_forward_tsn_chunk { |
michael@0 | 440 | struct sctp_chunkhdr ch; |
michael@0 | 441 | uint32_t new_cumulative_tsn; |
michael@0 | 442 | /* stream/sequence pairs (sctp_strseq) follow */ |
michael@0 | 443 | } SCTP_PACKED; |
michael@0 | 444 | |
michael@0 | 445 | struct sctp_strseq { |
michael@0 | 446 | uint16_t stream; |
michael@0 | 447 | uint16_t sequence; |
michael@0 | 448 | } SCTP_PACKED; |
michael@0 | 449 | |
michael@0 | 450 | struct sctp_forward_tsn_msg { |
michael@0 | 451 | struct sctphdr sh; |
michael@0 | 452 | struct sctp_forward_tsn_chunk msg; |
michael@0 | 453 | } SCTP_PACKED; |
michael@0 | 454 | |
michael@0 | 455 | /* should be a multiple of 4 - 1 aka 3/7/11 etc. */ |
michael@0 | 456 | |
michael@0 | 457 | #define SCTP_NUM_DB_TO_VERIFY 31 |
michael@0 | 458 | |
michael@0 | 459 | struct sctp_chunk_desc { |
michael@0 | 460 | uint8_t chunk_type; |
michael@0 | 461 | uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY]; |
michael@0 | 462 | uint32_t tsn_ifany; |
michael@0 | 463 | } SCTP_PACKED; |
michael@0 | 464 | |
michael@0 | 465 | |
michael@0 | 466 | struct sctp_pktdrop_chunk { |
michael@0 | 467 | struct sctp_chunkhdr ch; |
michael@0 | 468 | uint32_t bottle_bw; |
michael@0 | 469 | uint32_t current_onq; |
michael@0 | 470 | uint16_t trunc_len; |
michael@0 | 471 | uint16_t reserved; |
michael@0 | 472 | uint8_t data[]; |
michael@0 | 473 | } SCTP_PACKED; |
michael@0 | 474 | |
michael@0 | 475 | /**********STREAM RESET STUFF ******************/ |
michael@0 | 476 | |
michael@0 | 477 | struct sctp_stream_reset_out_request { |
michael@0 | 478 | struct sctp_paramhdr ph; |
michael@0 | 479 | uint32_t request_seq; /* monotonically increasing seq no */ |
michael@0 | 480 | uint32_t response_seq; /* if a response, the resp seq no */ |
michael@0 | 481 | uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */ |
michael@0 | 482 | uint16_t list_of_streams[]; /* if not all list of streams */ |
michael@0 | 483 | } SCTP_PACKED; |
michael@0 | 484 | |
michael@0 | 485 | struct sctp_stream_reset_in_request { |
michael@0 | 486 | struct sctp_paramhdr ph; |
michael@0 | 487 | uint32_t request_seq; |
michael@0 | 488 | uint16_t list_of_streams[]; /* if not all list of streams */ |
michael@0 | 489 | } SCTP_PACKED; |
michael@0 | 490 | |
michael@0 | 491 | |
michael@0 | 492 | struct sctp_stream_reset_tsn_request { |
michael@0 | 493 | struct sctp_paramhdr ph; |
michael@0 | 494 | uint32_t request_seq; |
michael@0 | 495 | } SCTP_PACKED; |
michael@0 | 496 | |
michael@0 | 497 | struct sctp_stream_reset_response { |
michael@0 | 498 | struct sctp_paramhdr ph; |
michael@0 | 499 | uint32_t response_seq; /* if a response, the resp seq no */ |
michael@0 | 500 | uint32_t result; |
michael@0 | 501 | } SCTP_PACKED; |
michael@0 | 502 | |
michael@0 | 503 | struct sctp_stream_reset_response_tsn { |
michael@0 | 504 | struct sctp_paramhdr ph; |
michael@0 | 505 | uint32_t response_seq; /* if a response, the resp seq no */ |
michael@0 | 506 | uint32_t result; |
michael@0 | 507 | uint32_t senders_next_tsn; |
michael@0 | 508 | uint32_t receivers_next_tsn; |
michael@0 | 509 | } SCTP_PACKED; |
michael@0 | 510 | |
michael@0 | 511 | struct sctp_stream_reset_add_strm { |
michael@0 | 512 | struct sctp_paramhdr ph; |
michael@0 | 513 | uint32_t request_seq; |
michael@0 | 514 | uint16_t number_of_streams; |
michael@0 | 515 | uint16_t reserved; |
michael@0 | 516 | } SCTP_PACKED; |
michael@0 | 517 | |
michael@0 | 518 | #define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */ |
michael@0 | 519 | #define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001 |
michael@0 | 520 | #define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002 |
michael@0 | 521 | #define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */ |
michael@0 | 522 | #define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004 |
michael@0 | 523 | #define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005 |
michael@0 | 524 | #define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */ |
michael@0 | 525 | |
michael@0 | 526 | /* |
michael@0 | 527 | * convience structures, note that if you are making a request for specific |
michael@0 | 528 | * streams then the request will need to be an overlay structure. |
michael@0 | 529 | */ |
michael@0 | 530 | |
michael@0 | 531 | struct sctp_stream_reset_tsn_req { |
michael@0 | 532 | struct sctp_chunkhdr ch; |
michael@0 | 533 | struct sctp_stream_reset_tsn_request sr_req; |
michael@0 | 534 | } SCTP_PACKED; |
michael@0 | 535 | |
michael@0 | 536 | struct sctp_stream_reset_resp { |
michael@0 | 537 | struct sctp_chunkhdr ch; |
michael@0 | 538 | struct sctp_stream_reset_response sr_resp; |
michael@0 | 539 | } SCTP_PACKED; |
michael@0 | 540 | |
michael@0 | 541 | /* respone only valid with a TSN request */ |
michael@0 | 542 | struct sctp_stream_reset_resp_tsn { |
michael@0 | 543 | struct sctp_chunkhdr ch; |
michael@0 | 544 | struct sctp_stream_reset_response_tsn sr_resp; |
michael@0 | 545 | } SCTP_PACKED; |
michael@0 | 546 | |
michael@0 | 547 | /****************************************************/ |
michael@0 | 548 | |
michael@0 | 549 | /* |
michael@0 | 550 | * Authenticated chunks support draft-ietf-tsvwg-sctp-auth |
michael@0 | 551 | */ |
michael@0 | 552 | |
michael@0 | 553 | /* Should we make the max be 32? */ |
michael@0 | 554 | #define SCTP_RANDOM_MAX_SIZE 256 |
michael@0 | 555 | struct sctp_auth_random { |
michael@0 | 556 | struct sctp_paramhdr ph;/* type = 0x8002 */ |
michael@0 | 557 | uint8_t random_data[]; |
michael@0 | 558 | } SCTP_PACKED; |
michael@0 | 559 | |
michael@0 | 560 | struct sctp_auth_chunk_list { |
michael@0 | 561 | struct sctp_paramhdr ph;/* type = 0x8003 */ |
michael@0 | 562 | uint8_t chunk_types[]; |
michael@0 | 563 | } SCTP_PACKED; |
michael@0 | 564 | |
michael@0 | 565 | struct sctp_auth_hmac_algo { |
michael@0 | 566 | struct sctp_paramhdr ph;/* type = 0x8004 */ |
michael@0 | 567 | uint16_t hmac_ids[]; |
michael@0 | 568 | } SCTP_PACKED; |
michael@0 | 569 | |
michael@0 | 570 | struct sctp_auth_chunk { |
michael@0 | 571 | struct sctp_chunkhdr ch; |
michael@0 | 572 | uint16_t shared_key_id; |
michael@0 | 573 | uint16_t hmac_id; |
michael@0 | 574 | uint8_t hmac[]; |
michael@0 | 575 | } SCTP_PACKED; |
michael@0 | 576 | |
michael@0 | 577 | struct sctp_auth_invalid_hmac { |
michael@0 | 578 | struct sctp_paramhdr ph; |
michael@0 | 579 | uint16_t hmac_id; |
michael@0 | 580 | uint16_t padding; |
michael@0 | 581 | } SCTP_PACKED; |
michael@0 | 582 | |
michael@0 | 583 | /* |
michael@0 | 584 | * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing |
michael@0 | 585 | * pieces. If ENCE is missing we could have a couple of blocks. This way we |
michael@0 | 586 | * optimize so we MOST likely can bundle a SACK/ECN with the smallest size |
michael@0 | 587 | * data chunk I will split into. We could increase throughput slightly by |
michael@0 | 588 | * taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I |
michael@0 | 589 | * feel is worth it for now. |
michael@0 | 590 | */ |
michael@0 | 591 | #ifndef SCTP_MAX_OVERHEAD |
michael@0 | 592 | #ifdef INET6 |
michael@0 | 593 | #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ |
michael@0 | 594 | sizeof(struct sctphdr) + \ |
michael@0 | 595 | sizeof(struct sctp_ecne_chunk) + \ |
michael@0 | 596 | sizeof(struct sctp_sack_chunk) + \ |
michael@0 | 597 | sizeof(struct ip6_hdr)) |
michael@0 | 598 | |
michael@0 | 599 | #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ |
michael@0 | 600 | sizeof(struct sctphdr) + \ |
michael@0 | 601 | sizeof(struct ip6_hdr)) |
michael@0 | 602 | |
michael@0 | 603 | |
michael@0 | 604 | #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \ |
michael@0 | 605 | sizeof(struct sctphdr)) |
michael@0 | 606 | |
michael@0 | 607 | #else |
michael@0 | 608 | #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \ |
michael@0 | 609 | sizeof(struct sctphdr) + \ |
michael@0 | 610 | sizeof(struct sctp_ecne_chunk) + \ |
michael@0 | 611 | sizeof(struct sctp_sack_chunk) + \ |
michael@0 | 612 | sizeof(struct ip)) |
michael@0 | 613 | |
michael@0 | 614 | #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \ |
michael@0 | 615 | sizeof(struct sctphdr) + \ |
michael@0 | 616 | sizeof(struct ip)) |
michael@0 | 617 | |
michael@0 | 618 | |
michael@0 | 619 | #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \ |
michael@0 | 620 | sizeof(struct sctphdr)) |
michael@0 | 621 | |
michael@0 | 622 | #endif /* INET6 */ |
michael@0 | 623 | #endif /* !SCTP_MAX_OVERHEAD */ |
michael@0 | 624 | |
michael@0 | 625 | #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \ |
michael@0 | 626 | sizeof(struct sctphdr) + \ |
michael@0 | 627 | sizeof(struct ip)) |
michael@0 | 628 | |
michael@0 | 629 | #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ |
michael@0 | 630 | sizeof(struct sctphdr)) |
michael@0 | 631 | |
michael@0 | 632 | #if defined(__Windows__) |
michael@0 | 633 | #include <packoff.h> |
michael@0 | 634 | #endif |
michael@0 | 635 | #if defined(__Userspace_os_Windows) |
michael@0 | 636 | #pragma pack () |
michael@0 | 637 | #endif |
michael@0 | 638 | #undef SCTP_PACKED |
michael@0 | 639 | #endif /* !__sctp_header_h__ */ |