xref: /titanic_50/usr/src/uts/common/netinet/sctp.h (revision abddfefb3168362a915cd681eb5a6498ec6c9e09)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_NETINET_SCTP_H
27 #define	_NETINET_SCTP_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 
35 /*
36  * This file contains the structure defintions and function prototypes
37  * described in the IETF SCTP socket API document.
38  */
39 
40 /* SCTP association ID type. */
41 typedef int	sctp_assoc_t;
42 typedef int32_t	sctp_assoc32_t;
43 
44 /*
45  * SCTP socket options
46  */
47 #define	SCTP_RTOINFO			1
48 #define	SCTP_ASSOCINFO			2
49 #define	SCTP_INITMSG			3
50 #define	SCTP_NODELAY			4
51 #define	SCTP_AUTOCLOSE			5
52 #define	SCTP_SET_PEER_PRIMARY_ADDR	6
53 #define	SCTP_PRIMARY_ADDR		7
54 #define	SCTP_ADAPTATION_LAYER		8
55 #define	SCTP_DISABLE_FRAGMENTS		9
56 #define	SCTP_PEER_ADDR_PARAMS		10
57 #define	SCTP_DEFAULT_SEND_PARAM		11
58 #define	SCTP_EVENTS			12
59 #define	SCTP_I_WANT_MAPPED_V4_ADDR	13
60 #define	SCTP_MAXSEG			14
61 #define	SCTP_STATUS			15
62 #define	SCTP_GET_PEER_ADDR_INFO		16
63 
64 /*
65  * Private socket options
66  */
67 #define	SCTP_GET_NLADDRS		17
68 #define	SCTP_GET_LADDRS			18
69 #define	SCTP_GET_NPADDRS		19
70 #define	SCTP_GET_PADDRS			20
71 #define	SCTP_ADD_ADDR			21
72 #define	SCTP_REM_ADDR			22
73 
74 /*
75  * Additional SCTP socket options. This socket option is used to enable or
76  * disable PR-SCTP support prior to establishing an association. By default,
77  * PR-SCTP support is disabled.
78  */
79 #define	SCTP_PRSCTP			23
80 
81 /*
82  * Ancillary data identifiers
83  */
84 #define	SCTP_SNDRCV		0x100
85 #define	SCTP_INIT		0x101
86 
87 /*
88  * Notification types
89  */
90 #define	SCTP_ASSOC_CHANGE		1
91 #define	SCTP_PEER_ADDR_CHANGE		2
92 #define	SCTP_REMOTE_ERROR		3
93 #define	SCTP_SEND_FAILED		4
94 #define	SCTP_SHUTDOWN_EVENT		5
95 #define	SCTP_ADAPTATION_INDICATION	6
96 #define	SCTP_PARTIAL_DELIVERY_EVENT	7
97 
98 /*
99  * SCTP Ancillary Data Definitions
100  */
101 
102 /*
103  * sctp_initmsg structure provides information for initializing new SCTP
104  * associations with sendmsg().  The SCTP_INITMSG socket option uses
105  * this same data structure.
106  */
107 struct sctp_initmsg {
108 	uint16_t	sinit_num_ostreams;
109 	uint16_t	sinit_max_instreams;
110 	uint16_t	sinit_max_attempts;
111 	uint16_t	sinit_max_init_timeo;
112 };
113 
114 /*
115  * sctp_sndrcvinfo structure specifies SCTP options for sendmsg() and
116  * describes SCTP header information about a received message through
117  * recvmsg().
118  */
119 struct sctp_sndrcvinfo {
120 	uint16_t	sinfo_stream;
121 	uint16_t	sinfo_ssn;
122 	uint16_t	sinfo_flags;
123 	uint32_t	sinfo_ppid;
124 	uint32_t	sinfo_context;
125 	uint32_t	sinfo_timetolive;
126 	uint32_t	sinfo_tsn;
127 	uint32_t	sinfo_cumtsn;
128 	sctp_assoc_t	sinfo_assoc_id;
129 };
130 
131 /* sinfo_flags */
132 #define	MSG_UNORDERED	0x01		/* Unordered data */
133 #define	MSG_ABORT	0x02		/* Abort the connection */
134 #define	MSG_EOF		0x04		/* Shutdown the connection */
135 
136 /*
137  * Use destination addr passed as parameter, not the association primary one.
138  */
139 #define	MSG_ADDR_OVER	0x08
140 /*
141  * This flag when set in sinfo_flags is used alongwith sinfo_timetolive to
142  * implement the "timed reliability" service discussed in RFC 3758.
143  */
144 #define	MSG_PR_SCTP	0x10
145 /*
146  * SCTP notification definitions
147  */
148 
149 /*
150  * To receive any ancillary data or notifications, the application can
151  * register it's interest by calling the SCTP_EVENTS setsockopt() with
152  * the sctp_event_subscribe structure.
153  */
154 struct sctp_event_subscribe {
155 	uint8_t	sctp_data_io_event;
156 	uint8_t sctp_association_event;
157 	uint8_t sctp_address_event;
158 	uint8_t sctp_send_failure_event;
159 	uint8_t sctp_peer_error_event;
160 	uint8_t sctp_shutdown_event;
161 	uint8_t sctp_partial_delivery_event;
162 	uint8_t sctp_adaptation_layer_event;
163 };
164 
165 /* Association events used in sctp_assoc_change structure */
166 #define	SCTP_COMM_UP		0
167 #define	SCTP_COMM_LOST		1
168 #define	SCTP_RESTART		2
169 #define	SCTP_SHUTDOWN_COMP	3
170 #define	SCTP_CANT_STR_ASSOC	4
171 
172 /*
173  * Association flags. This flags is filled in the sac_flags for a SCTP_COMM_UP
174  * event if the association supports PR-SCTP.
175  */
176 #define	SCTP_PRSCTP_CAPABLE	0x01
177 
178 /*
179  * sctp_assoc_change notification informs the socket that an SCTP association
180  * has either begun or ended.  The identifier for a new association is
181  * provided by this notification.
182  */
183 struct sctp_assoc_change {
184 	uint16_t	sac_type;
185 	uint16_t	sac_flags;
186 	uint32_t	sac_length;
187 	uint16_t	sac_state;
188 	uint16_t	sac_error;
189 	uint16_t	sac_outbound_streams;
190 	uint16_t	sac_inbound_streams;
191 	sctp_assoc_t	sac_assoc_id;
192 	/*
193 	 * The assoc ID can be followed by the ABORT chunk if available.
194 	 */
195 };
196 
197 /*
198  * A remote peer may send an Operational Error message to its peer. This
199  * message indicates a variety of error conditions on an association.
200  * The entire ERROR chunk as it appears on the wire is included in a
201  * SCTP_REMOTE_ERROR event.  Refer to the SCTP specification RFC2960
202  * and any extensions for a list of possible error formats.
203  */
204 struct sctp_remote_error {
205 	uint16_t	sre_type;
206 	uint16_t	sre_flags;
207 	uint32_t	sre_length;
208 	uint16_t	sre_error;
209 	sctp_assoc_t	sre_assoc_id;
210 	/*
211 	 * The assoc ID is followed by the actual error chunk.
212 	 */
213 };
214 
215 /*
216  * Note:
217  *
218  * In order to keep the offsets and size of the structure having a
219  * struct sockaddr_storage field the same between a 32-bit application
220  * and a 64-bit amd64 kernel, we use a #pragma pack(4) for those
221  * structures.
222  */
223 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
224 #pragma pack(4)
225 #endif
226 
227 /* Address change event state */
228 #define	SCTP_ADDR_AVAILABLE	0
229 #define	SCTP_ADDR_UNREACHABLE	1
230 #define	SCTP_ADDR_REMOVED	2
231 #define	SCTP_ADDR_ADDED		3
232 #define	SCTP_ADDR_MADE_PRIM	4
233 
234 /*
235  * When a destination address on a multi-homed peer encounters a change,
236  * an interface details event, sctp_paddr_change, is sent to the socket.
237  */
238 struct sctp_paddr_change {
239 	uint16_t	spc_type;
240 	uint16_t	spc_flags;
241 	uint32_t	spc_length;
242 	struct sockaddr_storage spc_aaddr;
243 	int		spc_state;
244 	int		spc_error;
245 	sctp_assoc_t	spc_assoc_id;
246 };
247 
248 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
249 #pragma pack()
250 #endif
251 
252 /* flags used in sctp_send_failed notification. */
253 #define	SCTP_DATA_UNSENT	1
254 #define	SCTP_DATA_SENT		2
255 
256 /*
257  * If SCTP cannot deliver a message it may return the message as a
258  * notification using the following structure.
259  */
260 struct sctp_send_failed {
261 	uint16_t	ssf_type;
262 	uint16_t	ssf_flags;
263 	uint32_t	ssf_length;
264 	uint32_t	ssf_error;
265 	struct sctp_sndrcvinfo ssf_info;
266 	sctp_assoc_t	ssf_assoc_id;
267 	/*
268 	 * The assoc ID is followed by the failed message.
269 	 */
270 };
271 
272 /*
273  * When a peer sends a SHUTDOWN, SCTP delivers the sctp_shutdown_event
274  * notification to inform the socket user that it should cease sending data.
275  */
276 struct sctp_shutdown_event {
277 	uint16_t	sse_type;
278 	uint16_t	sse_flags;
279 	uint16_t	sse_length;
280 	sctp_assoc_t	sse_assoc_id;
281 };
282 
283 /*
284  * When a peer sends an Adaptation Layer Indication parameter, SCTP
285  * delivers the sctp_adaptation_event notification to inform the socket
286  * user the peer's requested adaptation layer.
287  */
288 struct sctp_adaptation_event {
289 	uint16_t	sai_type;
290 	uint16_t	sai_flags;
291 	uint32_t	sai_length;
292 	uint32_t	sai_adaptation_ind;
293 	sctp_assoc_t	sai_assoc_id;
294 };
295 
296 /* Possible values in pdapi_indication for sctp_pdapi_event notification. */
297 #define	SCTP_PARTIAL_DELIVERY_ABORTED	1
298 
299 /*
300  * When a receiver is engaged in a partial delivery of a message the
301  * sctp_pdapi_event notification is used to indicate various events.
302  */
303 struct sctp_pdapi_event {
304 	uint16_t	pdapi_type;
305 	uint16_t	pdapi_flags;
306 	uint32_t	pdapi_length;
307 	uint32_t	pdapi_indication;
308 	sctp_assoc_t	pdapi_assoc_id;
309 };
310 
311 /*
312  * The sctp_notification structure is defined as the union of all
313  * notification types defined above.
314  */
315 union sctp_notification {
316 	struct {
317 		uint16_t		sn_type; /* Notification type. */
318 		uint16_t		sn_flags;
319 		uint32_t		sn_length;
320 	} sn_header;
321 	struct sctp_assoc_change	sn_assoc_change;
322 	struct sctp_paddr_change	sn_paddr_change;
323 	struct sctp_remote_error	sn_remote_error;
324 	struct sctp_send_failed		sn_send_failed;
325 	struct sctp_shutdown_event	sn_shutdown_event;
326 	struct sctp_adaptation_event	sn_adaptation_event;
327 	struct sctp_pdapi_event		sn_pdapi_event;
328 };
329 
330 /*
331  * sctp_opt_info() option definitions
332  */
333 
334 /*
335  * The protocol parameters used to initialize and bound retransmission
336  * timeout (RTO) are tunable.  See RFC2960 for more information on
337  * how these parameters are used in RTO calculation.
338  *
339  * The sctp_rtoinfo structure is used to access and modify these
340  * parameters.
341  */
342 struct sctp_rtoinfo {
343 	sctp_assoc_t	srto_assoc_id;
344 	uint32_t	srto_initial;
345 	uint32_t	srto_max;
346 	uint32_t	srto_min;
347 };
348 
349 /*
350  * The sctp_assocparams option is used to both examine and set various
351  * association and endpoint parameters.  See RFC2960 for more information
352  * on how this parameter is used.  The peer address parameter is ignored
353  * for one-to-one style socket.
354  */
355 struct sctp_assocparams {
356 	sctp_assoc_t	sasoc_assoc_id;
357 	uint16_t	sasoc_asocmaxrxt;
358 	uint16_t	sasoc_number_peer_destinations;
359 	uint32_t	sasoc_peer_rwnd;
360 	uint32_t	sasoc_local_rwnd;
361 	uint32_t	sasoc_cookie_life;
362 };
363 
364 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
365 #pragma pack(4)
366 #endif
367 
368 /* sctp_paddrinfo reachability state. */
369 #define	SCTP_INACTIVE	1
370 #define	SCTP_ACTIVE	2
371 
372 /*
373  * Applications can retrieve information about a specific peer address
374  * of an association, including its reachability state, congestion
375  * window, and retransmission timer values.  This information is
376  * read-only. The sctp_paddrinfo structure is used to access this
377  * information:
378  */
379 struct sctp_paddrinfo {
380 	sctp_assoc_t	spinfo_assoc_id;
381 	struct sockaddr_storage spinfo_address;
382 	int32_t		spinfo_state;
383 	uint32_t	spinfo_cwnd;
384 	uint32_t	spinfo_srtt;
385 	uint32_t	spinfo_rto;
386 	uint32_t	spinfo_mtu;
387 };
388 
389 /*
390  * Applications can enable or disable heartbeats for any peer address of
391  * an association, modify an address's heartbeat interval, force a
392  * heartbeat to be sent immediately, and adjust the address's maximum
393  * number of retransmissions sent before an address is considered
394  * unreachable.  The sctp_paddrparams structure is used to access and modify
395  * an address' parameters.
396  */
397 struct sctp_paddrparams {
398 	sctp_assoc_t		spp_assoc_id;
399 	struct sockaddr_storage	spp_address;
400 	uint32_t		spp_hbinterval;
401 	uint16_t		spp_pathmaxrxt;
402 };
403 
404 /*
405  * A socket user can request that the peer mark the enclosed address as the
406  * association's primary.  The enclosed address must be one of the
407  * association's locally bound addresses. The sctp_setpeerprim structure is
408  * used to make such request.
409  */
410 struct sctp_setpeerprim {
411 	sctp_assoc_t		sspp_assoc_id;
412 	struct sockaddr_storage	sspp_addr;
413 };
414 
415 /*
416  * A socket user can request that the local SCTP stack use the enclosed peer
417  * address as the association primary.  The enclosed address must be one of
418  * the association peer's addresses.  The sctp_setprim structure is used to
419  * make such request.
420  */
421 struct sctp_setprim {
422 	sctp_assoc_t		ssp_assoc_id;
423 	struct sockaddr_storage	ssp_addr;
424 };
425 
426 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
427 #pragma pack()
428 #endif
429 
430 /* SCTP association states */
431 #define	SCTPS_IDLE		-5	/* idle (opened, but not bound) */
432 #define	SCTPS_BOUND		-4	/* bound, ready to connect or accept */
433 #define	SCTPS_LISTEN		-3	/* listening for connection */
434 #define	SCTPS_COOKIE_WAIT	-2
435 #define	SCTPS_COOKIE_ECHOED	-1
436 /* states < SCTPS_ESTABLISHED are those where connections not established */
437 #define	SCTPS_ESTABLISHED	0	/* established */
438 #define	SCTPS_SHUTDOWN_PENDING	1
439 #define	SCTPS_SHUTDOWN_SENT	2
440 #define	SCTPS_SHUTDOWN_RECEIVED	3
441 #define	SCTPS_SHUTDOWN_ACK_SENT	4
442 
443 /*
444  * Applications can retrieve current status information about an
445  * association, including association state, peer receiver window size,
446  * number of unacked data chunks, and number of data chunks pending
447  * receipt.  This information is read-only.  The sctp_status structure is
448  * used to access this information:
449  */
450 struct sctp_status {
451 	sctp_assoc_t		sstat_assoc_id;
452 	int32_t			sstat_state;
453 	uint32_t		sstat_rwnd;
454 	uint16_t		sstat_unackdata;
455 	uint16_t		sstat_penddata;
456 	uint16_t		sstat_instrms;
457 	uint16_t		sstat_outstrms;
458 	uint32_t		sstat_fragmentation_point;
459 	struct sctp_paddrinfo	sstat_primary;
460 };
461 
462 /* Possible values for sstat_state */
463 #define	SCTP_CLOSED		SCTPS_IDLE
464 #define	SCTP_BOUND		SCTPS_BOUND
465 #define	SCTP_LISTEN		SCTPS_LISTEN
466 #define	SCTP_COOKIE_WAIT	SCTPS_COOKIE_WAIT
467 #define	SCTP_COOKIE_ECHOED	SCTPS_COOKIE_ECHOED
468 #define	SCTP_ESTABLISHED	SCTPS_ESTABLISHED
469 #define	SCTP_SHUTDOWN_PENDING	SCTPS_SHUTDOWN_PENDING
470 #define	SCTP_SHUTDOWN_SENT	SCTPS_SHUTDOWN_SENT
471 #define	SCTP_SHUTDOWN_RECEIVED	SCTPS_SHUTDOWN_RECEIVED
472 #define	SCTP_SHUTDOWN_ACK_SENT	SCTPS_SHUTDOWN_ACK_SENT
473 
474 /*
475  * A socket user can request that the local endpoint set the specified
476  * Adaptation Layer Indication parameter for all future INIT and INIT-ACK
477  * exchanges.  The sctp_setadaptation structure is used to make such request.
478  */
479 struct sctp_setadaptation {
480 	uint32_t   ssb_adaptation_ind;
481 };
482 
483 /*
484  * Private ioctl option structure
485  */
486 struct sctpopt {
487 	sctp_assoc_t	sopt_aid;
488 	int		sopt_name;
489 	uint_t		sopt_len;
490 	caddr_t		sopt_val;
491 };
492 
493 #if defined(_SYSCALL32)
494 struct sctpopt32 {
495 	sctp_assoc32_t	sopt_aid;
496 	int32_t		sopt_name;
497 	uint32_t	sopt_len;
498 	caddr32_t	sopt_val;
499 };
500 #endif	/* _SYSCALL32 */
501 
502 /* Forward Cumulative TSN chunk entry. */
503 typedef struct ftsn_entry_s {
504 	uint16_t	ftsn_sid;
505 	uint16_t	ftsn_ssn;
506 } ftsn_entry_t;
507 
508 /*
509  * New socket functions for SCTP
510  */
511 
512 /* sctp_bindx() operations. */
513 #define	SCTP_BINDX_ADD_ADDR	1
514 #define	SCTP_BINDX_REM_ADDR	2
515 
516 #if !defined(_KERNEL) || defined(_BOOT)
517 #ifdef	__STDC__
518 extern int sctp_bindx(int, void *, int, int);
519 extern void sctp_freeladdrs(void *);
520 extern void sctp_freepaddrs(void *);
521 extern int sctp_getladdrs(int, sctp_assoc_t, void **);
522 extern int sctp_getpaddrs(int, sctp_assoc_t, void **);
523 extern int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
524 extern int sctp_peeloff(int, sctp_assoc_t);
525 extern ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *,
526     socklen_t *, struct sctp_sndrcvinfo *, int *msg_flags);
527 extern ssize_t sctp_send(int, const void *, size_t,
528     const struct sctp_sndrcvinfo *, int);
529 extern ssize_t sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
530     socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
531 #else	/* __STDC__ */
532 extern int sctp_bindx();
533 extern void sctp_freeladdrs();
534 extern void sctp_freepaddrs();
535 extern int sctp_getladdrs();
536 extern int sctp_getpaddrs();
537 extern int sctp_opt_info();
538 extern int sctp_peeloff();
539 extern ssize_t sctp_recvmsg();
540 extern ssize_t sctp_send();
541 extern ssize_t sctp_sendmsg();
542 #endif	/* __STDC__ */
543 #endif	/* !defined(_KERNEL) || defined(_BOOT) */
544 
545 
546 /*
547  * SCTP protocol related elements.
548  */
549 
550 /* All SCTP chunks and parameters are 32-bit aligned */
551 #define	SCTP_ALIGN	4
552 
553 /*
554  * SCTP association optional parameter handling. The top two bits
555  * of the parameter type define how this and further parameters in
556  * the received chunk should be handled.
557  */
558 #define	SCTP_UNREC_PARAM_MASK	0xc000
559 /* Continue processing parameters after an unrecognized optional param? */
560 #define	SCTP_CONT_PROC_PARAMS	0x8000
561 /* Report this unreconized optional parameter or silently ignore it? */
562 #define	SCTP_REPORT_THIS_PARAM	0x4000
563 
564 /*
565  * Data chunk bit manipulations
566  */
567 #define	SCTP_DATA_EBIT	0x01
568 #define	SCTP_TBIT	0x01
569 #define	SCTP_DATA_BBIT	0x02
570 #define	SCTP_DATA_UBIT	0x04
571 
572 #define	SCTP_DATA_GET_BBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_BBIT)
573 #define	SCTP_GET_TBIT(cp)	((cp)->sch_flags & SCTP_TBIT)
574 #define	SCTP_DATA_GET_EBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_EBIT)
575 #define	SCTP_DATA_GET_UBIT(sdc)	((sdc)->sdh_flags & SCTP_DATA_UBIT)
576 
577 #define	SCTP_DATA_SET_BBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_BBIT)
578 #define	SCTP_SET_TBIT(cp)	((cp)->sch_flags |= SCTP_TBIT)
579 #define	SCTP_DATA_SET_EBIT(sdc)	((sdc)->sdh_flags |= SCTP_DATA_EBIT)
580 #define	SCTP_DATA_SET_UBIT(sdc)	((sdc)->sdh_flags |=  SCTP_DATA_UBIT)
581 
582 /* SCTP common header */
583 typedef struct sctp_hdr {
584 	uint16_t	sh_sport;
585 	uint16_t	sh_dport;
586 	uint32_t	sh_verf;
587 	uint32_t	sh_chksum;
588 } sctp_hdr_t;
589 
590 /* Chunk IDs */
591 typedef enum {
592 	CHUNK_DATA,
593 	CHUNK_INIT,
594 	CHUNK_INIT_ACK,
595 	CHUNK_SACK,
596 	CHUNK_HEARTBEAT,
597 	CHUNK_HEARTBEAT_ACK,
598 	CHUNK_ABORT,
599 	CHUNK_SHUTDOWN,
600 	CHUNK_SHUTDOWN_ACK,
601 	CHUNK_ERROR,
602 	CHUNK_COOKIE,
603 	CHUNK_COOKIE_ACK,
604 	CHUNK_ECNE,
605 	CHUNK_CWR,
606 	CHUNK_SHUTDOWN_COMPLETE,
607 	CHUNK_ASCONF_ACK = 128,
608 	CHUNK_FORWARD_TSN = 192,
609 	CHUNK_ASCONF = 193
610 } sctp_chunk_id_t;
611 
612 /* Common chunk header */
613 typedef struct sctp_chunk_hdr {
614 	uint8_t		sch_id;
615 	uint8_t		sch_flags;
616 	uint16_t	sch_len;
617 } sctp_chunk_hdr_t;
618 
619 /* INIT chunk data definition */
620 typedef struct sctp_init_chunk {
621 	uint32_t	sic_inittag;
622 	uint32_t	sic_a_rwnd;
623 	uint16_t	sic_outstr;
624 	uint16_t	sic_instr;
625 	uint32_t	sic_inittsn;
626 } sctp_init_chunk_t;
627 
628 /* SCTP DATA chunk */
629 typedef struct sctp_data_chunk {
630 	uint32_t	sdc_tsn;
631 	uint16_t	sdc_sid;
632 	uint16_t	sdc_ssn;
633 	uint32_t	sdc_payload_id;
634 } sctp_data_chunk_t;
635 
636 /* sctp_data_hdr includes the SCTP chunk hdr and the DATA chunk */
637 typedef struct sctp_data_hdr {
638 	sctp_chunk_hdr_t	sdh_chdr;
639 	sctp_data_chunk_t	sdh_data;
640 #define	sdh_id		sdh_chdr.sch_id
641 #define	sdh_flags	sdh_chdr.sch_flags
642 #define	sdh_len		sdh_chdr.sch_len
643 #define	sdh_tsn		sdh_data.sdc_tsn
644 #define	sdh_sid		sdh_data.sdc_sid
645 #define	sdh_ssn		sdh_data.sdc_ssn
646 #define	sdh_payload_id	sdh_data.sdc_payload_id
647 } sctp_data_hdr_t;
648 
649 typedef struct sctp_sack_chunk {
650 	uint32_t	ssc_cumtsn;
651 	uint32_t	ssc_a_rwnd;
652 	uint16_t	ssc_numfrags;
653 	uint16_t	ssc_numdups;
654 } sctp_sack_chunk_t;
655 
656 typedef struct sctp_sack_frag {
657 	uint16_t	ssf_start;
658 	uint16_t	ssf_end;
659 } sctp_sack_frag_t;
660 
661 /* Parameter types */
662 #define	PARM_UNKNOWN		0
663 #define	PARM_HBINFO		1
664 #define	PARM_ADDR4		5
665 #define	PARM_ADDR6		6
666 #define	PARM_COOKIE		7
667 #define	PARM_UNRECOGNIZED	8
668 #define	PARM_COOKIE_PRESERVE	9
669 #define	PARM_ADDR_HOST_NAME	11
670 #define	PARM_SUPP_ADDRS		12
671 #define	PARM_ECN		0x8000
672 #define	PARM_ECN_CAPABLE	PARM_ECN
673 #define	PARM_FORWARD_TSN	0xc000
674 #define	PARM_ADD_IP		0xc001
675 #define	PARM_DEL_IP		0xc002
676 #define	PARM_ERROR_IND		0xc003
677 #define	PARM_ASCONF_ERROR	PARM_ERROR_IND
678 #define	PARM_SET_PRIMARY	0xc004
679 #define	PARM_PRIMARY_ADDR	PARM_SET_PRIMARY
680 #define	PARM_SUCCESS		0xc005
681 #define	PARM_ASCONF_SUCCESS	PARM_SUCCESS
682 #define	PARM_ADAPT_LAYER_IND	0xc006
683 
684 
685 /* Lengths from SCTP spec */
686 #define	PARM_ADDR4_LEN		8
687 #define	PARM_ADDR6_LEN		20
688 
689 /* Parameter header */
690 typedef struct sctp_parm_hdr {
691 	uint16_t	sph_type;
692 	uint16_t	sph_len;
693 } sctp_parm_hdr_t;
694 
695 /*
696  * The following extend sctp_parm_hdr_t
697  * with cause-specfic content used to fill
698  * CAUSE blocks in ABORT or ERROR chunks.
699  * The overall size of the CAUSE block will
700  * be sizeof (sctp_parm_hdr_t) plus the size
701  * of the extended cause structure,
702  */
703 
704 /*
705  * Invalid stream-identifier extended cause.
706  * SCTP_ERR_BAD_SID
707  */
708 typedef struct sctp_bsc {
709 	uint16_t	bsc_sid;
710 	uint16_t	bsc_pad; /* RESV = 0 */
711 } sctp_bsc_t;
712 
713 /*
714  * Missing parameter extended cause, currently
715  * only one missing parameter is supported.
716  * SCTP_ERR_MISSING_PARM
717  */
718 typedef struct sctp_mpc {
719 	uint32_t	mpc_num;
720 	uint16_t	mpc_param;
721 	uint16_t	mpc_pad;
722 } sctp_mpc_t;
723 
724 /* Error causes */
725 #define	SCTP_ERR_UNKNOWN		0
726 #define	SCTP_ERR_BAD_SID		1
727 #define	SCTP_ERR_MISSING_PARM		2
728 #define	SCTP_ERR_STALE_COOKIE		3
729 #define	SCTP_ERR_NO_RESOURCES		4
730 #define	SCTP_ERR_BAD_ADDR		5
731 #define	SCTP_ERR_UNREC_CHUNK		6
732 #define	SCTP_ERR_BAD_MANDPARM		7
733 #define	SCTP_ERR_UNREC_PARM		8
734 #define	SCTP_ERR_NO_USR_DATA		9
735 #define	SCTP_ERR_COOKIE_SHUT		10
736 #define	SCTP_ERR_RESTART_NEW_ADDRS	11
737 #define	SCTP_ERR_USER_ABORT		12
738 #define	SCTP_ERR_DELETE_LASTADDR	256
739 #define	SCTP_ERR_RESOURCE_SHORTAGE	257
740 #define	SCTP_ERR_DELETE_SRCADDR		258
741 #define	SCTP_ERR_AUTH_ERR		260
742 
743 /*
744  * Extensions
745  */
746 
747 /* Extended Chunk Types */
748 #define	CHUNK_ASCONF		0xc1
749 #define	CHUNK_ASCONF_ACK	0x80
750 
751 /* Extension Error Causes */
752 #define	SCTP_ERR_DEL_LAST_ADDR	0x0100
753 #define	SCTP_ERR_RES_SHORTAGE	0x0101
754 #define	SCTP_ERR_DEL_SRC_ADDR	0x0102
755 #define	SCTP_ERR_ILLEGAL_ACK	0x0103
756 #define	SCTP_ERR_UNAUTHORIZED	0x0104
757 
758 typedef struct sctp_addip4 {
759 	sctp_parm_hdr_t		sad4_addip_ph;
760 	uint32_t		asconf_req_cid;
761 	sctp_parm_hdr_t		sad4_addr4_ph;
762 	ipaddr_t		sad4_addr;
763 } sctp_addip4_t;
764 
765 typedef struct sctp_addip6 {
766 	sctp_parm_hdr_t		sad6_addip_ph;
767 	uint32_t		asconf_req_cid;
768 	sctp_parm_hdr_t		sad6_addr6_ph;
769 	in6_addr_t		sad6_addr;
770 } sctp_addip6_t;
771 
772 #ifdef __cplusplus
773 }
774 #endif
775 
776 #endif	/* _NETINET_SCTP_H */
777