linux/include/uapi/linux/sctp.h

/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/* SCTP kernel implementation
 * (C) Copyright IBM Corp. 2001, 2004
 * Copyright (c) 1999-2000 Cisco, Inc.
 * Copyright (c) 1999-2001 Motorola, Inc.
 * Copyright (c) 2002 Intel Corp.
 *
 * This file is part of the SCTP kernel implementation
 *
 * This header represents the structures and constants needed to support
 * the SCTP Extension to the Sockets API.
 *
 * This SCTP implementation is free software;
 * you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This SCTP implementation is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 *                 ************************
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU CC; see the file COPYING.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Please send any bug reports or fixes you make to the
 * email address(es):
 *    lksctp developers <[email protected]>
 *
 * Or submit a bug report through the following website:
 *    http://www.sf.net/projects/lksctp
 *
 * Written or modified by:
 *    La Monte H.P. Yarroll    <[email protected]>
 *    R. Stewart               <[email protected]>
 *    K. Morneau               <[email protected]>
 *    Q. Xie                   <[email protected]>
 *    Karl Knutson             <[email protected]>
 *    Jon Grimm                <[email protected]>
 *    Daisy Chang              <[email protected]>
 *    Ryan Layer               <[email protected]>
 *    Ardelle Fan              <[email protected]>
 *    Sridhar Samudrala        <[email protected]>
 *    Inaky Perez-Gonzalez     <[email protected]>
 *    Vlad Yasevich            <[email protected]>
 *
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * be incorporated into the next SCTP release.
 */

#ifndef _UAPI_SCTP_H
#define _UAPI_SCTP_H

#include <linux/types.h>
#include <linux/socket.h>

sctp_assoc_t;

#define SCTP_FUTURE_ASSOC
#define SCTP_CURRENT_ASSOC
#define SCTP_ALL_ASSOC

/* The following symbols come from the Sockets API Extensions for
 * SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
 */
#define SCTP_RTOINFO
#define SCTP_ASSOCINFO
#define SCTP_INITMSG
#define SCTP_NODELAY
#define SCTP_AUTOCLOSE
#define SCTP_SET_PEER_PRIMARY_ADDR
#define SCTP_PRIMARY_ADDR
#define SCTP_ADAPTATION_LAYER
#define SCTP_DISABLE_FRAGMENTS
#define SCTP_PEER_ADDR_PARAMS
#define SCTP_DEFAULT_SEND_PARAM
#define SCTP_EVENTS
#define SCTP_I_WANT_MAPPED_V4_ADDR
#define SCTP_MAXSEG
#define SCTP_STATUS
#define SCTP_GET_PEER_ADDR_INFO
#define SCTP_DELAYED_ACK_TIME
#define SCTP_DELAYED_ACK
#define SCTP_DELAYED_SACK
#define SCTP_CONTEXT
#define SCTP_FRAGMENT_INTERLEAVE
#define SCTP_PARTIAL_DELIVERY_POINT
#define SCTP_MAX_BURST
#define SCTP_AUTH_CHUNK
#define SCTP_HMAC_IDENT
#define SCTP_AUTH_KEY
#define SCTP_AUTH_ACTIVE_KEY
#define SCTP_AUTH_DELETE_KEY
#define SCTP_PEER_AUTH_CHUNKS
#define SCTP_LOCAL_AUTH_CHUNKS
#define SCTP_GET_ASSOC_NUMBER
#define SCTP_GET_ASSOC_ID_LIST
#define SCTP_AUTO_ASCONF
#define SCTP_PEER_ADDR_THLDS
#define SCTP_RECVRCVINFO
#define SCTP_RECVNXTINFO
#define SCTP_DEFAULT_SNDINFO
#define SCTP_AUTH_DEACTIVATE_KEY
#define SCTP_REUSE_PORT
#define SCTP_PEER_ADDR_THLDS_V2

/* Internal Socket Options. Some of the sctp library functions are
 * implemented using these socket options.
 */
