18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* SCTP kernel implementation 38c2ecf20Sopenharmony_ci * (C) Copyright IBM Corp. 2001, 2004 48c2ecf20Sopenharmony_ci * Copyright (c) 1999-2000 Cisco, Inc. 58c2ecf20Sopenharmony_ci * Copyright (c) 1999-2001 Motorola, Inc. 68c2ecf20Sopenharmony_ci * Copyright (c) 2001 Intel Corp. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is part of the SCTP kernel implementation 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Please send any bug reports or fixes you make to the 118c2ecf20Sopenharmony_ci * email address(es): 128c2ecf20Sopenharmony_ci * lksctp developers <linux-sctp@vger.kernel.org> 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Written or modified by: 158c2ecf20Sopenharmony_ci * La Monte H.P. Yarroll <piggy@acm.org> 168c2ecf20Sopenharmony_ci * Karl Knutson <karl@athena.chicago.il.us> 178c2ecf20Sopenharmony_ci * Randall Stewart <randall@stewart.chicago.il.us> 188c2ecf20Sopenharmony_ci * Ken Morneau <kmorneau@cisco.com> 198c2ecf20Sopenharmony_ci * Qiaobing Xie <qxie1@motorola.com> 208c2ecf20Sopenharmony_ci * Xingang Guo <xingang.guo@intel.com> 218c2ecf20Sopenharmony_ci * Sridhar Samudrala <samudrala@us.ibm.com> 228c2ecf20Sopenharmony_ci * Daisy Chang <daisyc@us.ibm.com> 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifndef __sctp_constants_h__ 268c2ecf20Sopenharmony_ci#define __sctp_constants_h__ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <linux/sctp.h> 298c2ecf20Sopenharmony_ci#include <linux/ipv6.h> /* For ipv6hdr. */ 308c2ecf20Sopenharmony_ci#include <net/tcp_states.h> /* For TCP states used in enum sctp_sock_state */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* Value used for stream negotiation. */ 338c2ecf20Sopenharmony_cienum { SCTP_MAX_STREAM = 0xffff }; 348c2ecf20Sopenharmony_cienum { SCTP_DEFAULT_OUTSTREAMS = 10 }; 358c2ecf20Sopenharmony_cienum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM }; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* Since CIDs are sparse, we need all four of the following 388c2ecf20Sopenharmony_ci * symbols. CIDs are dense through SCTP_CID_BASE_MAX. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci#define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define SCTP_NUM_ADDIP_CHUNK_TYPES 2 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define SCTP_NUM_PRSCTP_CHUNK_TYPES 1 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define SCTP_NUM_RECONF_CHUNK_TYPES 1 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define SCTP_NUM_AUTH_CHUNK_TYPES 1 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNK_TYPES + \ 538c2ecf20Sopenharmony_ci SCTP_NUM_ADDIP_CHUNK_TYPES +\ 548c2ecf20Sopenharmony_ci SCTP_NUM_PRSCTP_CHUNK_TYPES +\ 558c2ecf20Sopenharmony_ci SCTP_NUM_RECONF_CHUNK_TYPES +\ 568c2ecf20Sopenharmony_ci SCTP_NUM_AUTH_CHUNK_TYPES) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* These are the different flavours of event. */ 598c2ecf20Sopenharmony_cienum sctp_event_type { 608c2ecf20Sopenharmony_ci SCTP_EVENT_T_CHUNK = 1, 618c2ecf20Sopenharmony_ci SCTP_EVENT_T_TIMEOUT, 628c2ecf20Sopenharmony_ci SCTP_EVENT_T_OTHER, 638c2ecf20Sopenharmony_ci SCTP_EVENT_T_PRIMITIVE 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* As a convenience for the state machine, we append SCTP_EVENT_* and 678c2ecf20Sopenharmony_ci * SCTP_ULP_* to the list of possible chunks. 688c2ecf20Sopenharmony_ci */ 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cienum sctp_event_timeout { 718c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_NONE = 0, 728c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T1_COOKIE, 738c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T1_INIT, 748c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T2_SHUTDOWN, 758c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T3_RTX, 768c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T4_RTO, 778c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD, 788c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_HEARTBEAT, 798c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_RECONF, 808c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_SACK, 818c2ecf20Sopenharmony_ci SCTP_EVENT_TIMEOUT_AUTOCLOSE, 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define SCTP_EVENT_TIMEOUT_MAX SCTP_EVENT_TIMEOUT_AUTOCLOSE 858c2ecf20Sopenharmony_ci#define SCTP_NUM_TIMEOUT_TYPES (SCTP_EVENT_TIMEOUT_MAX + 1) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cienum sctp_event_other { 888c2ecf20Sopenharmony_ci SCTP_EVENT_NO_PENDING_TSN = 0, 898c2ecf20Sopenharmony_ci SCTP_EVENT_ICMP_PROTO_UNREACH, 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define SCTP_EVENT_OTHER_MAX SCTP_EVENT_ICMP_PROTO_UNREACH 938c2ecf20Sopenharmony_ci#define SCTP_NUM_OTHER_TYPES (SCTP_EVENT_OTHER_MAX + 1) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* These are primitive requests from the ULP. */ 968c2ecf20Sopenharmony_cienum sctp_event_primitive { 978c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_ASSOCIATE = 0, 988c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_SHUTDOWN, 998c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_ABORT, 1008c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_SEND, 1018c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_REQUESTHEARTBEAT, 1028c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_ASCONF, 1038c2ecf20Sopenharmony_ci SCTP_PRIMITIVE_RECONF, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_RECONF 1078c2ecf20Sopenharmony_ci#define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* We define here a utility type for manipulating subtypes. 1108c2ecf20Sopenharmony_ci * The subtype constructors all work like this: 1118c2ecf20Sopenharmony_ci * 1128c2ecf20Sopenharmony_ci * union sctp_subtype foo = SCTP_ST_CHUNK(SCTP_CID_INIT); 1138c2ecf20Sopenharmony_ci */ 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ciunion sctp_subtype { 1168c2ecf20Sopenharmony_ci enum sctp_cid chunk; 1178c2ecf20Sopenharmony_ci enum sctp_event_timeout timeout; 1188c2ecf20Sopenharmony_ci enum sctp_event_other other; 1198c2ecf20Sopenharmony_ci enum sctp_event_primitive primitive; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ 1238c2ecf20Sopenharmony_cistatic inline union sctp_subtype \ 1248c2ecf20Sopenharmony_ciSCTP_ST_## _name (_type _arg) \ 1258c2ecf20Sopenharmony_ci{ union sctp_subtype _retval; _retval._elt = _arg; return _retval; } 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(CHUNK, enum sctp_cid, chunk) 1288c2ecf20Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, enum sctp_event_timeout, timeout) 1298c2ecf20Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(OTHER, enum sctp_event_other, other) 1308c2ecf20Sopenharmony_ciSCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, enum sctp_event_primitive, primitive) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA || \ 1348c2ecf20Sopenharmony_ci a->chunk_hdr->type == SCTP_CID_I_DATA) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* Internal error codes */ 1378c2ecf20Sopenharmony_cienum sctp_ierror { 1388c2ecf20Sopenharmony_ci SCTP_IERROR_NO_ERROR = 0, 1398c2ecf20Sopenharmony_ci SCTP_IERROR_BASE = 1000, 1408c2ecf20Sopenharmony_ci SCTP_IERROR_NO_COOKIE, 1418c2ecf20Sopenharmony_ci SCTP_IERROR_BAD_SIG, 1428c2ecf20Sopenharmony_ci SCTP_IERROR_STALE_COOKIE, 1438c2ecf20Sopenharmony_ci SCTP_IERROR_NOMEM, 1448c2ecf20Sopenharmony_ci SCTP_IERROR_MALFORMED, 1458c2ecf20Sopenharmony_ci SCTP_IERROR_BAD_TAG, 1468c2ecf20Sopenharmony_ci SCTP_IERROR_BIG_GAP, 1478c2ecf20Sopenharmony_ci SCTP_IERROR_DUP_TSN, 1488c2ecf20Sopenharmony_ci SCTP_IERROR_HIGH_TSN, 1498c2ecf20Sopenharmony_ci SCTP_IERROR_IGNORE_TSN, 1508c2ecf20Sopenharmony_ci SCTP_IERROR_NO_DATA, 1518c2ecf20Sopenharmony_ci SCTP_IERROR_BAD_STREAM, 1528c2ecf20Sopenharmony_ci SCTP_IERROR_BAD_PORTS, 1538c2ecf20Sopenharmony_ci SCTP_IERROR_AUTH_BAD_HMAC, 1548c2ecf20Sopenharmony_ci SCTP_IERROR_AUTH_BAD_KEYID, 1558c2ecf20Sopenharmony_ci SCTP_IERROR_PROTO_VIOLATION, 1568c2ecf20Sopenharmony_ci SCTP_IERROR_ERROR, 1578c2ecf20Sopenharmony_ci SCTP_IERROR_ABORT, 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/* SCTP state defines for internal state machine */ 1638c2ecf20Sopenharmony_cienum sctp_state { 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci SCTP_STATE_CLOSED = 0, 1668c2ecf20Sopenharmony_ci SCTP_STATE_COOKIE_WAIT = 1, 1678c2ecf20Sopenharmony_ci SCTP_STATE_COOKIE_ECHOED = 2, 1688c2ecf20Sopenharmony_ci SCTP_STATE_ESTABLISHED = 3, 1698c2ecf20Sopenharmony_ci SCTP_STATE_SHUTDOWN_PENDING = 4, 1708c2ecf20Sopenharmony_ci SCTP_STATE_SHUTDOWN_SENT = 5, 1718c2ecf20Sopenharmony_ci SCTP_STATE_SHUTDOWN_RECEIVED = 6, 1728c2ecf20Sopenharmony_ci SCTP_STATE_SHUTDOWN_ACK_SENT = 7, 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT 1778c2ecf20Sopenharmony_ci#define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1) 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* These are values for sk->state. 1808c2ecf20Sopenharmony_ci * For a UDP-style SCTP socket, the states are defined as follows 1818c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 1828c2ecf20Sopenharmony_ci * accept new associations, but it can initiate the creation of new ones. 1838c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 1848c2ecf20Sopenharmony_ci * accept new associations and can initiate the creation of new ones. 1858c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off 1868c2ecf20Sopenharmony_ci * socket with one association. 1878c2ecf20Sopenharmony_ci * For a TCP-style SCTP socket, the states are defined as follows 1888c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 1898c2ecf20Sopenharmony_ci * accept new associations, but it can initiate the creation of new ones. 1908c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 1918c2ecf20Sopenharmony_ci * accept new associations, but cannot initiate the creation of new ones. 1928c2ecf20Sopenharmony_ci * - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single 1938c2ecf20Sopenharmony_ci * association. 1948c2ecf20Sopenharmony_ci */ 1958c2ecf20Sopenharmony_cienum sctp_sock_state { 1968c2ecf20Sopenharmony_ci SCTP_SS_CLOSED = TCP_CLOSE, 1978c2ecf20Sopenharmony_ci SCTP_SS_LISTENING = TCP_LISTEN, 1988c2ecf20Sopenharmony_ci SCTP_SS_ESTABLISHING = TCP_SYN_SENT, 1998c2ecf20Sopenharmony_ci SCTP_SS_ESTABLISHED = TCP_ESTABLISHED, 2008c2ecf20Sopenharmony_ci SCTP_SS_CLOSING = TCP_CLOSE_WAIT, 2018c2ecf20Sopenharmony_ci}; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci/* These functions map various type to printable names. */ 2048c2ecf20Sopenharmony_ciconst char *sctp_cname(const union sctp_subtype id); /* chunk types */ 2058c2ecf20Sopenharmony_ciconst char *sctp_oname(const union sctp_subtype id); /* other events */ 2068c2ecf20Sopenharmony_ciconst char *sctp_tname(const union sctp_subtype id); /* timeouts */ 2078c2ecf20Sopenharmony_ciconst char *sctp_pname(const union sctp_subtype id); /* primitives */ 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci/* This is a table of printable names of sctp_state_t's. */ 2108c2ecf20Sopenharmony_ciextern const char *const sctp_state_tbl[]; 2118c2ecf20Sopenharmony_ciextern const char *const sctp_evttype_tbl[]; 2128c2ecf20Sopenharmony_ciextern const char *const sctp_status_tbl[]; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* Maximum chunk length considering padding requirements. */ 2158c2ecf20Sopenharmony_cienum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) }; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* Encourage Cookie-Echo bundling by pre-fragmenting chunks a little 2188c2ecf20Sopenharmony_ci * harder (until reaching ESTABLISHED state). 2198c2ecf20Sopenharmony_ci */ 2208c2ecf20Sopenharmony_cienum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 }; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci/* Guess at how big to make the TSN mapping array. 2238c2ecf20Sopenharmony_ci * We guarantee that we can handle at least this big a gap between the 2248c2ecf20Sopenharmony_ci * cumulative ACK and the highest TSN. In practice, we can often 2258c2ecf20Sopenharmony_ci * handle up to twice this value. 2268c2ecf20Sopenharmony_ci * 2278c2ecf20Sopenharmony_ci * NEVER make this more than 32767 (2^15-1). The Gap Ack Blocks in a 2288c2ecf20Sopenharmony_ci * SACK (see section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE 2298c2ecf20Sopenharmony_ci * must be less than 65535 (2^16 - 1), or we will have overflow 2308c2ecf20Sopenharmony_ci * problems creating SACK's. 2318c2ecf20Sopenharmony_ci */ 2328c2ecf20Sopenharmony_ci#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG 2338c2ecf20Sopenharmony_ci#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL 2348c2ecf20Sopenharmony_ci#define SCTP_TSN_MAP_SIZE 4096 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/* We will not record more than this many duplicate TSNs between two 2378c2ecf20Sopenharmony_ci * SACKs. The minimum PMTU is 512. Remove all the headers and there 2388c2ecf20Sopenharmony_ci * is enough room for 117 duplicate reports. Round down to the 2398c2ecf20Sopenharmony_ci * nearest power of 2. 2408c2ecf20Sopenharmony_ci */ 2418c2ecf20Sopenharmony_cienum { SCTP_MAX_DUP_TSNS = 16 }; 2428c2ecf20Sopenharmony_cienum { SCTP_MAX_GABS = 16 }; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* Heartbeat interval - 30 secs */ 2458c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_TIMEOUT_HEARTBEAT (30*1000) 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* Delayed sack timer - 200ms */ 2488c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_TIMEOUT_SACK (200) 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci/* RTO.Initial - 3 seconds 2518c2ecf20Sopenharmony_ci * RTO.Min - 1 second 2528c2ecf20Sopenharmony_ci * RTO.Max - 60 seconds 2538c2ecf20Sopenharmony_ci * RTO.Alpha - 1/8 2548c2ecf20Sopenharmony_ci * RTO.Beta - 1/4 2558c2ecf20Sopenharmony_ci */ 2568c2ecf20Sopenharmony_ci#define SCTP_RTO_INITIAL (3 * 1000) 2578c2ecf20Sopenharmony_ci#define SCTP_RTO_MIN (1 * 1000) 2588c2ecf20Sopenharmony_ci#define SCTP_RTO_MAX (60 * 1000) 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci#define SCTP_RTO_ALPHA 3 /* 1/8 when converted to right shifts. */ 2618c2ecf20Sopenharmony_ci#define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci/* Maximum number of new data packets that can be sent in a burst. */ 2648c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_MAX_BURST 4 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci#define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ 2718c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_MAXWINDOW 65535 /* default rwnd size */ 2728c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_RWND_SHIFT 4 /* by default, update on 1/16 of 2738c2ecf20Sopenharmony_ci * rcvbuf, which is 1/8 of initial 2748c2ecf20Sopenharmony_ci * window 2758c2ecf20Sopenharmony_ci */ 2768c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the limit 2778c2ecf20Sopenharmony_ci * to which we will raise the P-MTU. 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_ci#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci#define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci#define SCTP_COOKIE_MULTIPLE 32 /* Pad out our cookie to make our hash 2868c2ecf20Sopenharmony_ci * functions simpler to write. 2878c2ecf20Sopenharmony_ci */ 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci/* These are the values for pf exposure, UNUSED is to keep compatible with old 2908c2ecf20Sopenharmony_ci * applications by default. 2918c2ecf20Sopenharmony_ci */ 2928c2ecf20Sopenharmony_cienum { 2938c2ecf20Sopenharmony_ci SCTP_PF_EXPOSE_UNSET, 2948c2ecf20Sopenharmony_ci SCTP_PF_EXPOSE_DISABLE, 2958c2ecf20Sopenharmony_ci SCTP_PF_EXPOSE_ENABLE, 2968c2ecf20Sopenharmony_ci}; 2978c2ecf20Sopenharmony_ci#define SCTP_PF_EXPOSE_MAX SCTP_PF_EXPOSE_ENABLE 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci#define SCTP_PS_RETRANS_MAX 0xffff 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci/* These return values describe the success or failure of a number of 3028c2ecf20Sopenharmony_ci * routines which form the lower interface to SCTP_outqueue. 3038c2ecf20Sopenharmony_ci */ 3048c2ecf20Sopenharmony_cienum sctp_xmit { 3058c2ecf20Sopenharmony_ci SCTP_XMIT_OK, 3068c2ecf20Sopenharmony_ci SCTP_XMIT_PMTU_FULL, 3078c2ecf20Sopenharmony_ci SCTP_XMIT_RWND_FULL, 3088c2ecf20Sopenharmony_ci SCTP_XMIT_DELAY, 3098c2ecf20Sopenharmony_ci}; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci/* These are the commands for manipulating transports. */ 3128c2ecf20Sopenharmony_cienum sctp_transport_cmd { 3138c2ecf20Sopenharmony_ci SCTP_TRANSPORT_UP, 3148c2ecf20Sopenharmony_ci SCTP_TRANSPORT_DOWN, 3158c2ecf20Sopenharmony_ci SCTP_TRANSPORT_PF, 3168c2ecf20Sopenharmony_ci}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/* These are the address scopes defined mainly for IPv4 addresses 3198c2ecf20Sopenharmony_ci * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>. 3208c2ecf20Sopenharmony_ci * These scopes are hopefully generic enough to be used on scoping both 3218c2ecf20Sopenharmony_ci * IPv4 and IPv6 addresses in SCTP. 3228c2ecf20Sopenharmony_ci * At this point, the IPv6 scopes will be mapped to these internal scopes 3238c2ecf20Sopenharmony_ci * as much as possible. 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_cienum sctp_scope { 3268c2ecf20Sopenharmony_ci SCTP_SCOPE_GLOBAL, /* IPv4 global addresses */ 3278c2ecf20Sopenharmony_ci SCTP_SCOPE_PRIVATE, /* IPv4 private addresses */ 3288c2ecf20Sopenharmony_ci SCTP_SCOPE_LINK, /* IPv4 link local address */ 3298c2ecf20Sopenharmony_ci SCTP_SCOPE_LOOPBACK, /* IPv4 loopback address */ 3308c2ecf20Sopenharmony_ci SCTP_SCOPE_UNUSABLE, /* IPv4 unusable addresses */ 3318c2ecf20Sopenharmony_ci}; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_cienum { 3348c2ecf20Sopenharmony_ci SCTP_SCOPE_POLICY_DISABLE, /* Disable IPv4 address scoping */ 3358c2ecf20Sopenharmony_ci SCTP_SCOPE_POLICY_ENABLE, /* Enable IPv4 address scoping */ 3368c2ecf20Sopenharmony_ci SCTP_SCOPE_POLICY_PRIVATE, /* Follow draft but allow IPv4 private addresses */ 3378c2ecf20Sopenharmony_ci SCTP_SCOPE_POLICY_LINK, /* Follow draft but allow IPv4 link local addresses */ 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci#define SCTP_SCOPE_POLICY_MAX SCTP_SCOPE_POLICY_LINK 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci/* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>, 3438c2ecf20Sopenharmony_ci * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 192.88.99.0/24. 3448c2ecf20Sopenharmony_ci * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP 3458c2ecf20Sopenharmony_ci * addresses. 3468c2ecf20Sopenharmony_ci */ 3478c2ecf20Sopenharmony_ci#define IS_IPV4_UNUSABLE_ADDRESS(a) \ 3488c2ecf20Sopenharmony_ci ((htonl(INADDR_BROADCAST) == a) || \ 3498c2ecf20Sopenharmony_ci ipv4_is_multicast(a) || \ 3508c2ecf20Sopenharmony_ci ipv4_is_zeronet(a) || \ 3518c2ecf20Sopenharmony_ci ipv4_is_anycast_6to4(a)) 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci/* Flags used for the bind address copy functions. */ 3548c2ecf20Sopenharmony_ci#define SCTP_ADDR4_ALLOWED 0x00000001 /* IPv4 address is allowed by 3558c2ecf20Sopenharmony_ci local sock family */ 3568c2ecf20Sopenharmony_ci#define SCTP_ADDR6_ALLOWED 0x00000002 /* IPv6 address is allowed by 3578c2ecf20Sopenharmony_ci local sock family */ 3588c2ecf20Sopenharmony_ci#define SCTP_ADDR4_PEERSUPP 0x00000004 /* IPv4 address is supported by 3598c2ecf20Sopenharmony_ci peer */ 3608c2ecf20Sopenharmony_ci#define SCTP_ADDR6_PEERSUPP 0x00000008 /* IPv6 address is supported by 3618c2ecf20Sopenharmony_ci peer */ 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci/* Reasons to retransmit. */ 3648c2ecf20Sopenharmony_cienum sctp_retransmit_reason { 3658c2ecf20Sopenharmony_ci SCTP_RTXR_T3_RTX, 3668c2ecf20Sopenharmony_ci SCTP_RTXR_FAST_RTX, 3678c2ecf20Sopenharmony_ci SCTP_RTXR_PMTUD, 3688c2ecf20Sopenharmony_ci SCTP_RTXR_T1_RTX, 3698c2ecf20Sopenharmony_ci}; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* Reasons to lower cwnd. */ 3728c2ecf20Sopenharmony_cienum sctp_lower_cwnd { 3738c2ecf20Sopenharmony_ci SCTP_LOWER_CWND_T3_RTX, 3748c2ecf20Sopenharmony_ci SCTP_LOWER_CWND_FAST_RTX, 3758c2ecf20Sopenharmony_ci SCTP_LOWER_CWND_ECNE, 3768c2ecf20Sopenharmony_ci SCTP_LOWER_CWND_INACTIVE, 3778c2ecf20Sopenharmony_ci}; 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci/* SCTP-AUTH Necessary constants */ 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* SCTP-AUTH, Section 3.3 3838c2ecf20Sopenharmony_ci * 3848c2ecf20Sopenharmony_ci * The following Table 2 shows the currently defined values for HMAC 3858c2ecf20Sopenharmony_ci * identifiers. 3868c2ecf20Sopenharmony_ci * 3878c2ecf20Sopenharmony_ci * +-----------------+--------------------------+ 3888c2ecf20Sopenharmony_ci * | HMAC Identifier | Message Digest Algorithm | 3898c2ecf20Sopenharmony_ci * +-----------------+--------------------------+ 3908c2ecf20Sopenharmony_ci * | 0 | Reserved | 3918c2ecf20Sopenharmony_ci * | 1 | SHA-1 defined in [8] | 3928c2ecf20Sopenharmony_ci * | 2 | Reserved | 3938c2ecf20Sopenharmony_ci * | 3 | SHA-256 defined in [8] | 3948c2ecf20Sopenharmony_ci * +-----------------+--------------------------+ 3958c2ecf20Sopenharmony_ci */ 3968c2ecf20Sopenharmony_cienum { 3978c2ecf20Sopenharmony_ci SCTP_AUTH_HMAC_ID_RESERVED_0, 3988c2ecf20Sopenharmony_ci SCTP_AUTH_HMAC_ID_SHA1, 3998c2ecf20Sopenharmony_ci SCTP_AUTH_HMAC_ID_RESERVED_2, 4008c2ecf20Sopenharmony_ci#if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE) 4018c2ecf20Sopenharmony_ci SCTP_AUTH_HMAC_ID_SHA256, 4028c2ecf20Sopenharmony_ci#endif 4038c2ecf20Sopenharmony_ci __SCTP_AUTH_HMAC_MAX 4048c2ecf20Sopenharmony_ci}; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci#define SCTP_AUTH_HMAC_ID_MAX __SCTP_AUTH_HMAC_MAX - 1 4078c2ecf20Sopenharmony_ci#define SCTP_AUTH_NUM_HMACS __SCTP_AUTH_HMAC_MAX 4088c2ecf20Sopenharmony_ci#define SCTP_SHA1_SIG_SIZE 20 4098c2ecf20Sopenharmony_ci#define SCTP_SHA256_SIG_SIZE 32 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci/* SCTP-AUTH, Section 3.2 4128c2ecf20Sopenharmony_ci * The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH chunks 4138c2ecf20Sopenharmony_ci * MUST NOT be listed in the CHUNKS parameter 4148c2ecf20Sopenharmony_ci */ 4158c2ecf20Sopenharmony_ci#define SCTP_NUM_NOAUTH_CHUNKS 4 4168c2ecf20Sopenharmony_ci#define SCTP_AUTH_MAX_CHUNKS (SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS) 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/* SCTP-AUTH Section 6.1 4198c2ecf20Sopenharmony_ci * The RANDOM parameter MUST contain a 32 byte random number. 4208c2ecf20Sopenharmony_ci */ 4218c2ecf20Sopenharmony_ci#define SCTP_AUTH_RANDOM_LENGTH 32 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci#endif /* __sctp_constants_h__ */ 424