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