#define SCTP_SOCKOPT_BINDX_ADD
#define SCTP_SOCKOPT_BINDX_REM
#define SCTP_SOCKOPT_PEELOFF
/* Options 104-106 are deprecated and removed. Do not use this space */
#define SCTP_SOCKOPT_CONNECTX_OLD
#define SCTP_GET_PEER_ADDRS
#define SCTP_GET_LOCAL_ADDRS
#define SCTP_SOCKOPT_CONNECTX
#define SCTP_SOCKOPT_CONNECTX3
#define SCTP_GET_ASSOC_STATS
#define SCTP_PR_SUPPORTED
#define SCTP_DEFAULT_PRINFO
#define SCTP_PR_ASSOC_STATUS
#define SCTP_PR_STREAM_STATUS
#define SCTP_RECONFIG_SUPPORTED
#define SCTP_ENABLE_STREAM_RESET
#define SCTP_RESET_STREAMS
#define SCTP_RESET_ASSOC
#define SCTP_ADD_STREAMS
#define SCTP_SOCKOPT_PEELOFF_FLAGS
#define SCTP_STREAM_SCHEDULER
#define SCTP_STREAM_SCHEDULER_VALUE
#define SCTP_INTERLEAVING_SUPPORTED
#define SCTP_SENDMSG_CONNECT
#define SCTP_EVENT
#define SCTP_ASCONF_SUPPORTED
#define SCTP_AUTH_SUPPORTED
#define SCTP_ECN_SUPPORTED
#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
#define SCTP_EXPOSE_PF_STATE
#define SCTP_REMOTE_UDP_ENCAPS_PORT
#define SCTP_PLPMTUD_PROBE_INTERVAL

/* PR-SCTP policies */
#define SCTP_PR_SCTP_NONE
#define SCTP_PR_SCTP_TTL
#define SCTP_PR_SCTP_RTX
#define SCTP_PR_SCTP_PRIO
#define SCTP_PR_SCTP_MAX
#define SCTP_PR_SCTP_MASK

#define __SCTP_PR_INDEX(x)
#define SCTP_PR_INDEX(x)

#define SCTP_PR_POLICY(x)
#define SCTP_PR_SET_POLICY(flags, x)

#define SCTP_PR_TTL_ENABLED(x)
#define SCTP_PR_RTX_ENABLED(x)
#define SCTP_PR_PRIO_ENABLED(x)

/* For enable stream reset */
#define SCTP_ENABLE_RESET_STREAM_REQ
#define SCTP_ENABLE_RESET_ASSOC_REQ
#define SCTP_ENABLE_CHANGE_ASSOC_REQ
#define SCTP_ENABLE_STRRESET_MASK

#define SCTP_STREAM_RESET_INCOMING
#define SCTP_STREAM_RESET_OUTGOING

/* These are bit fields for msghdr->msg_flags.  See section 5.1.  */
/* On user space Linux, these live in <bits/socket.h> as an enum.  */
enum sctp_msg_flags {};

/* 5.3.1 SCTP Initiation Structure (SCTP_INIT)
 *
 *   This cmsghdr structure provides information for initializing new
 *   SCTP associations with sendmsg().  The SCTP_INITMSG socket option
 *   uses this same data structure.  This structure is not used for
 *   recvmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   ----------------------
 *   IPPROTO_SCTP  SCTP_INIT      struct sctp_initmsg
 */
struct sctp_initmsg {};

/* 5.3.2 SCTP Header Information Structure (SCTP_SNDRCV)
 *
 *   This cmsghdr structure specifies SCTP options for sendmsg() and
 *   describes SCTP header information about a received message through
 *   recvmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   ----------------------
 *   IPPROTO_SCTP  SCTP_SNDRCV    struct sctp_sndrcvinfo
 */
struct sctp_sndrcvinfo {};

/* 5.3.4 SCTP Send Information Structure (SCTP_SNDINFO)
 *
 *   This cmsghdr structure specifies SCTP options for sendmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   -------------------
 *   IPPROTO_SCTP  SCTP_SNDINFO   struct sctp_sndinfo
 */
struct sctp_sndinfo {};

/* 5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO)
 *
 *   This cmsghdr structure describes SCTP receive information
 *   about a received message through recvmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   -------------------
 *   IPPROTO_SCTP  SCTP_RCVINFO   struct sctp_rcvinfo
 */
struct sctp_rcvinfo {};

/* 5.3.6 SCTP Next Receive Information Structure (SCTP_NXTINFO)
 *
 *   This cmsghdr structure describes SCTP receive information
 *   of the next message that will be delivered through recvmsg()
 *   if this information is already available when delivering
 *   the current message.
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   -------------------
 *   IPPROTO_SCTP  SCTP_NXTINFO   struct sctp_nxtinfo
 */
struct sctp_nxtinfo {};

/* 5.3.7 SCTP PR-SCTP Information Structure (SCTP_PRINFO)
 *
 *   This cmsghdr structure specifies SCTP options for sendmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   -------------------
 *   IPPROTO_SCTP  SCTP_PRINFO    struct sctp_prinfo
 */
struct sctp_prinfo {};

