1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* SCTP kernel implementation 3*4882a593Smuzhiyun * (C) Copyright IBM Corp. 2001, 2004 4*4882a593Smuzhiyun * Copyright (c) 1999-2000 Cisco, Inc. 5*4882a593Smuzhiyun * Copyright (c) 1999-2001 Motorola, Inc. 6*4882a593Smuzhiyun * Copyright (c) 2001 Intel Corp. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * This file is part of the SCTP kernel implementation 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Please send any bug reports or fixes you make to the 11*4882a593Smuzhiyun * email address(es): 12*4882a593Smuzhiyun * lksctp developers <linux-sctp@vger.kernel.org> 13*4882a593Smuzhiyun * 14*4882a593Smuzhiyun * Written or modified by: 15*4882a593Smuzhiyun * La Monte H.P. Yarroll <piggy@acm.org> 16*4882a593Smuzhiyun * Karl Knutson <karl@athena.chicago.il.us> 17*4882a593Smuzhiyun * Randall Stewart <randall@stewart.chicago.il.us> 18*4882a593Smuzhiyun * Ken Morneau <kmorneau@cisco.com> 19*4882a593Smuzhiyun * Qiaobing Xie <qxie1@motorola.com> 20*4882a593Smuzhiyun * Xingang Guo <xingang.guo@intel.com> 21*4882a593Smuzhiyun * Sridhar Samudrala <samudrala@us.ibm.com> 22*4882a593Smuzhiyun * Daisy Chang <daisyc@us.ibm.com> 23*4882a593Smuzhiyun */ 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun #ifndef __sctp_constants_h__ 26*4882a593Smuzhiyun #define __sctp_constants_h__ 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun #include <linux/sctp.h> 29*4882a593Smuzhiyun #include <linux/ipv6.h> /* For ipv6hdr. */ 30*4882a593Smuzhiyun #include <net/tcp_states.h> /* For TCP states used in enum sctp_sock_state */ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* Value used for stream negotiation. */ 33*4882a593Smuzhiyun enum { SCTP_MAX_STREAM = 0xffff }; 34*4882a593Smuzhiyun enum { SCTP_DEFAULT_OUTSTREAMS = 10 }; 35*4882a593Smuzhiyun enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM }; 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun /* Since CIDs are sparse, we need all four of the following 38*4882a593Smuzhiyun * symbols. CIDs are dense through SCTP_CID_BASE_MAX. 39*4882a593Smuzhiyun */ 40*4882a593Smuzhiyun #define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun #define SCTP_NUM_ADDIP_CHUNK_TYPES 2 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #define SCTP_NUM_PRSCTP_CHUNK_TYPES 1 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #define SCTP_NUM_RECONF_CHUNK_TYPES 1 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun #define SCTP_NUM_AUTH_CHUNK_TYPES 1 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun #define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNK_TYPES + \ 53*4882a593Smuzhiyun SCTP_NUM_ADDIP_CHUNK_TYPES +\ 54*4882a593Smuzhiyun SCTP_NUM_PRSCTP_CHUNK_TYPES +\ 55*4882a593Smuzhiyun SCTP_NUM_RECONF_CHUNK_TYPES +\ 56*4882a593Smuzhiyun SCTP_NUM_AUTH_CHUNK_TYPES) 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* These are the different flavours of event. */ 59*4882a593Smuzhiyun enum sctp_event_type { 60*4882a593Smuzhiyun SCTP_EVENT_T_CHUNK = 1, 61*4882a593Smuzhiyun SCTP_EVENT_T_TIMEOUT, 62*4882a593Smuzhiyun SCTP_EVENT_T_OTHER, 63*4882a593Smuzhiyun SCTP_EVENT_T_PRIMITIVE 64*4882a593Smuzhiyun }; 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* As a convenience for the state machine, we append SCTP_EVENT_* and 67*4882a593Smuzhiyun * SCTP_ULP_* to the list of possible chunks. 68*4882a593Smuzhiyun */ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun enum sctp_event_timeout { 71*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_NONE = 0, 72*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T1_COOKIE, 73*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T1_INIT, 74*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T2_SHUTDOWN, 75*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T3_RTX, 76*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T4_RTO, 77*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD, 78*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_HEARTBEAT, 79*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_RECONF, 80*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_SACK, 81*4882a593Smuzhiyun SCTP_EVENT_TIMEOUT_AUTOCLOSE, 82*4882a593Smuzhiyun }; 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun #define SCTP_EVENT_TIMEOUT_MAX SCTP_EVENT_TIMEOUT_AUTOCLOSE 85*4882a593Smuzhiyun #define SCTP_NUM_TIMEOUT_TYPES (SCTP_EVENT_TIMEOUT_MAX + 1) 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun enum sctp_event_other { 88*4882a593Smuzhiyun SCTP_EVENT_NO_PENDING_TSN = 0, 89*4882a593Smuzhiyun SCTP_EVENT_ICMP_PROTO_UNREACH, 90*4882a593Smuzhiyun }; 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun #define SCTP_EVENT_OTHER_MAX SCTP_EVENT_ICMP_PROTO_UNREACH 93*4882a593Smuzhiyun #define SCTP_NUM_OTHER_TYPES (SCTP_EVENT_OTHER_MAX + 1) 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun /* These are primitive requests from the ULP. */ 96*4882a593Smuzhiyun enum sctp_event_primitive { 97*4882a593Smuzhiyun SCTP_PRIMITIVE_ASSOCIATE = 0, 98*4882a593Smuzhiyun SCTP_PRIMITIVE_SHUTDOWN, 99*4882a593Smuzhiyun SCTP_PRIMITIVE_ABORT, 100*4882a593Smuzhiyun SCTP_PRIMITIVE_SEND, 101*4882a593Smuzhiyun SCTP_PRIMITIVE_REQUESTHEARTBEAT, 102*4882a593Smuzhiyun SCTP_PRIMITIVE_ASCONF, 103*4882a593Smuzhiyun SCTP_PRIMITIVE_RECONF, 104*4882a593Smuzhiyun }; 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun #define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_RECONF 107*4882a593Smuzhiyun #define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1) 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun /* We define here a utility type for manipulating subtypes. 110*4882a593Smuzhiyun * The subtype constructors all work like this: 111*4882a593Smuzhiyun * 112*4882a593Smuzhiyun * union sctp_subtype foo = SCTP_ST_CHUNK(SCTP_CID_INIT); 113*4882a593Smuzhiyun */ 114*4882a593Smuzhiyun 115*4882a593Smuzhiyun union sctp_subtype { 116*4882a593Smuzhiyun enum sctp_cid chunk; 117*4882a593Smuzhiyun enum sctp_event_timeout timeout; 118*4882a593Smuzhiyun enum sctp_event_other other; 119*4882a593Smuzhiyun enum sctp_event_primitive primitive; 120*4882a593Smuzhiyun }; 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ 123*4882a593Smuzhiyun static inline union sctp_subtype \ 124*4882a593Smuzhiyun SCTP_ST_## _name (_type _arg) \ 125*4882a593Smuzhiyun { union sctp_subtype _retval; _retval._elt = _arg; return _retval; } 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, enum sctp_cid, chunk) 128*4882a593Smuzhiyun SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, enum sctp_event_timeout, timeout) 129*4882a593Smuzhiyun SCTP_SUBTYPE_CONSTRUCTOR(OTHER, enum sctp_event_other, other) 130*4882a593Smuzhiyun SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, enum sctp_event_primitive, primitive) 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun #define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA || \ 134*4882a593Smuzhiyun a->chunk_hdr->type == SCTP_CID_I_DATA) 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun /* Internal error codes */ 137*4882a593Smuzhiyun enum sctp_ierror { 138*4882a593Smuzhiyun SCTP_IERROR_NO_ERROR = 0, 139*4882a593Smuzhiyun SCTP_IERROR_BASE = 1000, 140*4882a593Smuzhiyun SCTP_IERROR_NO_COOKIE, 141*4882a593Smuzhiyun SCTP_IERROR_BAD_SIG, 142*4882a593Smuzhiyun SCTP_IERROR_STALE_COOKIE, 143*4882a593Smuzhiyun SCTP_IERROR_NOMEM, 144*4882a593Smuzhiyun SCTP_IERROR_MALFORMED, 145*4882a593Smuzhiyun SCTP_IERROR_BAD_TAG, 146*4882a593Smuzhiyun SCTP_IERROR_BIG_GAP, 147*4882a593Smuzhiyun SCTP_IERROR_DUP_TSN, 148*4882a593Smuzhiyun SCTP_IERROR_HIGH_TSN, 149*4882a593Smuzhiyun SCTP_IERROR_IGNORE_TSN, 150*4882a593Smuzhiyun SCTP_IERROR_NO_DATA, 151*4882a593Smuzhiyun SCTP_IERROR_BAD_STREAM, 152*4882a593Smuzhiyun SCTP_IERROR_BAD_PORTS, 153*4882a593Smuzhiyun SCTP_IERROR_AUTH_BAD_HMAC, 154*4882a593Smuzhiyun SCTP_IERROR_AUTH_BAD_KEYID, 155*4882a593Smuzhiyun SCTP_IERROR_PROTO_VIOLATION, 156*4882a593Smuzhiyun SCTP_IERROR_ERROR, 157*4882a593Smuzhiyun SCTP_IERROR_ABORT, 158*4882a593Smuzhiyun }; 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun /* SCTP state defines for internal state machine */ 163*4882a593Smuzhiyun enum sctp_state { 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun SCTP_STATE_CLOSED = 0, 166*4882a593Smuzhiyun SCTP_STATE_COOKIE_WAIT = 1, 167*4882a593Smuzhiyun SCTP_STATE_COOKIE_ECHOED = 2, 168*4882a593Smuzhiyun SCTP_STATE_ESTABLISHED = 3, 169*4882a593Smuzhiyun SCTP_STATE_SHUTDOWN_PENDING = 4, 170*4882a593Smuzhiyun SCTP_STATE_SHUTDOWN_SENT = 5, 171*4882a593Smuzhiyun SCTP_STATE_SHUTDOWN_RECEIVED = 6, 172*4882a593Smuzhiyun SCTP_STATE_SHUTDOWN_ACK_SENT = 7, 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun }; 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun #define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT 177*4882a593Smuzhiyun #define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1) 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun /* These are values for sk->state. 180*4882a593Smuzhiyun * For a UDP-style SCTP socket, the states are defined as follows 181*4882a593Smuzhiyun * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 182*4882a593Smuzhiyun * accept new associations, but it can initiate the creation of new ones. 183*4882a593Smuzhiyun * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 184*4882a593Smuzhiyun * accept new associations and can initiate the creation of new ones. 185*4882a593Smuzhiyun * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off 186*4882a593Smuzhiyun * socket with one association. 187*4882a593Smuzhiyun * For a TCP-style SCTP socket, the states are defined as follows 188*4882a593Smuzhiyun * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to 189*4882a593Smuzhiyun * accept new associations, but it can initiate the creation of new ones. 190*4882a593Smuzhiyun * - A socket in SCTP_SS_LISTENING state indicates that it is willing to 191*4882a593Smuzhiyun * accept new associations, but cannot initiate the creation of new ones. 192*4882a593Smuzhiyun * - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single 193*4882a593Smuzhiyun * association. 194*4882a593Smuzhiyun */ 195*4882a593Smuzhiyun enum sctp_sock_state { 196*4882a593Smuzhiyun SCTP_SS_CLOSED = TCP_CLOSE, 197*4882a593Smuzhiyun SCTP_SS_LISTENING = TCP_LISTEN, 198*4882a593Smuzhiyun SCTP_SS_ESTABLISHING = TCP_SYN_SENT, 199*4882a593Smuzhiyun SCTP_SS_ESTABLISHED = TCP_ESTABLISHED, 200*4882a593Smuzhiyun SCTP_SS_CLOSING = TCP_CLOSE_WAIT, 201*4882a593Smuzhiyun }; 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun /* These functions map various type to printable names. */ 204*4882a593Smuzhiyun const char *sctp_cname(const union sctp_subtype id); /* chunk types */ 205*4882a593Smuzhiyun const char *sctp_oname(const union sctp_subtype id); /* other events */ 206*4882a593Smuzhiyun const char *sctp_tname(const union sctp_subtype id); /* timeouts */ 207*4882a593Smuzhiyun const char *sctp_pname(const union sctp_subtype id); /* primitives */ 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun /* This is a table of printable names of sctp_state_t's. */ 210*4882a593Smuzhiyun extern const char *const sctp_state_tbl[]; 211*4882a593Smuzhiyun extern const char *const sctp_evttype_tbl[]; 212*4882a593Smuzhiyun extern const char *const sctp_status_tbl[]; 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun /* Maximum chunk length considering padding requirements. */ 215*4882a593Smuzhiyun enum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) }; 216*4882a593Smuzhiyun 217*4882a593Smuzhiyun /* Encourage Cookie-Echo bundling by pre-fragmenting chunks a little 218*4882a593Smuzhiyun * harder (until reaching ESTABLISHED state). 219*4882a593Smuzhiyun */ 220*4882a593Smuzhiyun enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 }; 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun /* Guess at how big to make the TSN mapping array. 223*4882a593Smuzhiyun * We guarantee that we can handle at least this big a gap between the 224*4882a593Smuzhiyun * cumulative ACK and the highest TSN. In practice, we can often 225*4882a593Smuzhiyun * handle up to twice this value. 226*4882a593Smuzhiyun * 227*4882a593Smuzhiyun * NEVER make this more than 32767 (2^15-1). The Gap Ack Blocks in a 228*4882a593Smuzhiyun * SACK (see section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE 229*4882a593Smuzhiyun * must be less than 65535 (2^16 - 1), or we will have overflow 230*4882a593Smuzhiyun * problems creating SACK's. 231*4882a593Smuzhiyun */ 232*4882a593Smuzhiyun #define SCTP_TSN_MAP_INITIAL BITS_PER_LONG 233*4882a593Smuzhiyun #define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL 234*4882a593Smuzhiyun #define SCTP_TSN_MAP_SIZE 4096 235*4882a593Smuzhiyun 236*4882a593Smuzhiyun /* We will not record more than this many duplicate TSNs between two 237*4882a593Smuzhiyun * SACKs. The minimum PMTU is 512. Remove all the headers and there 238*4882a593Smuzhiyun * is enough room for 117 duplicate reports. Round down to the 239*4882a593Smuzhiyun * nearest power of 2. 240*4882a593Smuzhiyun */ 241*4882a593Smuzhiyun enum { SCTP_MAX_DUP_TSNS = 16 }; 242*4882a593Smuzhiyun enum { SCTP_MAX_GABS = 16 }; 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun /* Heartbeat interval - 30 secs */ 245*4882a593Smuzhiyun #define SCTP_DEFAULT_TIMEOUT_HEARTBEAT (30*1000) 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun /* Delayed sack timer - 200ms */ 248*4882a593Smuzhiyun #define SCTP_DEFAULT_TIMEOUT_SACK (200) 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun /* RTO.Initial - 3 seconds 251*4882a593Smuzhiyun * RTO.Min - 1 second 252*4882a593Smuzhiyun * RTO.Max - 60 seconds 253*4882a593Smuzhiyun * RTO.Alpha - 1/8 254*4882a593Smuzhiyun * RTO.Beta - 1/4 255*4882a593Smuzhiyun */ 256*4882a593Smuzhiyun #define SCTP_RTO_INITIAL (3 * 1000) 257*4882a593Smuzhiyun #define SCTP_RTO_MIN (1 * 1000) 258*4882a593Smuzhiyun #define SCTP_RTO_MAX (60 * 1000) 259*4882a593Smuzhiyun 260*4882a593Smuzhiyun #define SCTP_RTO_ALPHA 3 /* 1/8 when converted to right shifts. */ 261*4882a593Smuzhiyun #define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun /* Maximum number of new data packets that can be sent in a burst. */ 264*4882a593Smuzhiyun #define SCTP_DEFAULT_MAX_BURST 4 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ 267*4882a593Smuzhiyun 268*4882a593Smuzhiyun #define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ 269*4882a593Smuzhiyun 270*4882a593Smuzhiyun #define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ 271*4882a593Smuzhiyun #define SCTP_DEFAULT_MAXWINDOW 65535 /* default rwnd size */ 272*4882a593Smuzhiyun #define SCTP_DEFAULT_RWND_SHIFT 4 /* by default, update on 1/16 of 273*4882a593Smuzhiyun * rcvbuf, which is 1/8 of initial 274*4882a593Smuzhiyun * window 275*4882a593Smuzhiyun */ 276*4882a593Smuzhiyun #define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the limit 277*4882a593Smuzhiyun * to which we will raise the P-MTU. 278*4882a593Smuzhiyun */ 279*4882a593Smuzhiyun #define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ 280*4882a593Smuzhiyun 281*4882a593Smuzhiyun #define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ 282*4882a593Smuzhiyun 283*4882a593Smuzhiyun #define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ 284*4882a593Smuzhiyun 285*4882a593Smuzhiyun #define SCTP_COOKIE_MULTIPLE 32 /* Pad out our cookie to make our hash 286*4882a593Smuzhiyun * functions simpler to write. 287*4882a593Smuzhiyun */ 288*4882a593Smuzhiyun 289*4882a593Smuzhiyun /* These are the values for pf exposure, UNUSED is to keep compatible with old 290*4882a593Smuzhiyun * applications by default. 291*4882a593Smuzhiyun */ 292*4882a593Smuzhiyun enum { 293*4882a593Smuzhiyun SCTP_PF_EXPOSE_UNSET, 294*4882a593Smuzhiyun SCTP_PF_EXPOSE_DISABLE, 295*4882a593Smuzhiyun SCTP_PF_EXPOSE_ENABLE, 296*4882a593Smuzhiyun }; 297*4882a593Smuzhiyun #define SCTP_PF_EXPOSE_MAX SCTP_PF_EXPOSE_ENABLE 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun #define SCTP_PS_RETRANS_MAX 0xffff 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun /* These return values describe the success or failure of a number of 302*4882a593Smuzhiyun * routines which form the lower interface to SCTP_outqueue. 303*4882a593Smuzhiyun */ 304*4882a593Smuzhiyun enum sctp_xmit { 305*4882a593Smuzhiyun SCTP_XMIT_OK, 306*4882a593Smuzhiyun SCTP_XMIT_PMTU_FULL, 307*4882a593Smuzhiyun SCTP_XMIT_RWND_FULL, 308*4882a593Smuzhiyun SCTP_XMIT_DELAY, 309*4882a593Smuzhiyun }; 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun /* These are the commands for manipulating transports. */ 312*4882a593Smuzhiyun enum sctp_transport_cmd { 313*4882a593Smuzhiyun SCTP_TRANSPORT_UP, 314*4882a593Smuzhiyun SCTP_TRANSPORT_DOWN, 315*4882a593Smuzhiyun SCTP_TRANSPORT_PF, 316*4882a593Smuzhiyun }; 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun /* These are the address scopes defined mainly for IPv4 addresses 319*4882a593Smuzhiyun * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>. 320*4882a593Smuzhiyun * These scopes are hopefully generic enough to be used on scoping both 321*4882a593Smuzhiyun * IPv4 and IPv6 addresses in SCTP. 322*4882a593Smuzhiyun * At this point, the IPv6 scopes will be mapped to these internal scopes 323*4882a593Smuzhiyun * as much as possible. 324*4882a593Smuzhiyun */ 325*4882a593Smuzhiyun enum sctp_scope { 326*4882a593Smuzhiyun SCTP_SCOPE_GLOBAL, /* IPv4 global addresses */ 327*4882a593Smuzhiyun SCTP_SCOPE_PRIVATE, /* IPv4 private addresses */ 328*4882a593Smuzhiyun SCTP_SCOPE_LINK, /* IPv4 link local address */ 329*4882a593Smuzhiyun SCTP_SCOPE_LOOPBACK, /* IPv4 loopback address */ 330*4882a593Smuzhiyun SCTP_SCOPE_UNUSABLE, /* IPv4 unusable addresses */ 331*4882a593Smuzhiyun }; 332*4882a593Smuzhiyun 333*4882a593Smuzhiyun enum { 334*4882a593Smuzhiyun SCTP_SCOPE_POLICY_DISABLE, /* Disable IPv4 address scoping */ 335*4882a593Smuzhiyun SCTP_SCOPE_POLICY_ENABLE, /* Enable IPv4 address scoping */ 336*4882a593Smuzhiyun SCTP_SCOPE_POLICY_PRIVATE, /* Follow draft but allow IPv4 private addresses */ 337*4882a593Smuzhiyun SCTP_SCOPE_POLICY_LINK, /* Follow draft but allow IPv4 link local addresses */ 338*4882a593Smuzhiyun }; 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun #define SCTP_SCOPE_POLICY_MAX SCTP_SCOPE_POLICY_LINK 341*4882a593Smuzhiyun 342*4882a593Smuzhiyun /* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>, 343*4882a593Smuzhiyun * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 192.88.99.0/24. 344*4882a593Smuzhiyun * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP 345*4882a593Smuzhiyun * addresses. 346*4882a593Smuzhiyun */ 347*4882a593Smuzhiyun #define IS_IPV4_UNUSABLE_ADDRESS(a) \ 348*4882a593Smuzhiyun ((htonl(INADDR_BROADCAST) == a) || \ 349*4882a593Smuzhiyun ipv4_is_multicast(a) || \ 350*4882a593Smuzhiyun ipv4_is_zeronet(a) || \ 351*4882a593Smuzhiyun ipv4_is_anycast_6to4(a)) 352*4882a593Smuzhiyun 353*4882a593Smuzhiyun /* Flags used for the bind address copy functions. */ 354*4882a593Smuzhiyun #define SCTP_ADDR4_ALLOWED 0x00000001 /* IPv4 address is allowed by 355*4882a593Smuzhiyun local sock family */ 356*4882a593Smuzhiyun #define SCTP_ADDR6_ALLOWED 0x00000002 /* IPv6 address is allowed by 357*4882a593Smuzhiyun local sock family */ 358*4882a593Smuzhiyun #define SCTP_ADDR4_PEERSUPP 0x00000004 /* IPv4 address is supported by 359*4882a593Smuzhiyun peer */ 360*4882a593Smuzhiyun #define SCTP_ADDR6_PEERSUPP 0x00000008 /* IPv6 address is supported by 361*4882a593Smuzhiyun peer */ 362*4882a593Smuzhiyun 363*4882a593Smuzhiyun /* Reasons to retransmit. */ 364*4882a593Smuzhiyun enum sctp_retransmit_reason { 365*4882a593Smuzhiyun SCTP_RTXR_T3_RTX, 366*4882a593Smuzhiyun SCTP_RTXR_FAST_RTX, 367*4882a593Smuzhiyun SCTP_RTXR_PMTUD, 368*4882a593Smuzhiyun SCTP_RTXR_T1_RTX, 369*4882a593Smuzhiyun }; 370*4882a593Smuzhiyun 371*4882a593Smuzhiyun /* Reasons to lower cwnd. */ 372*4882a593Smuzhiyun enum sctp_lower_cwnd { 373*4882a593Smuzhiyun SCTP_LOWER_CWND_T3_RTX, 374*4882a593Smuzhiyun SCTP_LOWER_CWND_FAST_RTX, 375*4882a593Smuzhiyun SCTP_LOWER_CWND_ECNE, 376*4882a593Smuzhiyun SCTP_LOWER_CWND_INACTIVE, 377*4882a593Smuzhiyun }; 378*4882a593Smuzhiyun 379*4882a593Smuzhiyun 380*4882a593Smuzhiyun /* SCTP-AUTH Necessary constants */ 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun /* SCTP-AUTH, Section 3.3 383*4882a593Smuzhiyun * 384*4882a593Smuzhiyun * The following Table 2 shows the currently defined values for HMAC 385*4882a593Smuzhiyun * identifiers. 386*4882a593Smuzhiyun * 387*4882a593Smuzhiyun * +-----------------+--------------------------+ 388*4882a593Smuzhiyun * | HMAC Identifier | Message Digest Algorithm | 389*4882a593Smuzhiyun * +-----------------+--------------------------+ 390*4882a593Smuzhiyun * | 0 | Reserved | 391*4882a593Smuzhiyun * | 1 | SHA-1 defined in [8] | 392*4882a593Smuzhiyun * | 2 | Reserved | 393*4882a593Smuzhiyun * | 3 | SHA-256 defined in [8] | 394*4882a593Smuzhiyun * +-----------------+--------------------------+ 395*4882a593Smuzhiyun */ 396*4882a593Smuzhiyun enum { 397*4882a593Smuzhiyun SCTP_AUTH_HMAC_ID_RESERVED_0, 398*4882a593Smuzhiyun SCTP_AUTH_HMAC_ID_SHA1, 399*4882a593Smuzhiyun SCTP_AUTH_HMAC_ID_RESERVED_2, 400*4882a593Smuzhiyun #if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE) 401*4882a593Smuzhiyun SCTP_AUTH_HMAC_ID_SHA256, 402*4882a593Smuzhiyun #endif 403*4882a593Smuzhiyun __SCTP_AUTH_HMAC_MAX 404*4882a593Smuzhiyun }; 405*4882a593Smuzhiyun 406*4882a593Smuzhiyun #define SCTP_AUTH_HMAC_ID_MAX __SCTP_AUTH_HMAC_MAX - 1 407*4882a593Smuzhiyun #define SCTP_AUTH_NUM_HMACS __SCTP_AUTH_HMAC_MAX 408*4882a593Smuzhiyun #define SCTP_SHA1_SIG_SIZE 20 409*4882a593Smuzhiyun #define SCTP_SHA256_SIG_SIZE 32 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun /* SCTP-AUTH, Section 3.2 412*4882a593Smuzhiyun * The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH chunks 413*4882a593Smuzhiyun * MUST NOT be listed in the CHUNKS parameter 414*4882a593Smuzhiyun */ 415*4882a593Smuzhiyun #define SCTP_NUM_NOAUTH_CHUNKS 4 416*4882a593Smuzhiyun #define SCTP_AUTH_MAX_CHUNKS (SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS) 417*4882a593Smuzhiyun 418*4882a593Smuzhiyun /* SCTP-AUTH Section 6.1 419*4882a593Smuzhiyun * The RANDOM parameter MUST contain a 32 byte random number. 420*4882a593Smuzhiyun */ 421*4882a593Smuzhiyun #define SCTP_AUTH_RANDOM_LENGTH 32 422*4882a593Smuzhiyun 423*4882a593Smuzhiyun #endif /* __sctp_constants_h__ */ 424