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