/* 5.3.8 SCTP AUTH Information Structure (SCTP_AUTHINFO)
 *
 *   This cmsghdr structure specifies SCTP options for sendmsg().
 *
 *   cmsg_level    cmsg_type      cmsg_data[]
 *   ------------  ------------   -------------------
 *   IPPROTO_SCTP  SCTP_AUTHINFO  struct sctp_authinfo
 */
struct sctp_authinfo {};

/*
 *  sinfo_flags: 16 bits (unsigned integer)
 *
 *   This field may contain any of the following flags and is composed of
 *   a bitwise OR of these values.
 */
enum sctp_sinfo_flags {};

sctp_cmsg_data_t;

/* These are cmsg_types.  */
sctp_cmsg_t;

/*
 * 5.3.1.1 SCTP_ASSOC_CHANGE
 *
 *   Communication notifications inform the ULP that an SCTP association
 *   has either begun or ended. The identifier for a new association is
 *   provided by this notificaion. The notification information has the
 *   following format:
 *
 */
struct sctp_assoc_change {};

/*
 *   sac_state: 32 bits (signed integer)
 *
 *   This field holds one of a number of values that communicate the
 *   event that happened to the association.  They include:
 *
 *   Note:  The following state names deviate from the API draft as
 *   the names clash too easily with other kernel symbols.
 */
enum sctp_sac_state {};

/*
 * 5.3.1.2 SCTP_PEER_ADDR_CHANGE
 *
 *   When a destination address on a multi-homed peer encounters a change
 *   an interface details event is sent.  The information has the
 *   following structure:
 */
struct sctp_paddr_change {} __attribute__((packed, aligned));

/*
 *    spc_state:  32 bits (signed integer)
 *
 *   This field holds one of a number of values that communicate the
 *   event that happened to the address.  They include:
 */
enum sctp_spc_state {};


/*
 * 5.3.1.3 SCTP_REMOTE_ERROR
 *
 *   A remote peer may send an Operational Error message to its peer.
 *   This message indicates a variety of error conditions on an
 *   association. The entire error TLV as it appears on the wire is
 *   included in a SCTP_REMOTE_ERROR event.  Please refer to the SCTP
 *   specification [SCTP] and any extensions for a list of possible
 *   error formats. SCTP error TLVs have the format:
 */
struct sctp_remote_error {};


/*
 * 5.3.1.4 SCTP_SEND_FAILED
 *
 *   If SCTP cannot deliver a message it may return the message as a
 *   notification.
 */
struct sctp_send_failed {};

struct sctp_send_failed_event {};

/*
 *   ssf_flags: 16 bits (unsigned integer)
 *
 *   The flag value will take one of the following values
 *
 *   SCTP_DATA_UNSENT  - Indicates that the data was never put on
 *                       the wire.
 *
 *   SCTP_DATA_SENT    - Indicates that the data was put on the wire.
 *                       Note that this does not necessarily mean that the
 *                       data was (or was not) successfully delivered.
 */
enum sctp_ssf_flags {};

/*
 * 5.3.1.5 SCTP_SHUTDOWN_EVENT
 *
 *   When a peer sends a SHUTDOWN, SCTP delivers this notification to
 *   inform the application that it should cease sending data.
 */
struct sctp_shutdown_event {};

/*
 * 5.3.1.6 SCTP_ADAPTATION_INDICATION
 *
 *   When a peer sends a Adaptation Layer Indication parameter , SCTP
 *   delivers this notification to inform the application
 *   that of the peers requested adaptation layer.
 */
struct sctp_adaptation_event {};

/*
 * 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
 *
 *   When a receiver is engaged in a partial delivery of a
 *   message this notification will be used to indicate
 *   various events.
 */
struct sctp_pdapi_event {};

enum {};

/*
 * 5.3.1.8.  SCTP_AUTHENTICATION_EVENT
 *
 *  When a receiver is using authentication this message will provide
 *  notifications regarding new keys being made active as well as errors.
 */
struct sctp_authkey_event {};

enum {};

/*
 * 6.1.9. SCTP_SENDER_DRY_EVENT
 *
 * When the SCTP stack has no more user data to send or retransmit, this
 * notification is given to the user. Also, at the time when a user app
 * subscribes to this event, if there is no data to be sent or
 * retransmit, the stack will immediately send up this notification.
 */
struct sctp_sender_dry_event {};

#define SCTP_STREAM_RESET_INCOMING_SSN
#define SCTP_STREAM_RESET_OUTGOING_SSN
#define SCTP_STREAM_RESET_DENIED
#define SCTP_STREAM_RESET_FAILED
struct sctp_stream_reset_event {};

