• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SCTP kernel Implementation: User API extensions.
2  *
3  * sctp.h
4  *
5  * Distributed under the terms of the LGPL v2.1 as described in
6  *    http://www.gnu.org/copyleft/lesser.txt
7  *
8  * This file is part of the user library that offers support for the
9  * Linux Kernel SCTP Implementation. The main purpose of this
10  * code is to provide the SCTP Socket API mappings for user
11  * application to interface with SCTP in kernel.
12  *
13  * This header represents the structures and constants needed to support
14  * the SCTP Extension to the Sockets API.
15  *
16  * (C) Copyright IBM Corp. 2001, 2004
17  * Copyright (c) 1999-2000 Cisco, Inc.
18  * Copyright (c) 1999-2001 Motorola, Inc.
19  *
20  * Written or modified by:
21  *    La Monte H.P. Yarroll    <piggy@acm.org>
22  *    R. Stewart               <randall@sctp.chicago.il.us>
23  *    K. Morneau               <kmorneau@cisco.com>
24  *    Q. Xie                   <qxie1@email.mot.com>
25  *    Karl Knutson             <karl@athena.chicago.il.us>
26  *    Jon Grimm                <jgrimm@austin.ibm.com>
27  *    Daisy Chang              <daisyc@us.ibm.com>
28  *    Inaky Perez-Gonzalez     <inaky.gonzalez@intel.com>
29  *    Sridhar Samudrala        <sri@us.ibm.com>
30  *    Vlad Yasevich		<vladislav.yasevich@hp.com>
31  */
32 
33 #ifndef __linux_sctp_h__
34 #define __linux_sctp_h__
35 
36 #include <stdint.h>
37 #include <linux/types.h>
38 #include <sys/socket.h>
39 
40 __BEGIN_DECLS
41 
42 typedef __s32 sctp_assoc_t;
43 
44 /* Socket option layer for SCTP */
45 #ifndef SOL_SCTP
46 #define SOL_SCTP	132
47 #endif
48 
49 #ifndef IPPROTO_SCTP
50 #define IPPROTO_SCTP    132
51 #endif
52 
53 /* 9. Preprocessor constants */
54 #define HAVE_SCTP
55 #define HAVE_KERNEL_SCTP
56 #define HAVE_SCTP_MULTIBUF
57 #define HAVE_SCTP_NOCONNECT
58 #define HAVE_SCTP_PRSCTP
59 #define HAVE_SCTP_ADDIP
60 #define HAVE_SCTP_CANSET_PRIMARY
61 
62 /* The following symbols come from the Sockets API Extensions for
63  * SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
64  */
65 #define SCTP_RTOINFO	0
66 #define SCTP_ASSOCINFO  1
67 #define SCTP_INITMSG	2
68 #define SCTP_NODELAY	3		/* Get/set nodelay option. */
69 #define SCTP_AUTOCLOSE	4
70 #define SCTP_SET_PEER_PRIMARY_ADDR 5
71 #define SCTP_PRIMARY_ADDR	6
72 #define SCTP_ADAPTATION_LAYER	7
73 #define SCTP_DISABLE_FRAGMENTS	8
74 #define SCTP_PEER_ADDR_PARAMS	9
75 #define SCTP_DEFAULT_SEND_PARAM	10
76 #define SCTP_EVENTS	11
77 #define SCTP_I_WANT_MAPPED_V4_ADDR 12	/* Turn on/off mapped v4 addresses  */
78 #define SCTP_MAXSEG	13		/* Get/set maximum fragment. */
79 #define SCTP_STATUS	14
80 #define SCTP_GET_PEER_ADDR_INFO	15
81 #define SCTP_DELAYED_ACK_TIME	16
82 #define SCTP_DELAYED_ACK SCTP_DELAYED_ACK_TIME
83 #define SCTP_DELAYED_SACK SCTP_DELAYED_ACK_TIME
84 #define SCTP_CONTEXT	17
85 #define SCTP_FRAGMENT_INTERLEAVE	18
86 #define SCTP_PARTIAL_DELIVERY_POINT	19 /* Set/Get partial delivery point */
87 #define SCTP_MAX_BURST	20		/* Set/Get max burst */
88 #define SCTP_AUTH_CHUNK	21	/* Set only: add a chunk type to authenticate */
89 #define SCTP_HMAC_IDENT	22
90 #define SCTP_AUTH_KEY	23
91 #define SCTP_AUTH_ACTIVE_KEY	24
92 #define SCTP_AUTH_DELETE_KEY	25
93 #define SCTP_PEER_AUTH_CHUNKS	26	/* Read only */
94 #define SCTP_LOCAL_AUTH_CHUNKS	27	/* Read only */
95 #define SCTP_GET_ASSOC_NUMBER	28	/* Read only */
96 
97 /* Internal Socket Options. Some of the sctp library functions are
98  * implemented using these socket options.
99  */
100 #define SCTP_SOCKOPT_BINDX_ADD	100	/* BINDX requests for adding addrs */
101 #define SCTP_SOCKOPT_BINDX_REM	101	/* BINDX requests for removing addrs. */
102 #define SCTP_SOCKOPT_PEELOFF	102	/* peel off association. */
103 /* Options 104-106 are deprecated and removed. Do not use this space */
104 #define SCTP_SOCKOPT_CONNECTX_OLD	107	/* CONNECTX old requests. */
105 #define SCTP_GET_PEER_ADDRS	108		/* Get all peer addresss. */
106 #define SCTP_GET_LOCAL_ADDRS	109		/* Get all local addresss. */
107 #define SCTP_SOCKOPT_CONNECTX	110		/* CONNECTX requests. */
108 #define SCTP_SOCKOPT_CONNECTX3	111	/* CONNECTX requests (updated) */
109 
110 /* SCTP socket option used to read per endpoint association statistics. */
111 #define SCTP_GET_ASSOC_STATS    112      /* Read only */
112 
113 /*
114  * 5.2.1 SCTP Initiation Structure (SCTP_INIT)
115  *
116  *   This cmsghdr structure provides information for initializing new
117  *   SCTP associations with sendmsg().  The SCTP_INITMSG socket option
118  *   uses this same data structure.  This structure is not used for
119  *   recvmsg().
120  *
121  *   cmsg_level    cmsg_type      cmsg_data[]
122  *   ------------  ------------   ----------------------
123  *   IPPROTO_SCTP  SCTP_INIT      struct sctp_initmsg
124  *
125  */
126 struct sctp_initmsg {
127 	__u16 sinit_num_ostreams;
128 	__u16 sinit_max_instreams;
129 	__u16 sinit_max_attempts;
130 	__u16 sinit_max_init_timeo;
131 };
132 
133 /*
134  * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
135  *
136  *   This cmsghdr structure specifies SCTP options for sendmsg() and
137  *   describes SCTP header information about a received message through
138  *   recvmsg().
139  *
140  *   cmsg_level    cmsg_type      cmsg_data[]
141  *   ------------  ------------   ----------------------
142  *   IPPROTO_SCTP  SCTP_SNDRCV    struct sctp_sndrcvinfo
143  *
144  */
145 struct sctp_sndrcvinfo {
146 	__u16 sinfo_stream;
147 	__u16 sinfo_ssn;
148 	__u16 sinfo_flags;
149 	__u32 sinfo_ppid;
150 	__u32 sinfo_context;
151 	__u32 sinfo_timetolive;
152 	__u32 sinfo_tsn;
153 	__u32 sinfo_cumtsn;
154 	sctp_assoc_t sinfo_assoc_id;
155 };
156 
157 /*
158  *  sinfo_flags: 16 bits (unsigned integer)
159  *
160  *   This field may contain any of the following flags and is composed of
161  *   a bitwise OR of these values.
162  */
163 
164 enum sctp_sinfo_flags {
165 	SCTP_UNORDERED = 1,  /* Send/receive message unordered. */
166 	SCTP_ADDR_OVER = 2,  /* Override the primary destination. */
167 	SCTP_ABORT=4,        /* Send an ABORT message to the peer. */
168 	SCTP_SACK_IMMEDIATELY = 8,      /* SACK should be sent without delay */
169 	SCTP_EOF=MSG_FIN,    /* Initiate graceful shutdown process. */
170 };
171 
172 
173 typedef union {
174 	__u8   			raw;
175 	struct sctp_initmsg	init;
176 	struct sctp_sndrcvinfo	sndrcv;
177 } sctp_cmsg_data_t;
178 
179 /* These are cmsg_types.  */
180 typedef enum sctp_cmsg_type {
181 	SCTP_INIT,              /* 5.2.1 SCTP Initiation Structure */
182 #define SCTP_INIT SCTP_INIT
183 	SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
184 #define SCTP_SNDRCV SCTP_SNDRCV
185 } sctp_cmsg_t;
186 
187 
188 /*
189  * 5.3.1.1 SCTP_ASSOC_CHANGE
190  *
191  *   Communication notifications inform the ULP that an SCTP association
192  *   has either begun or ended. The identifier for a new association is
193  *   provided by this notificaion. The notification information has the
194  *   following format:
195  *
196  */
197 struct sctp_assoc_change {
198 	__u16 sac_type;
199 	__u16 sac_flags;
200 	__u32 sac_length;
201 	__u16 sac_state;
202 	__u16 sac_error;
203 	__u16 sac_outbound_streams;
204 	__u16 sac_inbound_streams;
205 	sctp_assoc_t sac_assoc_id;
206 	__u8 sac_info[0];
207 };
208 
209 /*
210  *   sac_state: 32 bits (signed integer)
211  *
212  *   This field holds one of a number of values that communicate the
213  *   event that happened to the association.  They include:
214  *
215  *   Note:  The following state names deviate from the API draft as
216  *   the names clash too easily with other kernel symbols.
217  */
218 enum sctp_sac_state {
219 	SCTP_COMM_UP,
220 	SCTP_COMM_LOST,
221 	SCTP_RESTART,
222 	SCTP_SHUTDOWN_COMP,
223 	SCTP_CANT_STR_ASSOC,
224 };
225 
226 /*
227  * 5.3.1.2 SCTP_PEER_ADDR_CHANGE
228  *
229  *   When a destination address on a multi-homed peer encounters a change
230  *   an interface details event is sent.  The information has the
231  *   following structure:
232  */
233 struct sctp_paddr_change {
234 	__u16 spc_type;
235 	__u16 spc_flags;
236 	__u32 spc_length;
237 	struct sockaddr_storage spc_aaddr;
238 	int spc_state;
239 	int spc_error;
240 	sctp_assoc_t spc_assoc_id;
241 } __attribute__((packed, aligned(4)));
242 
243 /*
244  *    spc_state:  32 bits (signed integer)
245  *
246  *   This field holds one of a number of values that communicate the
247  *   event that happened to the address.  They include:
248  */
249 enum sctp_spc_state {
250 	SCTP_ADDR_AVAILABLE,
251 	SCTP_ADDR_UNREACHABLE,
252 	SCTP_ADDR_REMOVED,
253 	SCTP_ADDR_ADDED,
254 	SCTP_ADDR_MADE_PRIM,
255 	SCTP_ADDR_CONFIRMED,
256 };
257 
258 
259 /*
260  * 5.3.1.3 SCTP_REMOTE_ERROR
261  *
262  *   A remote peer may send an Operational Error message to its peer.
263  *   This message indicates a variety of error conditions on an
264  *   association. The entire error TLV as it appears on the wire is
265  *   included in a SCTP_REMOTE_ERROR event.  Please refer to the SCTP
266  *   specification [SCTP] and any extensions for a list of possible
267  *   error formats. SCTP error TLVs have the format:
268  */
269 struct sctp_remote_error {
270 	__u16 sre_type;
271 	__u16 sre_flags;
272 	__u32 sre_length;
273 	__u16 sre_error;
274 	sctp_assoc_t sre_assoc_id;
275 	__u8 sre_data[0];
276 };
277 
278 
279 /*
280  * 5.3.1.4 SCTP_SEND_FAILED
281  *
282  *   If SCTP cannot deliver a message it may return the message as a
283  *   notification.
284  */
285 struct sctp_send_failed {
286 	__u16 ssf_type;
287 	__u16 ssf_flags;
288 	__u32 ssf_length;
289 	__u32 ssf_error;
290 	struct sctp_sndrcvinfo ssf_info;
291 	sctp_assoc_t ssf_assoc_id;
292 	__u8 ssf_data[0];
293 };
294 
295 /*
296  *   ssf_flags: 16 bits (unsigned integer)
297  *
298  *   The flag value will take one of the following values
299  *
300  *   SCTP_DATA_UNSENT  - Indicates that the data was never put on
301  *                       the wire.
302  *
303  *   SCTP_DATA_SENT    - Indicates that the data was put on the wire.
304  *                       Note that this does not necessarily mean that the
305  *                       data was (or was not) successfully delivered.
306  */
307 enum sctp_ssf_flags {
308 	SCTP_DATA_UNSENT,
309 	SCTP_DATA_SENT,
310 };
311 
312 /*
313  * 5.3.1.5 SCTP_SHUTDOWN_EVENT
314  *
315  *   When a peer sends a SHUTDOWN, SCTP delivers this notification to
316  *   inform the application that it should cease sending data.
317  */
318 struct sctp_shutdown_event {
319 	__u16 sse_type;
320 	__u16 sse_flags;
321 	__u32 sse_length;
322 	sctp_assoc_t sse_assoc_id;
323 };
324 
325 /*
326  * 5.3.1.6 SCTP_ADAPTATION_INDICATION
327  *
328  *   When a peer sends a Adaptation Layer Indication parameter , SCTP
329  *   delivers this notification to inform the application
330  *   that of the peers requested adaptation layer.
331  */
332 struct sctp_adaptation_event {
333 	__u16 sai_type;
334 	__u16 sai_flags;
335 	__u32 sai_length;
336 	__u32 sai_adaptation_ind;
337 	sctp_assoc_t sai_assoc_id;
338 };
339 
340 /*
341  * 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
342  *
343  *   When a receiver is engaged in a partial delivery of a
344  *   message this notification will be used to indicate
345  *   various events.
346  */
347 struct sctp_pdapi_event {
348 	__u16 pdapi_type;
349 	__u16 pdapi_flags;
350 	__u32 pdapi_length;
351 	__u32 pdapi_indication;
352 	sctp_assoc_t pdapi_assoc_id;
353 };
354 
355 enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
356 
357 /*
358 * 5.3.1.8.  SCTP_AUTHENTICATION_EVENT
359 *
360 *  When a receiver is using authentication this message will provide
361 *  notifications regarding new keys being made active as well as errors.
362 */
363 
364 struct sctp_authkey_event {
365 	__u16 auth_type;
366 	__u16 auth_flags;
367 	__u32 auth_length;
368 	__u16 auth_keynumber;
369 	__u16 auth_altkeynumber;
370 	__u32 auth_indication;
371 	sctp_assoc_t auth_assoc_id;
372 };
373 
374 enum { SCTP_AUTH_NEWKEY = 0, };
375 
376 struct sctp_sender_dry_event {
377        __u16 sender_dry_type;
378        __u16 sender_dry_flags;
379        __u32 sender_dry_length;
380        sctp_assoc_t sender_dry_assoc_id;
381 };
382 
383 /*
384  * Described in Section 7.3
385  *   Ancillary Data and Notification Interest Options
386  */
387 struct sctp_event_subscribe {
388 	__u8 sctp_data_io_event;
389 	__u8 sctp_association_event;
390 	__u8 sctp_address_event;
391 	__u8 sctp_send_failure_event;
392 	__u8 sctp_peer_error_event;
393 	__u8 sctp_shutdown_event;
394 	__u8 sctp_partial_delivery_event;
395 	__u8 sctp_adaptation_layer_event;
396 	__u8 sctp_authentication_event;
397 	__u8 sctp_sender_dry_event;
398 };
399 
400 /*
401  * 5.3.1 SCTP Notification Structure
402  *
403  *   The notification structure is defined as the union of all
404  *   notification types.
405  *
406  */
407 union sctp_notification {
408 	struct {
409 		__u16 sn_type;             /* Notification type. */
410 		__u16 sn_flags;
411 		__u32 sn_length;
412 	} sn_header;
413 	struct sctp_assoc_change sn_assoc_change;
414 	struct sctp_paddr_change sn_paddr_change;
415 	struct sctp_remote_error sn_remote_error;
416 	struct sctp_send_failed sn_send_failed;
417 	struct sctp_shutdown_event sn_shutdown_event;
418 	struct sctp_adaptation_event sn_adaptation_event;
419 	struct sctp_pdapi_event sn_pdapi_event;
420 	struct sctp_authkey_event sn_authkey_event;
421 	struct sctp_sender_dry_event sn_sender_dry_event;
422 };
423 
424 /* Section 5.3.1
425  * All standard values for sn_type flags are greater than 2^15.
426  * Values from 2^15 and down are reserved.
427  */
428 
429 enum sctp_sn_type {
430 	SCTP_SN_TYPE_BASE     = (1<<15),
431 	SCTP_ASSOC_CHANGE,
432 #define SCTP_ASSOC_CHANGE SCTP_ASSOC_CHANGE
433 	SCTP_PEER_ADDR_CHANGE,
434 #define SCTP_PEER_ADDR_CHANGE SCTP_PEER_ADDR_CHANGE
435 	SCTP_SEND_FAILED,
436 #define SCTP_SEND_FAILED SCTP_SEND_FAILED
437 	SCTP_REMOTE_ERROR,
438 #define SCTP_REMOTE_ERROR SCTP_REMOTE_ERROR
439 	SCTP_SHUTDOWN_EVENT,
440 #define SCTP_SHUTDOWN_EVENT SCTP_SHUTDOWN_EVENT
441 	SCTP_PARTIAL_DELIVERY_EVENT,
442 #define SCTP_PARTIAL_DELIVERY_EVENT SCTP_PARTIAL_DELIVERY_EVENT
443 	SCTP_ADAPTATION_INDICATION,
444 #define SCTP_ADAPTATION_INDICATION SCTP_ADAPTATION_INDICATION
445 	SCTP_AUTHENTICATION_INDICATION,
446 #define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_INDICATION
447 	SCTP_SENDER_DRY_EVENT,
448 #define SCTP_SENDER_DRY_EVENT SCTP_SENDER_DRY_EVENT
449 };
450 
451 /* Notification error codes used to fill up the error fields in some
452  * notifications.
453  * SCTP_PEER_ADDRESS_CHAGE 	: spc_error
454  * SCTP_ASSOC_CHANGE		: sac_error
455  * These names should be potentially included in the draft 04 of the SCTP
456  * sockets API specification.
457  */
458 typedef enum sctp_sn_error {
459 	SCTP_FAILED_THRESHOLD,
460 	SCTP_RECEIVED_SACK,
461 	SCTP_HEARTBEAT_SUCCESS,
462 	SCTP_RESPONSE_TO_USER_REQ,
463 	SCTP_INTERNAL_ERROR,
464 	SCTP_SHUTDOWN_GUARD_EXPIRES,
465 	SCTP_PEER_FAULTY,
466 } sctp_sn_error_t;
467 
468 /*
469  * 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
470  *
471  *   The protocol parameters used to initialize and bound retransmission
472  *   timeout (RTO) are tunable.  See [SCTP] for more information on how
473  *   these parameters are used in RTO calculation.
474  */
475 struct sctp_rtoinfo {
476 	sctp_assoc_t	srto_assoc_id;
477 	__u32		srto_initial;
478 	__u32		srto_max;
479 	__u32		srto_min;
480 };
481 
482 /*
483  * 7.1.2 Association Parameters (SCTP_ASSOCINFO)
484  *
485  *   This option is used to both examine and set various association and
486  *   endpoint parameters.
487  */
488 struct sctp_assocparams {
489 	sctp_assoc_t	sasoc_assoc_id;
490 	__u16		sasoc_asocmaxrxt;
491 	__u16		sasoc_number_peer_destinations;
492 	__u32		sasoc_peer_rwnd;
493 	__u32		sasoc_local_rwnd;
494 	__u32		sasoc_cookie_life;
495 };
496 
497 /*
498  * 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
499  *
500  *  Requests that the peer mark the enclosed address as the association
501  *  primary. The enclosed address must be one of the association's
502  *  locally bound addresses. The following structure is used to make a
503  *   set primary request:
504  */
505 struct sctp_setpeerprim {
506 	sctp_assoc_t            sspp_assoc_id;
507 	struct sockaddr_storage sspp_addr;
508 } __attribute__((packed, aligned(4)));
509 
510 /*
511  * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
512  *
513  *  Requests that the local SCTP stack use the enclosed peer address as
514  *  the association primary. The enclosed address must be one of the
515  *  association peer's addresses. The following structure is used to
516  *  make a set peer primary request:
517  */
518 struct sctp_setprim {
519 	sctp_assoc_t            ssp_assoc_id;
520 	struct sockaddr_storage ssp_addr;
521 } __attribute__((packed, aligned(4)));
522 
523 /* For backward compatibility use, define the old name too */
524 #define sctp_prim sctp_setprim
525 
526 /*
527  * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER)
528  *
529  * Requests that the local endpoint set the specified Adaptation Layer
530  * Indication parameter for all future INIT and INIT-ACK exchanges.
531  */
532 struct sctp_setadaptation {
533 	__u32	ssb_adaptation_ind;
534 };
535 
536 /*
537  * 7.1.13 Peer Address Parameters  (SCTP_PEER_ADDR_PARAMS)
538  *
539  *   Applications can enable or disable heartbeats for any peer address
540  *   of an association, modify an address's heartbeat interval, force a
541  *   heartbeat to be sent immediately, and adjust the address's maximum
542  *   number of retransmissions sent before an address is considered
543  *   unreachable. The following structure is used to access and modify an
544  *   address's parameters:
545  */
546 enum  sctp_spp_flags {
547 	SPP_HB_ENABLE = 1<<0,		/*Enable heartbeats*/
548 	SPP_HB_DISABLE = 1<<1,		/*Disable heartbeats*/
549 	SPP_HB = SPP_HB_ENABLE | SPP_HB_DISABLE,
550 	SPP_HB_DEMAND = 1<<2,		/*Send heartbeat immediately*/
551 	SPP_PMTUD_ENABLE = 1<<3,	/*Enable PMTU discovery*/
552 	SPP_PMTUD_DISABLE = 1<<4,	/*Disable PMTU discovery*/
553 	SPP_PMTUD = SPP_PMTUD_ENABLE | SPP_PMTUD_DISABLE,
554 	SPP_SACKDELAY_ENABLE = 1<<5,	/*Enable SACK*/
555 	SPP_SACKDELAY_DISABLE = 1<<6,	/*Disable SACK*/
556 	SPP_SACKDELAY = SPP_SACKDELAY_ENABLE | SPP_SACKDELAY_DISABLE,
557 	SPP_HB_TIME_IS_ZERO = 1<<7,	/* Set HB delay to 0 */
558 };
559 
560 struct sctp_paddrparams {
561 	sctp_assoc_t		spp_assoc_id;
562 	struct sockaddr_storage	spp_address;
563 	__u32			spp_hbinterval;
564 	__u16			spp_pathmaxrxt;
565 	__u32			spp_pathmtu;
566 	__u32			spp_sackdelay;
567 	__u32			spp_flags;
568 } __attribute__((packed, aligned(4)));
569 
570 /*
571  * 7.1.18.  Add a chunk that must be authenticated (SCTP_AUTH_CHUNK)
572  *
573  * This set option adds a chunk type that the user is requesting to be
574  * received only in an authenticated way.  Changes to the list of chunks
575  * will only effect future associations on the socket.
576  */
577 struct sctp_authchunk {
578 	__u8		sauth_chunk;
579 };
580 
581 /*
582  * 7.1.19.  Get or set the list of supported HMAC Identifiers (SCTP_HMAC_IDENT)
583  *
584  * This option gets or sets the list of HMAC algorithms that the local
585  * endpoint requires the peer to use.
586 */
587 
588 enum {
589 	SCTP_AUTH_HMAC_ID_SHA1 = 1,
590 	SCTP_AUTH_HMAC_ID_SHA256 = 3,
591 };
592 
593 struct sctp_hmacalgo {
594 	__u32		shmac_number_of_idents;
595 	__u16		shmac_idents[];
596 };
597 
598 /*
599  * 7.1.20.  Set a shared key (SCTP_AUTH_KEY)
600  *
601  * This option will set a shared secret key which is used to build an
602  * association shared key.
603  */
604 struct sctp_authkey {
605 	sctp_assoc_t	sca_assoc_id;
606 	__u16		sca_keynumber;
607 	__u16		sca_keylength;
608 	__u8		sca_key[];
609 };
610 
611 /*
612  * 7.1.21.  Get or set the active shared key (SCTP_AUTH_ACTIVE_KEY)
613  *
614  * This option will get or set the active shared key to be used to build
615  * the association shared key.
616  */
617 
618 struct sctp_authkeyid {
619 	sctp_assoc_t	scact_assoc_id;
620 	__u16		scact_keynumber;
621 };
622 
623 
624 /*
625  * 7.1.23.  Get or set delayed ack timer (SCTP_DELAYED_SACK)
626  *
627  * This option will effect the way delayed acks are performed.  This
628  * option allows you to get or set the delayed ack time, in
629  * milliseconds.  It also allows changing the delayed ack frequency.
630  * Changing the frequency to 1 disables the delayed sack algorithm.  If
631  * the assoc_id is 0, then this sets or gets the endpoints default
632  * values.  If the assoc_id field is non-zero, then the set or get
633  * effects the specified association for the one to many model (the
634  * assoc_id field is ignored by the one to one model).  Note that if
635  * sack_delay or sack_freq are 0 when setting this option, then the
636  * current values will remain unchanged.
637  */
638 struct sctp_sack_info {
639 	sctp_assoc_t	sack_assoc_id;
640 	uint32_t	sack_delay;
641 	uint32_t	sack_freq;
642 };
643 
644 struct sctp_assoc_value {
645     sctp_assoc_t            assoc_id;
646     uint32_t                assoc_value;
647 };
648 
649 /*
650  * 7.2.2 Peer Address Information
651  *
652  *   Applications can retrieve information about a specific peer address
653  *   of an association, including its reachability state, congestion
654  *   window, and retransmission timer values.  This information is
655  *   read-only. The following structure is used to access this
656  *   information:
657  */
658 struct sctp_paddrinfo {
659 	sctp_assoc_t		spinfo_assoc_id;
660 	struct sockaddr_storage	spinfo_address;
661 	__s32			spinfo_state;
662 	__u32			spinfo_cwnd;
663 	__u32			spinfo_srtt;
664 	__u32			spinfo_rto;
665 	__u32			spinfo_mtu;
666 } __attribute__((packed, aligned(4)));
667 
668 /* Peer addresses's state. */
669 /* UNKNOWN: Peer address passed by the upper layer in sendmsg or connect[x]
670  * calls.
671  * UNCONFIRMED: Peer address received in INIT/INIT-ACK address parameters.
672  *              Not yet confirmed by a heartbeat and not available for data
673  *		transfers.
674  * ACTIVE : Peer address confirmed, active and available for data transfers.
675  * INACTIVE: Peer address inactive and not available for data transfers.
676  */
677 enum sctp_spinfo_state {
678 	SCTP_INACTIVE,
679 	SCTP_PF,
680 	SCTP_ACTIVE,
681 	SCTP_UNCONFIRMED,
682 	SCTP_UNKNOWN = 0xffff
683 };
684 
685 /*
686  * 7.2.1 Association Status (SCTP_STATUS)
687  *
688  *   Applications can retrieve current status information about an
689  *   association, including association state, peer receiver window size,
690  *   number of unacked data chunks, and number of data chunks pending
691  *   receipt.  This information is read-only.  The following structure is
692  *   used to access this information:
693  */
694 struct sctp_status {
695 	sctp_assoc_t		sstat_assoc_id;
696 	__s32			sstat_state;
697 	__u32			sstat_rwnd;
698 	__u16			sstat_unackdata;
699 	__u16			sstat_penddata;
700 	__u16			sstat_instrms;
701 	__u16			sstat_outstrms;
702 	__u32			sstat_fragmentation_point;
703 	struct sctp_paddrinfo	sstat_primary;
704 };
705 
706 /*
707  * 7.2.3.  Get the list of chunks the peer requires to be authenticated
708  *         (SCTP_PEER_AUTH_CHUNKS)
709  *
710  * This option gets a list of chunks for a specified association that
711  * the peer requires to be received authenticated only.
712  */
713 struct sctp_authchunks {
714 	sctp_assoc_t	gauth_assoc_id;
715 	__u32		gauth_number_of_chunks;
716 	uint8_t		gauth_chunks[];
717 };
718 /* The broken spelling has been released already,
719  * so don't break anyone, now that it's fixed.
720  */
721 #define guth_number_of_chunks gauth_number_of_chunks
722 
723 /* Association states.  */
724 enum sctp_sstat_state {
725 	SCTP_EMPTY                = 0,
726 	SCTP_CLOSED               = 1,
727 	SCTP_COOKIE_WAIT          = 2,
728 	SCTP_COOKIE_ECHOED        = 3,
729 	SCTP_ESTABLISHED          = 4,
730 	SCTP_SHUTDOWN_PENDING     = 5,
731 	SCTP_SHUTDOWN_SENT        = 6,
732 	SCTP_SHUTDOWN_RECEIVED    = 7,
733 	SCTP_SHUTDOWN_ACK_SENT    = 8,
734 };
735 
736 /*
737  * 8.3, 8.5 get all peer/local addresses in an association.
738  * This parameter struct is used by SCTP_GET_PEER_ADDRS and
739  * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
740  * sctp_getpaddrs() and sctp_getladdrs() API.
741  */
742 struct sctp_getaddrs_old {
743 	sctp_assoc_t            assoc_id;
744 	int			addr_num;
745 	struct sockaddr		*addrs;
746 };
747 struct sctp_getaddrs {
748 	sctp_assoc_t		assoc_id; /*input*/
749 	__u32			addr_num; /*output*/
750 	__u8			addrs[0]; /*output, variable size*/
751 };
752 
753 /* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves
754  * association stats. All stats are counts except sas_maxrto and
755  * sas_obs_rto_ipaddr. maxrto is the max observed rto + transport since
756  * the last call. Will return 0 when did not change since last call
757  */
758 struct sctp_assoc_stats {
759 	sctp_assoc_t	sas_assoc_id;    /* Input */
760 					 /* Transport of the observed max RTO spike */
761 	struct sockaddr_storage sas_obs_rto_ipaddr;
762 	__u64		sas_maxrto;      /* Maximum Observed RTO for period */
763 	__u64		sas_isacks;	 /* SACKs received */
764 	__u64		sas_osacks;	 /* SACKs sent */
765 	__u64		sas_opackets;	 /* Packets sent */
766 	__u64		sas_ipackets;	 /* Packets received */
767 	__u64		sas_rtxchunks;   /* Retransmitted Chunks */
768 	__u64		sas_outofseqtsns;/* TSN received > next expected */
769 	__u64		sas_idupchunks;  /* Dups received (ordered+unordered) */
770 	__u64		sas_gapcnt;      /* Gap Acknowledgements Received */
771 	__u64		sas_ouodchunks;  /* Unordered data chunks sent */
772 	__u64		sas_iuodchunks;  /* Unordered data chunks received */
773 	__u64		sas_oodchunks;	 /* Ordered data chunks sent */
774 	__u64		sas_iodchunks;	 /* Ordered data chunks received */
775 	__u64		sas_octrlchunks; /* Control chunks sent */
776 	__u64		sas_ictrlchunks; /* Control chunks received */
777 };
778 
779 /* These are bit fields for msghdr->msg_flags.  See section 5.1.  */
780 /* On user space Linux, these live in <bits/socket.h> as an enum.  */
781 enum sctp_msg_flags {
782 	MSG_NOTIFICATION = 0x8000,
783 #define MSG_NOTIFICATION MSG_NOTIFICATION
784 };
785 
786 /*
787  * 8.1 sctp_bindx()
788  *
789  * The flags parameter is formed from the bitwise OR of zero or more of the
790  * following currently defined flags:
791  */
792 #define SCTP_BINDX_ADD_ADDR 0x01
793 #define SCTP_BINDX_REM_ADDR 0x02
794 
795 /* This is the structure that is passed as an argument(optval) to
796  * getsockopt(SCTP_SOCKOPT_PEELOFF).
797  */
798 typedef struct {
799 	sctp_assoc_t associd;
800 	int sd;
801 } sctp_peeloff_arg_t;
802 
803 
804 int sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags);
805 
806 int sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt,
807 		  sctp_assoc_t *id);
808 
809 int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
810 
811 /* Prototype for the library function sctp_opt_info defined in
812  * API 7. Socket Options.
813  */
814 int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size);
815 
816 /* Get all peer address on a socket.  This is a new SCTP API
817  * described in the section 8.3 of the Sockets API Extensions for SCTP.
818  * This is implemented using the getsockopt() interface.
819  */
820 int sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
821 
822 /* Frees all resources allocated by sctp_getpaddrs().  This is a new SCTP API
823  * described in the section 8.4 of the Sockets API Extensions for SCTP.
824  */
825 int sctp_freepaddrs(struct sockaddr *addrs);
826 
827 /* Get all locally bound address on a socket.  This is a new SCTP API
828  * described in the section 8.5 of the Sockets API Extensions for SCTP.
829  * This is implemented using the getsockopt() interface.
830  */
831 int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
832 
833 /* Frees all resources allocated by sctp_getladdrs().  This is a new SCTP API
834  * described in the section 8.6 of the Sockets API Extensions for SCTP.
835  */
836 int sctp_freeladdrs(struct sockaddr *addrs);
837 
838 /* This library function assists the user with the advanced features
839  * of SCTP.  This is a new SCTP API described in the section 8.7 of the
840  * Sockets API Extensions for SCTP. This is implemented using the
841  * sendmsg() interface.
842  */
843 int sctp_sendmsg(int s, const void *msg, size_t len, struct sockaddr *to,
844 		 socklen_t tolen, uint32_t ppid, uint32_t flags,
845 		 uint16_t stream_no, uint32_t timetolive, uint32_t context);
846 
847 /* This library function assist the user with sending a message without
848  * dealing directly with the CMSG header.
849  */
850 int sctp_send(int s, const void *msg, size_t len,
851               const struct sctp_sndrcvinfo *sinfo, int flags);
852 
853 /* This library function assists the user with the advanced features
854  * of SCTP.  This is a new SCTP API described in the section 8.8 of the
855  * Sockets API Extensions for SCTP. This is implemented using the
856  * recvmsg() interface.
857  */
858 int sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from,
859 		 socklen_t *fromlen, struct sctp_sndrcvinfo *sinfo,
860 		 int *msg_flags);
861 
862 /* Return the address length for an address family. */
863 int sctp_getaddrlen(sa_family_t family);
864 
865 __END_DECLS
866 
867 #endif /* __linux_sctp_h__ */
868