Home | History | Annotate | Line # | Download | only in netinet
      1  1.1      rjs /*	$KAME: sctp.h,v 1.18 2005/03/06 16:04:16 itojun Exp $	*/
      2  1.7   andvar /*	$NetBSD: sctp.h,v 1.7 2025/02/28 09:07:12 andvar Exp $ */
      3  1.1      rjs 
      4  1.1      rjs #ifndef _NETINET_SCTP_H_
      5  1.1      rjs #define _NETINET_SCTP_H_
      6  1.1      rjs 
      7  1.1      rjs /*
      8  1.1      rjs  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
      9  1.1      rjs  * All rights reserved.
     10  1.1      rjs  *
     11  1.1      rjs  * Redistribution and use in source and binary forms, with or without
     12  1.1      rjs  * modification, are permitted provided that the following conditions
     13  1.1      rjs  * are met:
     14  1.1      rjs  * 1. Redistributions of source code must retain the above copyright
     15  1.1      rjs  *    notice, this list of conditions and the following disclaimer.
     16  1.1      rjs  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1      rjs  *    notice, this list of conditions and the following disclaimer in the
     18  1.1      rjs  *    documentation and/or other materials provided with the distribution.
     19  1.1      rjs  * 3. All advertising materials mentioning features or use of this software
     20  1.1      rjs  *    must display the following acknowledgement:
     21  1.1      rjs  *      This product includes software developed by Cisco Systems, Inc.
     22  1.1      rjs  * 4. Neither the name of the project nor the names of its contributors
     23  1.1      rjs  *    may be used to endorse or promote products derived from this software
     24  1.1      rjs  *    without specific prior written permission.
     25  1.1      rjs  *
     26  1.1      rjs  * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
     27  1.1      rjs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  1.1      rjs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  1.1      rjs  * ARE DISCLAIMED.  IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
     30  1.1      rjs  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  1.1      rjs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  1.1      rjs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  1.1      rjs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  1.1      rjs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  1.1      rjs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  1.1      rjs  * SUCH DAMAGE.
     37  1.1      rjs  */
     38  1.1      rjs #include <sys/types.h>
     39  1.1      rjs 
     40  1.1      rjs /*
     41  1.1      rjs  * SCTP protocol - RFC2960.
     42  1.1      rjs  */
     43  1.1      rjs 
     44  1.1      rjs struct sctphdr {
     45  1.1      rjs 	u_int16_t src_port;		/* source port */
     46  1.1      rjs 	u_int16_t dest_port;		/* destination port */
     47  1.1      rjs 	u_int32_t v_tag;		/* verification tag of packet */
     48  1.1      rjs 	u_int32_t checksum;		/* Adler32 C-Sum */
     49  1.1      rjs 	/* chunks follow... */
     50  1.2      rjs } __packed;
     51  1.1      rjs 
     52  1.1      rjs /*
     53  1.1      rjs  * SCTP Chunks
     54  1.1      rjs  */
     55  1.1      rjs struct sctp_chunkhdr {
     56  1.1      rjs 	u_int8_t  chunk_type;		/* chunk type */
     57  1.1      rjs 	u_int8_t  chunk_flags;		/* chunk flags */
     58  1.1      rjs 	u_int16_t chunk_length;		/* chunk length */
     59  1.1      rjs 	/* optional params follow */
     60  1.2      rjs } __packed;
     61  1.1      rjs 
     62  1.1      rjs /*
     63  1.1      rjs  * SCTP chunk parameters
     64  1.1      rjs  */
     65  1.1      rjs struct sctp_paramhdr {
     66  1.1      rjs 	u_int16_t param_type;		/* parameter type */
     67  1.1      rjs 	u_int16_t param_length;		/* parameter length */
     68  1.2      rjs } __packed;
     69  1.1      rjs 
     70  1.1      rjs /*
     71  1.1      rjs  * user socket options
     72  1.1      rjs  */
     73  1.1      rjs /* read-write options */
     74  1.1      rjs #define SCTP_NODELAY			0x00000001
     75  1.1      rjs #define SCTP_MAXSEG			0x00000002
     76  1.1      rjs #define SCTP_ASSOCINFO			0x00000003
     77  1.1      rjs 
     78  1.1      rjs #define SCTP_INITMSG			0x00000004
     79  1.1      rjs #define SCTP_AUTOCLOSE			0x00000005
     80  1.1      rjs #define SCTP_SET_PEER_PRIMARY_ADDR	0x00000006
     81  1.1      rjs #define SCTP_PRIMARY_ADDR		0x00000007
     82  1.1      rjs 
     83  1.1      rjs /* read-only options */
     84  1.1      rjs #define SCTP_STATUS			0x00000008
     85  1.1      rjs #define SCTP_PCB_STATUS			0x00000009
     86  1.1      rjs 
     87  1.1      rjs /* ancillary data/notification interest options */
     88  1.1      rjs #define SCTP_EVENTS			0x0000000a
     89  1.1      rjs /* sctp_opt_info params */
     90  1.1      rjs #define SCTP_PEER_ADDR_PARAMS 		0x0000000b
     91  1.1      rjs #define SCTP_GET_PEER_ADDR_INFO		0x0000000c
     92  1.1      rjs /* Hidden socket option that gets the addresses */
     93  1.1      rjs #define SCTP_GET_PEER_ADDRESSES		0x0000000d
     94  1.1      rjs #define SCTP_GET_LOCAL_ADDRESSES	0x0000000e
     95  1.1      rjs /*
     96  1.1      rjs  * Blocking I/O is enabled on any TCP type socket by default.
     97  1.1      rjs  * For the UDP model if this is turned on then the socket buffer is
     98  1.1      rjs  * shared for send resources amongst all associations. The default
     99  1.1      rjs  * for the UDP model is that is SS_NBIO is set. Which means all associations
    100  1.3  msaitoh  * have a separate send limit BUT they will NOT ever BLOCK instead
    101  1.4   andvar  * you will get an error back EAGAIN if you try to send too much. If
    102  1.1      rjs  * you want the blocking symantics you set this option at the cost
    103  1.1      rjs  * of sharing one socket send buffer size amongst all associations.
    104  1.1      rjs  * Peeled off sockets turn this option off and block... but since both TCP and
    105  1.1      rjs  * peeled off sockets have only one assoc per socket this is fine.
    106  1.1      rjs  * It probably does NOT make sense to set this  on SS_NBIO on a TCP model OR
    107  1.1      rjs  * peeled off UDP model, but we do allow you to do so. You just use
    108  1.1      rjs  * the normal syscall to toggle SS_NBIO the way you want.
    109  1.1      rjs  */
    110  1.5   andvar /* Blocking I/O is controlled by the SS_NBIO flag on the
    111  1.1      rjs  * socket state so_state field.
    112  1.1      rjs  */
    113  1.1      rjs #define SCTP_GET_SNDBUF_USE		0x0000000f
    114  1.1      rjs /* latter added read/write */
    115  1.1      rjs #define SCTP_ADAPTION_LAYER		0x00000010
    116  1.1      rjs #define SCTP_DISABLE_FRAGMENTS		0x00000011
    117  1.1      rjs /* sctp_bindx() flags as socket options */
    118  1.1      rjs #define SCTP_BINDX_ADD_ADDR		0x00000012
    119  1.1      rjs #define SCTP_BINDX_REM_ADDR		0x00000013
    120  1.1      rjs /* return the total count in bytes needed to hold all local addresses bound */
    121  1.1      rjs #define SCTP_GET_LOCAL_ADDR_SIZE	0x00000014
    122  1.1      rjs /* Without this applied we will give V4 and V6 addresses on a V6 socket */
    123  1.1      rjs #define SCTP_I_WANT_MAPPED_V4_ADDR	0x00000015
    124  1.1      rjs /* Return the total count in bytes needed to hold the remote address */
    125  1.1      rjs #define SCTP_GET_REMOTE_ADDR_SIZE	0x00000016
    126  1.1      rjs #define SCTP_GET_PEGS			0x00000017
    127  1.1      rjs #define SCTP_DEFAULT_SEND_PARAM		0x00000018
    128  1.1      rjs #define SCTP_SET_DEBUG_LEVEL		0x00000019
    129  1.1      rjs #define SCTP_RTOINFO			0x0000001a
    130  1.1      rjs #define SCTP_AUTO_ASCONF		0x0000001b
    131  1.1      rjs #define SCTP_MAXBURST			0x0000001c
    132  1.1      rjs #define SCTP_GET_STAT_LOG		0x0000001d
    133  1.1      rjs #define SCTP_CONNECT_X			0x0000001e	/* hidden opt for connectx */
    134  1.1      rjs #define SCTP_RESET_STREAMS		0x0000001f
    135  1.1      rjs #define SCTP_CONNECT_X_DELAYED		0x00000020	/* hidden opt for connectx_delayed
    136  1.1      rjs 							 * part of sctp_sendx()
    137  1.1      rjs 							 */
    138  1.1      rjs #define SCTP_CONNECT_X_COMPLETE         0x00000021
    139  1.1      rjs #define SCTP_GET_ASOC_ID_LIST           0x00000022
    140  1.1      rjs 
    141  1.1      rjs /* Other BSD items */
    142  1.1      rjs #define SCTP_GET_NONCE_VALUES           0x00000023
    143  1.1      rjs #define SCTP_DELAYED_ACK_TIME           0x00000024
    144  1.1      rjs 
    145  1.1      rjs /* Things for the AUTH draft possibly */
    146  1.1      rjs #define SCTP_PEER_PUBLIC_KEY            0x00000100 /* get the peers public key */
    147  1.1      rjs #define SCTP_MY_PUBLIC_KEY              0x00000101 /* get/set my endpoints public key */
    148  1.1      rjs #define SCTP_SET_AUTH_SECRET            0x00000102 /* get/set my shared secret */
    149  1.6   andvar #define SCTP_SET_AUTH_CHUNKS            0x00000103 /* specify what chunks you want
    150  1.6   andvar 						     * the system may have additional requirements
    151  1.1      rjs 						     * as well. I.e. probably ASCONF/ASCONF-ACK no matter
    152  1.1      rjs 						     * if you want it or not.
    153  1.1      rjs 						     */
    154  1.1      rjs /* Debug things that need to be purged */
    155  1.1      rjs #define SCTP_SET_INITIAL_DBG_SEQ	0x00001f00
    156  1.1      rjs #define SCTP_RESET_PEGS                 0x00002000
    157  1.1      rjs #define SCTP_CLR_STAT_LOG               0x00002100
    158  1.1      rjs 
    159  1.1      rjs /*
    160  1.1      rjs  * user state values
    161  1.1      rjs  */
    162  1.1      rjs #define SCTP_CLOSED			0x0000
    163  1.1      rjs #define SCTP_BOUND			0x1000
    164  1.1      rjs #define SCTP_LISTEN			0x2000
    165  1.1      rjs #define SCTP_COOKIE_WAIT		0x0002
    166  1.1      rjs #define SCTP_COOKIE_ECHOED		0x0004
    167  1.1      rjs #define SCTP_ESTABLISHED		0x0008
    168  1.1      rjs #define SCTP_SHUTDOWN_SENT		0x0010
    169  1.1      rjs #define SCTP_SHUTDOWN_RECEIVED		0x0020
    170  1.1      rjs #define SCTP_SHUTDOWN_ACK_SENT		0x0040
    171  1.1      rjs #define SCTP_SHUTDOWN_PENDING		0x0080
    172  1.1      rjs 
    173  1.1      rjs /*
    174  1.1      rjs  * SCTP operational error codes (user visible)
    175  1.1      rjs  */
    176  1.1      rjs #define SCTP_ERROR_NO_ERROR		0x0000
    177  1.1      rjs #define SCTP_ERROR_INVALID_STREAM	0x0001
    178  1.1      rjs #define SCTP_ERROR_MISSING_PARAM	0x0002
    179  1.1      rjs #define SCTP_ERROR_STALE_COOKIE		0x0003
    180  1.1      rjs #define SCTP_ERROR_OUT_OF_RESOURCES	0x0004
    181  1.1      rjs #define SCTP_ERROR_UNRESOLVABLE_ADDR	0x0005
    182  1.1      rjs #define SCTP_ERROR_UNRECOG_CHUNK	0x0006
    183  1.1      rjs #define SCTP_ERROR_INVALID_PARAM	0x0007
    184  1.1      rjs #define SCTP_ERROR_UNRECOG_PARAM	0x0008
    185  1.1      rjs #define SCTP_ERROR_NO_USER_DATA		0x0009
    186  1.1      rjs #define SCTP_ERROR_COOKIE_IN_SHUTDOWN	0x000a
    187  1.1      rjs /* draft-ietf-tsvwg-sctpimpguide */
    188  1.1      rjs #define SCTP_ERROR_RESTART_NEWADDRS	0x000b
    189  1.1      rjs /* draft-ietf-tsvwg-addip-sctp */
    190  1.1      rjs #define SCTP_ERROR_DELETE_LAST_ADDR	0x0100
    191  1.1      rjs #define SCTP_ERROR_RESOURCE_SHORTAGE	0x0101
    192  1.1      rjs #define SCTP_ERROR_DELETE_SOURCE_ADDR	0x0102
    193  1.1      rjs #define SCTP_ERROR_ILLEGAL_ASCONF_ACK	0x0103
    194  1.1      rjs 
    195  1.1      rjs /*
    196  1.4   andvar  * error cause parameters (user visible)
    197  1.1      rjs  */
    198  1.1      rjs struct sctp_error_cause {
    199  1.1      rjs 	u_int16_t code;
    200  1.1      rjs 	u_int16_t length;
    201  1.1      rjs 	/* optional cause-specific info may follow */
    202  1.2      rjs } __packed;
    203  1.1      rjs 
    204  1.1      rjs struct sctp_error_invalid_stream {
    205  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_INVALID_STREAM */
    206  1.1      rjs 	u_int16_t stream_id;		/* stream id of the DATA in error */
    207  1.1      rjs 	u_int16_t reserved;
    208  1.2      rjs } __packed;
    209  1.1      rjs 
    210  1.1      rjs struct sctp_error_missing_param {
    211  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_MISSING_PARAM */
    212  1.1      rjs 	u_int32_t num_missing_params;	/* number of missing parameters */
    213  1.1      rjs 	/* u_int16_t param_type's follow */
    214  1.2      rjs } __packed;
    215  1.1      rjs 
    216  1.1      rjs struct sctp_error_stale_cookie {
    217  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_STALE_COOKIE */
    218  1.1      rjs 	u_int32_t stale_time;		/* time in usec of staleness */
    219  1.2      rjs } __packed;
    220  1.1      rjs 
    221  1.1      rjs struct sctp_error_out_of_resource {
    222  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_OUT_OF_RESOURCES */
    223  1.2      rjs } __packed;
    224  1.1      rjs 
    225  1.1      rjs struct sctp_error_unresolv_addr {
    226  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
    227  1.1      rjs 
    228  1.2      rjs } __packed;
    229  1.1      rjs 
    230  1.1      rjs struct sctp_error_unrecognized_chunk {
    231  1.1      rjs 	struct sctp_error_cause cause;	/* code=SCTP_ERROR_UNRECOG_CHUNK */
    232  1.1      rjs 	struct sctp_chunkhdr ch;	/* header from chunk in error */
    233  1.2      rjs } __packed;
    234  1.1      rjs 
    235  1.1      rjs #define HAVE_SCTP			1
    236  1.1      rjs #define HAVE_KERNEL_SCTP		1
    237  1.1      rjs #define HAVE_SCTP_PRSCTP		1
    238  1.1      rjs #define HAVE_SCTP_ADDIP			1
    239  1.1      rjs #define HAVE_SCTP_CANSET_PRIMARY	1
    240  1.1      rjs #define HAVE_SCTP_SAT_NETWORK_CAPABILITY1
    241  1.1      rjs #define HAVE_SCTP_MULTIBUF              1
    242  1.1      rjs #define HAVE_SCTP_NOCONNECT             0
    243  1.1      rjs #define HAVE_SCTP_ECN_NONCE             1  /* ECN Nonce option */
    244  1.1      rjs 
    245  1.1      rjs /* Main SCTP chunk types, we place
    246  1.1      rjs  * these here since that way natd and f/w's
    247  1.1      rjs  * in user land can find them.
    248  1.1      rjs  */
    249  1.1      rjs #define SCTP_DATA		0x00
    250  1.1      rjs #define SCTP_INITIATION		0x01
    251  1.1      rjs #define SCTP_INITIATION_ACK	0x02
    252  1.1      rjs #define SCTP_SELECTIVE_ACK	0x03
    253  1.1      rjs #define SCTP_HEARTBEAT_REQUEST	0x04
    254  1.1      rjs #define SCTP_HEARTBEAT_ACK	0x05
    255  1.1      rjs #define SCTP_ABORT_ASSOCIATION	0x06
    256  1.1      rjs #define SCTP_SHUTDOWN		0x07
    257  1.1      rjs #define SCTP_SHUTDOWN_ACK	0x08
    258  1.1      rjs #define SCTP_OPERATION_ERROR	0x09
    259  1.1      rjs #define SCTP_COOKIE_ECHO	0x0a
    260  1.1      rjs #define SCTP_COOKIE_ACK		0x0b
    261  1.1      rjs #define SCTP_ECN_ECHO		0x0c
    262  1.1      rjs #define SCTP_ECN_CWR		0x0d
    263  1.1      rjs #define SCTP_SHUTDOWN_COMPLETE	0x0e
    264  1.1      rjs 
    265  1.1      rjs /* draft-ietf-tsvwg-addip-sctp */
    266  1.1      rjs #define SCTP_ASCONF		0xc1
    267  1.1      rjs #define	SCTP_ASCONF_ACK		0x80
    268  1.1      rjs 
    269  1.1      rjs /* draft-ietf-stewart-prsctp */
    270  1.1      rjs #define SCTP_FORWARD_CUM_TSN	0xc0
    271  1.1      rjs 
    272  1.1      rjs /* draft-ietf-stewart-pktdrpsctp */
    273  1.1      rjs #define SCTP_PACKET_DROPPED	0x81
    274  1.1      rjs 
    275  1.1      rjs /* draft-ietf-stewart-strreset-xxx */
    276  1.1      rjs #define SCTP_STREAM_RESET       0x82
    277  1.1      rjs 
    278  1.1      rjs /* ABORT and SHUTDOWN COMPLETE FLAG */
    279  1.1      rjs #define SCTP_HAD_NO_TCB		0x01
    280  1.1      rjs 
    281  1.1      rjs /* Packet dropped flags */
    282  1.1      rjs #define SCTP_FROM_MIDDLE_BOX	SCTP_HAD_NO_TCB
    283  1.1      rjs #define SCTP_BADCRC		0x02
    284  1.1      rjs #define SCTP_PACKET_TRUNCATED	0x04
    285  1.1      rjs 
    286  1.1      rjs #define SCTP_SAT_NETWORK_MIN	     400	/* min ms for RTT to set satellite time */
    287  1.1      rjs #define SCTP_SAT_NETWORK_BURST_INCR  2		/* how many times to multiply maxburst in sat */
    288  1.7   andvar /* Data Chunk Specific Flags */
    289  1.1      rjs #define SCTP_DATA_FRAG_MASK	0x03
    290  1.1      rjs #define SCTP_DATA_MIDDLE_FRAG	0x00
    291  1.1      rjs #define SCTP_DATA_LAST_FRAG	0x01
    292  1.1      rjs #define SCTP_DATA_FIRST_FRAG	0x02
    293  1.1      rjs #define SCTP_DATA_NOT_FRAG	0x03
    294  1.1      rjs #define SCTP_DATA_UNORDERED	0x04
    295  1.1      rjs 
    296  1.1      rjs /* ECN Nonce: SACK Chunk Specific Flags */
    297  1.1      rjs #define SCTP_SACK_NONCE_SUM     0x01
    298  1.1      rjs 
    299  1.1      rjs #include <netinet/sctp_uio.h>
    300  1.1      rjs 
    301  1.1      rjs #endif /* !_NETINET_SCTP_H_ */
    302