#define SCTP_ASSOC_RESET_DENIED
#define SCTP_ASSOC_RESET_FAILED
struct sctp_assoc_reset_event {};

#define SCTP_ASSOC_CHANGE_DENIED
#define SCTP_ASSOC_CHANGE_FAILED
#define SCTP_STREAM_CHANGE_DENIED
#define SCTP_STREAM_CHANGE_FAILED
struct sctp_stream_change_event {};

/*
 * Described in Section 7.3
 *   Ancillary Data and Notification Interest Options
 */
struct sctp_event_subscribe {};

/*
 * 5.3.1 SCTP Notification Structure
 *
 *   The notification structure is defined as the union of all
 *   notification types.
 *
 */
sctp_notification;

/* Section 5.3.1
 * All standard values for sn_type flags are greater than 2^15.
 * Values from 2^15 and down are reserved.
 */

enum sctp_sn_type {};

/* Notification error codes used to fill up the error fields in some
 * notifications.
 * SCTP_PEER_ADDRESS_CHAGE 	: spc_error
 * SCTP_ASSOC_CHANGE		: sac_error
 * These names should be potentially included in the draft 04 of the SCTP
 * sockets API specification.
 */
sctp_sn_error_t;

/*
 * 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
 *
 *   The protocol parameters used to initialize and bound retransmission
 *   timeout (RTO) are tunable.  See [SCTP] for more information on how
 *   these parameters are used in RTO calculation.
 */
struct sctp_rtoinfo {};

/*
 * 7.1.2 Association Parameters (SCTP_ASSOCINFO)
 *
 *   This option is used to both examine and set various association and
 *   endpoint parameters.
 */
struct sctp_assocparams {};

/*
 * 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
 *
 *  Requests that the peer mark the enclosed address as the association
 *  primary. The enclosed address must be one of the association's
 *  locally bound addresses. The following structure is used to make a
 *   set primary request:
 */
struct sctp_setpeerprim {} __attribute__((packed, aligned));

/*
 * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
 *
 *  Requests that the local SCTP stack use the enclosed peer address as
 *  the association primary. The enclosed address must be one of the
 *  association peer's addresses. The following structure is used to
 *  make a set peer primary request:
 */
struct sctp_prim {} __attribute__((packed, aligned));

/* For backward compatibility use, define the old name too */
#define sctp_setprim

/*
 * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER)
 *
 * Requests that the local endpoint set the specified Adaptation Layer
 * Indication parameter for all future INIT and INIT-ACK exchanges.
 */
struct sctp_setadaptation {};

/*
 * 7.1.13 Peer Address Parameters  (SCTP_PEER_ADDR_PARAMS)
 *
 *   Applications can enable or disable heartbeats for any peer address
 *   of an association, modify an address's heartbeat interval, force a
 *   heartbeat to be sent immediately, and adjust the address's maximum
 *   number of retransmissions sent before an address is considered
 *   unreachable. The following structure is used to access and modify an
 *   address's parameters:
 */
enum  sctp_spp_flags {};

struct sctp_paddrparams {} __attribute__((packed, aligned));

/*
 * 7.1.18.  Add a chunk that must be authenticated (SCTP_AUTH_CHUNK)
 *
 * This set option adds a chunk type that the user is requesting to be
 * received only in an authenticated way.  Changes to the list of chunks
 * will only effect future associations on the socket.
 */
struct sctp_authchunk {};

/*
 * 7.1.19.  Get or set the list of supported HMAC Identifiers (SCTP_HMAC_IDENT)
 *
 * This option gets or sets the list of HMAC algorithms that the local
 * endpoint requires the peer to use.
 */
#ifndef __KERNEL__
/* This here is only used by user space as is. It might not be a good idea
 * to export/reveal the whole structure with reserved fields etc.
 */
enum {
	SCTP_AUTH_HMAC_ID_SHA1 = 1,
	SCTP_AUTH_HMAC_ID_SHA256 = 3,
};
#endif

struct sctp_hmacalgo {};

/* Sadly, user and kernel space have different names for
 * this structure member, so this is to not break anything.
 */
#define shmac_number_of_idents

/*
 * 7.1.20.  Set a shared key (SCTP_AUTH_KEY)
 *
 * This option will set a shared secret key which is used to build an
 * association shared key.
 */
struct sctp_authkey {};

/*
 * 7.1.21.  Get or set the active shared key (SCTP_AUTH_ACTIVE_KEY)
 *
 * This option will get or set the active shared key to be used to build
 * the association shared key.
 */

