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