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