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