xref: /titanic_52/usr/src/uts/common/netinet/sctp.h (revision 77ebe684ef29c4e071249d0fcb90f306d3aa1f12)
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 /*
22*77ebe684SGeorge Shepherd  * Copyright 2008 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 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * Ancillary data identifiers
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate #define	SCTP_SNDRCV		0x100
857c478bd9Sstevel@tonic-gate #define	SCTP_INIT		0x101
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Notification types
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	SCTP_ASSOC_CHANGE		1
917c478bd9Sstevel@tonic-gate #define	SCTP_PEER_ADDR_CHANGE		2
927c478bd9Sstevel@tonic-gate #define	SCTP_REMOTE_ERROR		3
937c478bd9Sstevel@tonic-gate #define	SCTP_SEND_FAILED		4
947c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_EVENT		5
95558fbd03Skcpoon #define	SCTP_ADAPTATION_INDICATION	6
967c478bd9Sstevel@tonic-gate #define	SCTP_PARTIAL_DELIVERY_EVENT	7
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * SCTP Ancillary Data Definitions
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * sctp_initmsg structure provides information for initializing new SCTP
1047c478bd9Sstevel@tonic-gate  * associations with sendmsg().  The SCTP_INITMSG socket option uses
1057c478bd9Sstevel@tonic-gate  * this same data structure.
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate struct sctp_initmsg {
1087c478bd9Sstevel@tonic-gate 	uint16_t	sinit_num_ostreams;
1097c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_instreams;
1107c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_attempts;
1117c478bd9Sstevel@tonic-gate 	uint16_t	sinit_max_init_timeo;
1127c478bd9Sstevel@tonic-gate };
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * sctp_sndrcvinfo structure specifies SCTP options for sendmsg() and
1167c478bd9Sstevel@tonic-gate  * describes SCTP header information about a received message through
1177c478bd9Sstevel@tonic-gate  * recvmsg().
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate struct sctp_sndrcvinfo {
1207c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_stream;
1217c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_ssn;
1227c478bd9Sstevel@tonic-gate 	uint16_t	sinfo_flags;
1237c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_ppid;
1247c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_context;
1257c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_timetolive;
1267c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_tsn;
1277c478bd9Sstevel@tonic-gate 	uint32_t	sinfo_cumtsn;
1287c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sinfo_assoc_id;
1297c478bd9Sstevel@tonic-gate };
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /* sinfo_flags */
1327c478bd9Sstevel@tonic-gate #define	MSG_UNORDERED	0x01		/* Unordered data */
1337c478bd9Sstevel@tonic-gate #define	MSG_ABORT	0x02		/* Abort the connection */
1347c478bd9Sstevel@tonic-gate #define	MSG_EOF		0x04		/* Shutdown the connection */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  * Use destination addr passed as parameter, not the association primary one.
1387c478bd9Sstevel@tonic-gate  */
1397c478bd9Sstevel@tonic-gate #define	MSG_ADDR_OVER	0x08
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * This flag when set in sinfo_flags is used alongwith sinfo_timetolive to
1427c478bd9Sstevel@tonic-gate  * implement the "timed reliability" service discussed in RFC 3758.
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate #define	MSG_PR_SCTP	0x10
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * SCTP notification definitions
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * To receive any ancillary data or notifications, the application can
1517c478bd9Sstevel@tonic-gate  * register it's interest by calling the SCTP_EVENTS setsockopt() with
1527c478bd9Sstevel@tonic-gate  * the sctp_event_subscribe structure.
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate struct sctp_event_subscribe {
1557c478bd9Sstevel@tonic-gate 	uint8_t	sctp_data_io_event;
1567c478bd9Sstevel@tonic-gate 	uint8_t sctp_association_event;
1577c478bd9Sstevel@tonic-gate 	uint8_t sctp_address_event;
1587c478bd9Sstevel@tonic-gate 	uint8_t sctp_send_failure_event;
1597c478bd9Sstevel@tonic-gate 	uint8_t sctp_peer_error_event;
1607c478bd9Sstevel@tonic-gate 	uint8_t sctp_shutdown_event;
1617c478bd9Sstevel@tonic-gate 	uint8_t sctp_partial_delivery_event;
162558fbd03Skcpoon 	uint8_t sctp_adaptation_layer_event;
1637c478bd9Sstevel@tonic-gate };
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /* Association events used in sctp_assoc_change structure */
1667c478bd9Sstevel@tonic-gate #define	SCTP_COMM_UP		0
1677c478bd9Sstevel@tonic-gate #define	SCTP_COMM_LOST		1
1687c478bd9Sstevel@tonic-gate #define	SCTP_RESTART		2
1697c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_COMP	3
1707c478bd9Sstevel@tonic-gate #define	SCTP_CANT_STR_ASSOC	4
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate /*
1737c478bd9Sstevel@tonic-gate  * Association flags. This flags is filled in the sac_flags for a SCTP_COMM_UP
1747c478bd9Sstevel@tonic-gate  * event if the association supports PR-SCTP.
1757c478bd9Sstevel@tonic-gate  */
1767c478bd9Sstevel@tonic-gate #define	SCTP_PRSCTP_CAPABLE	0x01
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /*
1797c478bd9Sstevel@tonic-gate  * sctp_assoc_change notification informs the socket that an SCTP association
1807c478bd9Sstevel@tonic-gate  * has either begun or ended.  The identifier for a new association is
1817c478bd9Sstevel@tonic-gate  * provided by this notification.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate struct sctp_assoc_change {
1847c478bd9Sstevel@tonic-gate 	uint16_t	sac_type;
1857c478bd9Sstevel@tonic-gate 	uint16_t	sac_flags;
1867c478bd9Sstevel@tonic-gate 	uint32_t	sac_length;
1877c478bd9Sstevel@tonic-gate 	uint16_t	sac_state;
1887c478bd9Sstevel@tonic-gate 	uint16_t	sac_error;
1897c478bd9Sstevel@tonic-gate 	uint16_t	sac_outbound_streams;
1907c478bd9Sstevel@tonic-gate 	uint16_t	sac_inbound_streams;
1917c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sac_assoc_id;
1927c478bd9Sstevel@tonic-gate 	/*
1937c478bd9Sstevel@tonic-gate 	 * The assoc ID can be followed by the ABORT chunk if available.
1947c478bd9Sstevel@tonic-gate 	 */
1957c478bd9Sstevel@tonic-gate };
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate /*
1987c478bd9Sstevel@tonic-gate  * A remote peer may send an Operational Error message to its peer. This
1997c478bd9Sstevel@tonic-gate  * message indicates a variety of error conditions on an association.
2007c478bd9Sstevel@tonic-gate  * The entire ERROR chunk as it appears on the wire is included in a
2017c478bd9Sstevel@tonic-gate  * SCTP_REMOTE_ERROR event.  Refer to the SCTP specification RFC2960
2027c478bd9Sstevel@tonic-gate  * and any extensions for a list of possible error formats.
2037c478bd9Sstevel@tonic-gate  */
2047c478bd9Sstevel@tonic-gate struct sctp_remote_error {
2057c478bd9Sstevel@tonic-gate 	uint16_t	sre_type;
2067c478bd9Sstevel@tonic-gate 	uint16_t	sre_flags;
2077c478bd9Sstevel@tonic-gate 	uint32_t	sre_length;
2087c478bd9Sstevel@tonic-gate 	uint16_t	sre_error;
2097c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sre_assoc_id;
2107c478bd9Sstevel@tonic-gate 	/*
2117c478bd9Sstevel@tonic-gate 	 * The assoc ID is followed by the actual error chunk.
2127c478bd9Sstevel@tonic-gate 	 */
2137c478bd9Sstevel@tonic-gate };
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate  * Note:
2177c478bd9Sstevel@tonic-gate  *
2187c478bd9Sstevel@tonic-gate  * In order to keep the offsets and size of the structure having a
2197c478bd9Sstevel@tonic-gate  * struct sockaddr_storage field the same between a 32-bit application
2207c478bd9Sstevel@tonic-gate  * and a 64-bit amd64 kernel, we use a #pragma pack(4) for those
2217c478bd9Sstevel@tonic-gate  * structures.
2227c478bd9Sstevel@tonic-gate  */
2237c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2247c478bd9Sstevel@tonic-gate #pragma pack(4)
2257c478bd9Sstevel@tonic-gate #endif
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate /* Address change event state */
2287c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_AVAILABLE	0
2297c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_UNREACHABLE	1
2307c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_REMOVED	2
2317c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_ADDED		3
2327c478bd9Sstevel@tonic-gate #define	SCTP_ADDR_MADE_PRIM	4
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate  * When a destination address on a multi-homed peer encounters a change,
2367c478bd9Sstevel@tonic-gate  * an interface details event, sctp_paddr_change, is sent to the socket.
2377c478bd9Sstevel@tonic-gate  */
2387c478bd9Sstevel@tonic-gate struct sctp_paddr_change {
2397c478bd9Sstevel@tonic-gate 	uint16_t	spc_type;
2407c478bd9Sstevel@tonic-gate 	uint16_t	spc_flags;
2417c478bd9Sstevel@tonic-gate 	uint32_t	spc_length;
2427c478bd9Sstevel@tonic-gate 	struct sockaddr_storage spc_aaddr;
2437c478bd9Sstevel@tonic-gate 	int		spc_state;
2447c478bd9Sstevel@tonic-gate 	int		spc_error;
2457c478bd9Sstevel@tonic-gate 	sctp_assoc_t	spc_assoc_id;
2467c478bd9Sstevel@tonic-gate };
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2497c478bd9Sstevel@tonic-gate #pragma pack()
2507c478bd9Sstevel@tonic-gate #endif
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /* flags used in sctp_send_failed notification. */
2537c478bd9Sstevel@tonic-gate #define	SCTP_DATA_UNSENT	1
2547c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SENT		2
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate /*
2577c478bd9Sstevel@tonic-gate  * If SCTP cannot deliver a message it may return the message as a
2587c478bd9Sstevel@tonic-gate  * notification using the following structure.
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate struct sctp_send_failed {
2617c478bd9Sstevel@tonic-gate 	uint16_t	ssf_type;
2627c478bd9Sstevel@tonic-gate 	uint16_t	ssf_flags;
2637c478bd9Sstevel@tonic-gate 	uint32_t	ssf_length;
2647c478bd9Sstevel@tonic-gate 	uint32_t	ssf_error;
2657c478bd9Sstevel@tonic-gate 	struct sctp_sndrcvinfo ssf_info;
2667c478bd9Sstevel@tonic-gate 	sctp_assoc_t	ssf_assoc_id;
2677c478bd9Sstevel@tonic-gate 	/*
2687c478bd9Sstevel@tonic-gate 	 * The assoc ID is followed by the failed message.
2697c478bd9Sstevel@tonic-gate 	 */
2707c478bd9Sstevel@tonic-gate };
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * When a peer sends a SHUTDOWN, SCTP delivers the sctp_shutdown_event
2747c478bd9Sstevel@tonic-gate  * notification to inform the socket user that it should cease sending data.
2757c478bd9Sstevel@tonic-gate  */
2767c478bd9Sstevel@tonic-gate struct sctp_shutdown_event {
2777c478bd9Sstevel@tonic-gate 	uint16_t	sse_type;
2787c478bd9Sstevel@tonic-gate 	uint16_t	sse_flags;
2797c478bd9Sstevel@tonic-gate 	uint16_t	sse_length;
2807c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sse_assoc_id;
2817c478bd9Sstevel@tonic-gate };
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate /*
284558fbd03Skcpoon  * When a peer sends an Adaptation Layer Indication parameter, SCTP
285558fbd03Skcpoon  * delivers the sctp_adaptation_event notification to inform the socket
286558fbd03Skcpoon  * user the peer's requested adaptation layer.
2877c478bd9Sstevel@tonic-gate  */
288558fbd03Skcpoon struct sctp_adaptation_event {
2897c478bd9Sstevel@tonic-gate 	uint16_t	sai_type;
2907c478bd9Sstevel@tonic-gate 	uint16_t	sai_flags;
2917c478bd9Sstevel@tonic-gate 	uint32_t	sai_length;
292558fbd03Skcpoon 	uint32_t	sai_adaptation_ind;
2937c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sai_assoc_id;
2947c478bd9Sstevel@tonic-gate };
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate /* Possible values in pdapi_indication for sctp_pdapi_event notification. */
2977c478bd9Sstevel@tonic-gate #define	SCTP_PARTIAL_DELIVERY_ABORTED	1
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate /*
3007c478bd9Sstevel@tonic-gate  * When a receiver is engaged in a partial delivery of a message the
3017c478bd9Sstevel@tonic-gate  * sctp_pdapi_event notification is used to indicate various events.
3027c478bd9Sstevel@tonic-gate  */
3037c478bd9Sstevel@tonic-gate struct sctp_pdapi_event {
3047c478bd9Sstevel@tonic-gate 	uint16_t	pdapi_type;
3057c478bd9Sstevel@tonic-gate 	uint16_t	pdapi_flags;
3067c478bd9Sstevel@tonic-gate 	uint32_t	pdapi_length;
3077c478bd9Sstevel@tonic-gate 	uint32_t	pdapi_indication;
3087c478bd9Sstevel@tonic-gate 	sctp_assoc_t	pdapi_assoc_id;
3097c478bd9Sstevel@tonic-gate };
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate /*
3127c478bd9Sstevel@tonic-gate  * The sctp_notification structure is defined as the union of all
3137c478bd9Sstevel@tonic-gate  * notification types defined above.
3147c478bd9Sstevel@tonic-gate  */
3157c478bd9Sstevel@tonic-gate union sctp_notification {
3167c478bd9Sstevel@tonic-gate 	struct {
3177c478bd9Sstevel@tonic-gate 		uint16_t		sn_type; /* Notification type. */
3187c478bd9Sstevel@tonic-gate 		uint16_t		sn_flags;
3197c478bd9Sstevel@tonic-gate 		uint32_t		sn_length;
3207c478bd9Sstevel@tonic-gate 	} sn_header;
3217c478bd9Sstevel@tonic-gate 	struct sctp_assoc_change	sn_assoc_change;
3227c478bd9Sstevel@tonic-gate 	struct sctp_paddr_change	sn_paddr_change;
3237c478bd9Sstevel@tonic-gate 	struct sctp_remote_error	sn_remote_error;
3247c478bd9Sstevel@tonic-gate 	struct sctp_send_failed		sn_send_failed;
3257c478bd9Sstevel@tonic-gate 	struct sctp_shutdown_event	sn_shutdown_event;
326558fbd03Skcpoon 	struct sctp_adaptation_event	sn_adaptation_event;
3277c478bd9Sstevel@tonic-gate 	struct sctp_pdapi_event		sn_pdapi_event;
3287c478bd9Sstevel@tonic-gate };
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate /*
3317c478bd9Sstevel@tonic-gate  * sctp_opt_info() option definitions
3327c478bd9Sstevel@tonic-gate  */
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate /*
3357c478bd9Sstevel@tonic-gate  * The protocol parameters used to initialize and bound retransmission
3367c478bd9Sstevel@tonic-gate  * timeout (RTO) are tunable.  See RFC2960 for more information on
3377c478bd9Sstevel@tonic-gate  * how these parameters are used in RTO calculation.
3387c478bd9Sstevel@tonic-gate  *
3397c478bd9Sstevel@tonic-gate  * The sctp_rtoinfo structure is used to access and modify these
3407c478bd9Sstevel@tonic-gate  * parameters.
3417c478bd9Sstevel@tonic-gate  */
3427c478bd9Sstevel@tonic-gate struct sctp_rtoinfo {
3437c478bd9Sstevel@tonic-gate 	sctp_assoc_t	srto_assoc_id;
3447c478bd9Sstevel@tonic-gate 	uint32_t	srto_initial;
3457c478bd9Sstevel@tonic-gate 	uint32_t	srto_max;
3467c478bd9Sstevel@tonic-gate 	uint32_t	srto_min;
3477c478bd9Sstevel@tonic-gate };
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate /*
3507c478bd9Sstevel@tonic-gate  * The sctp_assocparams option is used to both examine and set various
3517c478bd9Sstevel@tonic-gate  * association and endpoint parameters.  See RFC2960 for more information
3527c478bd9Sstevel@tonic-gate  * on how this parameter is used.  The peer address parameter is ignored
3537c478bd9Sstevel@tonic-gate  * for one-to-one style socket.
3547c478bd9Sstevel@tonic-gate  */
3557c478bd9Sstevel@tonic-gate struct sctp_assocparams {
3567c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sasoc_assoc_id;
3577c478bd9Sstevel@tonic-gate 	uint16_t	sasoc_asocmaxrxt;
3587c478bd9Sstevel@tonic-gate 	uint16_t	sasoc_number_peer_destinations;
3597c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_peer_rwnd;
3607c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_local_rwnd;
3617c478bd9Sstevel@tonic-gate 	uint32_t	sasoc_cookie_life;
3627c478bd9Sstevel@tonic-gate };
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
3657c478bd9Sstevel@tonic-gate #pragma pack(4)
3667c478bd9Sstevel@tonic-gate #endif
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /* sctp_paddrinfo reachability state. */
3697c478bd9Sstevel@tonic-gate #define	SCTP_INACTIVE	1
3707c478bd9Sstevel@tonic-gate #define	SCTP_ACTIVE	2
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate /*
3737c478bd9Sstevel@tonic-gate  * Applications can retrieve information about a specific peer address
3747c478bd9Sstevel@tonic-gate  * of an association, including its reachability state, congestion
3757c478bd9Sstevel@tonic-gate  * window, and retransmission timer values.  This information is
3767c478bd9Sstevel@tonic-gate  * read-only. The sctp_paddrinfo structure is used to access this
3777c478bd9Sstevel@tonic-gate  * information:
3787c478bd9Sstevel@tonic-gate  */
3797c478bd9Sstevel@tonic-gate struct sctp_paddrinfo {
3807c478bd9Sstevel@tonic-gate 	sctp_assoc_t	spinfo_assoc_id;
3817c478bd9Sstevel@tonic-gate 	struct sockaddr_storage spinfo_address;
3827c478bd9Sstevel@tonic-gate 	int32_t		spinfo_state;
3837c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_cwnd;
3847c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_srtt;
3857c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_rto;
3867c478bd9Sstevel@tonic-gate 	uint32_t	spinfo_mtu;
3877c478bd9Sstevel@tonic-gate };
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate /*
3907c478bd9Sstevel@tonic-gate  * Applications can enable or disable heartbeats for any peer address of
3917c478bd9Sstevel@tonic-gate  * an association, modify an address's heartbeat interval, force a
3927c478bd9Sstevel@tonic-gate  * heartbeat to be sent immediately, and adjust the address's maximum
3937c478bd9Sstevel@tonic-gate  * number of retransmissions sent before an address is considered
3947c478bd9Sstevel@tonic-gate  * unreachable.  The sctp_paddrparams structure is used to access and modify
3957c478bd9Sstevel@tonic-gate  * an address' parameters.
3967c478bd9Sstevel@tonic-gate  */
3977c478bd9Sstevel@tonic-gate struct sctp_paddrparams {
3987c478bd9Sstevel@tonic-gate 	sctp_assoc_t		spp_assoc_id;
3997c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	spp_address;
4007c478bd9Sstevel@tonic-gate 	uint32_t		spp_hbinterval;
4017c478bd9Sstevel@tonic-gate 	uint16_t		spp_pathmaxrxt;
4027c478bd9Sstevel@tonic-gate };
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  * A socket user can request that the peer mark the enclosed address as the
4067c478bd9Sstevel@tonic-gate  * association's primary.  The enclosed address must be one of the
4077c478bd9Sstevel@tonic-gate  * association's locally bound addresses. The sctp_setpeerprim structure is
4087c478bd9Sstevel@tonic-gate  * used to make such request.
4097c478bd9Sstevel@tonic-gate  */
4107c478bd9Sstevel@tonic-gate struct sctp_setpeerprim {
4117c478bd9Sstevel@tonic-gate 	sctp_assoc_t		sspp_assoc_id;
4127c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	sspp_addr;
4137c478bd9Sstevel@tonic-gate };
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate /*
4167c478bd9Sstevel@tonic-gate  * A socket user can request that the local SCTP stack use the enclosed peer
4177c478bd9Sstevel@tonic-gate  * address as the association primary.  The enclosed address must be one of
4187c478bd9Sstevel@tonic-gate  * the association peer's addresses.  The sctp_setprim structure is used to
4197c478bd9Sstevel@tonic-gate  * make such request.
4207c478bd9Sstevel@tonic-gate  */
4217c478bd9Sstevel@tonic-gate struct sctp_setprim {
4227c478bd9Sstevel@tonic-gate 	sctp_assoc_t		ssp_assoc_id;
4237c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	ssp_addr;
4247c478bd9Sstevel@tonic-gate };
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
4277c478bd9Sstevel@tonic-gate #pragma pack()
4287c478bd9Sstevel@tonic-gate #endif
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate /* SCTP association states */
4317c478bd9Sstevel@tonic-gate #define	SCTPS_IDLE		-5	/* idle (opened, but not bound) */
4327c478bd9Sstevel@tonic-gate #define	SCTPS_BOUND		-4	/* bound, ready to connect or accept */
4337c478bd9Sstevel@tonic-gate #define	SCTPS_LISTEN		-3	/* listening for connection */
4347c478bd9Sstevel@tonic-gate #define	SCTPS_COOKIE_WAIT	-2
4357c478bd9Sstevel@tonic-gate #define	SCTPS_COOKIE_ECHOED	-1
4367c478bd9Sstevel@tonic-gate /* states < SCTPS_ESTABLISHED are those where connections not established */
4377c478bd9Sstevel@tonic-gate #define	SCTPS_ESTABLISHED	0	/* established */
4387c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_PENDING	1
4397c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_SENT	2
4407c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_RECEIVED	3
4417c478bd9Sstevel@tonic-gate #define	SCTPS_SHUTDOWN_ACK_SENT	4
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate /*
4447c478bd9Sstevel@tonic-gate  * Applications can retrieve current status information about an
4457c478bd9Sstevel@tonic-gate  * association, including association state, peer receiver window size,
4467c478bd9Sstevel@tonic-gate  * number of unacked data chunks, and number of data chunks pending
4477c478bd9Sstevel@tonic-gate  * receipt.  This information is read-only.  The sctp_status structure is
4487c478bd9Sstevel@tonic-gate  * used to access this information:
4497c478bd9Sstevel@tonic-gate  */
4507c478bd9Sstevel@tonic-gate struct sctp_status {
4517c478bd9Sstevel@tonic-gate 	sctp_assoc_t		sstat_assoc_id;
4527c478bd9Sstevel@tonic-gate 	int32_t			sstat_state;
4537c478bd9Sstevel@tonic-gate 	uint32_t		sstat_rwnd;
4547c478bd9Sstevel@tonic-gate 	uint16_t		sstat_unackdata;
4557c478bd9Sstevel@tonic-gate 	uint16_t		sstat_penddata;
4567c478bd9Sstevel@tonic-gate 	uint16_t		sstat_instrms;
4577c478bd9Sstevel@tonic-gate 	uint16_t		sstat_outstrms;
4587c478bd9Sstevel@tonic-gate 	uint32_t		sstat_fragmentation_point;
4597c478bd9Sstevel@tonic-gate 	struct sctp_paddrinfo	sstat_primary;
4607c478bd9Sstevel@tonic-gate };
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate /* Possible values for sstat_state */
4637c478bd9Sstevel@tonic-gate #define	SCTP_CLOSED		SCTPS_IDLE
4647c478bd9Sstevel@tonic-gate #define	SCTP_BOUND		SCTPS_BOUND
4657c478bd9Sstevel@tonic-gate #define	SCTP_LISTEN		SCTPS_LISTEN
4667c478bd9Sstevel@tonic-gate #define	SCTP_COOKIE_WAIT	SCTPS_COOKIE_WAIT
4677c478bd9Sstevel@tonic-gate #define	SCTP_COOKIE_ECHOED	SCTPS_COOKIE_ECHOED
4687c478bd9Sstevel@tonic-gate #define	SCTP_ESTABLISHED	SCTPS_ESTABLISHED
4697c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_PENDING	SCTPS_SHUTDOWN_PENDING
4707c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_SENT	SCTPS_SHUTDOWN_SENT
4717c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_RECEIVED	SCTPS_SHUTDOWN_RECEIVED
4727c478bd9Sstevel@tonic-gate #define	SCTP_SHUTDOWN_ACK_SENT	SCTPS_SHUTDOWN_ACK_SENT
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate /*
4757c478bd9Sstevel@tonic-gate  * A socket user can request that the local endpoint set the specified
476558fbd03Skcpoon  * Adaptation Layer Indication parameter for all future INIT and INIT-ACK
477558fbd03Skcpoon  * exchanges.  The sctp_setadaptation structure is used to make such request.
4787c478bd9Sstevel@tonic-gate  */
479558fbd03Skcpoon struct sctp_setadaptation {
480558fbd03Skcpoon 	uint32_t   ssb_adaptation_ind;
4817c478bd9Sstevel@tonic-gate };
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate /*
4847c478bd9Sstevel@tonic-gate  * Private ioctl option structure
4857c478bd9Sstevel@tonic-gate  */
4867c478bd9Sstevel@tonic-gate struct sctpopt {
4877c478bd9Sstevel@tonic-gate 	sctp_assoc_t	sopt_aid;
4887c478bd9Sstevel@tonic-gate 	int		sopt_name;
4897c478bd9Sstevel@tonic-gate 	uint_t		sopt_len;
4907c478bd9Sstevel@tonic-gate 	caddr_t		sopt_val;
4917c478bd9Sstevel@tonic-gate };
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
4947c478bd9Sstevel@tonic-gate struct sctpopt32 {
4957c478bd9Sstevel@tonic-gate 	sctp_assoc32_t	sopt_aid;
4967c478bd9Sstevel@tonic-gate 	int32_t		sopt_name;
4977c478bd9Sstevel@tonic-gate 	uint32_t	sopt_len;
4987c478bd9Sstevel@tonic-gate 	caddr32_t	sopt_val;
4997c478bd9Sstevel@tonic-gate };
5007c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate /* Forward Cumulative TSN chunk entry. */
5037c478bd9Sstevel@tonic-gate typedef struct ftsn_entry_s {
5047c478bd9Sstevel@tonic-gate 	uint16_t	ftsn_sid;
5057c478bd9Sstevel@tonic-gate 	uint16_t	ftsn_ssn;
5067c478bd9Sstevel@tonic-gate } ftsn_entry_t;
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate /*
5097c478bd9Sstevel@tonic-gate  * New socket functions for SCTP
5107c478bd9Sstevel@tonic-gate  */
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate /* sctp_bindx() operations. */
5137c478bd9Sstevel@tonic-gate #define	SCTP_BINDX_ADD_ADDR	1
5147c478bd9Sstevel@tonic-gate #define	SCTP_BINDX_REM_ADDR	2
5157c478bd9Sstevel@tonic-gate 
5167c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) || defined(_BOOT)
5177c478bd9Sstevel@tonic-gate #ifdef	__STDC__
5187c478bd9Sstevel@tonic-gate extern int sctp_bindx(int, void *, int, int);
5197c478bd9Sstevel@tonic-gate extern void sctp_freeladdrs(void *);
5207c478bd9Sstevel@tonic-gate extern void sctp_freepaddrs(void *);
5217c478bd9Sstevel@tonic-gate extern int sctp_getladdrs(int, sctp_assoc_t, void **);
5227c478bd9Sstevel@tonic-gate extern int sctp_getpaddrs(int, sctp_assoc_t, void **);
5237c478bd9Sstevel@tonic-gate extern int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
5247c478bd9Sstevel@tonic-gate extern int sctp_peeloff(int, sctp_assoc_t);
5257c478bd9Sstevel@tonic-gate extern ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *,
5267c478bd9Sstevel@tonic-gate     socklen_t *, struct sctp_sndrcvinfo *, int *msg_flags);
5277c478bd9Sstevel@tonic-gate extern ssize_t sctp_send(int, const void *, size_t,
5287c478bd9Sstevel@tonic-gate     const struct sctp_sndrcvinfo *, int);
5297c478bd9Sstevel@tonic-gate extern ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
5307c478bd9Sstevel@tonic-gate     socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
5317c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
5327c478bd9Sstevel@tonic-gate extern int sctp_bindx();
5337c478bd9Sstevel@tonic-gate extern void sctp_freeladdrs();
5347c478bd9Sstevel@tonic-gate extern void sctp_freepaddrs();
5357c478bd9Sstevel@tonic-gate extern int sctp_getladdrs();
5367c478bd9Sstevel@tonic-gate extern int sctp_getpaddrs();
5377c478bd9Sstevel@tonic-gate extern int sctp_opt_info();
5387c478bd9Sstevel@tonic-gate extern int sctp_peeloff();
5397c478bd9Sstevel@tonic-gate extern ssize_t sctp_recvmsg();
5407c478bd9Sstevel@tonic-gate extern ssize_t sctp_send();
5417c478bd9Sstevel@tonic-gate extern ssize_t sctp_sendmsg();
5427c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
5437c478bd9Sstevel@tonic-gate #endif	/* !defined(_KERNEL) || defined(_BOOT) */
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate /*
5477c478bd9Sstevel@tonic-gate  * SCTP protocol related elements.
5487c478bd9Sstevel@tonic-gate  */
5497c478bd9Sstevel@tonic-gate 
5507c478bd9Sstevel@tonic-gate /* All SCTP chunks and parameters are 32-bit aligned */
5517c478bd9Sstevel@tonic-gate #define	SCTP_ALIGN	4
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate /*
554*77ebe684SGeorge Shepherd  * SCTP association optional parameter handling. The top two bits
555*77ebe684SGeorge Shepherd  * of the parameter type define how this and further parameters in
556*77ebe684SGeorge Shepherd  * the received chunk should be handled.
557*77ebe684SGeorge Shepherd  */
558*77ebe684SGeorge Shepherd #define	SCTP_UNREC_PARAM_MASK	0xc000
559*77ebe684SGeorge Shepherd /* Continue processing parameters after an unrecognized optional param? */
560*77ebe684SGeorge Shepherd #define	SCTP_CONT_PROC_PARAMS	0x8000
561*77ebe684SGeorge Shepherd /* Report this unreconized optional parameter or silently ignore it? */
562*77ebe684SGeorge Shepherd #define	SCTP_REPORT_THIS_PARAM	0x4000
563*77ebe684SGeorge Shepherd 
564*77ebe684SGeorge Shepherd /*
5657c478bd9Sstevel@tonic-gate  * Data chunk bit manipulations
5667c478bd9Sstevel@tonic-gate  */
5677c478bd9Sstevel@tonic-gate #define	SCTP_DATA_EBIT	0x01
5687c478bd9Sstevel@tonic-gate #define	SCTP_TBIT	0x01
5697c478bd9Sstevel@tonic-gate #define	SCTP_DATA_BBIT	0x02
5707c478bd9Sstevel@tonic-gate #define	SCTP_DATA_UBIT	0x04
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_BBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_BBIT)
5737c478bd9Sstevel@tonic-gate #define	SCTP_GET_TBIT(cp)	((cp)->sch_flags & SCTP_TBIT)
5747c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_EBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_EBIT)
5757c478bd9Sstevel@tonic-gate #define	SCTP_DATA_GET_UBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_UBIT)
5767c478bd9Sstevel@tonic-gate 
5777c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_BBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_BBIT)
5787c478bd9Sstevel@tonic-gate #define	SCTP_SET_TBIT(cp)	((cp)->sch_flags |= SCTP_TBIT)
5797c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_EBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_EBIT)
5807c478bd9Sstevel@tonic-gate #define	SCTP_DATA_SET_UBIT(sdc)	((sdc)->sdh_flags |=  SCTP_DATA_UBIT)
5817c478bd9Sstevel@tonic-gate 
5827c478bd9Sstevel@tonic-gate /* SCTP common header */
5837c478bd9Sstevel@tonic-gate typedef struct sctp_hdr {
5847c478bd9Sstevel@tonic-gate 	uint16_t	sh_sport;
5857c478bd9Sstevel@tonic-gate 	uint16_t	sh_dport;
5867c478bd9Sstevel@tonic-gate 	uint32_t	sh_verf;
5877c478bd9Sstevel@tonic-gate 	uint32_t	sh_chksum;
5887c478bd9Sstevel@tonic-gate } sctp_hdr_t;
5897c478bd9Sstevel@tonic-gate 
5907c478bd9Sstevel@tonic-gate /* Chunk IDs */
5917c478bd9Sstevel@tonic-gate typedef enum {
5927c478bd9Sstevel@tonic-gate 	CHUNK_DATA,
5937c478bd9Sstevel@tonic-gate 	CHUNK_INIT,
5947c478bd9Sstevel@tonic-gate 	CHUNK_INIT_ACK,
5957c478bd9Sstevel@tonic-gate 	CHUNK_SACK,
5967c478bd9Sstevel@tonic-gate 	CHUNK_HEARTBEAT,
5977c478bd9Sstevel@tonic-gate 	CHUNK_HEARTBEAT_ACK,
5987c478bd9Sstevel@tonic-gate 	CHUNK_ABORT,
5997c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN,
6007c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN_ACK,
6017c478bd9Sstevel@tonic-gate 	CHUNK_ERROR,
6027c478bd9Sstevel@tonic-gate 	CHUNK_COOKIE,
6037c478bd9Sstevel@tonic-gate 	CHUNK_COOKIE_ACK,
6047c478bd9Sstevel@tonic-gate 	CHUNK_ECNE,
6057c478bd9Sstevel@tonic-gate 	CHUNK_CWR,
6067c478bd9Sstevel@tonic-gate 	CHUNK_SHUTDOWN_COMPLETE,
6077c478bd9Sstevel@tonic-gate 	CHUNK_ASCONF_ACK = 128,
6087c478bd9Sstevel@tonic-gate 	CHUNK_FORWARD_TSN = 192,
6097c478bd9Sstevel@tonic-gate 	CHUNK_ASCONF = 193
6107c478bd9Sstevel@tonic-gate } sctp_chunk_id_t;
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate /* Common chunk header */
6137c478bd9Sstevel@tonic-gate typedef struct sctp_chunk_hdr {
6147c478bd9Sstevel@tonic-gate 	uint8_t		sch_id;
6157c478bd9Sstevel@tonic-gate 	uint8_t		sch_flags;
6167c478bd9Sstevel@tonic-gate 	uint16_t	sch_len;
6177c478bd9Sstevel@tonic-gate } sctp_chunk_hdr_t;
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate /* INIT chunk data definition */
6207c478bd9Sstevel@tonic-gate typedef struct sctp_init_chunk {
6217c478bd9Sstevel@tonic-gate 	uint32_t	sic_inittag;
6227c478bd9Sstevel@tonic-gate 	uint32_t	sic_a_rwnd;
6237c478bd9Sstevel@tonic-gate 	uint16_t	sic_outstr;
6247c478bd9Sstevel@tonic-gate 	uint16_t	sic_instr;
6257c478bd9Sstevel@tonic-gate 	uint32_t	sic_inittsn;
6267c478bd9Sstevel@tonic-gate } sctp_init_chunk_t;
6277c478bd9Sstevel@tonic-gate 
6287c478bd9Sstevel@tonic-gate /* SCTP DATA chunk */
6297c478bd9Sstevel@tonic-gate typedef struct sctp_data_chunk {
6307c478bd9Sstevel@tonic-gate 	uint32_t	sdc_tsn;
6317c478bd9Sstevel@tonic-gate 	uint16_t	sdc_sid;
6327c478bd9Sstevel@tonic-gate 	uint16_t	sdc_ssn;
6337c478bd9Sstevel@tonic-gate 	uint32_t	sdc_payload_id;
6347c478bd9Sstevel@tonic-gate } sctp_data_chunk_t;
6357c478bd9Sstevel@tonic-gate 
6367c478bd9Sstevel@tonic-gate /* sctp_data_hdr includes the SCTP chunk hdr and the DATA chunk */
6377c478bd9Sstevel@tonic-gate typedef struct sctp_data_hdr {
6387c478bd9Sstevel@tonic-gate 	sctp_chunk_hdr_t	sdh_chdr;
6397c478bd9Sstevel@tonic-gate 	sctp_data_chunk_t	sdh_data;
6407c478bd9Sstevel@tonic-gate #define	sdh_id		sdh_chdr.sch_id
6417c478bd9Sstevel@tonic-gate #define	sdh_flags	sdh_chdr.sch_flags
6427c478bd9Sstevel@tonic-gate #define	sdh_len		sdh_chdr.sch_len
6437c478bd9Sstevel@tonic-gate #define	sdh_tsn		sdh_data.sdc_tsn
6447c478bd9Sstevel@tonic-gate #define	sdh_sid		sdh_data.sdc_sid
6457c478bd9Sstevel@tonic-gate #define	sdh_ssn		sdh_data.sdc_ssn
6467c478bd9Sstevel@tonic-gate #define	sdh_payload_id	sdh_data.sdc_payload_id
6477c478bd9Sstevel@tonic-gate } sctp_data_hdr_t;
6487c478bd9Sstevel@tonic-gate 
6497c478bd9Sstevel@tonic-gate typedef struct sctp_sack_chunk {
6507c478bd9Sstevel@tonic-gate 	uint32_t	ssc_cumtsn;
6517c478bd9Sstevel@tonic-gate 	uint32_t	ssc_a_rwnd;
6527c478bd9Sstevel@tonic-gate 	uint16_t	ssc_numfrags;
6537c478bd9Sstevel@tonic-gate 	uint16_t	ssc_numdups;
6547c478bd9Sstevel@tonic-gate } sctp_sack_chunk_t;
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate typedef struct sctp_sack_frag {
6577c478bd9Sstevel@tonic-gate 	uint16_t	ssf_start;
6587c478bd9Sstevel@tonic-gate 	uint16_t	ssf_end;
6597c478bd9Sstevel@tonic-gate } sctp_sack_frag_t;
6607c478bd9Sstevel@tonic-gate 
6617c478bd9Sstevel@tonic-gate /* Parameter types */
6627c478bd9Sstevel@tonic-gate #define	PARM_UNKNOWN		0
6637c478bd9Sstevel@tonic-gate #define	PARM_HBINFO		1
6647c478bd9Sstevel@tonic-gate #define	PARM_ADDR4		5
6657c478bd9Sstevel@tonic-gate #define	PARM_ADDR6		6
6667c478bd9Sstevel@tonic-gate #define	PARM_COOKIE		7
6677c478bd9Sstevel@tonic-gate #define	PARM_UNRECOGNIZED	8
6687c478bd9Sstevel@tonic-gate #define	PARM_COOKIE_PRESERVE	9
6697c478bd9Sstevel@tonic-gate #define	PARM_ADDR_HOST_NAME	11
6707c478bd9Sstevel@tonic-gate #define	PARM_SUPP_ADDRS		12
6717c478bd9Sstevel@tonic-gate #define	PARM_ECN		0x8000
6727c478bd9Sstevel@tonic-gate #define	PARM_ECN_CAPABLE	PARM_ECN
6737c478bd9Sstevel@tonic-gate #define	PARM_FORWARD_TSN	0xc000
6747c478bd9Sstevel@tonic-gate #define	PARM_ADD_IP		0xc001
6757c478bd9Sstevel@tonic-gate #define	PARM_DEL_IP		0xc002
6767c478bd9Sstevel@tonic-gate #define	PARM_ERROR_IND		0xc003
6777c478bd9Sstevel@tonic-gate #define	PARM_ASCONF_ERROR	PARM_ERROR_IND
6787c478bd9Sstevel@tonic-gate #define	PARM_SET_PRIMARY	0xc004
6797c478bd9Sstevel@tonic-gate #define	PARM_PRIMARY_ADDR	PARM_SET_PRIMARY
6807c478bd9Sstevel@tonic-gate #define	PARM_SUCCESS		0xc005
6817c478bd9Sstevel@tonic-gate #define	PARM_ASCONF_SUCCESS	PARM_SUCCESS
6827c478bd9Sstevel@tonic-gate #define	PARM_ADAPT_LAYER_IND	0xc006
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate 
6857c478bd9Sstevel@tonic-gate /* Lengths from SCTP spec */
6867c478bd9Sstevel@tonic-gate #define	PARM_ADDR4_LEN		8
6877c478bd9Sstevel@tonic-gate #define	PARM_ADDR6_LEN		20
6887c478bd9Sstevel@tonic-gate 
6897c478bd9Sstevel@tonic-gate /* Parameter header */
6907c478bd9Sstevel@tonic-gate typedef struct sctp_parm_hdr {
6917c478bd9Sstevel@tonic-gate 	uint16_t	sph_type;
6927c478bd9Sstevel@tonic-gate 	uint16_t	sph_len;
6937c478bd9Sstevel@tonic-gate } sctp_parm_hdr_t;
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate /* Error causes */
6967c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNKNOWN		0
6977c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_SID		1
6987c478bd9Sstevel@tonic-gate #define	SCTP_ERR_MISSING_PARM		2
6997c478bd9Sstevel@tonic-gate #define	SCTP_ERR_STALE_COOKIE		3
7007c478bd9Sstevel@tonic-gate #define	SCTP_ERR_NO_RESOURCES		4
7017c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_ADDR		5
7027c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNREC_CHUNK		6
7037c478bd9Sstevel@tonic-gate #define	SCTP_ERR_BAD_MANDPARM		7
7047c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNREC_PARM		8
7057c478bd9Sstevel@tonic-gate #define	SCTP_ERR_NO_USR_DATA		9
7067c478bd9Sstevel@tonic-gate #define	SCTP_ERR_COOKIE_SHUT		10
7077c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RESTART_NEW_ADDRS	11
7087c478bd9Sstevel@tonic-gate #define	SCTP_ERR_USER_ABORT		12
7097c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DELETE_LASTADDR	256
7107c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RESOURCE_SHORTAGE	257
7117c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DELETE_SRCADDR		258
7127c478bd9Sstevel@tonic-gate #define	SCTP_ERR_AUTH_ERR		260
7137c478bd9Sstevel@tonic-gate 
7147c478bd9Sstevel@tonic-gate /*
7157c478bd9Sstevel@tonic-gate  * Extensions
7167c478bd9Sstevel@tonic-gate  */
7177c478bd9Sstevel@tonic-gate 
7187c478bd9Sstevel@tonic-gate /* Extended Chunk Types */
7197c478bd9Sstevel@tonic-gate #define	CHUNK_ASCONF		0xc1
7207c478bd9Sstevel@tonic-gate #define	CHUNK_ASCONF_ACK	0x80
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate /* Extension Error Causes */
7237c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DEL_LAST_ADDR	0x0100
7247c478bd9Sstevel@tonic-gate #define	SCTP_ERR_RES_SHORTAGE	0x0101
7257c478bd9Sstevel@tonic-gate #define	SCTP_ERR_DEL_SRC_ADDR	0x0102
7267c478bd9Sstevel@tonic-gate #define	SCTP_ERR_ILLEGAL_ACK	0x0103
7277c478bd9Sstevel@tonic-gate #define	SCTP_ERR_UNAUTHORIZED	0x0104
7287c478bd9Sstevel@tonic-gate 
7297c478bd9Sstevel@tonic-gate typedef struct sctp_addip4 {
7307c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad4_addip_ph;
7317c478bd9Sstevel@tonic-gate 	uint32_t		asconf_req_cid;
7327c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad4_addr4_ph;
7337c478bd9Sstevel@tonic-gate 	ipaddr_t		sad4_addr;
7347c478bd9Sstevel@tonic-gate } sctp_addip4_t;
7357c478bd9Sstevel@tonic-gate 
7367c478bd9Sstevel@tonic-gate typedef struct sctp_addip6 {
7377c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad6_addip_ph;
7387c478bd9Sstevel@tonic-gate 	uint32_t		asconf_req_cid;
7397c478bd9Sstevel@tonic-gate 	sctp_parm_hdr_t		sad6_addr6_ph;
7407c478bd9Sstevel@tonic-gate 	in6_addr_t		sad6_addr;
7417c478bd9Sstevel@tonic-gate } sctp_addip6_t;
7427c478bd9Sstevel@tonic-gate 
7437c478bd9Sstevel@tonic-gate #ifdef __cplusplus
7447c478bd9Sstevel@tonic-gate }
7457c478bd9Sstevel@tonic-gate #endif
7467c478bd9Sstevel@tonic-gate 
7477c478bd9Sstevel@tonic-gate #endif	/* _NETINET_SCTP_H */
748