struct sctp_authkeyid {};


/*
 * 7.1.23.  Get or set delayed ack timer (SCTP_DELAYED_SACK)
 *
 * This option will effect the way delayed acks are performed.  This
 * option allows you to get or set the delayed ack time, in
 * milliseconds.  It also allows changing the delayed ack frequency.
 * Changing the frequency to 1 disables the delayed sack algorithm.  If
 * the assoc_id is 0, then this sets or gets the endpoints default
 * values.  If the assoc_id field is non-zero, then the set or get
 * effects the specified association for the one to many model (the
 * assoc_id field is ignored by the one to one model).  Note that if
 * sack_delay or sack_freq are 0 when setting this option, then the
 * current values will remain unchanged.
 */
struct sctp_sack_info {};

struct sctp_assoc_value {};

struct sctp_stream_value {};

/*
 * 7.2.2 Peer Address Information
 *
 *   Applications can retrieve information about a specific peer address
 *   of an association, including its reachability state, congestion
 *   window, and retransmission timer values.  This information is
 *   read-only. The following structure is used to access this
 *   information:
 */
struct sctp_paddrinfo {} __attribute__((packed, aligned));

/* Peer addresses's state. */
/* UNKNOWN: Peer address passed by the upper layer in sendmsg or connect[x]
 * calls.
 * UNCONFIRMED: Peer address received in INIT/INIT-ACK address parameters.
 *              Not yet confirmed by a heartbeat and not available for data
 *		transfers.
 * ACTIVE : Peer address confirmed, active and available for data transfers.
 * INACTIVE: Peer address inactive and not available for data transfers.
 */
enum sctp_spinfo_state {};

/*
 * 7.2.1 Association Status (SCTP_STATUS)
 *
 *   Applications can retrieve current status information about an
 *   association, including association state, peer receiver window size,
 *   number of unacked data chunks, and number of data chunks pending
 *   receipt.  This information is read-only.  The following structure is
 *   used to access this information:
 */
struct sctp_status {};

/*
 * 7.2.3.  Get the list of chunks the peer requires to be authenticated
 *         (SCTP_PEER_AUTH_CHUNKS)
 *
 * This option gets a list of chunks for a specified association that
 * the peer requires to be received authenticated only.
 */
struct sctp_authchunks {};

/* The broken spelling has been released already in lksctp-tools header,
 * so don't break anyone, now that it's fixed.
 */
#define guth_number_of_chunks

/* Association states.  */
enum sctp_sstat_state {};

/*
 * 8.2.6. Get the Current Identifiers of Associations
 *        (SCTP_GET_ASSOC_ID_LIST)
 *
 * This option gets the current list of SCTP association identifiers of
 * the SCTP associations handled by a one-to-many style socket.
 */
struct sctp_assoc_ids {};

/*
 * 8.3, 8.5 get all peer/local addresses in an association.
 * This parameter struct is used by SCTP_GET_PEER_ADDRS and
 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
 * sctp_getpaddrs() and sctp_getladdrs() API.
 */
struct sctp_getaddrs_old {};

struct sctp_getaddrs {};

/* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves
 * association stats. All stats are counts except sas_maxrto and
 * sas_obs_rto_ipaddr. maxrto is the max observed rto + transport since
 * the last call. Will return 0 when RTO was not update since last call
 */
struct sctp_assoc_stats {};

/*
 * 8.1 sctp_bindx()
 *
 * The flags parameter is formed from the bitwise OR of zero or more of the
 * following currently defined flags:
 */
#define SCTP_BINDX_ADD_ADDR
#define SCTP_BINDX_REM_ADDR

/* This is the structure that is passed as an argument(optval) to
 * getsockopt(SCTP_SOCKOPT_PEELOFF).
 */
sctp_peeloff_arg_t;

sctp_peeloff_flags_arg_t;

/*
 *  Peer Address Thresholds socket option
 */
struct sctp_paddrthlds {};

/* Use a new structure with spt_pathcpthld for back compatibility */
struct sctp_paddrthlds_v2 {};

/*
 * Socket Option for Getting the Association/Stream-Specific PR-SCTP Status
 */
struct sctp_prstatus {};

struct sctp_default_prinfo {};

struct sctp_info {};

struct sctp_reset_streams {};

struct sctp_add_streams {};

struct sctp_event {};

struct sctp_udpencaps {};

/* SCTP Stream schedulers */
enum sctp_sched_type {};

/* Probe Interval socket option */
struct sctp_probeinterval {};

#endif /* _UAPI_SCTP_H */