1 /* $KAME: sctp_constants.h,v 1.17 2005/03/06 16:04:17 itojun Exp $ */ 2 /* $NetBSD: sctp_constants.h,v 1.4 2022/05/18 13:37:52 andvar Exp $ */ 3 4 #ifndef __SCTP_CONSTANTS_H__ 5 #define __SCTP_CONSTANTS_H__ 6 7 /* 8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by Cisco Systems, Inc. 22 * 4. Neither the name of the project nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 #define SCTP_VERSION_STRING "KAME-BSD 1.1" 39 /*#define SCTP_AUDITING_ENABLED 1 used for debug/auditing */ 40 #define SCTP_AUDIT_SIZE 256 41 #define SCTP_STAT_LOG_SIZE 80000 42 43 /* Places that CWND log can happen from */ 44 #define SCTP_CWND_LOG_FROM_FR 1 45 #define SCTP_CWND_LOG_FROM_RTX 2 46 #define SCTP_CWND_LOG_FROM_BRST 3 47 #define SCTP_CWND_LOG_FROM_SS 4 48 #define SCTP_CWND_LOG_FROM_CA 5 49 #define SCTP_CWND_LOG_FROM_SAT 6 50 #define SCTP_BLOCK_LOG_INTO_BLK 7 51 #define SCTP_BLOCK_LOG_OUTOF_BLK 8 52 #define SCTP_BLOCK_LOG_CHECK 9 53 #define SCTP_STR_LOG_FROM_INTO_STRD 10 54 #define SCTP_STR_LOG_FROM_IMMED_DEL 11 55 #define SCTP_STR_LOG_FROM_INSERT_HD 12 56 #define SCTP_STR_LOG_FROM_INSERT_MD 13 57 #define SCTP_STR_LOG_FROM_INSERT_TL 14 58 #define SCTP_STR_LOG_FROM_MARK_TSN 15 59 #define SCTP_STR_LOG_FROM_EXPRS_DEL 16 60 #define SCTP_FR_LOG_BIGGEST_TSNS 17 61 #define SCTP_FR_LOG_STRIKE_TEST 18 62 #define SCTP_FR_LOG_STRIKE_CHUNK 19 63 #define SCTP_FR_T3_TIMEOUT 20 64 #define SCTP_MAP_PREPARE_SLIDE 21 65 #define SCTP_MAP_SLIDE_FROM 22 66 #define SCTP_MAP_SLIDE_RESULT 23 67 #define SCTP_MAP_SLIDE_CLEARED 24 68 #define SCTP_MAP_SLIDE_NONE 25 69 #define SCTP_FR_T3_MARK_TIME 26 70 #define SCTP_FR_T3_MARKED 27 71 #define SCTP_FR_T3_STOPPED 28 72 #define SCTP_FR_MARKED 30 73 #define SCTP_CWND_LOG_NOADV_SS 31 74 #define SCTP_CWND_LOG_NOADV_CA 32 75 #define SCTP_MAX_BURST_APPLIED 33 76 #define SCTP_MAX_IFP_APPLIED 34 77 #define SCTP_MAX_BURST_ERROR_STOP 35 78 #define SCTP_INCREASE_PEER_RWND 36 79 #define SCTP_DECREASE_PEER_RWND 37 80 #define SCTP_SET_PEER_RWND_VIA_SACK 38 81 #define SCTP_LOG_MBCNT_INCREASE 39 82 #define SCTP_LOG_MBCNT_DECREASE 40 83 #define SCTP_LOG_MBCNT_CHKSET 41 84 /* 85 * To turn on various logging, you must first define SCTP_STAT_LOGGING. 86 * Then to get something to log you define one of the logging defines i.e. 87 * 88 * SCTP_CWND_LOGGING 89 * SCTP_BLK_LOGGING 90 * SCTP_STR_LOGGING 91 * SCTP_FR_LOGGING 92 * 93 * Any one or a combination of the logging can be turned on. 94 */ 95 #define SCTP_LOG_EVENT_CWND 1 96 #define SCTP_LOG_EVENT_BLOCK 2 97 #define SCTP_LOG_EVENT_STRM 3 98 #define SCTP_LOG_EVENT_FR 4 99 #define SCTP_LOG_EVENT_MAP 5 100 #define SCTP_LOG_EVENT_MAXBURST 6 101 #define SCTP_LOG_EVENT_RWND 7 102 #define SCTP_LOG_EVENT_MBCNT 8 103 104 105 /* number of associations by default for zone allocation */ 106 #define SCTP_MAX_NUM_OF_ASOC 40000 107 /* how many addresses per assoc remote and local */ 108 #define SCTP_SCALE_FOR_ADDR 2 109 110 /* default AUTO_ASCONF mode enable(1)/disable(0) value (sysctl) */ 111 #define SCTP_DEFAULT_AUTO_ASCONF 0 112 113 /* 114 * If you wish to use MD5 instead of SLA uncomment the line below. 115 * Why you would like to do this: 116 * a) There may be IPR on SHA-1, or so the FIP-180-1 page says, 117 * b) MD5 is 3 times faster (has coded here). 118 * 119 * The disadvantage is it is thought that MD5 has been cracked... see RFC2104. 120 */ 121 /*#define USE_MD5 1 */ 122 /* 123 * Note: I can't seem to get this to compile now for some reason- the 124 * kernel can't link in the md5 crypto 125 */ 126 127 /* DEFINE HERE WHAT CRC YOU WANT TO USE */ 128 #define SCTP_USECRC_RFC2960 1 129 /*#define SCTP_USECRC_FLETCHER 1*/ 130 /*#define SCTP_USECRC_SSHCRC32 1*/ 131 /*#define SCTP_USECRC_FASTCRC32 1*/ 132 /*#define SCTP_USECRC_CRC32 1*/ 133 /*#define SCTP_USECRC_TCP32 1*/ 134 /*#define SCTP_USECRC_CRC16SMAL 1*/ 135 /*#define SCTP_USECRC_CRC16 1 */ 136 /*#define SCTP_USECRC_MODADLER 1*/ 137 138 #ifndef SCTP_ADLER32_BASE 139 #define SCTP_ADLER32_BASE 65521 140 #endif 141 142 #define SCTP_CWND_POSTS_LIST 256 143 /* 144 * the SCTP protocol signature 145 * this includes the version number encoded in the last 4 bits 146 * of the signature. 147 */ 148 #define PROTO_SIGNATURE_A 0x30000000 149 #define SCTP_VERSION_NUMBER 0x3 150 151 #define MAX_TSN 0xffffffff 152 #define MAX_SEQ 0xffff 153 154 /* how many executions every N tick's */ 155 #define SCTP_MAX_ITERATOR_AT_ONCE 20 156 157 /* number of clock ticks between iterator executions */ 158 #define SCTP_ITERATOR_TICKS 1 159 160 /* option: 161 * If you comment out the following you will receive the old 162 * behavior of obeying cwnd for the fast retransmit algorithm. 163 * With this defined a FR happens right away with-out waiting 164 * for the flightsize to drop below the cwnd value (which is 165 * reduced by the FR to 1/2 the inflight packets). 166 */ 167 #define SCTP_IGNORE_CWND_ON_FR 1 168 169 /* 170 * Adds implementors guide behavior to only use newest highest 171 * update in SACK gap ack's to figure out if you need to stroke 172 * a chunk for FR. 173 */ 174 #define SCTP_NO_FR_UNLESS_SEGMENT_SMALLER 1 175 176 /* default max I can burst out after a fast retransmit */ 177 #define SCTP_DEF_MAX_BURST 8 178 179 /* Packet transmit states in the sent field */ 180 #define SCTP_DATAGRAM_UNSENT 0 181 #define SCTP_DATAGRAM_SENT 1 182 #define SCTP_DATAGRAM_RESEND1 2 /* not used (in code, but may hit this value) */ 183 #define SCTP_DATAGRAM_RESEND2 3 /* not used (in code, but may hit this value) */ 184 #define SCTP_DATAGRAM_RESEND3 4 /* not used (in code, but may hit this value) */ 185 #define SCTP_DATAGRAM_RESEND 5 186 #define SCTP_DATAGRAM_ACKED 10010 187 #define SCTP_DATAGRAM_INBOUND 10011 188 #define SCTP_READY_TO_TRANSMIT 10012 189 #define SCTP_DATAGRAM_MARKED 20010 190 #define SCTP_FORWARD_TSN_SKIP 30010 191 192 /* SCTP chunk types */ 193 /* Moved to sctp.h so f/w and natd 194 * boxes can find the chunk types. 195 */ 196 197 /* align to 32-bit sizes */ 198 #define SCTP_SIZE32(x) ((((x)+3) >> 2) << 2) 199 200 #define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA) 201 #define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA) 202 203 /* SCTP parameter types */ 204 #define SCTP_HEARTBEAT_INFO 0x0001 205 #define SCTP_IPV4_ADDRESS 0x0005 206 #define SCTP_IPV6_ADDRESS 0x0006 207 #define SCTP_STATE_COOKIE 0x0007 208 #define SCTP_UNRECOG_PARAM 0x0008 209 #define SCTP_COOKIE_PRESERVE 0x0009 210 #define SCTP_HOSTNAME_ADDRESS 0x000b 211 #define SCTP_SUPPORTED_ADDRTYPE 0x000c 212 #define SCTP_ECN_CAPABLE 0x8000 213 /* draft-ietf-stewart-strreset-xxx */ 214 #define SCTP_STR_RESET_REQUEST 0x000d 215 #define SCTP_STR_RESET_RESPONSE 0x000e 216 217 /* ECN Nonce: draft-ladha-sctp-ecn-nonce */ 218 #define SCTP_ECN_NONCE_SUPPORTED 0x8001 219 /* 220 * draft-ietf-stewart-strreset-xxx 221 * param=0x8001 len=0xNNNN 222 * Byte | Byte | Byte | Byte 223 * Byte | Byte ... 224 * 225 * Where each Byte is a chunk type 226 * extension supported so for example 227 * to support all chunks one would have (in hex): 228 * 229 * 80 01 00 09 230 * C0 C1 80 81 231 * 82 00 00 00 232 * 233 * Has the parameter. 234 * C0 = PR-SCTP (RFC3758) 235 * C1, 80 = ASCONF (addip draft) 236 * 81 = Packet Drop 237 * 82 = Stream Reset 238 */ 239 240 /* draft-ietf-tsvwg-prsctp */ 241 #define SCTP_SUPPORTED_CHUNK_EXT 0x8008 242 243 /* number of extensions we support */ 244 #define SCTP_EXT_COUNT 5 /* num of extensions we support chunk wise */ 245 #define SCTP_PAD_EXT_COUNT 3 /* num of pad bytes needed to get to 32 bit boundary */ 246 247 248 #define SCTP_PRSCTP_SUPPORTED 0xc000 249 /* draft-ietf-tsvwg-addip-sctp */ 250 #define SCTP_ADD_IP_ADDRESS 0xc001 251 #define SCTP_DEL_IP_ADDRESS 0xc002 252 #define SCTP_ERROR_CAUSE_IND 0xc003 253 #define SCTP_SET_PRIM_ADDR 0xc004 254 #define SCTP_SUCCESS_REPORT 0xc005 255 #define SCTP_ULP_ADAPTION 0xc006 256 257 /* Notification error codes */ 258 #define SCTP_NOTIFY_DATAGRAM_UNSENT 0x0001 259 #define SCTP_NOTIFY_DATAGRAM_SENT 0x0002 260 #define SCTP_FAILED_THRESHOLD 0x0004 261 #define SCTP_HEARTBEAT_SUCCESS 0x0008 262 #define SCTP_RESPONSE_TO_USER_REQ 0x000f 263 #define SCTP_INTERNAL_ERROR 0x0010 264 #define SCTP_SHUTDOWN_GUARD_EXPIRES 0x0020 265 #define SCTP_RECEIVED_SACK 0x0040 266 #define SCTP_PEER_FAULTY 0x0080 267 268 /* Error causes used in SCTP op-err's and aborts */ 269 #define SCTP_CAUSE_INV_STRM 0x001 270 #define SCTP_CAUSE_MISS_PARAM 0x002 271 #define SCTP_CAUSE_STALE_COOKIE 0x003 272 #define SCTP_CAUSE_OUT_OF_RESC 0x004 273 #define SCTP_CAUSE_UNRESOLV_ADDR 0x005 274 #define SCTP_CAUSE_UNRECOG_CHUNK 0x006 275 #define SCTP_CAUSE_INVALID_PARAM 0x007 276 /* This one is also the same as SCTP_UNRECOG_PARAM above */ 277 #define SCTP_CAUSE_UNRECOG_PARAM 0x008 278 #define SCTP_CAUSE_NOUSER_DATA 0x009 279 #define SCTP_CAUSE_COOKIE_IN_SHUTDOWN 0x00a 280 #define SCTP_CAUSE_RESTART_W_NEWADDR 0x00b 281 #define SCTP_CAUSE_USER_INITIATED_ABT 0x00c 282 #define SCTP_CAUSE_PROTOCOL_VIOLATION 0x00d 283 284 /* Error's from add ip */ 285 #define SCTP_CAUSE_DELETEING_LAST_ADDR 0x100 286 #define SCTP_CAUSE_OPERATION_REFUSED 0x101 287 #define SCTP_CAUSE_DELETING_SRC_ADDR 0x102 288 #define SCTP_CAUSE_ILLEGAL_ASCONF 0x103 289 290 /* bits for TOS field */ 291 #define SCTP_ECT0_BIT 0x02 292 #define SCTP_ECT1_BIT 0x01 293 #define SCTP_CE_BITS 0x03 294 295 /* below turns off above */ 296 #define SCTP_FLEXIBLE_ADDRESS 0x20 297 #define SCTP_NO_HEARTBEAT 0x40 298 299 /* mask to get sticky */ 300 #define SCTP_STICKY_OPTIONS_MASK 0x0c 301 302 /* MTU discovery flags */ 303 #define SCTP_DONT_FRAGMENT 0x0100 304 #define SCTP_FRAGMENT_OK 0x0200 305 #define SCTP_PR_SCTP_ENABLED 0x0400 306 #define SCTP_PR_SCTP_BUFFER 0x0800 307 308 /* Chunk flags */ 309 #define SCTP_WINDOW_PROBE 0x01 310 311 /* 312 * SCTP states for internal state machine 313 * XXX (should match "user" values) 314 */ 315 #define SCTP_STATE_EMPTY 0x0000 316 #define SCTP_STATE_INUSE 0x0001 317 #define SCTP_STATE_COOKIE_WAIT 0x0002 318 #define SCTP_STATE_COOKIE_ECHOED 0x0004 319 #define SCTP_STATE_OPEN 0x0008 320 #define SCTP_STATE_SHUTDOWN_SENT 0x0010 321 #define SCTP_STATE_SHUTDOWN_RECEIVED 0x0020 322 #define SCTP_STATE_SHUTDOWN_ACK_SENT 0x0040 323 #define SCTP_STATE_SHUTDOWN_PENDING 0x0080 324 #define SCTP_STATE_CLOSED_SOCKET 0x0100 325 #define SCTP_STATE_MASK 0x007f 326 327 #define SCTP_GET_STATE(asoc) ((asoc)->state & SCTP_STATE_MASK) 328 329 /* SCTP reachability state for each address */ 330 #define SCTP_ADDR_REACHABLE 0x001 331 #define SCTP_ADDR_NOT_REACHABLE 0x002 332 #define SCTP_ADDR_NOHB 0x004 333 #define SCTP_ADDR_BEING_DELETED 0x008 334 #define SCTP_ADDR_NOT_IN_ASSOC 0x010 335 #define SCTP_ADDR_WAS_PRIMARY 0x020 336 #define SCTP_ADDR_SWITCH_PRIMARY 0x040 337 #define SCTP_ADDR_OUT_OF_SCOPE 0x080 338 #define SCTP_ADDR_DOUBLE_SWITCH 0x100 339 #define SCTP_ADDR_UNCONFIRMED 0x200 340 341 #define SCTP_REACHABLE_MASK 0x203 342 343 /* bound address types (e.g. valid address types to allow) */ 344 #define SCTP_BOUND_V6 0x01 345 #define SCTP_BOUND_V4 0x02 346 347 /* How long a cookie lives in seconds */ 348 #define SCTP_DEFAULT_COOKIE_LIFE 60 349 350 /* resource limit of streams */ 351 #define MAX_SCTP_STREAMS 2048 352 353 /* Maximum the mapping array will grow to (TSN mapping array) */ 354 #define SCTP_MAPPING_ARRAY 512 355 356 /* size of the initial malloc on the mapping array */ 357 #define SCTP_INITIAL_MAPPING_ARRAY 16 358 /* how much we grow the mapping array each call */ 359 #define SCTP_MAPPING_ARRAY_INCR 32 360 361 /* 362 * Here we define the timer types used by the implementation 363 * as arguments in the set/get timer type calls. 364 */ 365 #define SCTP_TIMER_INIT 0 366 #define SCTP_TIMER_RECV 1 367 #define SCTP_TIMER_SEND 2 368 #define SCTP_TIMER_HEARTBEAT 3 369 #define SCTP_TIMER_PMTU 4 370 #define SCTP_TIMER_MAXSHUTDOWN 5 371 #define SCTP_TIMER_SIGNATURE 6 372 /* 373 * number of timer types in the base SCTP structure used in 374 * the set/get and has the base default. 375 */ 376 #define SCTP_NUM_TMRS 7 377 378 /* timer types */ 379 #define SCTP_TIMER_TYPE_NONE 0 380 #define SCTP_TIMER_TYPE_SEND 1 381 #define SCTP_TIMER_TYPE_INIT 2 382 #define SCTP_TIMER_TYPE_RECV 3 383 #define SCTP_TIMER_TYPE_SHUTDOWN 4 384 #define SCTP_TIMER_TYPE_HEARTBEAT 5 385 #define SCTP_TIMER_TYPE_COOKIE 6 386 #define SCTP_TIMER_TYPE_NEWCOOKIE 7 387 #define SCTP_TIMER_TYPE_PATHMTURAISE 8 388 #define SCTP_TIMER_TYPE_SHUTDOWNACK 9 389 #define SCTP_TIMER_TYPE_ASCONF 10 390 #define SCTP_TIMER_TYPE_SHUTDOWNGUARD 11 391 #define SCTP_TIMER_TYPE_AUTOCLOSE 12 392 #define SCTP_TIMER_TYPE_EVENTWAKE 13 393 #define SCTP_TIMER_TYPE_STRRESET 14 394 #define SCTP_TIMER_TYPE_INPKILL 15 395 396 /* 397 * Number of ticks before the soxwakeup() event that 398 * is delayed is sent AFTER the accept() call 399 */ 400 #define SCTP_EVENTWAKEUP_WAIT_TICKS 3000 401 402 /* 403 * Of course we really don't collect stale cookies, being folks 404 * of decerning taste. However we do count them, if we get too 405 * many before the association comes up.. we give up. Below is 406 * the constant that dictates when we give it up...this is a 407 * implementation dependent treatment. In ours we do not ask for 408 * a extension of time, but just retry this many times... 409 */ 410 #define SCTP_MAX_STALE_COOKIES_I_COLLECT 10 411 412 /* max number of TSN's dup'd that I will hold */ 413 #define SCTP_MAX_DUP_TSNS 20 414 415 #define SCTP_TIMER_TYPE_ITERATOR 16 416 /* 417 * Here we define the types used when setting the retry amounts. 418 */ 419 /* constants for type of set */ 420 #define SCTP_MAXATTEMPT_INIT 2 421 #define SCTP_MAXATTEMPT_SEND 3 422 423 /* Maximum TSN's we will summarize in a drop report */ 424 425 #define SCTP_MAX_DROP_REPORT 16 426 427 /* How many drop re-attempts we make on INIT/COOKIE-ECHO */ 428 #define SCTP_RETRY_DROPPED_THRESH 4 429 430 /* And the max we will keep a history of in the tcb 431 * which MUST be lower than 256. 432 */ 433 434 #define SCTP_MAX_DROP_SAVE_REPORT 16 435 436 /* 437 * Here we define the default timers and the default number 438 * of attemts we make for each respective side (send/init). 439 */ 440 441 /* Maxmium number of chunks a single association can have 442 * on it. Note that this is a squishy number since 443 * the count can run over this if the user sends a large 444 * message down .. the fragmented chunks don't count until 445 * AFTER the message is on queue.. it would be the next 446 * send that blocks things. This number will get tuned 447 * up at boot in the sctp_init and use the number 448 * of clusters as a base. This way high bandwidth 449 * environments will not get impacted by the lower 450 * bandwidth sending a bunch of 1 byte chunks 451 */ 452 #define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512 453 454 #define MSEC_TO_TICKS(x) (((x) * hz) / 1000) 455 #define TICKS_TO_MSEC(x) (((x) * 1000) / hz) 456 #define SEC_TO_TICKS(x) ((x) * hz) 457 458 /* init timer def = 1 sec */ 459 #define SCTP_INIT_SEC 1 460 461 /* send timer def = 1 seconds */ 462 #define SCTP_SEND_SEC 1 463 464 /* recv timer def = 200ms */ 465 #define SCTP_RECV_MSEC 200 466 467 /* 30 seconds + RTO (in ms) */ 468 #define SCTP_HB_DEFAULT_MSEC 30000 469 470 /* Max time I will wait for Shutdown to complete */ 471 #define SCTP_DEF_MAX_SHUTDOWN_SEC 180 472 473 474 /* This is how long a secret lives, NOT how long a cookie lives 475 * how many ticks the current secret will live. 476 */ 477 #define SCTP_DEFAULT_SECRET_LIFE_SEC 3600 478 479 #define SCTP_RTO_UPPER_BOUND (60000) /* 60 sec in ms */ 480 #define SCTP_RTO_UPPER_BOUND_SEC 60 /* for the init timer */ 481 #define SCTP_RTO_LOWER_BOUND (1000) /* 1 sec in ms */ 482 #define SCTP_RTO_INITIAL (3000) /* 3 sec in ms */ 483 484 485 #define SCTP_INP_KILL_TIMEOUT 1000 /* number of ms to retry kill of inpcb*/ 486 487 #define SCTP_DEF_MAX_INIT 8 488 #define SCTP_DEF_MAX_SEND 10 489 490 #define SCTP_DEF_PMTU_RAISE_SEC 600 /* 10 min between raise attempts */ 491 #define SCTP_DEF_PMTU_MIN 600 492 493 #define SCTP_MSEC_IN_A_SEC 1000 494 #define SCTP_USEC_IN_A_SEC 1000000 495 #define SCTP_NSEC_IN_A_SEC 1000000000 496 497 #define SCTP_MAX_OUTSTANDING_DG 10000 498 499 /* How many streams I request initally by default */ 500 #define SCTP_OSTREAM_INITIAL 10 501 502 #define SCTP_SEG_TO_RWND_UPD 32 /* How many smallest_mtu's need to increase before 503 * a window update sack is sent (should be a 504 * power of 2). 505 */ 506 #define SCTP_SCALE_OF_RWND_TO_UPD 4 /* Incr * this > hiwat, send 507 * window update. Should be a 508 * power of 2. 509 */ 510 #define SCTP_MINIMAL_RWND (4096) /* minimal rwnd */ 511 512 #define SCTP_ADDRMAX 20 513 514 515 /* SCTP DEBUG Switch parameters */ 516 #define SCTP_DEBUG_TIMER1 0x00000001 517 #define SCTP_DEBUG_TIMER2 0x00000002 518 #define SCTP_DEBUG_TIMER3 0x00000004 519 #define SCTP_DEBUG_TIMER4 0x00000008 520 #define SCTP_DEBUG_OUTPUT1 0x00000010 521 #define SCTP_DEBUG_OUTPUT2 0x00000020 522 #define SCTP_DEBUG_OUTPUT3 0x00000040 523 #define SCTP_DEBUG_OUTPUT4 0x00000080 524 #define SCTP_DEBUG_UTIL1 0x00000100 525 #define SCTP_DEBUG_UTIL2 0x00000200 526 #define SCTP_DEBUG_INPUT1 0x00001000 527 #define SCTP_DEBUG_INPUT2 0x00002000 528 #define SCTP_DEBUG_INPUT3 0x00004000 529 #define SCTP_DEBUG_INPUT4 0x00008000 530 #define SCTP_DEBUG_ASCONF1 0x00010000 531 #define SCTP_DEBUG_ASCONF2 0x00020000 532 #define SCTP_DEBUG_OUTPUT5 0x00040000 533 #define SCTP_DEBUG_PCB1 0x00100000 534 #define SCTP_DEBUG_PCB2 0x00200000 535 #define SCTP_DEBUG_PCB3 0x00400000 536 #define SCTP_DEBUG_PCB4 0x00800000 537 #define SCTP_DEBUG_INDATA1 0x01000000 538 #define SCTP_DEBUG_INDATA2 0x02000000 539 #define SCTP_DEBUG_INDATA3 0x04000000 540 #define SCTP_DEBUG_INDATA4 0x08000000 541 #define SCTP_DEBUG_USRREQ1 0x10000000 542 #define SCTP_DEBUG_USRREQ2 0x20000000 543 #define SCTP_DEBUG_PEEL1 0x40000000 544 #define SCTP_DEBUG_ALL 0x7ff3f3ff 545 #define SCTP_DEBUG_NOISY 0x00040000 546 547 /* What sender needs to see to avoid SWS or we consider peers rwnd 0 */ 548 #define SCTP_SWS_SENDER_DEF 1420 549 550 /* 551 * SWS is scaled to the sb_hiwat of the socket. 552 * A value of 2 is hiwat/4, 1 would be hiwat/2 etc. 553 */ 554 /* What receiver needs to see in sockbuf or we tell peer its 1 */ 555 #define SCTP_SWS_RECEIVER_DEF 3000 556 557 558 #define SCTP_INITIAL_CWND 4380 559 560 /* amount peer is obligated to have in rwnd or I will abort */ 561 #define SCTP_MIN_RWND 1500 562 563 #define SCTP_WINDOW_MIN 1500 /* smallest rwnd can be */ 564 #define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to 565 * My playing around suggests a 566 * value greater than 64k does not 567 * do much, I guess via the kernel 568 * limitations on the stream/socket. 569 */ 570 571 #define SCTP_MAX_BUNDLE_UP 256 /* max number of chunks to bundle */ 572 573 /* I can handle a 1meg re-assembly */ 574 #define SCTP_DEFAULT_MAXMSGREASM 1048576 575 576 #define SCTP_DEFAULT_MAXSEGMENT 65535 577 578 #define DEFAULT_CHUNK_BUFFER 2048 579 #define DEFAULT_PARAM_BUFFER 512 580 581 #define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ 582 #define SCTP_HOW_MANY_SECRETS 2 /* how many secrets I keep */ 583 584 #define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */ 585 #define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */ 586 587 #ifdef USE_MD5 588 #define SCTP_SIGNATURE_SIZE 16 /* size of a MD5 signature */ 589 #else 590 #define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ 591 #endif /* USE_MD5 */ 592 593 #define SCTP_SIGNATURE_ALOC_SIZE 20 594 595 /* 596 * SCTP upper layer notifications 597 */ 598 #define SCTP_NOTIFY_ASSOC_UP 1 599 #define SCTP_NOTIFY_ASSOC_DOWN 2 600 #define SCTP_NOTIFY_INTERFACE_DOWN 3 601 #define SCTP_NOTIFY_INTERFACE_UP 4 602 #define SCTP_NOTIFY_DG_FAIL 5 603 #define SCTP_NOTIFY_STRDATA_ERR 6 604 #define SCTP_NOTIFY_ASSOC_ABORTED 7 605 #define SCTP_NOTIFY_PEER_OPENED_STREAM 8 606 #define SCTP_NOTIFY_STREAM_OPENED_OK 9 607 #define SCTP_NOTIFY_ASSOC_RESTART 10 608 #define SCTP_NOTIFY_HB_RESP 11 609 #define SCTP_NOTIFY_ASCONF_SUCCESS 12 610 #define SCTP_NOTIFY_ASCONF_FAILED 13 611 #define SCTP_NOTIFY_PEER_SHUTDOWN 14 612 #define SCTP_NOTIFY_ASCONF_ADD_IP 15 613 #define SCTP_NOTIFY_ASCONF_DELETE_IP 16 614 #define SCTP_NOTIFY_ASCONF_SET_PRIMARY 17 615 #define SCTP_NOTIFY_PARTIAL_DELVIERY_INDICATION 18 616 #define SCTP_NOTIFY_ADAPTION_INDICATION 19 617 #define SCTP_NOTIFY_INTERFACE_CONFIRMED 20 618 #define SCTP_NOTIFY_STR_RESET_RECV 21 619 #define SCTP_NOTIFY_STR_RESET_SEND 22 620 #define SCTP_NOTIFY_MAX 22 621 622 623 624 625 626 /* clock variance is 10ms */ 627 #define SCTP_CLOCK_GRANULARITY 10 628 629 #define IP_HDR_SIZE 40 /* we use the size of a IP6 header here 630 * this detracts a small amount for ipv4 631 * but it simplifies the ipv6 addition 632 */ 633 634 #ifndef IPPROTO_SCTP 635 #define IPPROTO_SCTP 132 /* the Official IANA number :-) */ 636 #endif /* !IPPROTO_SCTP */ 637 638 #define SCTP_MAX_DATA_BUNDLING 256 639 #define SCTP_MAX_CONTROL_BUNDLING 20 640 641 /* modular comparison */ 642 /* True if a > b (mod = M) */ 643 #define compare_with_wrap(a, b, M) (((a > b) && ((a - b) < ((M >> 1) + 1))) || \ 644 ((b > a) && ((b - a) > ((M >> 1) + 1)))) 645 646 647 /* Mapping array manipulation routines */ 648 #define SCTP_IS_TSN_PRESENT(arry, gap) ((arry[(gap >> 3)] >> (gap & 0x07)) & 0x01) 649 #define SCTP_SET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] |= (0x01 << ((gap & 0x07)))) 650 #define SCTP_UNSET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] &= ((~(0x01 << ((gap & 0x07)))) & 0xff)) 651 652 /* pegs */ 653 #define SCTP_NUMBER_OF_PEGS 96 654 /* peg index's */ 655 #define SCTP_PEG_SACKS_SEEN 0 656 #define SCTP_PEG_SACKS_SENT 1 657 #define SCTP_PEG_TSNS_SENT 2 658 #define SCTP_PEG_TSNS_RCVD 3 659 #define SCTP_DATAGRAMS_SENT 4 660 #define SCTP_DATAGRAMS_RCVD 5 661 #define SCTP_RETRANTSN_SENT 6 662 #define SCTP_DUPTSN_RECVD 7 663 #define SCTP_HB_RECV 8 664 #define SCTP_HB_ACK_RECV 9 665 #define SCTP_HB_SENT 10 666 #define SCTP_WINDOW_PROBES 11 667 #define SCTP_DATA_DG_RECV 12 668 #define SCTP_TMIT_TIMER 13 669 #define SCTP_RECV_TIMER 14 670 #define SCTP_HB_TIMER 15 671 #define SCTP_FAST_RETRAN 16 672 #define SCTP_TIMERS_EXP 17 673 #define SCTP_FR_INAWINDOW 18 674 #define SCTP_RWND_BLOCKED 19 675 #define SCTP_CWND_BLOCKED 20 676 #define SCTP_RWND_DROPS 21 677 #define SCTP_BAD_STRMNO 22 678 #define SCTP_BAD_SSN_WRAP 23 679 #define SCTP_DROP_NOMEMORY 24 680 #define SCTP_DROP_FRAG 25 681 #define SCTP_BAD_VTAGS 26 682 #define SCTP_BAD_CSUM 27 683 #define SCTP_INPKTS 28 684 #define SCTP_IN_MCAST 29 685 #define SCTP_HDR_DROPS 30 686 #define SCTP_NOPORTS 31 687 #define SCTP_CWND_NOFILL 32 688 #define SCTP_CALLS_TO_CO 33 689 #define SCTP_CO_NODATASNT 34 690 #define SCTP_CWND_NOUSE_SS 35 691 #define SCTP_MAX_BURST_APL 36 692 #define SCTP_EXPRESS_ROUTE 37 693 #define SCTP_NO_COPY_IN 38 694 #define SCTP_CACHED_SRC 39 695 #define SCTP_CWND_NOCUM 40 696 #define SCTP_CWND_SS 41 697 #define SCTP_CWND_CA 42 698 #define SCTP_CWND_SKIP 43 699 #define SCTP_CWND_NOUSE_CA 44 700 #define SCTP_MAX_CWND 45 701 #define SCTP_CWND_DIFF_CA 46 702 #define SCTP_CWND_DIFF_SA 47 703 #define SCTP_OQS_AT_SS 48 704 #define SCTP_SQQ_AT_SS 49 705 #define SCTP_OQS_AT_CA 50 706 #define SCTP_SQQ_AT_CA 51 707 #define SCTP_MOVED_MTU 52 708 #define SCTP_MOVED_QMAX 53 709 #define SCTP_SQC_AT_SS 54 710 #define SCTP_SQC_AT_CA 55 711 #define SCTP_MOVED_MAX 56 712 #define SCTP_MOVED_NLEF 57 713 #define SCTP_NAGLE_NOQ 58 714 #define SCTP_NAGLE_OFF 59 715 #define SCTP_OUTPUT_FRM_SND 60 716 #define SCTP_SOS_NOSNT 61 717 #define SCTP_NOS_NOSNT 62 718 #define SCTP_SOSE_NOSNT 63 719 #define SCTP_NOSE_NOSNT 64 720 #define SCTP_DATA_OUT_ERR 65 721 #define SCTP_DUP_SSN_RCVD 66 722 #define SCTP_DUP_FR 67 723 #define SCTP_VTAG_EXPR 68 724 #define SCTP_VTAG_BOGUS 69 725 #define SCTP_T3_SAFEGRD 70 726 #define SCTP_PDRP_FMBOX 71 727 #define SCTP_PDRP_FEHOS 72 728 #define SCTP_PDRP_MB_DA 73 729 #define SCTP_PDRP_MB_CT 74 730 #define SCTP_PDRP_BWRPT 75 731 #define SCTP_PDRP_CRUPT 76 732 #define SCTP_PDRP_NEDAT 77 733 #define SCTP_PDRP_PDBRK 78 734 #define SCTP_PDRP_TSNNF 79 735 #define SCTP_PDRP_DNFND 80 736 #define SCTP_PDRP_DIWNP 81 737 #define SCTP_PDRP_DIZRW 82 738 #define SCTP_PDRP_BADD 83 739 #define SCTP_PDRP_MARK 84 740 #define SCTP_ECNE_RCVD 85 741 #define SCTP_CWR_PERFO 86 742 #define SCTP_ECNE_SENT 87 743 #define SCTP_MSGC_DROP 88 744 #define SCTP_SEND_QUEUE_POP 89 745 #define SCTP_ERROUT_FRM_USR 90 746 #define SCTP_SENDTO_FULL_CWND 91 747 #define SCTP_QUEONLY_BURSTLMT 92 748 #define SCTP_IFP_QUEUE_FULL 93 749 #define SCTP_RESV2 94 750 #define SCTP_RESV3 95 751 752 /* 753 * This value defines the number of vtag block time wait entry's 754 * per list element. Each entry will take 2 4 byte ints (and of 755 * course the overhead of the next pointer as well). Using 15 as 756 * an example will yield * ((8 * 15) + 8) or 128 bytes of overhead 757 * for each timewait block that gets initialized. Increasing it to 758 * 31 would yield 256 bytes per block. 759 */ 760 /* Undef the following turns on per EP behavior */ 761 #define SCTP_VTAG_TIMEWAIT_PER_STACK 1 762 #ifdef SCTP_VTAG_TIMEWAIT_PER_STACK 763 #define SCTP_NUMBER_IN_VTAG_BLOCK 15 764 #else 765 /* The hash list is smaller if we are on a ep basis */ 766 #define SCTP_NUMBER_IN_VTAG_BLOCK 3 767 #endif 768 /* 769 * If we use the STACK option, we have an array of this size head 770 * pointers. This array is mod'd the with the size to find which 771 * bucket and then all entries must be searched to see if the tag 772 * is in timed wait. If so we reject it. 773 */ 774 #define SCTP_STACK_VTAG_HASH_SIZE 31 775 776 /* 777 * If we use the per-endpoint model than we do not have a hash 778 * table of entries but instead have a single head pointer and 779 * we must crawl through the entire list. 780 */ 781 782 /* 783 * Number of seconds of time wait, tied to MSL value (2 minutes), 784 * so 2 * MSL = 4 minutes or 480 seconds. 785 */ 786 #define SCTP_TIME_WAIT 480 787 788 #define IN4_ISPRIVATE_ADDRESS(a) \ 789 ((((const u_char *)&(a)->s_addr)[0] == 10) || \ 790 ((((const u_char *)&(a)->s_addr)[0] == 172) && \ 791 (((const u_char *)&(a)->s_addr)[1] >= 16) && \ 792 (((const u_char *)&(a)->s_addr)[1] <= 32)) || \ 793 ((((const u_char *)&(a)->s_addr)[0] == 192) && \ 794 (((const u_char *)&(a)->s_addr)[1] == 168))) 795 796 #define IN4_ISLOOPBACK_ADDRESS(a) \ 797 ((((const u_char *)&(a)->s_addr)[0] == 127) && \ 798 (((const u_char *)&(a)->s_addr)[1] == 0) && \ 799 (((const u_char *)&(a)->s_addr)[2] == 0) && \ 800 (((const u_char *)&(a)->s_addr)[3] == 1)) 801 802 803 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL)) 804 805 #if defined(__FreeBSD__) || defined(__APPLE__) 806 #define SCTP_GETTIME_TIMEVAL(x) (microuptime(x)) 807 #define SCTP_GETTIME_TIMESPEC(x) (nanouptime(x)) 808 #else 809 #define SCTP_GETTIME_TIMEVAL(x) (microtime(x)) 810 #define SCTP_GETTIME_TIMESPEC(x) (nanotime(x)) 811 #endif /* __FreeBSD__ */ 812 813 #define sctp_sowwakeup(inp, so) \ 814 do { \ 815 if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ 816 inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \ 817 } else { \ 818 sowwakeup(so); \ 819 } \ 820 } while (0) 821 822 #define sctp_sorwakeup(inp, so) \ 823 do { \ 824 if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ 825 inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \ 826 } else { \ 827 sorwakeup(so); \ 828 } \ 829 } while (0) 830 831 #endif /* _KERNEL */ 832 #endif 833