xref: /linux/include/net/sctp/constants.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
147505b8bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
260c778b2SVlad Yasevich /* SCTP kernel implementation
31da177e4SLinus Torvalds  * (C) Copyright IBM Corp. 2001, 2004
41da177e4SLinus Torvalds  * Copyright (c) 1999-2000 Cisco, Inc.
51da177e4SLinus Torvalds  * Copyright (c) 1999-2001 Motorola, Inc.
61da177e4SLinus Torvalds  * Copyright (c) 2001 Intel Corp.
71da177e4SLinus Torvalds  *
860c778b2SVlad Yasevich  * This file is part of the SCTP kernel implementation
91da177e4SLinus Torvalds  *
101da177e4SLinus Torvalds  * Please send any bug reports or fixes you make to the
111da177e4SLinus Torvalds  * email address(es):
1291705c61SDaniel Borkmann  *    lksctp developers <linux-sctp@vger.kernel.org>
131da177e4SLinus Torvalds  *
141da177e4SLinus Torvalds  * Written or modified by:
151da177e4SLinus Torvalds  *   La Monte H.P. Yarroll <piggy@acm.org>
161da177e4SLinus Torvalds  *   Karl Knutson          <karl@athena.chicago.il.us>
171da177e4SLinus Torvalds  *   Randall Stewart       <randall@stewart.chicago.il.us>
181da177e4SLinus Torvalds  *   Ken Morneau           <kmorneau@cisco.com>
191da177e4SLinus Torvalds  *   Qiaobing Xie          <qxie1@motorola.com>
201da177e4SLinus Torvalds  *   Xingang Guo           <xingang.guo@intel.com>
211da177e4SLinus Torvalds  *   Sridhar Samudrala     <samudrala@us.ibm.com>
221da177e4SLinus Torvalds  *   Daisy Chang           <daisyc@us.ibm.com>
231da177e4SLinus Torvalds  */
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds #ifndef __sctp_constants_h__
261da177e4SLinus Torvalds #define __sctp_constants_h__
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds #include <linux/sctp.h>
291da177e4SLinus Torvalds #include <linux/ipv6.h> /* For ipv6hdr. */
3084965614SXin Long #include <net/tcp_states.h>  /* For TCP states used in enum sctp_sock_state */
311da177e4SLinus Torvalds 
321da177e4SLinus Torvalds /* Value used for stream negotiation. */
331da177e4SLinus Torvalds enum { SCTP_MAX_STREAM = 0xffff };
341da177e4SLinus Torvalds enum { SCTP_DEFAULT_OUTSTREAMS = 10 };
351da177e4SLinus Torvalds enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds /* Since CIDs are sparse, we need all four of the following
381da177e4SLinus Torvalds  * symbols.  CIDs are dense through SCTP_CID_BASE_MAX.
391da177e4SLinus Torvalds  */
401da177e4SLinus Torvalds #define SCTP_CID_BASE_MAX		SCTP_CID_SHUTDOWN_COMPLETE
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds #define SCTP_NUM_BASE_CHUNK_TYPES	(SCTP_CID_BASE_MAX + 1)
431da177e4SLinus Torvalds 
441da177e4SLinus Torvalds #define SCTP_NUM_ADDIP_CHUNK_TYPES	2
451da177e4SLinus Torvalds 
461da177e4SLinus Torvalds #define SCTP_NUM_PRSCTP_CHUNK_TYPES	1
471da177e4SLinus Torvalds 
48d884aa63SXin Long #define SCTP_NUM_RECONF_CHUNK_TYPES	1
49d884aa63SXin Long 
501f485649SVlad Yasevich #define SCTP_NUM_AUTH_CHUNK_TYPES	1
511f485649SVlad Yasevich 
521f485649SVlad Yasevich #define SCTP_NUM_CHUNK_TYPES		(SCTP_NUM_BASE_CHUNK_TYPES + \
531f485649SVlad Yasevich 					 SCTP_NUM_ADDIP_CHUNK_TYPES +\
541f485649SVlad Yasevich 					 SCTP_NUM_PRSCTP_CHUNK_TYPES +\
55d884aa63SXin Long 					 SCTP_NUM_RECONF_CHUNK_TYPES +\
561f485649SVlad Yasevich 					 SCTP_NUM_AUTH_CHUNK_TYPES)
571f485649SVlad Yasevich 
581da177e4SLinus Torvalds /* These are the different flavours of event.  */
5988ee48c1SXin Long enum sctp_event_type {
601da177e4SLinus Torvalds 	SCTP_EVENT_T_CHUNK = 1,
611da177e4SLinus Torvalds 	SCTP_EVENT_T_TIMEOUT,
621da177e4SLinus Torvalds 	SCTP_EVENT_T_OTHER,
631da177e4SLinus Torvalds 	SCTP_EVENT_T_PRIMITIVE
6461f0eb07SXin Long };
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds /* As a convenience for the state machine, we append SCTP_EVENT_* and
671da177e4SLinus Torvalds  * SCTP_ULP_* to the list of possible chunks.
681da177e4SLinus Torvalds  */
691da177e4SLinus Torvalds 
7019cd1592SXin Long enum sctp_event_timeout {
711da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_NONE = 0,
721da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T1_COOKIE,
731da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T1_INIT,
741da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
751da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T3_RTX,
761da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T4_RTO,
771da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
781da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_HEARTBEAT,
797b9438deSXin Long 	SCTP_EVENT_TIMEOUT_RECONF,
8092548ec2SXin Long 	SCTP_EVENT_TIMEOUT_PROBE,
811da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_SACK,
821da177e4SLinus Torvalds 	SCTP_EVENT_TIMEOUT_AUTOCLOSE,
8319cd1592SXin Long };
841da177e4SLinus Torvalds 
851da177e4SLinus Torvalds #define SCTP_EVENT_TIMEOUT_MAX		SCTP_EVENT_TIMEOUT_AUTOCLOSE
861da177e4SLinus Torvalds #define SCTP_NUM_TIMEOUT_TYPES		(SCTP_EVENT_TIMEOUT_MAX + 1)
871da177e4SLinus Torvalds 
88a0f098d0SXin Long enum sctp_event_other {
891da177e4SLinus Torvalds 	SCTP_EVENT_NO_PENDING_TSN = 0,
901da177e4SLinus Torvalds 	SCTP_EVENT_ICMP_PROTO_UNREACH,
91a0f098d0SXin Long };
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds #define SCTP_EVENT_OTHER_MAX		SCTP_EVENT_ICMP_PROTO_UNREACH
941da177e4SLinus Torvalds #define SCTP_NUM_OTHER_TYPES		(SCTP_EVENT_OTHER_MAX + 1)
951da177e4SLinus Torvalds 
961da177e4SLinus Torvalds /* These are primitive requests from the ULP.  */
97dc1e0e6eSXin Long enum sctp_event_primitive {
981da177e4SLinus Torvalds 	SCTP_PRIMITIVE_ASSOCIATE = 0,
991da177e4SLinus Torvalds 	SCTP_PRIMITIVE_SHUTDOWN,
1001da177e4SLinus Torvalds 	SCTP_PRIMITIVE_ABORT,
1011da177e4SLinus Torvalds 	SCTP_PRIMITIVE_SEND,
1021da177e4SLinus Torvalds 	SCTP_PRIMITIVE_REQUESTHEARTBEAT,
1031da177e4SLinus Torvalds 	SCTP_PRIMITIVE_ASCONF,
1047a090b04SXin Long 	SCTP_PRIMITIVE_RECONF,
105dc1e0e6eSXin Long };
1061da177e4SLinus Torvalds 
1077a090b04SXin Long #define SCTP_EVENT_PRIMITIVE_MAX	SCTP_PRIMITIVE_RECONF
1081da177e4SLinus Torvalds #define SCTP_NUM_PRIMITIVE_TYPES	(SCTP_EVENT_PRIMITIVE_MAX + 1)
1091da177e4SLinus Torvalds 
1101da177e4SLinus Torvalds /* We define here a utility type for manipulating subtypes.
1111da177e4SLinus Torvalds  * The subtype constructors all work like this:
1121da177e4SLinus Torvalds  *
113bfc6f827SXin Long  *   union sctp_subtype foo = SCTP_ST_CHUNK(SCTP_CID_INIT);
1141da177e4SLinus Torvalds  */
1151da177e4SLinus Torvalds 
116bfc6f827SXin Long union sctp_subtype {
1176d85e68fSXin Long 	enum sctp_cid chunk;
11819cd1592SXin Long 	enum sctp_event_timeout timeout;
119a0f098d0SXin Long 	enum sctp_event_other other;
120dc1e0e6eSXin Long 	enum sctp_event_primitive primitive;
121bfc6f827SXin Long };
1221da177e4SLinus Torvalds 
1231da177e4SLinus Torvalds #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
124bfc6f827SXin Long static inline union sctp_subtype	\
1251da177e4SLinus Torvalds SCTP_ST_## _name (_type _arg)		\
126bfc6f827SXin Long { union sctp_subtype _retval; _retval._elt = _arg; return _retval; }
1271da177e4SLinus Torvalds 
1286d85e68fSXin Long SCTP_SUBTYPE_CONSTRUCTOR(CHUNK,		enum sctp_cid,		chunk)
12919cd1592SXin Long SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT,	enum sctp_event_timeout, timeout)
130a0f098d0SXin Long SCTP_SUBTYPE_CONSTRUCTOR(OTHER,		enum sctp_event_other,	other)
131dc1e0e6eSXin Long SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE,	enum sctp_event_primitive, primitive)
1321da177e4SLinus Torvalds 
1331da177e4SLinus Torvalds 
134668c9bebSXin Long #define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA || \
135668c9bebSXin Long 			       a->chunk_hdr->type == SCTP_CID_I_DATA)
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds /* Internal error codes */
1384785c7aeSXin Long enum sctp_ierror {
1391da177e4SLinus Torvalds 	SCTP_IERROR_NO_ERROR	        = 0,
1401da177e4SLinus Torvalds 	SCTP_IERROR_BASE		= 1000,
1411da177e4SLinus Torvalds 	SCTP_IERROR_NO_COOKIE,
1421da177e4SLinus Torvalds 	SCTP_IERROR_BAD_SIG,
1431da177e4SLinus Torvalds 	SCTP_IERROR_STALE_COOKIE,
1441da177e4SLinus Torvalds 	SCTP_IERROR_NOMEM,
1451da177e4SLinus Torvalds 	SCTP_IERROR_MALFORMED,
1461da177e4SLinus Torvalds 	SCTP_IERROR_BAD_TAG,
1471da177e4SLinus Torvalds 	SCTP_IERROR_BIG_GAP,
1481da177e4SLinus Torvalds 	SCTP_IERROR_DUP_TSN,
1491da177e4SLinus Torvalds 	SCTP_IERROR_HIGH_TSN,
1501da177e4SLinus Torvalds 	SCTP_IERROR_IGNORE_TSN,
1511da177e4SLinus Torvalds 	SCTP_IERROR_NO_DATA,
1521da177e4SLinus Torvalds 	SCTP_IERROR_BAD_STREAM,
1531da177e4SLinus Torvalds 	SCTP_IERROR_BAD_PORTS,
154bbd0d598SVlad Yasevich 	SCTP_IERROR_AUTH_BAD_HMAC,
155bbd0d598SVlad Yasevich 	SCTP_IERROR_AUTH_BAD_KEYID,
156bbd0d598SVlad Yasevich 	SCTP_IERROR_PROTO_VIOLATION,
1577ab90804SVlad Yasevich 	SCTP_IERROR_ERROR,
1587ab90804SVlad Yasevich 	SCTP_IERROR_ABORT,
1594785c7aeSXin Long };
1601da177e4SLinus Torvalds 
1611da177e4SLinus Torvalds 
1621da177e4SLinus Torvalds 
1631da177e4SLinus Torvalds /* SCTP state defines for internal state machine */
16452106019SXin Long enum sctp_state {
1651da177e4SLinus Torvalds 
1660b8f9e25SVlad Yasevich 	SCTP_STATE_CLOSED		= 0,
1670b8f9e25SVlad Yasevich 	SCTP_STATE_COOKIE_WAIT		= 1,
1680b8f9e25SVlad Yasevich 	SCTP_STATE_COOKIE_ECHOED	= 2,
1690b8f9e25SVlad Yasevich 	SCTP_STATE_ESTABLISHED		= 3,
1700b8f9e25SVlad Yasevich 	SCTP_STATE_SHUTDOWN_PENDING	= 4,
1710b8f9e25SVlad Yasevich 	SCTP_STATE_SHUTDOWN_SENT	= 5,
1720b8f9e25SVlad Yasevich 	SCTP_STATE_SHUTDOWN_RECEIVED	= 6,
1730b8f9e25SVlad Yasevich 	SCTP_STATE_SHUTDOWN_ACK_SENT	= 7,
1741da177e4SLinus Torvalds 
17552106019SXin Long };
1761da177e4SLinus Torvalds 
1771da177e4SLinus Torvalds #define SCTP_STATE_MAX			SCTP_STATE_SHUTDOWN_ACK_SENT
1781da177e4SLinus Torvalds #define SCTP_STATE_NUM_STATES		(SCTP_STATE_MAX + 1)
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds /* These are values for sk->state.
1811da177e4SLinus Torvalds  * For a UDP-style SCTP socket, the states are defined as follows
1821da177e4SLinus Torvalds  * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
1831da177e4SLinus Torvalds  *   accept new associations, but it can initiate the creation of new ones.
1841da177e4SLinus Torvalds  * - A socket in SCTP_SS_LISTENING state indicates that it is willing to
1851da177e4SLinus Torvalds  *   accept new  associations and can initiate the creation of new ones.
1861da177e4SLinus Torvalds  * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off
1871da177e4SLinus Torvalds  *   socket with one association.
1881da177e4SLinus Torvalds  * For a TCP-style SCTP socket, the states are defined as follows
1891da177e4SLinus Torvalds  * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
1901da177e4SLinus Torvalds  *   accept new associations, but it can initiate the creation of new ones.
1911da177e4SLinus Torvalds  * - A socket in SCTP_SS_LISTENING state indicates that it is willing to
1921da177e4SLinus Torvalds  *   accept new associations, but cannot initiate the creation of new ones.
1931da177e4SLinus Torvalds  * - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single
1941da177e4SLinus Torvalds  *   association.
1951da177e4SLinus Torvalds  */
19684965614SXin Long enum sctp_sock_state {
1971da177e4SLinus Torvalds 	SCTP_SS_CLOSED         = TCP_CLOSE,
1981da177e4SLinus Torvalds 	SCTP_SS_LISTENING      = TCP_LISTEN,
1991da177e4SLinus Torvalds 	SCTP_SS_ESTABLISHING   = TCP_SYN_SENT,
2001da177e4SLinus Torvalds 	SCTP_SS_ESTABLISHED    = TCP_ESTABLISHED,
201df7e88f6SXin Long 	SCTP_SS_CLOSING        = TCP_CLOSE_WAIT,
20284965614SXin Long };
2031da177e4SLinus Torvalds 
204d9e2e410SXin Long enum sctp_plpmtud_state {
205d9e2e410SXin Long 	SCTP_PL_DISABLED,
206d9e2e410SXin Long 	SCTP_PL_BASE,
207d9e2e410SXin Long 	SCTP_PL_SEARCH,
208d9e2e410SXin Long 	SCTP_PL_COMPLETE,
209d9e2e410SXin Long 	SCTP_PL_ERROR,
210d9e2e410SXin Long };
211d9e2e410SXin Long 
212d9e2e410SXin Long #define	SCTP_BASE_PLPMTU	1200
213d9e2e410SXin Long #define	SCTP_MAX_PLPMTU		9000
214d9e2e410SXin Long #define	SCTP_MIN_PLPMTU		512
215d9e2e410SXin Long 
216d9e2e410SXin Long #define	SCTP_MAX_PROBES		3
217d9e2e410SXin Long 
218d9e2e410SXin Long #define SCTP_PL_BIG_STEP	32
219d9e2e410SXin Long #define SCTP_PL_MIN_STEP	4
220d9e2e410SXin Long 
2211da177e4SLinus Torvalds /* These functions map various type to printable names.  */
222bfc6f827SXin Long const char *sctp_cname(const union sctp_subtype id);	/* chunk types */
223bfc6f827SXin Long const char *sctp_oname(const union sctp_subtype id);	/* other events */
224bfc6f827SXin Long const char *sctp_tname(const union sctp_subtype id);	/* timeouts */
225bfc6f827SXin Long const char *sctp_pname(const union sctp_subtype id);	/* primitives */
2261da177e4SLinus Torvalds 
2271da177e4SLinus Torvalds /* This is a table of printable names of sctp_state_t's.  */
22836cbd3dcSJan Engelhardt extern const char *const sctp_state_tbl[];
22936cbd3dcSJan Engelhardt extern const char *const sctp_evttype_tbl[];
23036cbd3dcSJan Engelhardt extern const char *const sctp_status_tbl[];
2311da177e4SLinus Torvalds 
2321da177e4SLinus Torvalds /* Maximum chunk length considering padding requirements. */
2331da177e4SLinus Torvalds enum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) };
2341da177e4SLinus Torvalds 
2351da177e4SLinus Torvalds /* Encourage Cookie-Echo bundling by pre-fragmenting chunks a little
2361da177e4SLinus Torvalds  * harder (until reaching ESTABLISHED state).
2371da177e4SLinus Torvalds  */
2381da177e4SLinus Torvalds enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
2391da177e4SLinus Torvalds 
2401da177e4SLinus Torvalds /* Guess at how big to make the TSN mapping array.
2411da177e4SLinus Torvalds  * We guarantee that we can handle at least this big a gap between the
2421da177e4SLinus Torvalds  * cumulative ACK and the highest TSN.  In practice, we can often
2431da177e4SLinus Torvalds  * handle up to twice this value.
2441da177e4SLinus Torvalds  *
2451da177e4SLinus Torvalds  * NEVER make this more than 32767 (2^15-1).  The Gap Ack Blocks in a
2461da177e4SLinus Torvalds  * SACK (see  section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE
2471da177e4SLinus Torvalds  * must be less than 65535 (2^16 - 1), or we will have overflow
2481da177e4SLinus Torvalds  * problems creating SACK's.
2491da177e4SLinus Torvalds  */
2508e1ee18cSVlad Yasevich #define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
2518e1ee18cSVlad Yasevich #define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
2528e1ee18cSVlad Yasevich #define SCTP_TSN_MAP_SIZE 4096
2531da177e4SLinus Torvalds 
2541da177e4SLinus Torvalds /* We will not record more than this many duplicate TSNs between two
255c45698f8SMarcelo Ricardo Leitner  * SACKs.  The minimum PMTU is 512.  Remove all the headers and there
256c45698f8SMarcelo Ricardo Leitner  * is enough room for 117 duplicate reports.  Round down to the
2571da177e4SLinus Torvalds  * nearest power of 2.
2581da177e4SLinus Torvalds  */
2591da177e4SLinus Torvalds enum { SCTP_MAX_DUP_TSNS = 16 };
2601da177e4SLinus Torvalds enum { SCTP_MAX_GABS = 16 };
2611da177e4SLinus Torvalds 
2622f85a429SVlad Yasevich /* Heartbeat interval - 30 secs */
2633fd091e7SVladislav Yasevich #define SCTP_DEFAULT_TIMEOUT_HEARTBEAT	(30*1000)
2641da177e4SLinus Torvalds 
2652f85a429SVlad Yasevich /* Delayed sack timer - 200ms */
2663fd091e7SVladislav Yasevich #define SCTP_DEFAULT_TIMEOUT_SACK	(200)
2671da177e4SLinus Torvalds 
2681da177e4SLinus Torvalds /* RTO.Initial              - 3  seconds
2691da177e4SLinus Torvalds  * RTO.Min                  - 1  second
2701da177e4SLinus Torvalds  * RTO.Max                  - 60 seconds
2711da177e4SLinus Torvalds  * RTO.Alpha                - 1/8
2721da177e4SLinus Torvalds  * RTO.Beta                 - 1/4
2731da177e4SLinus Torvalds  */
2743fd091e7SVladislav Yasevich #define SCTP_RTO_INITIAL	(3 * 1000)
2753fd091e7SVladislav Yasevich #define SCTP_RTO_MIN		(1 * 1000)
2763fd091e7SVladislav Yasevich #define SCTP_RTO_MAX		(60 * 1000)
2771da177e4SLinus Torvalds 
2781da177e4SLinus Torvalds #define SCTP_RTO_ALPHA          3   /* 1/8 when converted to right shifts. */
2791da177e4SLinus Torvalds #define SCTP_RTO_BETA           2   /* 1/4 when converted to right shifts. */
2801da177e4SLinus Torvalds 
2811da177e4SLinus Torvalds /* Maximum number of new data packets that can be sent in a burst.  */
28270331571SVlad Yasevich #define SCTP_DEFAULT_MAX_BURST		4
2831da177e4SLinus Torvalds 
2841da177e4SLinus Torvalds #define SCTP_CLOCK_GRANULARITY	1	/* 1 jiffy */
2851da177e4SLinus Torvalds 
2863fd091e7SVladislav Yasevich #define SCTP_DEFAULT_COOKIE_LIFE	(60 * 1000) /* 60 seconds */
2871da177e4SLinus Torvalds 
2881da177e4SLinus Torvalds #define SCTP_DEFAULT_MINWINDOW	1500	/* default minimum rwnd size */
2891da177e4SLinus Torvalds #define SCTP_DEFAULT_MAXWINDOW	65535	/* default rwnd size */
29090f2f531SVlad Yasevich #define SCTP_DEFAULT_RWND_SHIFT  4	/* by default, update on 1/16 of
29190f2f531SVlad Yasevich 					 * rcvbuf, which is 1/8 of initial
29290f2f531SVlad Yasevich 					 * window
29390f2f531SVlad Yasevich 					 */
2941da177e4SLinus Torvalds #define SCTP_DEFAULT_MAXSEGMENT 1500	/* MTU size, this is the limit
2951da177e4SLinus Torvalds                                          * to which we will raise the P-MTU.
2961da177e4SLinus Torvalds 					 */
2971da177e4SLinus Torvalds #define SCTP_DEFAULT_MINSEGMENT 512	/* MTU size ... if no mtu disc */
298570617e7SDaniel Borkmann 
2991da177e4SLinus Torvalds #define SCTP_SECRET_SIZE 32		/* Number of octets in a 256 bits. */
3001da177e4SLinus Torvalds 
3011da177e4SLinus Torvalds #define SCTP_SIGNATURE_SIZE 20	        /* size of a SLA-1 signature */
3021da177e4SLinus Torvalds 
3031da177e4SLinus Torvalds #define SCTP_COOKIE_MULTIPLE 32 /* Pad out our cookie to make our hash
3041da177e4SLinus Torvalds 				 * functions simpler to write.
3051da177e4SLinus Torvalds 				 */
3061da177e4SLinus Torvalds 
307965ae444SXin Long #define SCTP_DEFAULT_UDP_PORT 9899	/* default UDP tunneling port */
308965ae444SXin Long 
309aef587beSXin Long /* These are the values for pf exposure, UNUSED is to keep compatible with old
310aef587beSXin Long  * applications by default.
311aef587beSXin Long  */
312aef587beSXin Long enum {
313aef587beSXin Long 	SCTP_PF_EXPOSE_UNSET,
314aef587beSXin Long 	SCTP_PF_EXPOSE_DISABLE,
315aef587beSXin Long 	SCTP_PF_EXPOSE_ENABLE,
316aef587beSXin Long };
317aef587beSXin Long #define SCTP_PF_EXPOSE_MAX	SCTP_PF_EXPOSE_ENABLE
318aef587beSXin Long 
31934515e94SXin Long #define SCTP_PS_RETRANS_MAX	0xffff
32034515e94SXin Long 
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  */
32486b36f2aSXin Long enum sctp_xmit {
3251da177e4SLinus Torvalds 	SCTP_XMIT_OK,
3261da177e4SLinus Torvalds 	SCTP_XMIT_PMTU_FULL,
3271da177e4SLinus Torvalds 	SCTP_XMIT_RWND_FULL,
328526cbef7SDavid Laight 	SCTP_XMIT_DELAY,
32986b36f2aSXin Long };
3301da177e4SLinus Torvalds 
3311da177e4SLinus Torvalds /* These are the commands for manipulating transports.  */
3320ceaeebeSXin Long enum sctp_transport_cmd {
3331da177e4SLinus Torvalds 	SCTP_TRANSPORT_UP,
3341da177e4SLinus Torvalds 	SCTP_TRANSPORT_DOWN,
3355aa93bcfSNeil Horman 	SCTP_TRANSPORT_PF,
3360ceaeebeSXin Long };
3371da177e4SLinus Torvalds 
3381da177e4SLinus Torvalds /* These are the address scopes defined mainly for IPv4 addresses
3391da177e4SLinus Torvalds  * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
3401da177e4SLinus Torvalds  * These scopes are hopefully generic enough to be used on scoping both
3411da177e4SLinus Torvalds  * IPv4 and IPv6 addresses in SCTP.
3421da177e4SLinus Torvalds  * At this point, the IPv6 scopes will be mapped to these internal scopes
3431da177e4SLinus Torvalds  * as much as possible.
3441da177e4SLinus Torvalds  */
3451c662018SXin Long enum sctp_scope {
3461da177e4SLinus Torvalds 	SCTP_SCOPE_GLOBAL,		/* IPv4 global addresses */
3471da177e4SLinus Torvalds 	SCTP_SCOPE_PRIVATE,		/* IPv4 private addresses */
3481da177e4SLinus Torvalds 	SCTP_SCOPE_LINK,		/* IPv4 link local address */
3491da177e4SLinus Torvalds 	SCTP_SCOPE_LOOPBACK,		/* IPv4 loopback address */
3501da177e4SLinus Torvalds 	SCTP_SCOPE_UNUSABLE,		/* IPv4 unusable addresses */
3511c662018SXin Long };
3521da177e4SLinus Torvalds 
353701ef3e6SXin Long enum {
35472388433SBhaskar Dutta 	SCTP_SCOPE_POLICY_DISABLE,	/* Disable IPv4 address scoping */
35572388433SBhaskar Dutta 	SCTP_SCOPE_POLICY_ENABLE,	/* Enable IPv4 address scoping */
35672388433SBhaskar Dutta 	SCTP_SCOPE_POLICY_PRIVATE,	/* Follow draft but allow IPv4 private addresses */
35772388433SBhaskar Dutta 	SCTP_SCOPE_POLICY_LINK,		/* Follow draft but allow IPv4 link local addresses */
358701ef3e6SXin Long };
359701ef3e6SXin Long 
360701ef3e6SXin Long #define SCTP_SCOPE_POLICY_MAX	SCTP_SCOPE_POLICY_LINK
36172388433SBhaskar Dutta 
3621da177e4SLinus Torvalds /* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>,
363*1d11fa23SXin Long  * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 192.88.99.0/24.
3641da177e4SLinus Torvalds  * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
3651da177e4SLinus Torvalds  * addresses.
3661da177e4SLinus Torvalds  */
3671da177e4SLinus Torvalds #define IS_IPV4_UNUSABLE_ADDRESS(a)	    \
368b5cb2bbcSJoe Perches 	((htonl(INADDR_BROADCAST) == a) ||  \
369b5cb2bbcSJoe Perches 	 ipv4_is_multicast(a) ||	    \
370b5cb2bbcSJoe Perches 	 ipv4_is_zeronet(a) ||		    \
371b5cb2bbcSJoe Perches 	 ipv4_is_anycast_6to4(a))
3721da177e4SLinus Torvalds 
3731da177e4SLinus Torvalds /* Flags used for the bind address copy functions.  */
374471e39dfSMarcelo Ricardo Leitner #define SCTP_ADDR4_ALLOWED	0x00000001	/* IPv4 address is allowed by
3751da177e4SLinus Torvalds 						   local sock family */
376471e39dfSMarcelo Ricardo Leitner #define SCTP_ADDR6_ALLOWED	0x00000002	/* IPv6 address is allowed by
377471e39dfSMarcelo Ricardo Leitner 						   local sock family */
378471e39dfSMarcelo Ricardo Leitner #define SCTP_ADDR4_PEERSUPP	0x00000004	/* IPv4 address is supported by
3791da177e4SLinus Torvalds 						   peer */
380471e39dfSMarcelo Ricardo Leitner #define SCTP_ADDR6_PEERSUPP	0x00000008	/* IPv6 address is supported by
3811da177e4SLinus Torvalds 						   peer */
3821da177e4SLinus Torvalds 
3831da177e4SLinus Torvalds /* Reasons to retransmit. */
384125c2982SXin Long enum sctp_retransmit_reason {
3851da177e4SLinus Torvalds 	SCTP_RTXR_T3_RTX,
3861da177e4SLinus Torvalds 	SCTP_RTXR_FAST_RTX,
3871da177e4SLinus Torvalds 	SCTP_RTXR_PMTUD,
388b6157d8eSVlad Yasevich 	SCTP_RTXR_T1_RTX,
389125c2982SXin Long };
3901da177e4SLinus Torvalds 
3911da177e4SLinus Torvalds /* Reasons to lower cwnd. */
392233e7936SXin Long enum sctp_lower_cwnd {
3931da177e4SLinus Torvalds 	SCTP_LOWER_CWND_T3_RTX,
3941da177e4SLinus Torvalds 	SCTP_LOWER_CWND_FAST_RTX,
3951da177e4SLinus Torvalds 	SCTP_LOWER_CWND_ECNE,
3961da177e4SLinus Torvalds 	SCTP_LOWER_CWND_INACTIVE,
397233e7936SXin Long };
3981da177e4SLinus Torvalds 
3991f485649SVlad Yasevich 
4001f485649SVlad Yasevich /* SCTP-AUTH Necessary constants */
4011f485649SVlad Yasevich 
4021f485649SVlad Yasevich /* SCTP-AUTH, Section 3.3
4031f485649SVlad Yasevich  *
4041f485649SVlad Yasevich  *  The following Table 2 shows the currently defined values for HMAC
4051f485649SVlad Yasevich  *  identifiers.
4061f485649SVlad Yasevich  *
4071f485649SVlad Yasevich  *  +-----------------+--------------------------+
4081f485649SVlad Yasevich  *  | HMAC Identifier | Message Digest Algorithm |
4091f485649SVlad Yasevich  *  +-----------------+--------------------------+
4101f485649SVlad Yasevich  *  | 0               | Reserved                 |
4111f485649SVlad Yasevich  *  | 1               | SHA-1 defined in [8]     |
4121f485649SVlad Yasevich  *  | 2               | Reserved                 |
4131f485649SVlad Yasevich  *  | 3               | SHA-256 defined in [8]   |
4141f485649SVlad Yasevich  *  +-----------------+--------------------------+
4151f485649SVlad Yasevich  */
4161f485649SVlad Yasevich enum {
4171f485649SVlad Yasevich 	SCTP_AUTH_HMAC_ID_RESERVED_0,
4181f485649SVlad Yasevich 	SCTP_AUTH_HMAC_ID_SHA1,
4191f485649SVlad Yasevich 	SCTP_AUTH_HMAC_ID_RESERVED_2,
420b7e0fe9fSVlad Yasevich #if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)
421b7e0fe9fSVlad Yasevich 	SCTP_AUTH_HMAC_ID_SHA256,
422b7e0fe9fSVlad Yasevich #endif
423b7e0fe9fSVlad Yasevich 	__SCTP_AUTH_HMAC_MAX
4241f485649SVlad Yasevich };
4251f485649SVlad Yasevich 
426b7e0fe9fSVlad Yasevich #define SCTP_AUTH_HMAC_ID_MAX	__SCTP_AUTH_HMAC_MAX - 1
427b7e0fe9fSVlad Yasevich #define SCTP_AUTH_NUM_HMACS 	__SCTP_AUTH_HMAC_MAX
4281f485649SVlad Yasevich #define SCTP_SHA1_SIG_SIZE 20
4291f485649SVlad Yasevich #define SCTP_SHA256_SIG_SIZE 32
4301f485649SVlad Yasevich 
4311f485649SVlad Yasevich /*  SCTP-AUTH, Section 3.2
4321f485649SVlad Yasevich  *     The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH chunks
4331f485649SVlad Yasevich  *     MUST NOT be listed in the CHUNKS parameter
4341f485649SVlad Yasevich  */
4351f485649SVlad Yasevich #define SCTP_NUM_NOAUTH_CHUNKS	4
4361f485649SVlad Yasevich #define SCTP_AUTH_MAX_CHUNKS	(SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS)
4371f485649SVlad Yasevich 
4381f485649SVlad Yasevich /* SCTP-AUTH Section 6.1
4391f485649SVlad Yasevich  * The RANDOM parameter MUST contain a 32 byte random number.
4401f485649SVlad Yasevich  */
4411f485649SVlad Yasevich #define SCTP_AUTH_RANDOM_LENGTH 32
4421f485649SVlad Yasevich 
443d1e462a7SXin Long #define SCTP_PROBE_TIMER_MIN	5000
444d1e462a7SXin Long 
4451da177e4SLinus Torvalds #endif /* __sctp_constants_h__ */
446