11da177e4SLinus Torvalds /* SCTP kernel reference Implementation 21da177e4SLinus Torvalds * (C) Copyright IBM Corp. 2001, 2004 31da177e4SLinus Torvalds * Copyright (c) 1999-2000 Cisco, Inc. 41da177e4SLinus Torvalds * Copyright (c) 1999-2001 Motorola, Inc. 51da177e4SLinus Torvalds * Copyright (c) 2001 Intel Corp. 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * This file is part of the SCTP kernel reference Implementation 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * The SCTP reference implementation is free software; 101da177e4SLinus Torvalds * you can redistribute it and/or modify it under the terms of 111da177e4SLinus Torvalds * the GNU General Public License as published by 121da177e4SLinus Torvalds * the Free Software Foundation; either version 2, or (at your option) 131da177e4SLinus Torvalds * any later version. 141da177e4SLinus Torvalds * 151da177e4SLinus Torvalds * The SCTP reference implementation is distributed in the hope that it 161da177e4SLinus Torvalds * will be useful, but WITHOUT ANY WARRANTY; without even the implied 171da177e4SLinus Torvalds * ************************ 181da177e4SLinus Torvalds * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 191da177e4SLinus Torvalds * See the GNU General Public License for more details. 201da177e4SLinus Torvalds * 211da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 221da177e4SLinus Torvalds * along with GNU CC; see the file COPYING. If not, write to 231da177e4SLinus Torvalds * the Free Software Foundation, 59 Temple Place - Suite 330, 241da177e4SLinus Torvalds * Boston, MA 02111-1307, USA. 251da177e4SLinus Torvalds * 261da177e4SLinus Torvalds * Please send any bug reports or fixes you make to the 271da177e4SLinus Torvalds * email address(es): 281da177e4SLinus Torvalds * lksctp developers <lksctp-developers@lists.sourceforge.net> 291da177e4SLinus Torvalds * 301da177e4SLinus Torvalds * Or submit a bug report through the following website: 311da177e4SLinus Torvalds * http://www.sf.net/projects/lksctp 321da177e4SLinus Torvalds * 331da177e4SLinus Torvalds * Written or modified by: 341da177e4SLinus Torvalds * La Monte H.P. Yarroll <piggy@acm.org> 351da177e4SLinus Torvalds * Karl Knutson <karl@athena.chicago.il.us> 361da177e4SLinus Torvalds * Randall Stewart <randall@stewart.chicago.il.us> 371da177e4SLinus Torvalds * Ken Morneau <kmorneau@cisco.com> 381da177e4SLinus Torvalds * Qiaobing Xie <qxie1@motorola.com> 391da177e4SLinus Torvalds * Xingang Guo <xingang.guo@intel.com> 401da177e4SLinus Torvalds * Sridhar Samudrala <samudrala@us.ibm.com> 411da177e4SLinus Torvalds * Daisy Chang <daisyc@us.ibm.com> 421da177e4SLinus Torvalds * 431da177e4SLinus Torvalds * Any bugs reported given to us we will try to fix... any fixes shared will 441da177e4SLinus Torvalds * be incorporated into the next SCTP release. 451da177e4SLinus Torvalds */ 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds #ifndef __sctp_constants_h__ 481da177e4SLinus Torvalds #define __sctp_constants_h__ 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds #include <linux/sctp.h> 511da177e4SLinus Torvalds #include <linux/ipv6.h> /* For ipv6hdr. */ 521da177e4SLinus Torvalds #include <net/sctp/user.h> 53c752f073SArnaldo Carvalho de Melo #include <net/tcp_states.h> /* For TCP states used in sctp_sock_state_t */ 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds /* Value used for stream negotiation. */ 561da177e4SLinus Torvalds enum { SCTP_MAX_STREAM = 0xffff }; 571da177e4SLinus Torvalds enum { SCTP_DEFAULT_OUTSTREAMS = 10 }; 581da177e4SLinus Torvalds enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM }; 591da177e4SLinus Torvalds 601da177e4SLinus Torvalds /* Since CIDs are sparse, we need all four of the following 611da177e4SLinus Torvalds * symbols. CIDs are dense through SCTP_CID_BASE_MAX. 621da177e4SLinus Torvalds */ 631da177e4SLinus Torvalds #define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE 641da177e4SLinus Torvalds #define SCTP_CID_MAX SCTP_CID_ASCONF_ACK 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds #define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) 671da177e4SLinus Torvalds #define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNKTYPES + 2) 681da177e4SLinus Torvalds 691da177e4SLinus Torvalds #define SCTP_NUM_ADDIP_CHUNK_TYPES 2 701da177e4SLinus Torvalds 711da177e4SLinus Torvalds #define SCTP_NUM_PRSCTP_CHUNK_TYPES 1 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds /* These are the different flavours of event. */ 741da177e4SLinus Torvalds typedef enum { 751da177e4SLinus Torvalds 761da177e4SLinus Torvalds SCTP_EVENT_T_CHUNK = 1, 771da177e4SLinus Torvalds SCTP_EVENT_T_TIMEOUT, 781da177e4SLinus Torvalds SCTP_EVENT_T_OTHER, 791da177e4SLinus Torvalds SCTP_EVENT_T_PRIMITIVE 801da177e4SLinus Torvalds 811da177e4SLinus Torvalds } sctp_event_t; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds #define SCTP_EVENT_T_MAX SCTP_EVENT_T_PRIMITIVE 841da177e4SLinus Torvalds #define SCTP_EVENT_T_NUM (SCTP_EVENT_T_MAX + 1) 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds /* As a convenience for the state machine, we append SCTP_EVENT_* and 871da177e4SLinus Torvalds * SCTP_ULP_* to the list of possible chunks. 881da177e4SLinus Torvalds */ 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds typedef enum { 911da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_NONE = 0, 921da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T1_COOKIE, 931da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T1_INIT, 941da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T2_SHUTDOWN, 951da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T3_RTX, 961da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T4_RTO, 971da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD, 981da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_HEARTBEAT, 991da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_SACK, 1001da177e4SLinus Torvalds SCTP_EVENT_TIMEOUT_AUTOCLOSE, 1011da177e4SLinus Torvalds } sctp_event_timeout_t; 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds #define SCTP_EVENT_TIMEOUT_MAX SCTP_EVENT_TIMEOUT_AUTOCLOSE 1041da177e4SLinus Torvalds #define SCTP_NUM_TIMEOUT_TYPES (SCTP_EVENT_TIMEOUT_MAX + 1) 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds typedef enum { 1071da177e4SLinus Torvalds SCTP_EVENT_NO_PENDING_TSN = 0, 1081da177e4SLinus Torvalds SCTP_EVENT_ICMP_PROTO_UNREACH, 1091da177e4SLinus Torvalds } sctp_event_other_t; 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds #define SCTP_EVENT_OTHER_MAX SCTP_EVENT_ICMP_PROTO_UNREACH 1121da177e4SLinus Torvalds #define SCTP_NUM_OTHER_TYPES (SCTP_EVENT_OTHER_MAX + 1) 1131da177e4SLinus Torvalds 1141da177e4SLinus Torvalds /* These are primitive requests from the ULP. */ 1151da177e4SLinus Torvalds typedef enum { 1161da177e4SLinus Torvalds SCTP_PRIMITIVE_ASSOCIATE = 0, 1171da177e4SLinus Torvalds SCTP_PRIMITIVE_SHUTDOWN, 1181da177e4SLinus Torvalds SCTP_PRIMITIVE_ABORT, 1191da177e4SLinus Torvalds SCTP_PRIMITIVE_SEND, 1201da177e4SLinus Torvalds SCTP_PRIMITIVE_REQUESTHEARTBEAT, 1211da177e4SLinus Torvalds SCTP_PRIMITIVE_ASCONF, 1221da177e4SLinus Torvalds } sctp_event_primitive_t; 1231da177e4SLinus Torvalds 1241da177e4SLinus Torvalds #define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_ASCONF 1251da177e4SLinus Torvalds #define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1) 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds /* We define here a utility type for manipulating subtypes. 1281da177e4SLinus Torvalds * The subtype constructors all work like this: 1291da177e4SLinus Torvalds * 1301da177e4SLinus Torvalds * sctp_subtype_t foo = SCTP_ST_CHUNK(SCTP_CID_INIT); 1311da177e4SLinus Torvalds */ 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds typedef union { 1341da177e4SLinus Torvalds sctp_cid_t chunk; 1351da177e4SLinus Torvalds sctp_event_timeout_t timeout; 1361da177e4SLinus Torvalds sctp_event_other_t other; 1371da177e4SLinus Torvalds sctp_event_primitive_t primitive; 1381da177e4SLinus Torvalds } sctp_subtype_t; 1391da177e4SLinus Torvalds 1401da177e4SLinus Torvalds #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ 1411da177e4SLinus Torvalds static inline sctp_subtype_t \ 1421da177e4SLinus Torvalds SCTP_ST_## _name (_type _arg) \ 1431da177e4SLinus Torvalds { sctp_subtype_t _retval; _retval._elt = _arg; return _retval; } 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, sctp_cid_t, chunk) 1461da177e4SLinus Torvalds SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, sctp_event_timeout_t, timeout) 1471da177e4SLinus Torvalds SCTP_SUBTYPE_CONSTRUCTOR(OTHER, sctp_event_other_t, other) 1481da177e4SLinus Torvalds SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive) 1491da177e4SLinus Torvalds 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds #define sctp_chunk_is_control(a) (a->chunk_hdr->type != SCTP_CID_DATA) 1521da177e4SLinus Torvalds #define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA) 1531da177e4SLinus Torvalds 1541da177e4SLinus Torvalds /* Calculate the actual data size in a data chunk */ 1551da177e4SLinus Torvalds #define SCTP_DATA_SNDSIZE(c) ((int)((unsigned long)(c->chunk_end)\ 1561da177e4SLinus Torvalds - (unsigned long)(c->chunk_hdr)\ 1571da177e4SLinus Torvalds - sizeof(sctp_data_chunk_t))) 1581da177e4SLinus Torvalds 1591da177e4SLinus Torvalds #define SCTP_MAX_ERROR_CAUSE SCTP_ERROR_NONEXIST_IP 1601da177e4SLinus Torvalds #define SCTP_NUM_ERROR_CAUSE 10 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds /* Internal error codes */ 1631da177e4SLinus Torvalds typedef enum { 1641da177e4SLinus Torvalds 1651da177e4SLinus Torvalds SCTP_IERROR_NO_ERROR = 0, 1661da177e4SLinus Torvalds SCTP_IERROR_BASE = 1000, 1671da177e4SLinus Torvalds SCTP_IERROR_NO_COOKIE, 1681da177e4SLinus Torvalds SCTP_IERROR_BAD_SIG, 1691da177e4SLinus Torvalds SCTP_IERROR_STALE_COOKIE, 1701da177e4SLinus Torvalds SCTP_IERROR_NOMEM, 1711da177e4SLinus Torvalds SCTP_IERROR_MALFORMED, 1721da177e4SLinus Torvalds SCTP_IERROR_BAD_TAG, 1731da177e4SLinus Torvalds SCTP_IERROR_BIG_GAP, 1741da177e4SLinus Torvalds SCTP_IERROR_DUP_TSN, 1751da177e4SLinus Torvalds SCTP_IERROR_HIGH_TSN, 1761da177e4SLinus Torvalds SCTP_IERROR_IGNORE_TSN, 1771da177e4SLinus Torvalds SCTP_IERROR_NO_DATA, 1781da177e4SLinus Torvalds SCTP_IERROR_BAD_STREAM, 1791da177e4SLinus Torvalds SCTP_IERROR_BAD_PORTS, 1801da177e4SLinus Torvalds 1811da177e4SLinus Torvalds } sctp_ierror_t; 1821da177e4SLinus Torvalds 1831da177e4SLinus Torvalds 1841da177e4SLinus Torvalds 1851da177e4SLinus Torvalds /* SCTP state defines for internal state machine */ 1861da177e4SLinus Torvalds typedef enum { 1871da177e4SLinus Torvalds 1881da177e4SLinus Torvalds SCTP_STATE_EMPTY = 0, 1891da177e4SLinus Torvalds SCTP_STATE_CLOSED = 1, 1901da177e4SLinus Torvalds SCTP_STATE_COOKIE_WAIT = 2, 1911da177e4SLinus Torvalds SCTP_STATE_COOKIE_ECHOED = 3, 1921da177e4SLinus Torvalds SCTP_STATE_ESTABLISHED = 4, 1931da177e4SLinus Torvalds SCTP_STATE_SHUTDOWN_PENDING = 5, 1941da177e4SLinus Torvalds SCTP_STATE_SHUTDOWN_SENT = 6, 1951da177e4SLinus Torvalds SCTP_STATE_SHUTDOWN_RECEIVED = 7, 1961da177e4SLinus Torvalds SCTP_STATE_SHUTDOWN_ACK_SENT = 8, 1971da177e4SLinus Torvalds 1981da177e4SLinus Torvalds } sctp_state_t; 1991da177e4SLinus Torvalds 2001da177e4SLinus Torvalds #define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT 2011da177e4SLinus Torvalds #define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1) 2021da177e4SLinus Torvalds 2031da177e4SLinus Torvalds /* These are values for sk->state. 2041da177e4SLinus Torvalds * For a UDP-style SCTP socket, the states are defined as follows 2051da177e4SLinus Torvalds * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 2061da177e4SLinus Torvalds * accept new associations, but it can initiate the creation of new ones. 2071da177e4SLinus Torvalds * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 2081da177e4SLinus Torvalds * accept new associations and can initiate the creation of new ones. 2091da177e4SLinus Torvalds * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off 2101da177e4SLinus Torvalds * socket with one association. 2111da177e4SLinus Torvalds * For a TCP-style SCTP socket, the states are defined as follows 2121da177e4SLinus Torvalds * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 2131da177e4SLinus Torvalds * accept new associations, but it can initiate the creation of new ones. 2141da177e4SLinus Torvalds * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 2151da177e4SLinus Torvalds * accept new associations, but cannot initiate the creation of new ones. 2161da177e4SLinus Torvalds * - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single 2171da177e4SLinus Torvalds * association. 2181da177e4SLinus Torvalds */ 2191da177e4SLinus Torvalds typedef enum { 2201da177e4SLinus Torvalds SCTP_SS_CLOSED = TCP_CLOSE, 2211da177e4SLinus Torvalds SCTP_SS_LISTENING = TCP_LISTEN, 2221da177e4SLinus Torvalds SCTP_SS_ESTABLISHING = TCP_SYN_SENT, 2231da177e4SLinus Torvalds SCTP_SS_ESTABLISHED = TCP_ESTABLISHED, 2241da177e4SLinus Torvalds SCTP_SS_DISCONNECTING = TCP_CLOSING, 2251da177e4SLinus Torvalds } sctp_sock_state_t; 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds /* These functions map various type to printable names. */ 2281da177e4SLinus Torvalds const char *sctp_cname(const sctp_subtype_t); /* chunk types */ 2291da177e4SLinus Torvalds const char *sctp_oname(const sctp_subtype_t); /* other events */ 2301da177e4SLinus Torvalds const char *sctp_tname(const sctp_subtype_t); /* timeouts */ 2311da177e4SLinus Torvalds const char *sctp_pname(const sctp_subtype_t); /* primitives */ 2321da177e4SLinus Torvalds 2331da177e4SLinus Torvalds /* This is a table of printable names of sctp_state_t's. */ 2341da177e4SLinus Torvalds extern const char *sctp_state_tbl[], *sctp_evttype_tbl[], *sctp_status_tbl[]; 2351da177e4SLinus Torvalds 2361da177e4SLinus Torvalds /* Maximum chunk length considering padding requirements. */ 2371da177e4SLinus Torvalds enum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) }; 2381da177e4SLinus Torvalds 2391da177e4SLinus Torvalds /* Encourage Cookie-Echo bundling by pre-fragmenting chunks a little 2401da177e4SLinus Torvalds * harder (until reaching ESTABLISHED state). 2411da177e4SLinus Torvalds */ 2421da177e4SLinus Torvalds enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 }; 2431da177e4SLinus Torvalds 2441da177e4SLinus Torvalds /* Guess at how big to make the TSN mapping array. 2451da177e4SLinus Torvalds * We guarantee that we can handle at least this big a gap between the 2461da177e4SLinus Torvalds * cumulative ACK and the highest TSN. In practice, we can often 2471da177e4SLinus Torvalds * handle up to twice this value. 2481da177e4SLinus Torvalds * 2491da177e4SLinus Torvalds * NEVER make this more than 32767 (2^15-1). The Gap Ack Blocks in a 2501da177e4SLinus Torvalds * SACK (see section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE 2511da177e4SLinus Torvalds * must be less than 65535 (2^16 - 1), or we will have overflow 2521da177e4SLinus Torvalds * problems creating SACK's. 2531da177e4SLinus Torvalds */ 2541da177e4SLinus Torvalds #define SCTP_TSN_MAP_SIZE 2048 2551da177e4SLinus Torvalds #define SCTP_TSN_MAX_GAP 65535 2561da177e4SLinus Torvalds 2571da177e4SLinus Torvalds /* We will not record more than this many duplicate TSNs between two 2581da177e4SLinus Torvalds * SACKs. The minimum PMTU is 576. Remove all the headers and there 2591da177e4SLinus Torvalds * is enough room for 131 duplicate reports. Round down to the 2601da177e4SLinus Torvalds * nearest power of 2. 2611da177e4SLinus Torvalds */ 2621da177e4SLinus Torvalds enum { SCTP_MIN_PMTU = 576 }; 2631da177e4SLinus Torvalds enum { SCTP_MAX_DUP_TSNS = 16 }; 2641da177e4SLinus Torvalds enum { SCTP_MAX_GABS = 16 }; 2651da177e4SLinus Torvalds 2662f85a429SVlad Yasevich /* Heartbeat interval - 30 secs */ 2673fd091e7SVladislav Yasevich #define SCTP_DEFAULT_TIMEOUT_HEARTBEAT (30*1000) 2681da177e4SLinus Torvalds 2692f85a429SVlad Yasevich /* Delayed sack timer - 200ms */ 2703fd091e7SVladislav Yasevich #define SCTP_DEFAULT_TIMEOUT_SACK (200) 2711da177e4SLinus Torvalds 2721da177e4SLinus Torvalds /* RTO.Initial - 3 seconds 2731da177e4SLinus Torvalds * RTO.Min - 1 second 2741da177e4SLinus Torvalds * RTO.Max - 60 seconds 2751da177e4SLinus Torvalds * RTO.Alpha - 1/8 2761da177e4SLinus Torvalds * RTO.Beta - 1/4 2771da177e4SLinus Torvalds */ 2783fd091e7SVladislav Yasevich #define SCTP_RTO_INITIAL (3 * 1000) 2793fd091e7SVladislav Yasevich #define SCTP_RTO_MIN (1 * 1000) 2803fd091e7SVladislav Yasevich #define SCTP_RTO_MAX (60 * 1000) 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds #define SCTP_RTO_ALPHA 3 /* 1/8 when converted to right shifts. */ 2831da177e4SLinus Torvalds #define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ 2841da177e4SLinus Torvalds 2851da177e4SLinus Torvalds /* Maximum number of new data packets that can be sent in a burst. */ 2861da177e4SLinus Torvalds #define SCTP_MAX_BURST 4 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ 2891da177e4SLinus Torvalds 2901da177e4SLinus Torvalds #define SCTP_DEF_MAX_INIT 6 2911da177e4SLinus Torvalds #define SCTP_DEF_MAX_SEND 10 2921da177e4SLinus Torvalds 2933fd091e7SVladislav Yasevich #define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ 2941da177e4SLinus Torvalds 2951da177e4SLinus Torvalds #define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ 2961da177e4SLinus Torvalds #define SCTP_DEFAULT_MAXWINDOW 65535 /* default rwnd size */ 2971da177e4SLinus Torvalds #define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the limit 2981da177e4SLinus Torvalds * to which we will raise the P-MTU. 2991da177e4SLinus Torvalds */ 3001da177e4SLinus Torvalds #define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ 3011da177e4SLinus Torvalds #define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */ 3021da177e4SLinus Torvalds #define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current 3031da177e4SLinus Torvalds * secret will live? 3041da177e4SLinus Torvalds */ 3051da177e4SLinus Torvalds #define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ 3061da177e4SLinus Torvalds 3071da177e4SLinus Torvalds #define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ 3081da177e4SLinus Torvalds 3091da177e4SLinus Torvalds #define SCTP_COOKIE_MULTIPLE 32 /* Pad out our cookie to make our hash 3101da177e4SLinus Torvalds * functions simpler to write. 3111da177e4SLinus Torvalds */ 3121da177e4SLinus Torvalds 3131da177e4SLinus Torvalds #if defined (CONFIG_SCTP_HMAC_MD5) 3141b489e11SHerbert Xu #define SCTP_COOKIE_HMAC_ALG "hmac(md5)" 3151da177e4SLinus Torvalds #elif defined (CONFIG_SCTP_HMAC_SHA1) 3161b489e11SHerbert Xu #define SCTP_COOKIE_HMAC_ALG "hmac(sha1)" 3171da177e4SLinus Torvalds #else 3181da177e4SLinus Torvalds #define SCTP_COOKIE_HMAC_ALG NULL 3191da177e4SLinus Torvalds #endif 3201da177e4SLinus Torvalds 3211da177e4SLinus Torvalds /* These return values describe the success or failure of a number of 3221da177e4SLinus Torvalds * routines which form the lower interface to SCTP_outqueue. 3231da177e4SLinus Torvalds */ 3241da177e4SLinus Torvalds typedef enum { 3251da177e4SLinus Torvalds SCTP_XMIT_OK, 3261da177e4SLinus Torvalds SCTP_XMIT_PMTU_FULL, 3271da177e4SLinus Torvalds SCTP_XMIT_RWND_FULL, 3281da177e4SLinus Torvalds SCTP_XMIT_NAGLE_DELAY, 3291da177e4SLinus Torvalds } sctp_xmit_t; 3301da177e4SLinus Torvalds 3311da177e4SLinus Torvalds /* These are the commands for manipulating transports. */ 3321da177e4SLinus Torvalds typedef enum { 3331da177e4SLinus Torvalds SCTP_TRANSPORT_UP, 3341da177e4SLinus Torvalds SCTP_TRANSPORT_DOWN, 3351da177e4SLinus Torvalds } sctp_transport_cmd_t; 3361da177e4SLinus Torvalds 3371da177e4SLinus Torvalds /* These are the address scopes defined mainly for IPv4 addresses 3381da177e4SLinus Torvalds * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>. 3391da177e4SLinus Torvalds * These scopes are hopefully generic enough to be used on scoping both 3401da177e4SLinus Torvalds * IPv4 and IPv6 addresses in SCTP. 3411da177e4SLinus Torvalds * At this point, the IPv6 scopes will be mapped to these internal scopes 3421da177e4SLinus Torvalds * as much as possible. 3431da177e4SLinus Torvalds */ 3441da177e4SLinus Torvalds typedef enum { 3451da177e4SLinus Torvalds SCTP_SCOPE_GLOBAL, /* IPv4 global addresses */ 3461da177e4SLinus Torvalds SCTP_SCOPE_PRIVATE, /* IPv4 private addresses */ 3471da177e4SLinus Torvalds SCTP_SCOPE_LINK, /* IPv4 link local address */ 3481da177e4SLinus Torvalds SCTP_SCOPE_LOOPBACK, /* IPv4 loopback address */ 3491da177e4SLinus Torvalds SCTP_SCOPE_UNUSABLE, /* IPv4 unusable addresses */ 3501da177e4SLinus Torvalds } sctp_scope_t; 3511da177e4SLinus Torvalds 3521da177e4SLinus Torvalds /* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>, 3531da177e4SLinus Torvalds * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 198.18.0.0/24, 3541da177e4SLinus Torvalds * 192.88.99.0/24. 3551da177e4SLinus Torvalds * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP 3561da177e4SLinus Torvalds * addresses. 3571da177e4SLinus Torvalds */ 3581da177e4SLinus Torvalds #define IS_IPV4_UNUSABLE_ADDRESS(a) \ 359dbc16db1SAl Viro ((htonl(INADDR_BROADCAST) == *a) || \ 3601da177e4SLinus Torvalds (MULTICAST(*a)) || \ 3611da177e4SLinus Torvalds (((unsigned char *)(a))[0] == 0) || \ 3621da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 198) && \ 3631da177e4SLinus Torvalds (((unsigned char *)(a))[1] == 18) && \ 3641da177e4SLinus Torvalds (((unsigned char *)(a))[2] == 0)) || \ 3651da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 192) && \ 3661da177e4SLinus Torvalds (((unsigned char *)(a))[1] == 88) && \ 3671da177e4SLinus Torvalds (((unsigned char *)(a))[2] == 99))) 3681da177e4SLinus Torvalds 3691da177e4SLinus Torvalds /* IPv4 Link-local addresses: 169.254.0.0/16. */ 3701da177e4SLinus Torvalds #define IS_IPV4_LINK_ADDRESS(a) \ 3711da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 169) && \ 3721da177e4SLinus Torvalds (((unsigned char *)(a))[1] == 254)) 3731da177e4SLinus Torvalds 3741da177e4SLinus Torvalds /* RFC 1918 "Address Allocation for Private Internets" defines the IPv4 3751da177e4SLinus Torvalds * private address space as the following: 3761da177e4SLinus Torvalds * 3771da177e4SLinus Torvalds * 10.0.0.0 - 10.255.255.255 (10/8 prefix) 3781da177e4SLinus Torvalds * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix) 3791da177e4SLinus Torvalds * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) 3801da177e4SLinus Torvalds */ 3811da177e4SLinus Torvalds #define IS_IPV4_PRIVATE_ADDRESS(a) \ 3821da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 10) || \ 3831da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 172) && \ 3841da177e4SLinus Torvalds (((unsigned char *)(a))[1] >= 16) && \ 3851da177e4SLinus Torvalds (((unsigned char *)(a))[1] < 32)) || \ 3861da177e4SLinus Torvalds ((((unsigned char *)(a))[0] == 192) && \ 3871da177e4SLinus Torvalds (((unsigned char *)(a))[1] == 168))) 3881da177e4SLinus Torvalds 3891da177e4SLinus Torvalds /* Flags used for the bind address copy functions. */ 3901da177e4SLinus Torvalds #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by 3911da177e4SLinus Torvalds local sock family */ 3921da177e4SLinus Torvalds #define SCTP_ADDR4_PEERSUPP 0x00000002 /* IPv4 address is supported by 3931da177e4SLinus Torvalds peer */ 3941da177e4SLinus Torvalds #define SCTP_ADDR6_PEERSUPP 0x00000004 /* IPv6 address is supported by 3951da177e4SLinus Torvalds peer */ 3961da177e4SLinus Torvalds 3971da177e4SLinus Torvalds /* Reasons to retransmit. */ 3981da177e4SLinus Torvalds typedef enum { 3991da177e4SLinus Torvalds SCTP_RTXR_T3_RTX, 4001da177e4SLinus Torvalds SCTP_RTXR_FAST_RTX, 4011da177e4SLinus Torvalds SCTP_RTXR_PMTUD, 4021da177e4SLinus Torvalds } sctp_retransmit_reason_t; 4031da177e4SLinus Torvalds 4041da177e4SLinus Torvalds /* Reasons to lower cwnd. */ 4051da177e4SLinus Torvalds typedef enum { 4061da177e4SLinus Torvalds SCTP_LOWER_CWND_T3_RTX, 4071da177e4SLinus Torvalds SCTP_LOWER_CWND_FAST_RTX, 4081da177e4SLinus Torvalds SCTP_LOWER_CWND_ECNE, 4091da177e4SLinus Torvalds SCTP_LOWER_CWND_INACTIVE, 4101da177e4SLinus Torvalds } sctp_lower_cwnd_t; 4111da177e4SLinus Torvalds 4121da177e4SLinus Torvalds #endif /* __sctp_constants_h__ */ 413