xref: /illumos-gate/usr/src/uts/common/netinet/sctp.h (revision 9f13099e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5558fbd03Skcpoon  * Common Development and Distribution License (the "License").
6558fbd03Skcpoon  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2247b33325SGeorge Shepherd  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_NETINET_SCTP_H
277c478bd9Sstevel@tonic-gate #define	_NETINET_SCTP_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef __cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * This file contains the structure defintions and function prototypes
377c478bd9Sstevel@tonic-gate  * described in the IETF SCTP socket API document.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /* SCTP association ID type. */
417c478bd9Sstevel@tonic-gate typedef int	sctp_assoc_t;
427c478bd9Sstevel@tonic-gate typedef int32_t	sctp_assoc32_t;
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * SCTP socket options
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #define	SCTP_RTOINFO			1
487c478bd9Sstevel@tonic-gate #define	SCTP_ASSOCINFO			2
497c478bd9Sstevel@tonic-gate #define	SCTP_INITMSG			3
507c478bd9Sstevel@tonic-gate #define	SCTP_NODELAY			4
517c478bd9Sstevel@tonic-gate #define	SCTP_AUTOCLOSE			5
527c478bd9Sstevel@tonic-gate #define	SCTP_SET_PEER_PRIMARY_ADDR	6
537c478bd9Sstevel@tonic-gate #define	SCTP_PRIMARY_ADDR		7
54558fbd03Skcpoon #define	SCTP_ADAPTATION_LAYER		8
557c478bd9Sstevel@tonic-gate #define	SCTP_DISABLE_FRAGMENTS		9
567c478bd9Sstevel@tonic-gate #define	SCTP_PEER_ADDR_PARAMS		10
577c478bd9Sstevel@tonic-gate #define	SCTP_DEFAULT_SEND_PARAM		11
587c478bd9Sstevel@tonic-gate #define	SCTP_EVENTS			12
597c478bd9Sstevel@tonic-gate #define	SCTP_I_WANT_MAPPED_V4_ADDR	13
607c478bd9Sstevel@tonic-gate #define	SCTP_MAXSEG			14
617c478bd9Sstevel@tonic-gate #define	SCTP_STATUS			15
627c478bd9Sstevel@tonic-gate #define	SCTP_GET_PEER_ADDR_INFO		16
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Private socket options
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate #define	SCTP_GET_NLADDRS		17
687c478bd9Sstevel@tonic-gate #define	SCTP_GET_LADDRS			18
697c478bd9Sstevel@tonic-gate #define	SCTP_GET_NPADDRS		19
707c478bd9Sstevel@tonic-gate #define	SCTP_GET_PADDRS			20
717c478bd9Sstevel@tonic-gate #define	SCTP_ADD_ADDR			21
727c478bd9Sstevel@tonic-gate #define	SCTP_REM_ADDR			22
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * Additional SCTP socket options. This socket option is used to enable or
767c478bd9Sstevel@tonic-gate  * disable PR-SCTP support prior to establishing an association. By default,
777c478bd9Sstevel@tonic-gate  * PR-SCTP support is disabled.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	SCTP_PRSCTP			23
807c478bd9Sstevel@tonic-gate 
81*9f13099eSGeorge Shepherd /*
82*9f13099eSGeorge Shepherd  * SCTP socket option used to read per endpoint association statistics.
83*9f13099eSGeorge Shepherd  */
84*9f13099eSGeorge Shepherd #define	SCTP_GET_ASSOC_STATS		24
85*9f13099eSGeorge Shepherd 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * Ancillary data identifiers
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	SCTP_SNDRCV		0x100
907c478bd9Sstevel@tonic-gate #define	SCTP_INIT		0x101
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Notification types
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate #define	SCTP_ASSOC_CHANGE		1
967c478bd9Sstevel@tonic-gate #define	SCTP_PEER_ADDR_CHANGE		2
977c478bd9Sstevel@tonic-gate #define	SCTP_REMOTE_ERROR		3
987c478bd9Sstevel@tonic-gate #define	SCTP_SEND_FAILED		4
997c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_EVENT		5
100558fbd03Skcpoon #define	SCTP_ADAPTATION_INDICATION	6
1017c478bd9Sstevel@tonic-gate #define	SCTP_PARTIAL_DELIVERY_EVENT	7
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * SCTP Ancillary Data Definitions
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * sctp_initmsg structure provides information for initializing new SCTP
1097c478bd9Sstevel@tonic-gate  * associations with sendmsg().  The SCTP_INITMSG socket option uses
1107c478bd9Sstevel@tonic-gate  * this same data structure.
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate struct sctp_initmsg {
1137c478bd9Sstevel@tonic-gate 	uint16_t	sinit_num_ostreams;
1147c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_instreams;
1157c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_attempts;
1167c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_init_timeo;
1177c478bd9Sstevel@tonic-gate };
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * sctp_sndrcvinfo structure specifies SCTP options for sendmsg() and
1217c478bd9Sstevel@tonic-gate  * describes SCTP header information about a received message through
1227c478bd9Sstevel@tonic-gate  * recvmsg().
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate struct sctp_sndrcvinfo {
1257c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_stream;
1267c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_ssn;
1277c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_flags;
1287c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_ppid;
1297c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_context;
1307c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_timetolive;
1317c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_tsn;
1327c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_cumtsn;
1337c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sinfo_assoc_id;
1347c478bd9Sstevel@tonic-gate };
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /* sinfo_flags */
1377c478bd9Sstevel@tonic-gate #define	MSG_UNORDERED	0x01		/* Unordered data */
1387c478bd9Sstevel@tonic-gate #define	MSG_ABORT	0x02		/* Abort the connection */
1397c478bd9Sstevel@tonic-gate #define	MSG_EOF		0x04		/* Shutdown the connection */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * Use destination addr passed as parameter, not the association primary one.
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate #define	MSG_ADDR_OVER	0x08
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * This flag when set in sinfo_flags is used alongwith sinfo_timetolive to
1477c478bd9Sstevel@tonic-gate  * implement the "timed reliability" service discussed in RFC 3758.
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	MSG_PR_SCTP	0x10
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * SCTP notification definitions
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * To receive any ancillary data or notifications, the application can
1567c478bd9Sstevel@tonic-gate  * register it's interest by calling the SCTP_EVENTS setsockopt() with
1577c478bd9Sstevel@tonic-gate  * the sctp_event_subscribe structure.
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate struct sctp_event_subscribe {
1607c478bd9Sstevel@tonic-gate 	uint8_t	sctp_data_io_event;
1617c478bd9Sstevel@tonic-gate 	uint8_t sctp_association_event;
1627c478bd9Sstevel@tonic-gate 	uint8_t sctp_address_event;
1637c478bd9Sstevel@tonic-gate 	uint8_t sctp_send_failure_event;
1647c478bd9Sstevel@tonic-gate 	uint8_t sctp_peer_error_event;
1657c478bd9Sstevel@tonic-gate 	uint8_t sctp_shutdown_event;
1667c478bd9Sstevel@tonic-gate 	uint8_t sctp_partial_delivery_event;
167558fbd03Skcpoon 	uint8_t sctp_adaptation_layer_event;
1687c478bd9Sstevel@tonic-gate };
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /* Association events used in sctp_assoc_change structure */
1717c478bd9Sstevel@tonic-gate #define	SCTP_COMM_UP		0
1727c478bd9Sstevel@tonic-gate #define	SCTP_COMM_LOST		1
1737c478bd9Sstevel@tonic-gate #define	SCTP_RESTART		2
1747c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_COMP	3
1757c478bd9Sstevel@tonic-gate #define	SCTP_CANT_STR_ASSOC	4
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * Association flags. This flags is filled in the sac_flags for a SCTP_COMM_UP
1797c478bd9Sstevel@tonic-gate  * event if the association supports PR-SCTP.
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate #define	SCTP_PRSCTP_CAPABLE	0x01
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * sctp_assoc_change notification informs the socket that an SCTP association
1857c478bd9Sstevel@tonic-gate  * has either begun or ended.  The identifier for a new association is
1867c478bd9Sstevel@tonic-gate  * provided by this notification.
1877c478bd9Sstevel@tonic-gate  */
1887c478bd9Sstevel@tonic-gate struct sctp_assoc_change {
1897c478bd9Sstevel@tonic-gate 	uint16_t	sac_type;
1907c478bd9Sstevel@tonic-gate 	uint16_t	sac_flags;
1917c478bd9Sstevel@tonic-gate 	uint32_t	sac_length;
1927c478bd9Sstevel@tonic-gate 	uint16_t	sac_state;
1937c478bd9Sstevel@tonic-gate 	uint16_t	sac_error;
1947c478bd9Sstevel@tonic-gate 	uint16_t	sac_outbound_streams;
1957c478bd9Sstevel@tonic-gate 	uint16_t	sac_inbound_streams;
1967c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sac_assoc_id;
1977c478bd9Sstevel@tonic-gate 	/*
1987c478bd9Sstevel@tonic-gate 	 * The assoc ID can be followed by the ABORT chunk if available.
1997c478bd9Sstevel@tonic-gate 	 */
2007c478bd9Sstevel@tonic-gate };
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * A remote peer may send an Operational Error message to its peer. This
2047c478bd9Sstevel@tonic-gate  * message indicates a variety of error conditions on an association.
2057c478bd9Sstevel@tonic-gate  * The entire ERROR chunk as it appears on the wire is included in a
2067c478bd9Sstevel@tonic-gate  * SCTP_REMOTE_ERROR event.  Refer to the SCTP specification RFC2960
2077c478bd9Sstevel@tonic-gate  * and any extensions for a list of possible error formats.
2087c478bd9Sstevel@tonic-gate  */
2097c478bd9Sstevel@tonic-gate struct sctp_remote_error {
2107c478bd9Sstevel@tonic-gate 	uint16_t	sre_type;
2117c478bd9Sstevel@tonic-gate 	uint16_t	sre_flags;
2127c478bd9Sstevel@tonic-gate 	uint32_t	sre_length;
2137c478bd9Sstevel@tonic-gate 	uint16_t	sre_error;
2147c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sre_assoc_id;
2157c478bd9Sstevel@tonic-gate 	/*
2167c478bd9Sstevel@tonic-gate 	 * The assoc ID is followed by the actual error chunk.
2177c478bd9Sstevel@tonic-gate 	 */
2187c478bd9Sstevel@tonic-gate };
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate  * Note:
2227c478bd9Sstevel@tonic-gate  *
2237c478bd9Sstevel@tonic-gate  * In order to keep the offsets and size of the structure having a
2247c478bd9Sstevel@tonic-gate  * struct sockaddr_storage field the same between a 32-bit application
2257c478bd9Sstevel@tonic-gate  * and a 64-bit amd64 kernel, we use a #pragma pack(4) for those
2267c478bd9Sstevel@tonic-gate  * structures.
2277c478bd9Sstevel@tonic-gate  */
2287c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2297c478bd9Sstevel@tonic-gate #pragma pack(4)
2307c478bd9Sstevel@tonic-gate #endif
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /* Address change event state */
2337c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_AVAILABLE	0
2347c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_UNREACHABLE	1
2357c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_REMOVED	2
2367c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_ADDED		3
2377c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_MADE_PRIM	4
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate /*
2407c478bd9Sstevel@tonic-gate  * When a destination address on a multi-homed peer encounters a change,
2417c478bd9Sstevel@tonic-gate  * an interface details event, sctp_paddr_change, is sent to the socket.
2427c478bd9Sstevel@tonic-gate  */
2437c478bd9Sstevel@tonic-gate struct sctp_paddr_change {
2447c478bd9Sstevel@tonic-gate 	uint16_t	spc_type;
2457c478bd9Sstevel@tonic-gate 	uint16_t	spc_flags;
2467c478bd9Sstevel@tonic-gate 	uint32_t	spc_length;
2477c478bd9Sstevel@tonic-gate 	struct sockaddr_storage spc_aaddr;
2487c478bd9Sstevel@tonic-gate 	int		spc_state;
2497c478bd9Sstevel@tonic-gate 	int		spc_error;
2507c478bd9Sstevel@tonic-gate 	sctp_assoc_t	spc_assoc_id;
2517c478bd9Sstevel@tonic-gate };
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2547c478bd9Sstevel@tonic-gate #pragma pack()
2557c478bd9Sstevel@tonic-gate #endif
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /* flags used in sctp_send_failed notification. */
2587c478bd9Sstevel@tonic-gate #define	SCTP_DATA_UNSENT	1
2597c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SENT		2
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate  * If SCTP cannot deliver a message it may return the message as a
2637c478bd9Sstevel@tonic-gate  * notification using the following structure.
2647c478bd9Sstevel@tonic-gate  */
2657c478bd9Sstevel@tonic-gate struct sctp_send_failed {
2667c478bd9Sstevel@tonic-gate 	uint16_t	ssf_type;
2677c478bd9Sstevel@tonic-gate 	uint16_t	ssf_flags;
2687c478bd9Sstevel@tonic-gate 	uint32_t	ssf_length;
2697c478bd9Sstevel@tonic-gate 	uint32_t	ssf_error;
2707c478bd9Sstevel@tonic-gate 	struct sctp_sndrcvinfo ssf_info;
2717c478bd9Sstevel@tonic-gate 	sctp_assoc_t	ssf_assoc_id;
2727c478bd9Sstevel@tonic-gate 	/*
2737c478bd9Sstevel@tonic-gate 	 * The assoc ID is followed by the failed message.
2747c478bd9Sstevel@tonic-gate 	 */
2757c478bd9Sstevel@tonic-gate };
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate  * When a peer sends a SHUTDOWN, SCTP delivers the sctp_shutdown_event
2797c478bd9Sstevel@tonic-gate  * notification to inform the socket user that it should cease sending data.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate struct sctp_shutdown_event {
2827c478bd9Sstevel@tonic-gate 	uint16_t	sse_type;
2837c478bd9Sstevel@tonic-gate 	uint16_t	sse_flags;
2847c478bd9Sstevel@tonic-gate 	uint16_t	sse_length;
2857c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sse_assoc_id;
2867c478bd9Sstevel@tonic-gate };
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate /*
289558fbd03Skcpoon  * When a peer sends an Adaptation Layer Indication parameter, SCTP
290558fbd03Skcpoon  * delivers the sctp_adaptation_event notification to inform the socket
291558fbd03Skcpoon  * user the peer's requested adaptation layer.
2927c478bd9Sstevel@tonic-gate  */
293558fbd03Skcpoon struct sctp_adaptation_event {
2947c478bd9Sstevel@tonic-gate 	uint16_t	sai_type;
2957c478bd9Sstevel@tonic-gate 	uint16_t	sai_flags;
2967c478bd9Sstevel@tonic-gate 	uint32_t	sai_length;
297558fbd03Skcpoon 	uint32_t	sai_adaptation_ind;
2987c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sai_assoc_id;
2997c478bd9Sstevel@tonic-gate };
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /* Possible values in pdapi_indication for sctp_pdapi_event notification. */
3027c478bd9Sstevel@tonic-gate #define	SCTP_PARTIAL_DELIVERY_ABORTED	1
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate /*
3057c478bd9Sstevel@tonic-gate  * When a receiver is engaged in a partial delivery of a message the
3067c478bd9Sstevel@tonic-gate  * sctp_pdapi_event notification is used to indicate various events.
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate struct sctp_pdapi_event {
3097c478bd9Sstevel@tonic-gate 	uint16_t	pdapi_type;
3107c478bd9Sstevel@tonic-gate 	uint16_t	pdapi_flags;
3117c478bd9Sstevel@tonic-gate 	uint32_t	pdapi_length;
3127c478bd9Sstevel@tonic-gate 	uint32_t	pdapi_indication;
3137c478bd9Sstevel@tonic-gate 	sctp_assoc_t	pdapi_assoc_id;
3147c478bd9Sstevel@tonic-gate };
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * The sctp_notification structure is defined as the union of all
3187c478bd9Sstevel@tonic-gate  * notification types defined above.
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate union sctp_notification {
3217c478bd9Sstevel@tonic-gate 	struct {
3227c478bd9Sstevel@tonic-gate 		uint16_t		sn_type; /* Notification type. */
3237c478bd9Sstevel@tonic-gate 		uint16_t		sn_flags;
3247c478bd9Sstevel@tonic-gate 		uint32_t		sn_length;
3257c478bd9Sstevel@tonic-gate 	} sn_header;
3267c478bd9Sstevel@tonic-gate 	struct sctp_assoc_change	sn_assoc_change;
3277c478bd9Sstevel@tonic-gate 	struct sctp_paddr_change	sn_paddr_change;
3287c478bd9Sstevel@tonic-gate 	struct sctp_remote_error	sn_remote_error;
3297c478bd9Sstevel@tonic-gate 	struct sctp_send_failed		sn_send_failed;
3307c478bd9Sstevel@tonic-gate 	struct sctp_shutdown_event	sn_shutdown_event;
331558fbd03Skcpoon 	struct sctp_adaptation_event	sn_adaptation_event;
3327c478bd9Sstevel@tonic-gate 	struct sctp_pdapi_event		sn_pdapi_event;
3337c478bd9Sstevel@tonic-gate };
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate /*
3367c478bd9Sstevel@tonic-gate  * sctp_opt_info() option definitions
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /*
3407c478bd9Sstevel@tonic-gate  * The protocol parameters used to initialize and bound retransmission
3417c478bd9Sstevel@tonic-gate  * timeout (RTO) are tunable.  See RFC2960 for more information on
3427c478bd9Sstevel@tonic-gate  * how these parameters are used in RTO calculation.
3437c478bd9Sstevel@tonic-gate  *
3447c478bd9Sstevel@tonic-gate  * The sctp_rtoinfo structure is used to access and modify these
3457c478bd9Sstevel@tonic-gate  * parameters.
3467c478bd9Sstevel@tonic-gate  */
3477c478bd9Sstevel@tonic-gate struct sctp_rtoinfo {
3487c478bd9Sstevel@tonic-gate 	sctp_assoc_t	srto_assoc_id;
3497c478bd9Sstevel@tonic-gate 	uint32_t	srto_initial;
3507c478bd9Sstevel@tonic-gate 	uint32_t	srto_max;
3517c478bd9Sstevel@tonic-gate 	uint32_t	srto_min;
3527c478bd9Sstevel@tonic-gate };
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate /*
3557c478bd9Sstevel@tonic-gate  * The sctp_assocparams option is used to both examine and set various
3567c478bd9Sstevel@tonic-gate  * association and endpoint parameters.  See RFC2960 for more information
3577c478bd9Sstevel@tonic-gate  * on how this parameter is used.  The peer address parameter is ignored
3587c478bd9Sstevel@tonic-gate  * for one-to-one style socket.
3597c478bd9Sstevel@tonic-gate  */
3607c478bd9Sstevel@tonic-gate struct sctp_assocparams {
3617c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sasoc_assoc_id;
3627c478bd9Sstevel@tonic-gate 	uint16_t	sasoc_asocmaxrxt;
3637c478bd9Sstevel@tonic-gate 	uint16_t	sasoc_number_peer_destinations;
3647c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_peer_rwnd;
3657c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_local_rwnd;
3667c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_cookie_life;
3677c478bd9Sstevel@tonic-gate };
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
3707c478bd9Sstevel@tonic-gate #pragma pack(4)
3717c478bd9Sstevel@tonic-gate #endif
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate /* sctp_paddrinfo reachability state. */
3747c478bd9Sstevel@tonic-gate #define	SCTP_INACTIVE	1
3757c478bd9Sstevel@tonic-gate #define	SCTP_ACTIVE	2
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate /*
3787c478bd9Sstevel@tonic-gate  * Applications can retrieve information about a specific peer address
3797c478bd9Sstevel@tonic-gate  * of an association, including its reachability state, congestion
3807c478bd9Sstevel@tonic-gate  * window, and retransmission timer values.  This information is
3817c478bd9Sstevel@tonic-gate  * read-only. The sctp_paddrinfo structure is used to access this
3827c478bd9Sstevel@tonic-gate  * information:
3837c478bd9Sstevel@tonic-gate  */
3847c478bd9Sstevel@tonic-gate struct sctp_paddrinfo {
3857c478bd9Sstevel@tonic-gate 	sctp_assoc_t	spinfo_assoc_id;
3867c478bd9Sstevel@tonic-gate 	struct sockaddr_storage spinfo_address;
3877c478bd9Sstevel@tonic-gate 	int32_t		spinfo_state;
3887c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_cwnd;
3897c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_srtt;
3907c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_rto;
3917c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_mtu;
3927c478bd9Sstevel@tonic-gate };
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate /*
3957c478bd9Sstevel@tonic-gate  * Applications can enable or disable heartbeats for any peer address of
3967c478bd9Sstevel@tonic-gate  * an association, modify an address's heartbeat interval, force a
3977c478bd9Sstevel@tonic-gate  * heartbeat to be sent immediately, and adjust the address's maximum
3987c478bd9Sstevel@tonic-gate  * number of retransmissions sent before an address is considered
3997c478bd9Sstevel@tonic-gate  * unreachable.  The sctp_paddrparams structure is used to access and modify
4007c478bd9Sstevel@tonic-gate  * an address' parameters.
4017c478bd9Sstevel@tonic-gate  */
4027c478bd9Sstevel@tonic-gate struct sctp_paddrparams {
4037c478bd9Sstevel@tonic-gate 	sctp_assoc_t		spp_assoc_id;
4047c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	spp_address;
4057c478bd9Sstevel@tonic-gate 	uint32_t		spp_hbinterval;
4067c478bd9Sstevel@tonic-gate 	uint16_t		spp_pathmaxrxt;
4077c478bd9Sstevel@tonic-gate };
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate /*
4107c478bd9Sstevel@tonic-gate  * A socket user can request that the peer mark the enclosed address as the
4117c478bd9Sstevel@tonic-gate  * association's primary.  The enclosed address must be one of the
4127c478bd9Sstevel@tonic-gate  * association's locally bound addresses. The sctp_setpeerprim structure is
4137c478bd9Sstevel@tonic-gate  * used to make such request.
4147c478bd9Sstevel@tonic-gate  */
4157c478bd9Sstevel@tonic-gate struct sctp_setpeerprim {
4167c478bd9Sstevel@tonic-gate 	sctp_assoc_t		sspp_assoc_id;
4177c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	sspp_addr;
4187c478bd9Sstevel@tonic-gate };
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate /*
4217c478bd9Sstevel@tonic-gate  * A socket user can request that the local SCTP stack use the enclosed peer
4227c478bd9Sstevel@tonic-gate  * address as the association primary.  The enclosed address must be one of
4237c478bd9Sstevel@tonic-gate  * the association peer's addresses.  The sctp_setprim structure is used to
4247c478bd9Sstevel@tonic-gate  * make such request.
4257c478bd9Sstevel@tonic-gate  */
4267c478bd9Sstevel@tonic-gate struct sctp_setprim {
4277c478bd9Sstevel@tonic-gate 	sctp_assoc_t		ssp_assoc_id;
4287c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	ssp_addr;
4297c478bd9Sstevel@tonic-gate };
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
4327c478bd9Sstevel@tonic-gate #pragma pack()
4337c478bd9Sstevel@tonic-gate #endif
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate /* SCTP association states */
4367c478bd9Sstevel@tonic-gate #define	SCTPS_IDLE		-5	/* idle (opened, but not bound) */
4377c478bd9Sstevel@tonic-gate #define	SCTPS_BOUND		-4	/* bound, ready to connect or accept */
4387c478bd9Sstevel@tonic-gate #define	SCTPS_LISTEN		-3	/* listening for connection */
4397c478bd9Sstevel@tonic-gate #define	SCTPS_COOKIE_WAIT	-2
4407c478bd9Sstevel@tonic-gate #define	SCTPS_COOKIE_ECHOED	-1
4417c478bd9Sstevel@tonic-gate /* states < SCTPS_ESTABLISHED are those where connections not established */
4427c478bd9Sstevel@tonic-gate #define	SCTPS_ESTABLISHED	0	/* established */
4437c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_PENDING	1
4447c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_SENT	2
4457c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_RECEIVED	3
4467c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_ACK_SENT	4
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate /*
4497c478bd9Sstevel@tonic-gate  * Applications can retrieve current status information about an
4507c478bd9Sstevel@tonic-gate  * association, including association state, peer receiver window size,
4517c478bd9Sstevel@tonic-gate  * number of unacked data chunks, and number of data chunks pending
4527c478bd9Sstevel@tonic-gate  * receipt.  This information is read-only.  The sctp_status structure is
4537c478bd9Sstevel@tonic-gate  * used to access this information:
4547c478bd9Sstevel@tonic-gate  */
4557c478bd9Sstevel@tonic-gate struct sctp_status {
4567c478bd9Sstevel@tonic-gate 	sctp_assoc_t		sstat_assoc_id;
4577c478bd9Sstevel@tonic-gate 	int32_t			sstat_state;
4587c478bd9Sstevel@tonic-gate 	uint32_t		sstat_rwnd;
4597c478bd9Sstevel@tonic-gate 	uint16_t		sstat_unackdata;
4607c478bd9Sstevel@tonic-gate 	uint16_t		sstat_penddata;
4617c478bd9Sstevel@tonic-gate 	uint16_t		sstat_instrms;
4627c478bd9Sstevel@tonic-gate 	uint16_t		sstat_outstrms;
4637c478bd9Sstevel@tonic-gate 	uint32_t		sstat_fragmentation_point;
4647c478bd9Sstevel@tonic-gate 	struct sctp_paddrinfo	sstat_primary;
4657c478bd9Sstevel@tonic-gate };
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate /* Possible values for sstat_state */
4687c478bd9Sstevel@tonic-gate #define	SCTP_CLOSED		SCTPS_IDLE
4697c478bd9Sstevel@tonic-gate #define	SCTP_BOUND		SCTPS_BOUND
4707c478bd9Sstevel@tonic-gate #define	SCTP_LISTEN		SCTPS_LISTEN
4717c478bd9Sstevel@tonic-gate #define	SCTP_COOKIE_WAIT	SCTPS_COOKIE_WAIT
4727c478bd9Sstevel@tonic-gate #define	SCTP_COOKIE_ECHOED	SCTPS_COOKIE_ECHOED
4737c478bd9Sstevel@tonic-gate #define	SCTP_ESTABLISHED	SCTPS_ESTABLISHED
4747c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_PENDING	SCTPS_SHUTDOWN_PENDING
4757c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_SENT	SCTPS_SHUTDOWN_SENT
4767c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_RECEIVED	SCTPS_SHUTDOWN_RECEIVED
4777c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_ACK_SENT	SCTPS_SHUTDOWN_ACK_SENT
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate /*
4807c478bd9Sstevel@tonic-gate  * A socket user can request that the local endpoint set the specified
481558fbd03Skcpoon  * Adaptation Layer Indication parameter for all future INIT and INIT-ACK
482558fbd03Skcpoon  * exchanges.  The sctp_setadaptation structure is used to make such request.
4837c478bd9Sstevel@tonic-gate  */
484558fbd03Skcpoon struct sctp_setadaptation {
485558fbd03Skcpoon 	uint32_t   ssb_adaptation_ind;
4867c478bd9Sstevel@tonic-gate };
4877c478bd9Sstevel@tonic-gate 
488*9f13099eSGeorge Shepherd /*
489*9f13099eSGeorge Shepherd  * A socket user request reads local per endpoint association stats.
490*9f13099eSGeorge Shepherd  * All stats are counts except sas_maxrto, which is the max value
491*9f13099eSGeorge Shepherd  * since the last user request for stats on this endpoint.
492*9f13099eSGeorge Shepherd  */
493*9f13099eSGeorge Shepherd typedef struct sctp_assoc_stats {
494*9f13099eSGeorge Shepherd 	uint64_t	sas_rtxchunks; /* Retransmitted Chunks */
495*9f13099eSGeorge Shepherd 	uint64_t	sas_gapcnt; /* Gap Acknowledgements Received */
496*9f13099eSGeorge Shepherd 	uint64_t	sas_maxrto; /* Maximum Observed RTO this period */
497*9f13099eSGeorge Shepherd 	uint64_t	sas_outseqtsns; /* TSN received > next expected */
498*9f13099eSGeorge Shepherd 	uint64_t	sas_osacks; /* SACKs sent */
499*9f13099eSGeorge Shepherd 	uint64_t	sas_isacks; /* SACKs received */
500*9f13099eSGeorge Shepherd 	uint64_t	sas_octrlchunks; /* Control chunks sent - no dups */
501*9f13099eSGeorge Shepherd 	uint64_t	sas_ictrlchunks; /* Control chunks received - no dups */
502*9f13099eSGeorge Shepherd 	uint64_t	sas_oodchunks; /* Ordered data chunks sent */
503*9f13099eSGeorge Shepherd 	uint64_t	sas_iodchunks; /* Ordered data chunks received */
504*9f13099eSGeorge Shepherd 	uint64_t	sas_ouodchunks; /* Unordered data chunks sent */
505*9f13099eSGeorge Shepherd 	uint64_t	sas_iuodchunks; /* Unordered data chunks received */
506*9f13099eSGeorge Shepherd 	uint64_t	sas_idupchunks; /* Dups received (ordered+unordered) */
507*9f13099eSGeorge Shepherd } sctp_assoc_stats_t;
508*9f13099eSGeorge Shepherd 
5097c478bd9Sstevel@tonic-gate /*
5107c478bd9Sstevel@tonic-gate  * Private ioctl option structure
5117c478bd9Sstevel@tonic-gate  */
5127c478bd9Sstevel@tonic-gate struct sctpopt {
5137c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sopt_aid;
5147c478bd9Sstevel@tonic-gate 	int		sopt_name;
5157c478bd9Sstevel@tonic-gate 	uint_t		sopt_len;
5167c478bd9Sstevel@tonic-gate 	caddr_t		sopt_val;
5177c478bd9Sstevel@tonic-gate };
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
5207c478bd9Sstevel@tonic-gate struct sctpopt32 {
5217c478bd9Sstevel@tonic-gate 	sctp_assoc32_t	sopt_aid;
5227c478bd9Sstevel@tonic-gate 	int32_t		sopt_name;
5237c478bd9Sstevel@tonic-gate 	uint32_t	sopt_len;
5247c478bd9Sstevel@tonic-gate 	caddr32_t	sopt_val;
5257c478bd9Sstevel@tonic-gate };
5267c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate /* Forward Cumulative TSN chunk entry. */
5297c478bd9Sstevel@tonic-gate typedef struct ftsn_entry_s {
5307c478bd9Sstevel@tonic-gate 	uint16_t	ftsn_sid;
5317c478bd9Sstevel@tonic-gate 	uint16_t	ftsn_ssn;
5327c478bd9Sstevel@tonic-gate } ftsn_entry_t;
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate /*
5357c478bd9Sstevel@tonic-gate  * New socket functions for SCTP
5367c478bd9Sstevel@tonic-gate  */
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate /* sctp_bindx() operations. */
5397c478bd9Sstevel@tonic-gate #define	SCTP_BINDX_ADD_ADDR	1
5407c478bd9Sstevel@tonic-gate #define	SCTP_BINDX_REM_ADDR	2
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) || defined(_BOOT)
5437c478bd9Sstevel@tonic-gate #ifdef	__STDC__
5447c478bd9Sstevel@tonic-gate extern int sctp_bindx(int, void *, int, int);
5457c478bd9Sstevel@tonic-gate extern void sctp_freeladdrs(void *);
5467c478bd9Sstevel@tonic-gate extern void sctp_freepaddrs(void *);
5477c478bd9Sstevel@tonic-gate extern int sctp_getladdrs(int, sctp_assoc_t, void **);
5487c478bd9Sstevel@tonic-gate extern int sctp_getpaddrs(int, sctp_assoc_t, void **);
5497c478bd9Sstevel@tonic-gate extern int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
5507c478bd9Sstevel@tonic-gate extern int sctp_peeloff(int, sctp_assoc_t);
5517c478bd9Sstevel@tonic-gate extern ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *,
5527c478bd9Sstevel@tonic-gate     socklen_t *, struct sctp_sndrcvinfo *, int *msg_flags);
5537c478bd9Sstevel@tonic-gate extern ssize_t sctp_send(int, const void *, size_t,
5547c478bd9Sstevel@tonic-gate     const struct sctp_sndrcvinfo *, int);
5557c478bd9Sstevel@tonic-gate extern ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
5567c478bd9Sstevel@tonic-gate     socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
5577c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
5587c478bd9Sstevel@tonic-gate extern int sctp_bindx();
5597c478bd9Sstevel@tonic-gate extern void sctp_freeladdrs();
5607c478bd9Sstevel@tonic-gate extern void sctp_freepaddrs();
5617c478bd9Sstevel@tonic-gate extern int sctp_getladdrs();
5627c478bd9Sstevel@tonic-gate extern int sctp_getpaddrs();
5637c478bd9Sstevel@tonic-gate extern int sctp_opt_info();
5647c478bd9Sstevel@tonic-gate extern int sctp_peeloff();
5657c478bd9Sstevel@tonic-gate extern ssize_t sctp_recvmsg();
5667c478bd9Sstevel@tonic-gate extern ssize_t sctp_send();
5677c478bd9Sstevel@tonic-gate extern ssize_t sctp_sendmsg();
5687c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
5697c478bd9Sstevel@tonic-gate #endif	/* !defined(_KERNEL) || defined(_BOOT) */
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate /*
5737c478bd9Sstevel@tonic-gate  * SCTP protocol related elements.
5747c478bd9Sstevel@tonic-gate  */
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate /* All SCTP chunks and parameters are 32-bit aligned */
5777c478bd9Sstevel@tonic-gate #define	SCTP_ALIGN	4
5787c478bd9Sstevel@tonic-gate 
57977ebe684SGeorge Shepherd /*
58077ebe684SGeorge Shepherd  * SCTP association optional parameter handling. The top two bits
58177ebe684SGeorge Shepherd  * of the parameter type define how this and further parameters in
58277ebe684SGeorge Shepherd  * the received chunk should be handled.
58377ebe684SGeorge Shepherd  */
58477ebe684SGeorge Shepherd #define	SCTP_UNREC_PARAM_MASK	0xc000
58577ebe684SGeorge Shepherd /* Continue processing parameters after an unrecognized optional param? */
58677ebe684SGeorge Shepherd #define	SCTP_CONT_PROC_PARAMS	0x8000
58777ebe684SGeorge Shepherd /* Report this unreconized optional parameter or silently ignore it? */
58877ebe684SGeorge Shepherd #define	SCTP_REPORT_THIS_PARAM	0x4000
58977ebe684SGeorge Shepherd 
5907c478bd9Sstevel@tonic-gate /*
5917c478bd9Sstevel@tonic-gate  * Data chunk bit manipulations
5927c478bd9Sstevel@tonic-gate  */
5937c478bd9Sstevel@tonic-gate #define	SCTP_DATA_EBIT	0x01
5947c478bd9Sstevel@tonic-gate #define	SCTP_TBIT	0x01
5957c478bd9Sstevel@tonic-gate #define	SCTP_DATA_BBIT	0x02
5967c478bd9Sstevel@tonic-gate #define	SCTP_DATA_UBIT	0x04
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_BBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_BBIT)
5997c478bd9Sstevel@tonic-gate #define	SCTP_GET_TBIT(cp)	((cp)->sch_flags & SCTP_TBIT)
6007c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_EBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_EBIT)
6017c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_UBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_UBIT)
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_BBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_BBIT)
6047c478bd9Sstevel@tonic-gate #define	SCTP_SET_TBIT(cp)	((cp)->sch_flags |= SCTP_TBIT)
6057c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_EBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_EBIT)
6067c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_UBIT(sdc)	((sdc)->sdh_flags |=  SCTP_DATA_UBIT)
6077c478bd9Sstevel@tonic-gate 
6087c478bd9Sstevel@tonic-gate /* SCTP common header */
6097c478bd9Sstevel@tonic-gate typedef struct sctp_hdr {
6107c478bd9Sstevel@tonic-gate 	uint16_t	sh_sport;
6117c478bd9Sstevel@tonic-gate 	uint16_t	sh_dport;
6127c478bd9Sstevel@tonic-gate 	uint32_t	sh_verf;
6137c478bd9Sstevel@tonic-gate 	uint32_t	sh_chksum;
6147c478bd9Sstevel@tonic-gate } sctp_hdr_t;
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate /* Chunk IDs */
6177c478bd9Sstevel@tonic-gate typedef enum {
6187c478bd9Sstevel@tonic-gate 	CHUNK_DATA,
6197c478bd9Sstevel@tonic-gate 	CHUNK_INIT,
6207c478bd9Sstevel@tonic-gate 	CHUNK_INIT_ACK,
6217c478bd9Sstevel@tonic-gate 	CHUNK_SACK,
6227c478bd9Sstevel@tonic-gate 	CHUNK_HEARTBEAT,
6237c478bd9Sstevel@tonic-gate 	CHUNK_HEARTBEAT_ACK,
6247c478bd9Sstevel@tonic-gate 	CHUNK_ABORT,
6257c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN,
6267c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN_ACK,
6277c478bd9Sstevel@tonic-gate 	CHUNK_ERROR,
6287c478bd9Sstevel@tonic-gate 	CHUNK_COOKIE,
6297c478bd9Sstevel@tonic-gate 	CHUNK_COOKIE_ACK,
6307c478bd9Sstevel@tonic-gate 	CHUNK_ECNE,
6317c478bd9Sstevel@tonic-gate 	CHUNK_CWR,
6327c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN_COMPLETE,
6337c478bd9Sstevel@tonic-gate 	CHUNK_ASCONF_ACK = 128,
6347c478bd9Sstevel@tonic-gate 	CHUNK_FORWARD_TSN = 192,
6357c478bd9Sstevel@tonic-gate 	CHUNK_ASCONF = 193
6367c478bd9Sstevel@tonic-gate } sctp_chunk_id_t;
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate /* Common chunk header */
6397c478bd9Sstevel@tonic-gate typedef struct sctp_chunk_hdr {
6407c478bd9Sstevel@tonic-gate 	uint8_t		sch_id;
6417c478bd9Sstevel@tonic-gate 	uint8_t		sch_flags;
6427c478bd9Sstevel@tonic-gate 	uint16_t	sch_len;
6437c478bd9Sstevel@tonic-gate } sctp_chunk_hdr_t;
6447c478bd9Sstevel@tonic-gate 
6457c478bd9Sstevel@tonic-gate /* INIT chunk data definition */
6467c478bd9Sstevel@tonic-gate typedef struct sctp_init_chunk {
6477c478bd9Sstevel@tonic-gate 	uint32_t	sic_inittag;
6487c478bd9Sstevel@tonic-gate 	uint32_t	sic_a_rwnd;
6497c478bd9Sstevel@tonic-gate 	uint16_t	sic_outstr;
6507c478bd9Sstevel@tonic-gate 	uint16_t	sic_instr;
6517c478bd9Sstevel@tonic-gate 	uint32_t	sic_inittsn;
6527c478bd9Sstevel@tonic-gate } sctp_init_chunk_t;
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate /* SCTP DATA chunk */
6557c478bd9Sstevel@tonic-gate typedef struct sctp_data_chunk {
6567c478bd9Sstevel@tonic-gate 	uint32_t	sdc_tsn;
6577c478bd9Sstevel@tonic-gate 	uint16_t	sdc_sid;
6587c478bd9Sstevel@tonic-gate 	uint16_t	sdc_ssn;
6597c478bd9Sstevel@tonic-gate 	uint32_t	sdc_payload_id;
6607c478bd9Sstevel@tonic-gate } sctp_data_chunk_t;
6617c478bd9Sstevel@tonic-gate 
6627c478bd9Sstevel@tonic-gate /* sctp_data_hdr includes the SCTP chunk hdr and the DATA chunk */
6637c478bd9Sstevel@tonic-gate typedef struct sctp_data_hdr {
6647c478bd9Sstevel@tonic-gate 	sctp_chunk_hdr_t	sdh_chdr;
6657c478bd9Sstevel@tonic-gate 	sctp_data_chunk_t	sdh_data;
6667c478bd9Sstevel@tonic-gate #define	sdh_id		sdh_chdr.sch_id
6677c478bd9Sstevel@tonic-gate #define	sdh_flags	sdh_chdr.sch_flags
6687c478bd9Sstevel@tonic-gate #define	sdh_len		sdh_chdr.sch_len
6697c478bd9Sstevel@tonic-gate #define	sdh_tsn		sdh_data.sdc_tsn
6707c478bd9Sstevel@tonic-gate #define	sdh_sid		sdh_data.sdc_sid
6717c478bd9Sstevel@tonic-gate #define	sdh_ssn		sdh_data.sdc_ssn
6727c478bd9Sstevel@tonic-gate #define	sdh_payload_id	sdh_data.sdc_payload_id
6737c478bd9Sstevel@tonic-gate } sctp_data_hdr_t;
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate typedef struct sctp_sack_chunk {
6767c478bd9Sstevel@tonic-gate 	uint32_t	ssc_cumtsn;
6777c478bd9Sstevel@tonic-gate 	uint32_t	ssc_a_rwnd;
6787c478bd9Sstevel@tonic-gate 	uint16_t	ssc_numfrags;
6797c478bd9Sstevel@tonic-gate 	uint16_t	ssc_numdups;
6807c478bd9Sstevel@tonic-gate } sctp_sack_chunk_t;
6817c478bd9Sstevel@tonic-gate 
6827c478bd9Sstevel@tonic-gate typedef struct sctp_sack_frag {
6837c478bd9Sstevel@tonic-gate 	uint16_t	ssf_start;
6847c478bd9Sstevel@tonic-gate 	uint16_t	ssf_end;
6857c478bd9Sstevel@tonic-gate } sctp_sack_frag_t;
6867c478bd9Sstevel@tonic-gate 
6877c478bd9Sstevel@tonic-gate /* Parameter types */
6887c478bd9Sstevel@tonic-gate #define	PARM_UNKNOWN		0
6897c478bd9Sstevel@tonic-gate #define	PARM_HBINFO		1
6907c478bd9Sstevel@tonic-gate #define	PARM_ADDR4		5
6917c478bd9Sstevel@tonic-gate #define	PARM_ADDR6		6
6927c478bd9Sstevel@tonic-gate #define	PARM_COOKIE		7
6937c478bd9Sstevel@tonic-gate #define	PARM_UNRECOGNIZED	8
6947c478bd9Sstevel@tonic-gate #define	PARM_COOKIE_PRESERVE	9
6957c478bd9Sstevel@tonic-gate #define	PARM_ADDR_HOST_NAME	11
6967c478bd9Sstevel@tonic-gate #define	PARM_SUPP_ADDRS		12
6977c478bd9Sstevel@tonic-gate #define	PARM_ECN		0x8000
6987c478bd9Sstevel@tonic-gate #define	PARM_ECN_CAPABLE	PARM_ECN
6997c478bd9Sstevel@tonic-gate #define	PARM_FORWARD_TSN	0xc000
7007c478bd9Sstevel@tonic-gate #define	PARM_ADD_IP		0xc001
7017c478bd9Sstevel@tonic-gate #define	PARM_DEL_IP		0xc002
7027c478bd9Sstevel@tonic-gate #define	PARM_ERROR_IND		0xc003
7037c478bd9Sstevel@tonic-gate #define	PARM_ASCONF_ERROR	PARM_ERROR_IND
7047c478bd9Sstevel@tonic-gate #define	PARM_SET_PRIMARY	0xc004
7057c478bd9Sstevel@tonic-gate #define	PARM_PRIMARY_ADDR	PARM_SET_PRIMARY
7067c478bd9Sstevel@tonic-gate #define	PARM_SUCCESS		0xc005
7077c478bd9Sstevel@tonic-gate #define	PARM_ASCONF_SUCCESS	PARM_SUCCESS
7087c478bd9Sstevel@tonic-gate #define	PARM_ADAPT_LAYER_IND	0xc006
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate 
7117c478bd9Sstevel@tonic-gate /* Lengths from SCTP spec */
7127c478bd9Sstevel@tonic-gate #define	PARM_ADDR4_LEN		8
7137c478bd9Sstevel@tonic-gate #define	PARM_ADDR6_LEN		20
7147c478bd9Sstevel@tonic-gate 
7157c478bd9Sstevel@tonic-gate /* Parameter header */
7167c478bd9Sstevel@tonic-gate typedef struct sctp_parm_hdr {
7177c478bd9Sstevel@tonic-gate 	uint16_t	sph_type;
7187c478bd9Sstevel@tonic-gate 	uint16_t	sph_len;
7197c478bd9Sstevel@tonic-gate } sctp_parm_hdr_t;
7207c478bd9Sstevel@tonic-gate 
72147b33325SGeorge Shepherd /*
72247b33325SGeorge Shepherd  * The following extend sctp_parm_hdr_t
72347b33325SGeorge Shepherd  * with cause-specfic content used to fill
72447b33325SGeorge Shepherd  * CAUSE blocks in ABORT or ERROR chunks.
72547b33325SGeorge Shepherd  * The overall size of the CAUSE block will
72647b33325SGeorge Shepherd  * be sizeof (sctp_parm_hdr_t) plus the size
72747b33325SGeorge Shepherd  * of the extended cause structure,
72847b33325SGeorge Shepherd  */
72947b33325SGeorge Shepherd 
73047b33325SGeorge Shepherd /*
73147b33325SGeorge Shepherd  * Invalid stream-identifier extended cause.
73247b33325SGeorge Shepherd  * SCTP_ERR_BAD_SID
73347b33325SGeorge Shepherd  */
73447b33325SGeorge Shepherd typedef struct sctp_bsc {
73547b33325SGeorge Shepherd 	uint16_t	bsc_sid;
73647b33325SGeorge Shepherd 	uint16_t	bsc_pad; /* RESV = 0 */
73747b33325SGeorge Shepherd } sctp_bsc_t;
73847b33325SGeorge Shepherd 
73947b33325SGeorge Shepherd /*
74047b33325SGeorge Shepherd  * Missing parameter extended cause, currently
74147b33325SGeorge Shepherd  * only one missing parameter is supported.
74247b33325SGeorge Shepherd  * SCTP_ERR_MISSING_PARM
74347b33325SGeorge Shepherd  */
74447b33325SGeorge Shepherd typedef struct sctp_mpc {
74547b33325SGeorge Shepherd 	uint32_t	mpc_num;
74647b33325SGeorge Shepherd 	uint16_t	mpc_param;
74747b33325SGeorge Shepherd 	uint16_t	mpc_pad;
74847b33325SGeorge Shepherd } sctp_mpc_t;
74947b33325SGeorge Shepherd 
7507c478bd9Sstevel@tonic-gate /* Error causes */
7517c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNKNOWN		0
7527c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_SID		1
7537c478bd9Sstevel@tonic-gate #define	SCTP_ERR_MISSING_PARM		2
7547c478bd9Sstevel@tonic-gate #define	SCTP_ERR_STALE_COOKIE		3
7557c478bd9Sstevel@tonic-gate #define	SCTP_ERR_NO_RESOURCES		4
7567c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_ADDR		5
7577c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNREC_CHUNK		6
7587c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_MANDPARM		7
7597c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNREC_PARM		8
7607c478bd9Sstevel@tonic-gate #define	SCTP_ERR_NO_USR_DATA		9
7617c478bd9Sstevel@tonic-gate #define	SCTP_ERR_COOKIE_SHUT		10
7627c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RESTART_NEW_ADDRS	11
7637c478bd9Sstevel@tonic-gate #define	SCTP_ERR_USER_ABORT		12
7647c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DELETE_LASTADDR	256
7657c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RESOURCE_SHORTAGE	257
7667c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DELETE_SRCADDR		258
7677c478bd9Sstevel@tonic-gate #define	SCTP_ERR_AUTH_ERR		260
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate /*
7707c478bd9Sstevel@tonic-gate  * Extensions
7717c478bd9Sstevel@tonic-gate  */
7727c478bd9Sstevel@tonic-gate 
7737c478bd9Sstevel@tonic-gate /* Extended Chunk Types */
7747c478bd9Sstevel@tonic-gate #define	CHUNK_ASCONF		0xc1
7757c478bd9Sstevel@tonic-gate #define	CHUNK_ASCONF_ACK	0x80
7767c478bd9Sstevel@tonic-gate 
7777c478bd9Sstevel@tonic-gate /* Extension Error Causes */
7787c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DEL_LAST_ADDR	0x0100
7797c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RES_SHORTAGE	0x0101
7807c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DEL_SRC_ADDR	0x0102
7817c478bd9Sstevel@tonic-gate #define	SCTP_ERR_ILLEGAL_ACK	0x0103
7827c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNAUTHORIZED	0x0104
7837c478bd9Sstevel@tonic-gate 
7847c478bd9Sstevel@tonic-gate typedef struct sctp_addip4 {
7857c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad4_addip_ph;
7867c478bd9Sstevel@tonic-gate 	uint32_t		asconf_req_cid;
7877c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad4_addr4_ph;
7887c478bd9Sstevel@tonic-gate 	ipaddr_t		sad4_addr;
7897c478bd9Sstevel@tonic-gate } sctp_addip4_t;
7907c478bd9Sstevel@tonic-gate 
7917c478bd9Sstevel@tonic-gate typedef struct sctp_addip6 {
7927c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad6_addip_ph;
7937c478bd9Sstevel@tonic-gate 	uint32_t		asconf_req_cid;
7947c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad6_addr6_ph;
7957c478bd9Sstevel@tonic-gate 	in6_addr_t		sad6_addr;
7967c478bd9Sstevel@tonic-gate } sctp_addip6_t;
7977c478bd9Sstevel@tonic-gate 
7987c478bd9Sstevel@tonic-gate #ifdef __cplusplus
7997c478bd9Sstevel@tonic-gate }
8007c478bd9Sstevel@tonic-gate #endif
8017c478bd9Sstevel@tonic-gate 
8027c478bd9Sstevel@tonic-gate #endif	/* _NETINET_SCTP_H */
803