162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/* SCTP kernel implementation
362306a36Sopenharmony_ci * (C) Copyright IBM Corp. 2001, 2004
462306a36Sopenharmony_ci * Copyright (c) 1999-2000 Cisco, Inc.
562306a36Sopenharmony_ci * Copyright (c) 1999-2001 Motorola, Inc.
662306a36Sopenharmony_ci * Copyright (c) 2001 Intel Corp.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This file is part of the SCTP kernel implementation
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * Please send any bug reports or fixes you make to the
1162306a36Sopenharmony_ci * email address(es):
1262306a36Sopenharmony_ci *    lksctp developers <linux-sctp@vger.kernel.org>
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * Written or modified by:
1562306a36Sopenharmony_ci *   La Monte H.P. Yarroll <piggy@acm.org>
1662306a36Sopenharmony_ci *   Karl Knutson          <karl@athena.chicago.il.us>
1762306a36Sopenharmony_ci *   Randall Stewart       <randall@stewart.chicago.il.us>
1862306a36Sopenharmony_ci *   Ken Morneau           <kmorneau@cisco.com>
1962306a36Sopenharmony_ci *   Qiaobing Xie          <qxie1@motorola.com>
2062306a36Sopenharmony_ci *   Xingang Guo           <xingang.guo@intel.com>
2162306a36Sopenharmony_ci *   Sridhar Samudrala     <samudrala@us.ibm.com>
2262306a36Sopenharmony_ci *   Daisy Chang           <daisyc@us.ibm.com>
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#ifndef __sctp_constants_h__
2662306a36Sopenharmony_ci#define __sctp_constants_h__
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#include <linux/sctp.h>
2962306a36Sopenharmony_ci#include <linux/ipv6.h> /* For ipv6hdr. */
3062306a36Sopenharmony_ci#include <net/tcp_states.h>  /* For TCP states used in enum sctp_sock_state */
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* Value used for stream negotiation. */
3362306a36Sopenharmony_cienum { SCTP_MAX_STREAM = 0xffff };
3462306a36Sopenharmony_cienum { SCTP_DEFAULT_OUTSTREAMS = 10 };
3562306a36Sopenharmony_cienum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/* Since CIDs are sparse, we need all four of the following
3862306a36Sopenharmony_ci * symbols.  CIDs are dense through SCTP_CID_BASE_MAX.
3962306a36Sopenharmony_ci */
4062306a36Sopenharmony_ci#define SCTP_CID_BASE_MAX		SCTP_CID_SHUTDOWN_COMPLETE
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define SCTP_NUM_BASE_CHUNK_TYPES	(SCTP_CID_BASE_MAX + 1)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define SCTP_NUM_ADDIP_CHUNK_TYPES	2
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define SCTP_NUM_PRSCTP_CHUNK_TYPES	1
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define SCTP_NUM_RECONF_CHUNK_TYPES	1
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define SCTP_NUM_AUTH_CHUNK_TYPES	1
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define SCTP_NUM_CHUNK_TYPES		(SCTP_NUM_BASE_CHUNK_TYPES + \
5362306a36Sopenharmony_ci					 SCTP_NUM_ADDIP_CHUNK_TYPES +\
5462306a36Sopenharmony_ci					 SCTP_NUM_PRSCTP_CHUNK_TYPES +\
5562306a36Sopenharmony_ci					 SCTP_NUM_RECONF_CHUNK_TYPES +\
5662306a36Sopenharmony_ci					 SCTP_NUM_AUTH_CHUNK_TYPES)
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* These are the different flavours of event.  */
5962306a36Sopenharmony_cienum sctp_event_type {
6062306a36Sopenharmony_ci	SCTP_EVENT_T_CHUNK = 1,
6162306a36Sopenharmony_ci	SCTP_EVENT_T_TIMEOUT,
6262306a36Sopenharmony_ci	SCTP_EVENT_T_OTHER,
6362306a36Sopenharmony_ci	SCTP_EVENT_T_PRIMITIVE
6462306a36Sopenharmony_ci};
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci/* As a convenience for the state machine, we append SCTP_EVENT_* and
6762306a36Sopenharmony_ci * SCTP_ULP_* to the list of possible chunks.
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cienum sctp_event_timeout {
7162306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_NONE = 0,
7262306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T1_COOKIE,
7362306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T1_INIT,
7462306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
7562306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T3_RTX,
7662306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T4_RTO,
7762306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
7862306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_HEARTBEAT,
7962306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_RECONF,
8062306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_PROBE,
8162306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_SACK,
8262306a36Sopenharmony_ci	SCTP_EVENT_TIMEOUT_AUTOCLOSE,
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define SCTP_EVENT_TIMEOUT_MAX		SCTP_EVENT_TIMEOUT_AUTOCLOSE
8662306a36Sopenharmony_ci#define SCTP_NUM_TIMEOUT_TYPES		(SCTP_EVENT_TIMEOUT_MAX + 1)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cienum sctp_event_other {
8962306a36Sopenharmony_ci	SCTP_EVENT_NO_PENDING_TSN = 0,
9062306a36Sopenharmony_ci	SCTP_EVENT_ICMP_PROTO_UNREACH,
9162306a36Sopenharmony_ci};
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define SCTP_EVENT_OTHER_MAX		SCTP_EVENT_ICMP_PROTO_UNREACH
9462306a36Sopenharmony_ci#define SCTP_NUM_OTHER_TYPES		(SCTP_EVENT_OTHER_MAX + 1)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* These are primitive requests from the ULP.  */
9762306a36Sopenharmony_cienum sctp_event_primitive {
9862306a36Sopenharmony_ci	SCTP_PRIMITIVE_ASSOCIATE = 0,
9962306a36Sopenharmony_ci	SCTP_PRIMITIVE_SHUTDOWN,
10062306a36Sopenharmony_ci	SCTP_PRIMITIVE_ABORT,
10162306a36Sopenharmony_ci	SCTP_PRIMITIVE_SEND,
10262306a36Sopenharmony_ci	SCTP_PRIMITIVE_REQUESTHEARTBEAT,
10362306a36Sopenharmony_ci	SCTP_PRIMITIVE_ASCONF,
10462306a36Sopenharmony_ci	SCTP_PRIMITIVE_RECONF,
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#define SCTP_EVENT_PRIMITIVE_MAX	SCTP_PRIMITIVE_RECONF
10862306a36Sopenharmony_ci#define SCTP_NUM_PRIMITIVE_TYPES	(SCTP_EVENT_PRIMITIVE_MAX + 1)
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/* We define here a utility type for manipulating subtypes.
11162306a36Sopenharmony_ci * The subtype constructors all work like this:
11262306a36Sopenharmony_ci *
11362306a36Sopenharmony_ci *   union sctp_subtype foo = SCTP_ST_CHUNK(SCTP_CID_INIT);
11462306a36Sopenharmony_ci */
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ciunion sctp_subtype {
11762306a36Sopenharmony_ci	enum sctp_cid chunk;
11862306a36Sopenharmony_ci	enum sctp_event_timeout timeout;
11962306a36Sopenharmony_ci	enum sctp_event_other other;
12062306a36Sopenharmony_ci	enum sctp_event_primitive primitive;
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
12462306a36Sopenharmony_cistatic inline union sctp_subtype	\
12562306a36Sopenharmony_ciSCTP_ST_## _name (_type _arg)		\
12662306a36Sopenharmony_ci{ union sctp_subtype _retval; _retval._elt = _arg; return _retval; }
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(CHUNK,		enum sctp_cid,		chunk)
12962306a36Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT,	enum sctp_event_timeout, timeout)
13062306a36Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(OTHER,		enum sctp_event_other,	other)
13162306a36Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE,	enum sctp_event_primitive, primitive)
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA || \
13562306a36Sopenharmony_ci			       a->chunk_hdr->type == SCTP_CID_I_DATA)
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* Internal error codes */
13862306a36Sopenharmony_cienum sctp_ierror {
13962306a36Sopenharmony_ci	SCTP_IERROR_NO_ERROR	        = 0,
14062306a36Sopenharmony_ci	SCTP_IERROR_BASE		= 1000,
14162306a36Sopenharmony_ci	SCTP_IERROR_NO_COOKIE,
14262306a36Sopenharmony_ci	SCTP_IERROR_BAD_SIG,
14362306a36Sopenharmony_ci	SCTP_IERROR_STALE_COOKIE,
14462306a36Sopenharmony_ci	SCTP_IERROR_NOMEM,
14562306a36Sopenharmony_ci	SCTP_IERROR_MALFORMED,
14662306a36Sopenharmony_ci	SCTP_IERROR_BAD_TAG,
14762306a36Sopenharmony_ci	SCTP_IERROR_BIG_GAP,
14862306a36Sopenharmony_ci	SCTP_IERROR_DUP_TSN,
14962306a36Sopenharmony_ci	SCTP_IERROR_HIGH_TSN,
15062306a36Sopenharmony_ci	SCTP_IERROR_IGNORE_TSN,
15162306a36Sopenharmony_ci	SCTP_IERROR_NO_DATA,
15262306a36Sopenharmony_ci	SCTP_IERROR_BAD_STREAM,
15362306a36Sopenharmony_ci	SCTP_IERROR_BAD_PORTS,
15462306a36Sopenharmony_ci	SCTP_IERROR_AUTH_BAD_HMAC,
15562306a36Sopenharmony_ci	SCTP_IERROR_AUTH_BAD_KEYID,
15662306a36Sopenharmony_ci	SCTP_IERROR_PROTO_VIOLATION,
15762306a36Sopenharmony_ci	SCTP_IERROR_ERROR,
15862306a36Sopenharmony_ci	SCTP_IERROR_ABORT,
15962306a36Sopenharmony_ci};
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/* SCTP state defines for internal state machine */
16462306a36Sopenharmony_cienum sctp_state {
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci	SCTP_STATE_CLOSED		= 0,
16762306a36Sopenharmony_ci	SCTP_STATE_COOKIE_WAIT		= 1,
16862306a36Sopenharmony_ci	SCTP_STATE_COOKIE_ECHOED	= 2,
16962306a36Sopenharmony_ci	SCTP_STATE_ESTABLISHED		= 3,
17062306a36Sopenharmony_ci	SCTP_STATE_SHUTDOWN_PENDING	= 4,
17162306a36Sopenharmony_ci	SCTP_STATE_SHUTDOWN_SENT	= 5,
17262306a36Sopenharmony_ci	SCTP_STATE_SHUTDOWN_RECEIVED	= 6,
17362306a36Sopenharmony_ci	SCTP_STATE_SHUTDOWN_ACK_SENT	= 7,
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci};
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci#define SCTP_STATE_MAX			SCTP_STATE_SHUTDOWN_ACK_SENT
17862306a36Sopenharmony_ci#define SCTP_STATE_NUM_STATES		(SCTP_STATE_MAX + 1)
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci/* These are values for sk->state.
18162306a36Sopenharmony_ci * For a UDP-style SCTP socket, the states are defined as follows
18262306a36Sopenharmony_ci * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
18362306a36Sopenharmony_ci *   accept new associations, but it can initiate the creation of new ones.
18462306a36Sopenharmony_ci * - A socket in SCTP_SS_LISTENING state indicates that it is willing to
18562306a36Sopenharmony_ci *   accept new  associations and can initiate the creation of new ones.
18662306a36Sopenharmony_ci * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off
18762306a36Sopenharmony_ci *   socket with one association.
18862306a36Sopenharmony_ci * For a TCP-style SCTP socket, the states are defined as follows
18962306a36Sopenharmony_ci * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
19062306a36Sopenharmony_ci *   accept new associations, but it can initiate the creation of new ones.
19162306a36Sopenharmony_ci * - A socket in SCTP_SS_LISTENING state indicates that it is willing to
19262306a36Sopenharmony_ci *   accept new associations, but cannot initiate the creation of new ones.
19362306a36Sopenharmony_ci * - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single
19462306a36Sopenharmony_ci *   association.
19562306a36Sopenharmony_ci */
19662306a36Sopenharmony_cienum sctp_sock_state {
19762306a36Sopenharmony_ci	SCTP_SS_CLOSED         = TCP_CLOSE,
19862306a36Sopenharmony_ci	SCTP_SS_LISTENING      = TCP_LISTEN,
19962306a36Sopenharmony_ci	SCTP_SS_ESTABLISHING   = TCP_SYN_SENT,
20062306a36Sopenharmony_ci	SCTP_SS_ESTABLISHED    = TCP_ESTABLISHED,
20162306a36Sopenharmony_ci	SCTP_SS_CLOSING        = TCP_CLOSE_WAIT,
20262306a36Sopenharmony_ci};
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cienum sctp_plpmtud_state {
20562306a36Sopenharmony_ci	SCTP_PL_DISABLED,
20662306a36Sopenharmony_ci	SCTP_PL_BASE,
20762306a36Sopenharmony_ci	SCTP_PL_SEARCH,
20862306a36Sopenharmony_ci	SCTP_PL_COMPLETE,
20962306a36Sopenharmony_ci	SCTP_PL_ERROR,
21062306a36Sopenharmony_ci};
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci#define	SCTP_BASE_PLPMTU	1200
21362306a36Sopenharmony_ci#define	SCTP_MAX_PLPMTU		9000
21462306a36Sopenharmony_ci#define	SCTP_MIN_PLPMTU		512
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#define	SCTP_MAX_PROBES		3
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#define SCTP_PL_BIG_STEP	32
21962306a36Sopenharmony_ci#define SCTP_PL_MIN_STEP	4
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/* These functions map various type to printable names.  */
22262306a36Sopenharmony_ciconst char *sctp_cname(const union sctp_subtype id);	/* chunk types */
22362306a36Sopenharmony_ciconst char *sctp_oname(const union sctp_subtype id);	/* other events */
22462306a36Sopenharmony_ciconst char *sctp_tname(const union sctp_subtype id);	/* timeouts */
22562306a36Sopenharmony_ciconst char *sctp_pname(const union sctp_subtype id);	/* primitives */
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci/* This is a table of printable names of sctp_state_t's.  */
22862306a36Sopenharmony_ciextern const char *const sctp_state_tbl[];
22962306a36Sopenharmony_ciextern const char *const sctp_evttype_tbl[];
23062306a36Sopenharmony_ciextern const char *const sctp_status_tbl[];
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci/* Maximum chunk length considering padding requirements. */
23362306a36Sopenharmony_cienum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) };
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci/* Encourage Cookie-Echo bundling by pre-fragmenting chunks a little
23662306a36Sopenharmony_ci * harder (until reaching ESTABLISHED state).
23762306a36Sopenharmony_ci */
23862306a36Sopenharmony_cienum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/* Guess at how big to make the TSN mapping array.
24162306a36Sopenharmony_ci * We guarantee that we can handle at least this big a gap between the
24262306a36Sopenharmony_ci * cumulative ACK and the highest TSN.  In practice, we can often
24362306a36Sopenharmony_ci * handle up to twice this value.
24462306a36Sopenharmony_ci *
24562306a36Sopenharmony_ci * NEVER make this more than 32767 (2^15-1).  The Gap Ack Blocks in a
24662306a36Sopenharmony_ci * SACK (see  section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE
24762306a36Sopenharmony_ci * must be less than 65535 (2^16 - 1), or we will have overflow
24862306a36Sopenharmony_ci * problems creating SACK's.
24962306a36Sopenharmony_ci */
25062306a36Sopenharmony_ci#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
25162306a36Sopenharmony_ci#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
25262306a36Sopenharmony_ci#define SCTP_TSN_MAP_SIZE 4096
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* We will not record more than this many duplicate TSNs between two
25562306a36Sopenharmony_ci * SACKs.  The minimum PMTU is 512.  Remove all the headers and there
25662306a36Sopenharmony_ci * is enough room for 117 duplicate reports.  Round down to the
25762306a36Sopenharmony_ci * nearest power of 2.
25862306a36Sopenharmony_ci */
25962306a36Sopenharmony_cienum { SCTP_MAX_DUP_TSNS = 16 };
26062306a36Sopenharmony_cienum { SCTP_MAX_GABS = 16 };
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci/* Heartbeat interval - 30 secs */
26362306a36Sopenharmony_ci#define SCTP_DEFAULT_TIMEOUT_HEARTBEAT	(30*1000)
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci/* Delayed sack timer - 200ms */
26662306a36Sopenharmony_ci#define SCTP_DEFAULT_TIMEOUT_SACK	(200)
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci/* RTO.Initial              - 3  seconds
26962306a36Sopenharmony_ci * RTO.Min                  - 1  second
27062306a36Sopenharmony_ci * RTO.Max                  - 60 seconds
27162306a36Sopenharmony_ci * RTO.Alpha                - 1/8
27262306a36Sopenharmony_ci * RTO.Beta                 - 1/4
27362306a36Sopenharmony_ci */
27462306a36Sopenharmony_ci#define SCTP_RTO_INITIAL	(3 * 1000)
27562306a36Sopenharmony_ci#define SCTP_RTO_MIN		(1 * 1000)
27662306a36Sopenharmony_ci#define SCTP_RTO_MAX		(60 * 1000)
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci#define SCTP_RTO_ALPHA          3   /* 1/8 when converted to right shifts. */
27962306a36Sopenharmony_ci#define SCTP_RTO_BETA           2   /* 1/4 when converted to right shifts. */
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci/* Maximum number of new data packets that can be sent in a burst.  */
28262306a36Sopenharmony_ci#define SCTP_DEFAULT_MAX_BURST		4
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ci#define SCTP_CLOCK_GRANULARITY	1	/* 1 jiffy */
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci#define SCTP_DEFAULT_COOKIE_LIFE	(60 * 1000) /* 60 seconds */
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci#define SCTP_DEFAULT_MINWINDOW	1500	/* default minimum rwnd size */
28962306a36Sopenharmony_ci#define SCTP_DEFAULT_MAXWINDOW	65535	/* default rwnd size */
29062306a36Sopenharmony_ci#define SCTP_DEFAULT_RWND_SHIFT  4	/* by default, update on 1/16 of
29162306a36Sopenharmony_ci					 * rcvbuf, which is 1/8 of initial
29262306a36Sopenharmony_ci					 * window
29362306a36Sopenharmony_ci					 */
29462306a36Sopenharmony_ci#define SCTP_DEFAULT_MAXSEGMENT 1500	/* MTU size, this is the limit
29562306a36Sopenharmony_ci                                         * to which we will raise the P-MTU.
29662306a36Sopenharmony_ci					 */
29762306a36Sopenharmony_ci#define SCTP_DEFAULT_MINSEGMENT 512	/* MTU size ... if no mtu disc */
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci#define SCTP_SECRET_SIZE 32		/* Number of octets in a 256 bits. */
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci#define SCTP_SIGNATURE_SIZE 20	        /* size of a SLA-1 signature */
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci#define SCTP_COOKIE_MULTIPLE 32 /* Pad out our cookie to make our hash
30462306a36Sopenharmony_ci				 * functions simpler to write.
30562306a36Sopenharmony_ci				 */
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci#define SCTP_DEFAULT_UDP_PORT 9899	/* default UDP tunneling port */
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci/* These are the values for pf exposure, UNUSED is to keep compatible with old
31062306a36Sopenharmony_ci * applications by default.
31162306a36Sopenharmony_ci */
31262306a36Sopenharmony_cienum {
31362306a36Sopenharmony_ci	SCTP_PF_EXPOSE_UNSET,
31462306a36Sopenharmony_ci	SCTP_PF_EXPOSE_DISABLE,
31562306a36Sopenharmony_ci	SCTP_PF_EXPOSE_ENABLE,
31662306a36Sopenharmony_ci};
31762306a36Sopenharmony_ci#define SCTP_PF_EXPOSE_MAX	SCTP_PF_EXPOSE_ENABLE
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci#define SCTP_PS_RETRANS_MAX	0xffff
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/* These return values describe the success or failure of a number of
32262306a36Sopenharmony_ci * routines which form the lower interface to SCTP_outqueue.
32362306a36Sopenharmony_ci */
32462306a36Sopenharmony_cienum sctp_xmit {
32562306a36Sopenharmony_ci	SCTP_XMIT_OK,
32662306a36Sopenharmony_ci	SCTP_XMIT_PMTU_FULL,
32762306a36Sopenharmony_ci	SCTP_XMIT_RWND_FULL,
32862306a36Sopenharmony_ci	SCTP_XMIT_DELAY,
32962306a36Sopenharmony_ci};
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci/* These are the commands for manipulating transports.  */
33262306a36Sopenharmony_cienum sctp_transport_cmd {
33362306a36Sopenharmony_ci	SCTP_TRANSPORT_UP,
33462306a36Sopenharmony_ci	SCTP_TRANSPORT_DOWN,
33562306a36Sopenharmony_ci	SCTP_TRANSPORT_PF,
33662306a36Sopenharmony_ci};
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci/* These are the address scopes defined mainly for IPv4 addresses
33962306a36Sopenharmony_ci * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
34062306a36Sopenharmony_ci * These scopes are hopefully generic enough to be used on scoping both
34162306a36Sopenharmony_ci * IPv4 and IPv6 addresses in SCTP.
34262306a36Sopenharmony_ci * At this point, the IPv6 scopes will be mapped to these internal scopes
34362306a36Sopenharmony_ci * as much as possible.
34462306a36Sopenharmony_ci */
34562306a36Sopenharmony_cienum sctp_scope {
34662306a36Sopenharmony_ci	SCTP_SCOPE_GLOBAL,		/* IPv4 global addresses */
34762306a36Sopenharmony_ci	SCTP_SCOPE_PRIVATE,		/* IPv4 private addresses */
34862306a36Sopenharmony_ci	SCTP_SCOPE_LINK,		/* IPv4 link local address */
34962306a36Sopenharmony_ci	SCTP_SCOPE_LOOPBACK,		/* IPv4 loopback address */
35062306a36Sopenharmony_ci	SCTP_SCOPE_UNUSABLE,		/* IPv4 unusable addresses */
35162306a36Sopenharmony_ci};
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_cienum {
35462306a36Sopenharmony_ci	SCTP_SCOPE_POLICY_DISABLE,	/* Disable IPv4 address scoping */
35562306a36Sopenharmony_ci	SCTP_SCOPE_POLICY_ENABLE,	/* Enable IPv4 address scoping */
35662306a36Sopenharmony_ci	SCTP_SCOPE_POLICY_PRIVATE,	/* Follow draft but allow IPv4 private addresses */
35762306a36Sopenharmony_ci	SCTP_SCOPE_POLICY_LINK,		/* Follow draft but allow IPv4 link local addresses */
35862306a36Sopenharmony_ci};
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci#define SCTP_SCOPE_POLICY_MAX	SCTP_SCOPE_POLICY_LINK
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci/* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>,
36362306a36Sopenharmony_ci * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 192.88.99.0/24.
36462306a36Sopenharmony_ci * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
36562306a36Sopenharmony_ci * addresses.
36662306a36Sopenharmony_ci */
36762306a36Sopenharmony_ci#define IS_IPV4_UNUSABLE_ADDRESS(a)	    \
36862306a36Sopenharmony_ci	((htonl(INADDR_BROADCAST) == a) ||  \
36962306a36Sopenharmony_ci	 ipv4_is_multicast(a) ||	    \
37062306a36Sopenharmony_ci	 ipv4_is_zeronet(a) ||		    \
37162306a36Sopenharmony_ci	 ipv4_is_anycast_6to4(a))
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ci/* Flags used for the bind address copy functions.  */
37462306a36Sopenharmony_ci#define SCTP_ADDR4_ALLOWED	0x00000001	/* IPv4 address is allowed by
37562306a36Sopenharmony_ci						   local sock family */
37662306a36Sopenharmony_ci#define SCTP_ADDR6_ALLOWED	0x00000002	/* IPv6 address is allowed by
37762306a36Sopenharmony_ci						   local sock family */
37862306a36Sopenharmony_ci#define SCTP_ADDR4_PEERSUPP	0x00000004	/* IPv4 address is supported by
37962306a36Sopenharmony_ci						   peer */
38062306a36Sopenharmony_ci#define SCTP_ADDR6_PEERSUPP	0x00000008	/* IPv6 address is supported by
38162306a36Sopenharmony_ci						   peer */
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_ci/* Reasons to retransmit. */
38462306a36Sopenharmony_cienum sctp_retransmit_reason {
38562306a36Sopenharmony_ci	SCTP_RTXR_T3_RTX,
38662306a36Sopenharmony_ci	SCTP_RTXR_FAST_RTX,
38762306a36Sopenharmony_ci	SCTP_RTXR_PMTUD,
38862306a36Sopenharmony_ci	SCTP_RTXR_T1_RTX,
38962306a36Sopenharmony_ci};
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci/* Reasons to lower cwnd. */
39262306a36Sopenharmony_cienum sctp_lower_cwnd {
39362306a36Sopenharmony_ci	SCTP_LOWER_CWND_T3_RTX,
39462306a36Sopenharmony_ci	SCTP_LOWER_CWND_FAST_RTX,
39562306a36Sopenharmony_ci	SCTP_LOWER_CWND_ECNE,
39662306a36Sopenharmony_ci	SCTP_LOWER_CWND_INACTIVE,
39762306a36Sopenharmony_ci};
39862306a36Sopenharmony_ci
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_ci/* SCTP-AUTH Necessary constants */
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ci/* SCTP-AUTH, Section 3.3
40362306a36Sopenharmony_ci *
40462306a36Sopenharmony_ci *  The following Table 2 shows the currently defined values for HMAC
40562306a36Sopenharmony_ci *  identifiers.
40662306a36Sopenharmony_ci *
40762306a36Sopenharmony_ci *  +-----------------+--------------------------+
40862306a36Sopenharmony_ci *  | HMAC Identifier | Message Digest Algorithm |
40962306a36Sopenharmony_ci *  +-----------------+--------------------------+
41062306a36Sopenharmony_ci *  | 0               | Reserved                 |
41162306a36Sopenharmony_ci *  | 1               | SHA-1 defined in [8]     |
41262306a36Sopenharmony_ci *  | 2               | Reserved                 |
41362306a36Sopenharmony_ci *  | 3               | SHA-256 defined in [8]   |
41462306a36Sopenharmony_ci *  +-----------------+--------------------------+
41562306a36Sopenharmony_ci */
41662306a36Sopenharmony_cienum {
41762306a36Sopenharmony_ci	SCTP_AUTH_HMAC_ID_RESERVED_0,
41862306a36Sopenharmony_ci	SCTP_AUTH_HMAC_ID_SHA1,
41962306a36Sopenharmony_ci	SCTP_AUTH_HMAC_ID_RESERVED_2,
42062306a36Sopenharmony_ci#if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)
42162306a36Sopenharmony_ci	SCTP_AUTH_HMAC_ID_SHA256,
42262306a36Sopenharmony_ci#endif
42362306a36Sopenharmony_ci	__SCTP_AUTH_HMAC_MAX
42462306a36Sopenharmony_ci};
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci#define SCTP_AUTH_HMAC_ID_MAX	__SCTP_AUTH_HMAC_MAX - 1
42762306a36Sopenharmony_ci#define SCTP_AUTH_NUM_HMACS 	__SCTP_AUTH_HMAC_MAX
42862306a36Sopenharmony_ci#define SCTP_SHA1_SIG_SIZE 20
42962306a36Sopenharmony_ci#define SCTP_SHA256_SIG_SIZE 32
43062306a36Sopenharmony_ci
43162306a36Sopenharmony_ci/*  SCTP-AUTH, Section 3.2
43262306a36Sopenharmony_ci *     The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH chunks
43362306a36Sopenharmony_ci *     MUST NOT be listed in the CHUNKS parameter
43462306a36Sopenharmony_ci */
43562306a36Sopenharmony_ci#define SCTP_NUM_NOAUTH_CHUNKS	4
43662306a36Sopenharmony_ci#define SCTP_AUTH_MAX_CHUNKS	(SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS)
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci/* SCTP-AUTH Section 6.1
43962306a36Sopenharmony_ci * The RANDOM parameter MUST contain a 32 byte random number.
44062306a36Sopenharmony_ci */
44162306a36Sopenharmony_ci#define SCTP_AUTH_RANDOM_LENGTH 32
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci#define SCTP_PROBE_TIMER_MIN	5000
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci#endif /* __sctp_constants_h__ */
446