/* ipsctp_sock.h - IPNET SCTP socket header file */ /* * Copyright (c) 2007 Wind River Systems, Inc. * * The right to copy, distribute or otherwise make use of this software * may be licensed only pursuant to the terms of an applicable Wind River * license agreement. No license to Wind River intellectual property rights * is granted herein. All rights not licensed by Wind River are reserved * by Wind River. */ /* modification history -------------------- 01a,18jul07,fei Created,base on draft-ietf-tsvwg-sctpsocket-16. */ #ifndef IPSCTP_SOCK_H #define IPSCTP_SOCK_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** * * This is the header file for ipsctp_sock.c module. */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* ancillary data types */ typedef enum Ipsctp_cmsg_t_enum { IPSCTP_INIT = 0x0001, IPSCTP_SNDRCV, IPSCTP_EXTRCV } Ipsctp_cmsg_t; typedef Ip_u32 Ipsctp_assoc_t; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * All options that support specific settings on an association by * filling in either an association id variable or a sockaddr_storage * SHOULD also support setting of the same value for the entire endpoint * (i.e. future associations). To accomplish this the following logic * is used when setting one of these options: * * a) If an address is specified via a sockaddr_storage that is included * in the structure, the address is used to lookup the association * and the settings are applied to the specific address (if * appropriate) or to the entire association. * b) If an association identification is filled in but not a * sockaddr_storage (if present), the association is found using the * association identification and the settings should be applied to * the entire association (since a specific address is not * specified). Note this also applies to options that hold an * association identification in their structure but do not have a * sockaddr_storage field. * c) If neither the sockaddr_storage or association identification is * set, i.e. the sockaddr_storage is set to all 0's (INADDR_ANY) and * the association identification is 0, the settings are a default * and to be applied to the endpoint (all future associations). * * For the one-to-many style sockets, an sctp_assoc_t structure * (association ID) is used to identify the association instance that * the operation affects. So it must be set when using this style. * * For the one-to-one style sockets and branched off one-to-many style * sockets (see Section 8.2) this association ID parameter is ignored. * * Note that socket or IP level options are set or retrieved per socket. * This means that for one-to-many style sockets, those options will be * applied to all associations belonging to the socket. And for one-to- * one style, those options will be applied to all peer addresses of the * association controlled by the socket. Applications should be very * careful in setting those options. */ enum Ipsctp_optname { IPSCTP_OPTNAME_BASE = 0, IPSCTP_RTOINFO = 1, IPSCTP_ASSOCINFO = 2, IPSCTP_DEFAULT_SEND_PARAM = 3, IPSCTP_GET_PEER_ADDR_INFO = 4, IPSCTP_PRIMARY_ADDR = 5, IPSCTP_ADAPTATION_LAYER = 6, IPSCTP_PEER_ADDR_PARAMS = 7, IPSCTP_STATUS = 8, IPSCTP_CONTEXT = 9, IPSCTP_AUTH_ACTIVE_KEY = 10, IPSCTP_AUTH_CHUNK = 11, IPSCTP_AUTH_KEY = 12, IPSCTP_AUTH_DEACTIVATE_KEY = 13, IPSCTP_AUTH_DELETE_KEY = 14, IPSCTP_PEER_AUTH_CHUNKS = 15, IPSCTP_LOCAL_AUTH_CHUNKS = 16, IPSCTP_EVENTS = 17, IPSCTP_INITMSG = 18, IPSCTP_AUTOCLOSE = 19, IPSCTP_DISABLE_FRAGMENTS = 20, IPSCTP_FRAGMENT_INTERLEAVE = 21, IPSCTP_PARTIAL_DELIVERY_POINT = 22, IPSCTP_MAXSEG = 23, IPSCTP_NODELAY = 24, IPSCTP_SET_PEER_PRIMARY_ADDR = 25, IPSCTP_I_WANT_MAPPED_V4_ADDR = 26, IPSCTP_DELAYED_SACK = 27, IPSCTP_USE_EXT_RCVINFO = 28, IPSCTP_AUTO_ASCONF = 29, IPSCTP_EXPLICIT_EOR = 30, IPSCTP_REUSE_PORT = 31, IPSCTP_GET_ASSOC_NUMBER = 32, IPSCTP_GET_ASSOC_ID_LIST = 33, IPSCTP_GET_PEER_ADDRS = 34, IPSCTP_GET_LOCAL_ADDRS = 35, IPSCTP_GET_PEER_ADDRS_SIZE = 36, IPSCTP_GET_LOCAL_ADDRS_SIZE = 37, IPSCTP_BINDX_ADD_ADDR = 38, IPSCTP_BINDX_REM_ADDR = 39, IPSCTP_GET_ADDR_LEN = 40, IPSCTP_CONNECTX = 41, IPSCTP_CONNECTX_DELAY = 42, IPSCTP_CONNECTX_COMPLETE = 43, IPSCTP_MAX_BURST = 44, IPSCTP_GET_PEELOFF = 45, IPSCTP_OPTNAME_MAX }; /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* *=========================================================================== * IPSCTP sctp init message parameters *=========================================================================== * 5.2.1. SCTP Initiation Structure (SCTP_INIT) * This cmsghdr structure provides information for initializing new SCTP * associations with sendmsg(). The SCTP_INITMSG socket option uses * this same data structure. This structure is not used for recvmsg(). * * cmsg_level cmsg_type cmsg_data[] * ------------ ------------ ---------------------- * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg */ struct Ipsctp_initmsg { Ip_u16 sinit_num_ostreams; /* the number of streams that the application wishes to be able to send to */ Ip_u16 sinit_max_instreams; /* the maximum number of inbound streams the application is prepared to support */ Ip_u16 sinit_max_attempts; /* how many attempts the SCTP endpoint should make at resending the INIT. This value overrides the system SCTP 'Max.Init.Retransmits' value. */ Ip_u16 sinit_max_init_timeo;/* the largest Time-Out or RTO value (in milliseconds) to use in attempting an INIT. Normally the 'RTO.Max'is used to limit the doubling of the RTO upon timeout. For the INIT message this value MAY override 'RTO.Max'(60 seconds).*/ }; /* *=========================================================================== * IPSCTP sinfo_flags member of structure sctp_sndrcvinfo *=========================================================================== * sinfo_flags: 16 bits (unsigned integer) * * This field may contain any of the following flags and is composed of * a bitwise OR of these values. * * recvmsg() flags: * SCTP_UNORDERED - This flag is present when the message was sent non- * ordered. * * * sendmsg() flags: * SCTP_UNORDERED - This flag requests the un-ordered delivery of the * message. If this flag is clear the datagram is considered an * ordered send. * * SCTP_ADDR_OVER - This flag, in the one-to-many style, requests the * SCTP stack to override the primary destination address with the * address found with the sendto/sendmsg call. * * SCTP_ABORT - Setting this flag causes the specified association to * abort by sending an ABORT message to the peer (one-to-many style * only). The ABORT chunk will contain an error cause 'User * Initiated Abort' with cause code 12. The cause specific * information of this error cause is provided in msg_iov. * * SCTP_EOF - Setting this flag invokes the SCTP graceful shutdown * procedures on the specified association. Graceful shutdown * assures that all data enqueued by both endpoints is successfully * transmitted before closing the association (one-to-many style * only). * * SCTP_SENDALL - This flag, if set, will cause a one-to-many model * socket to send the message to all associations that are currently * established on this socket. For the one-to-one socket, this flag * has no effect. */ #define IPSCTP_UNORDERED 0x0001 #define IPSCTP_ADDR_OVER 0x0002 #define IPSCTP_ABORT 0x0004 #define IPSCTP_EOF 0x0008 #define IPSCTP_SENDALL 0x0010 #define IPSCTP_EOR 0x0020 /* *=========================================================================== * IPSCTP sctp sndrcvinfo parameters *=========================================================================== * 5.2.2. SCTP Header Information Structure (SCTP_SNDRCV) * * This cmsghdr structure specifies SCTP options for sendmsg() and * describes SCTP header information about a received message through * recvmsg(). * * cmsg_level cmsg_type cmsg_data[] * ------------ ------------ ---------------------- * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo */ struct Ipsctp_sndrcvinfo { Ip_u16 sinfo_stream; /* number of streams */ Ip_u16 sinfo_ssn; /* stream sequence number */ Ip_u16 sinfo_flags; /* flags for sendmsg() and recvmsg() */ Ip_u16 sinfo_pr_policy; /* */ Ip_u32 sinfo_ppid; /* payload protocol id */ Ip_u32 sinfo_context; /* context data for sendmsg() only */ Ip_u32 sinfo_pr_value; /* */ Ip_u32 sinfo_tsn; /* transmission sequence number */ Ip_u32 sinfo_cumtsn; /* cumulative transmission sequence number */ Ipsctp_assoc_t sinfo_assoc_id; /* association id */ }; typedef struct Ipsctp_sctp_sndrcvinfo_struct { Ip_u16 sinfo_stream; /* number of streams */ Ip_u16 sinfo_ssn; /* stream sequence number */ Ip_u16 sinfo_flags; /* flags for sendmsg() and recvmsg() */ Ip_u16 sinfo_pr_policy; /* */ Ip_u32 sinfo_ppid; /* payload protocol id */ Ip_u32 sinfo_context; /* context data for sendmsg() only */ Ip_u32 sinfo_pr_value; /* */ Ip_u32 sinfo_tsn; /* transmission sequence number */ Ip_u32 sinfo_cumtsn; /* cumulative transmission sequence number */ } Ipsctp_sctp_sndrcvinfo; /* *=========================================================================== * IPSCTP serinfo_next_flags member of structure sctp_extrcvinfo *=========================================================================== * serinfo_next_flags: 16 bit (unsigned integer) * * This bitmask will hold one or more of the following values: * SCTP_NEXT_MSG_AVAIL - This bit, when set to 1, indicates that next * message information is available i.e.: next_stream, next_asocid, * next_length and next_ppid fields all have valid values. If this * bit is set to 0, then these fields are not valid and should be * ignored. * * SCTP_NEXT_MSG_ISCOMPLETE - This bit, when set, indicates that the * next message is completely in the receive buffer. The next_length * field thus contains the entire message size. If this flag is set * to 0, then the next_length field only contains part of the message * size since the message is still being received (it is being * partially delivered). * * SCTP_NEXT_MSG_IS_UNORDERED - This bit, when set, indicates that the * next message to be received was sent by the peer as unordered. If * this bit is not set (i.e the bit is 0) the next message to be read * is an ordered message in the stream specified. * * SCTP_NEXT_MSG_IS_NOTIFICATION - This bit, when set, indicates that * the next message to be received is not a message from the peer, * but instead is a MSG_NOTIFICATION from the local SCTP stack. */ #define IPSCTP_NEXT_MSG_AVAIL 0x0001 #define IPSCTP_NEXT_MSG_ISCOMPLETE 0x0002 #define IPSCTP_NEXT_MSG_IS_UNORDERED 0x0004 #define IPSCTP_NEXT_MSG_IS_NOTIFICATION 0x0008 /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.2.3. Extended SCTP Header Information Structure (SCTP_EXTRCV) * * This cmsghdr structure specifies SCTP options for SCTP header * information about a received message via recvmsg(). Note that this * structure is an extended version of SCTP_SNDRCV (see Section 5.2.2) * and will only be received if the user has set the socket option * SCTP_USE_EXT_RCVINFO to true in addition to any event subscription * needed to receive ancillary data. Note that next message data is not * valid unless the current message is completely read, i.e. the MSG_EOR * is set, in other words if you have more data to read from the current * message then no next message information will be available. * * cmsg_level cmsg_type cmsg_data[] * ------------ ------------ ---------------------- * IPPROTO_SCTP SCTP_EXTRCV struct sctp_extrcvinfo */ struct Ipsctp_extrcvinfo { struct Ipsctp_sndrcvinfo serinfo_sinfo; Ip_u16 serinfo_next_flags; /* next message bitmask flags */ Ip_u16 serinfo_next_stream; /* next stream numbers */ Ip_u32 serinfo_next_aid; /* next association id to receive */ Ip_u32 serinfo_next_length; /* length of next message */ Ip_u32 serinfo_next_ppid; /* next message payload protocol id */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.1. SCTP_ASSOC_CHANGE * * Communication notifications inform the ULP that an SCTP association * has either begun or ended. The identifier for a new association is * provided by this notification. */ struct Ipsctp_assoc_change { Ip_u16 sac_type; /* SCTP_ASSOC_CHANGE */ Ip_u16 sac_flags; /* unused */ Ip_u32 sac_length; /* total length, including sn_header */ Ip_u16 sac_state; /* state of the event */ Ip_u16 sac_error; /* error condition */ Ip_u16 sac_outbound_streams; /* max outbound streams allowed */ Ip_u16 sac_inbound_streams; /* max inbound streams allowed */ Ipsctp_assoc_t sac_assoc_id; /* association id */ Ip_u8 sac_info[0]; /* variable chunk information */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * sac_state: 16 bits (signed integer) * * This field holds one of a number of values that communicate the event * that happened to the association. They include: * * Event Name Description * * ---------------- --------------- * * SCTP_COMM_UP - A new association is now ready and data may be * exchanged with this peer. * SCTP_COMM_LOST - The association has failed. The association is now * in the closed state. If SEND FAILED notifications are turned on, * a SCTP_COMM_LOST is followed by a series of SCTP_SEND_FAILED * events, one for each outstanding message. * SCTP_RESTART - SCTP has detected that the peer has restarted. * SCTP_SHUTDOWN_COMP - The association has gracefully closed. * SCTP_CANT_STR_ASSOC - The association failed to setup. If non * blocking mode is set and data was sent (in the udp mode), a * SCTP_CANT_STR_ASSOC is followed by a series of SCTP_SEND_FAILED * events, one for each outstanding message. */ enum Ipsctp_sac_state { IPSCTP_COMM_UP = 1, IPSCTP_COMM_LOST = 2, IPSCTP_RESTART = 3, IPSCTP_SHUTDOWN_COMP = 4, IPSCTP_CANT_STR_ASSOC = 5, IPSCTP_SAC_STATE_MAX = 6 }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.2. SCTP_PEER_ADDR_CHANGE * * When a destination address on a multi-homed peer encounters a change * an interface details event is sent. */ struct Ipsctp_paddr_change { Ip_u16 spc_type; /* SCTP_PEER_ADDR_CHANGE */ Ip_u16 spc_flags; /* unused */ Ip_u32 spc_length; /* total length, including sn_header */ struct Ip_sockaddr_storage spc_aaddr; /* affected remove peer addr */ Ip_u32 spc_state; /* state of the event */ Ip_u32 spc_error; /* error condition */ Ipsctp_assoc_t spc_assoc_id; /* association id */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * spc_state: 32 bits (signed integer) * * This field holds one of a number of values that communicate the event * that happened to the address. They include: * * Event Name Description * * ---------------- --------------- * * SCTP_ADDR_AVAILABLE - This address is now reachable. * SCTP_ADDR_UNREACHABLE - The address specified can no longer be * reached. Any data sent to this address is rerouted to an * alternate until this address becomes reachable. * SCTP_ADDR_REMOVED - The address is no longer part of the * association. * SCTP_ADDR_ADDED - The address is now part of the association. * SCTP_ADDR_MADE_PRIM - This address has now been made to be the * primary destination address. * SCTP_ADDR_CONFIRMED - This address has now been confirmed as a valid * address. */ enum Ipsctp_spc_state { IPSCTP_ADDR_AVAILABLE = 1, IPSCTP_ADDR_UNREACHABLE = 2, IPSCTP_ADDR_REMOVED = 3, IPSCTP_ADDR_ADDED = 4, IPSCTP_ADDR_MADE_PRIM = 5, IPSCTP_ADDR_CONFIRMED = 6, IPSCTP_SPC_STATE_MAX = 7 }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.3. SCTP_REMOTE_ERROR * * A remote peer may send an Operational Error message to its peer. * This message indicates a variety of error conditions on an * association. The entire ERROR chunk as it appears on the wire is * included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP * specification [RFC4960] and any extensions for a list of possible * error formats. */ struct Ipsctp_remote_error { Ip_u16 sre_type; /* SCTP_REMOTE_ERROR */ Ip_u16 sre_flags; /* unused */ Ip_u32 sre_length; /* total length, including sn_header */ Ip_u16 sre_error; /* error condition */ Ipsctp_assoc_t sre_assoc_id; /* association id */ Ip_u8 sre_data[0]; /* ERROR chunk */ }; /* *=========================================================================== * IPSCTP sctp sctp_send_failed *=========================================================================== * ssf_flags: 16 bits (unsigned integer) * * The flag value will take one of the following values: * * SCTP_DATA_UNSENT - Indicates that the data was never put on the * wire. * SCTP_DATA_SENT - Indicates that the data was put on the wire. Note * that this does not necessarily mean that the data was (or was not) * successfully delivered. */ #define IPSCTP_DATA_UNSENT 0x0001 #define IPSCTP_DATA_SENT 0x0002 /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.4. SCTP_SEND_FAILED * * If SCTP cannot deliver a message it may return the message as a * notification. */ struct Ipsctp_send_failed { Ip_u16 ssf_type; /* SCTP_SEND_FAILED */ Ip_u16 ssf_flags; /* flags */ Ip_u32 ssf_length; /* total length, including sn_header */ Ip_u32 ssf_error; /* error condition */ struct Ipsctp_sndrcvinfo ssf_info; /* undelivered msg send info */ Ipsctp_assoc_t ssf_assoc_id; /* association id */ Ip_u8 ssf_data[0]; /* the original undelivered message */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.5. SCTP_SHUTDOWN_EVENT * When a peer sends a SHUTDOWN, SCTP delivers this notification to * inform the application that it should cease sending data. */ struct Ipsctp_shutdown_event { Ip_u16 sse_type; /* SCTP_SHUTDOWN_EVENT */ Ip_u16 sse_flags; /* unused */ Ip_u32 sse_length; /* total length, including sn_header */ Ipsctp_assoc_t sse_assoc_id; /* association id */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.6. SCTP_ADAPTATION_INDICATION * * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application that of the * peers requested adaptation layer. */ struct Ipsctp_adaptation_event { Ip_u16 sai_type; /* SCTP_ADAPTATION_INDICATION */ Ip_u16 sai_flags; /* unused */ Ip_u32 sai_length; /* total length, including sn_header */ Ip_u32 sai_adaptation_ind; /* bit array for adaptation parameter */ Ipsctp_assoc_t sai_assoc_id; /* association id */ }; /* *=========================================================================== * IPSCTP sctp sctp_pdapi_event *=========================================================================== * pdapi_indication: 32 bits (unsigned integer) * * This field holds the indication being sent to the application * possible values include: * * SCTP_PARTIAL_DELIVERY_ABORTED */ #define IPSCTP_PARTIAL_DELIVERY_ABORTED 0x0001 /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.7. SCTP_PARTIAL_DELIVERY_EVENT * * When a receiver is engaged in a partial delivery of a message this * notification will be used to indicate various events. */ struct Ipsctp_pdapi_event { Ip_u16 pdapi_type; /* SCTP_PARTIAL_DELIVERY_EVENT */ Ip_u16 pdapi_flags; /* unused */ Ip_u32 pdapi_length; /* total length, including sn_header */ Ip_u32 pdapi_indication; /* indication values */ Ip_u32 pdapi_stream; /* partially delivered stream */ Ip_u32 pdapi_seq; /* stream sequence number */ Ipsctp_assoc_t pdapi_assoc_id; /* association id */ }; /* *=========================================================================== * IPSCTP sctp sctp_authkey_event *=========================================================================== * auth_indication: 32 bits (unsigned integer) * * This field hold the error or indication being reported. The * following values are currently defined: * SCTP_AUTH_NEWKEY - this report indicates that a new key has been * made active (used for the first time by the peer) and is now the * active key. The auth_keynumber field holds the user specified key * number. */ #define IPSCTP_AUTH_NEWKEY 0x0001 /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.8. SCTP_AUTHENTICATION_EVENT * * When a receiver is using authentication this message will provide * notifications regarding new keys being made active as well as errors. */ struct Ipsctp_authkey_event { Ip_u16 auth_type; /* SCTP_AUTHENTICATION_EVENT */ Ip_u16 auth_flags; /* unused */ Ip_u32 auth_length; /* total length, including sn_header */ Ip_u16 auth_keynumber; /* keynumber for the effected key */ Ip_u16 auth_altkeynumber; /* alternate keynumber */ Ip_u32 auth_indication; /* error or indication being reported */ Ipsctp_assoc_t auth_assoc_id; /* association id */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1.9. SCTP_AUTHENTICATION_EVENT * * When an association is set up and the peer does not support SCTP-AUTH * this notification is provided by the kernel to the user. */ struct Ipsctp_no_auth_event { Ip_u16 no_auth_type; Ip_u16 no_auth_flags; Ip_u32 no_auth_length; Ipsctp_assoc_t no_auth_assoc_id; }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 5.3.1. SCTP Notification Structure * * The notification structure is defined as the union of all * notification types. */ union Ipsctp_notification { struct { Ip_u16 sn_type; /* Notification type. */ Ip_u16 sn_flags; /* notification-specific flags */ Ip_u32 sn_length; /* notification length, including sn_type, sn_flags, and sn_length fields */ } sn_header; struct Ipsctp_assoc_change sn_assoc_change; struct Ipsctp_paddr_change sn_paddr_change; struct Ipsctp_remote_error sn_remote_error; struct Ipsctp_send_failed sn_send_failed; struct Ipsctp_shutdown_event sn_shutdown_event; struct Ipsctp_adaptation_event sn_adaptation_event; struct Ipsctp_pdapi_event sn_pdapi_event; struct Ipsctp_authkey_event sn_auth_event; struct Ipsctp_no_auth_event sn_no_auth_event; }; /* *=========================================================================== * IPSCTP sctp sctp_notification *=========================================================================== * sn_type: 16 bits (unsigned integer) * * The following list describes the SCTP notification and event types * for the field sn_type. * * SCTP_ASSOC_CHANGE: This tag indicates that an association has either * been opened or closed. Refer to Section 5.3.1.1 for details. * SCTP_PEER_ADDR_CHANGE: This tag indicates that an address that is * part of an existing association has experienced a change of state * (e.g. a failure or return to service of the reachability of a * endpoint via a specific transport address). Please see * Section 5.3.1.2 for data structure details. * SCTP_REMOTE_ERROR: The attached error message is an Operational * Error received from the remote peer. It includes the complete TLV * sent by the remote endpoint. See Section 5.3.1.3 for the detailed * format. * SCTP_SEND_FAILED: The attached datagram could not be sent to the * remote endpoint. This structure includes the original * SCTP_SNDRCVINFO that was used in sending this message i.e. this * structure uses the sctp_sndrecvinfo per Section 5.3.1.4. * SCTP_SHUTDOWN_EVENT: The peer has sent a SHUTDOWN. No further data * should be sent on this socket. * SCTP_ADAPTATION_INDICATION: This notification holds the peers * indicated adaptation layer. Please see Section 5.3.1.6. * SCTP_PARTIAL_DELIVERY_EVENT: This notification is used to tell a * receiver that the partial delivery has been aborted. This may * indicate the association is about to be aborted. Please see * Section 5.3.1.7 * SCTP_AUTHENTICATION_EVENT: This notification is used to tell a * receiver that either an error occurred on authentication, or a new * key was made active. Section 5.3.1.8 * SCTP_NO_AUTHENTICATION_EVENT: This notification is used to tell a * receiver that the peer does not support SCTP-AUTH. * Section 5.3.1.9 * * All standard values for sn_type are greater than 2^15. Values from * 2^15 and down are reserved. */ enum Ipsctp_sn_type { IPSCTP_SN_TYPE_MIN = (1<<15), IPSCTP_ASSOC_CHANGE = (1<<15) + 1, IPSCTP_PEER_ADDR_CHANGE = (1<<15) + 2, IPSCTP_REMOTE_ERROR = (1<<15) + 3, IPSCTP_SEND_FAILED = (1<<15) + 4, IPSCTP_SHUTDOWN_EVENT = (1<<15) + 5, IPSCTP_ADAPTATION_INDICATION = (1<<15) + 6, IPSCTP_PARTIAL_DELIVERY_EVENT = (1<<15) + 7, IPSCTP_AUTHENTICATION_EVENT = (1<<15) + 8, IPSCTP_NO_AUTHENTICATION_EVENT = (1<<15) + 9 }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.1. Retransmission Timeout Parameters (SCTP_RTOINFO) * * The protocol parameters used to initialize and bound retransmission * timeout (RTO) are tunable. See [RFC4960] for more information on how * these parameters are used in RTO calculation. */ struct Ipsctp_rtoinfo { Ipsctp_assoc_t srto_assoc_id; /* association id */ Ip_u32 srto_initial; /* initial RTO value */ Ip_u32 srto_max; /* max RTO */ Ip_u32 srto_min; /* min RTO */ }; typedef struct Ipsctp_rtoinfo_struct { Ip_u32 srto_initial; /* initial RTO value */ Ip_u32 srto_max; /* max RTO */ Ip_u32 srto_min; /* min RTO */ } Ipsctp_sctp_rtoinfo; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.2. Association Parameters (SCTP_ASSOCINFO) * * This option is used to both examine and set various association and * endpoint parameters. * * Note: When configuring the SCTP endpoint, the user should avoid * having the value of 'Association.Max.Retrans' larger than the * summation of the 'Path.Max.Retrans' of all the destination addresses * for the remote endpoint. Otherwise, all the destination addresses * may become inactive while the endpoint still considers the peer * endpoint reachable. */ struct Ipsctp_assocparams { Ipsctp_assoc_t sasoc_assoc_id; /* association id */ Ip_u16 sasoc_asocmaxrxt; /* max retransmission attempts */ Ip_u16 sasoc_number_peer_destinations; /* num of peer's dest addr */ Ip_u32 sasoc_peer_rwnd; /* current peers rwnd */ Ip_u32 sasoc_local_rwnd; /* last reported rwnd */ Ip_u32 sasoc_cookie_life; /* cookie life value */ }; typedef struct Ipsctp_sctp_assocparams_struct { Ip_u16 sasoc_asocmaxrxt; /* max retransmission attempts */ Ip_u32 sasoc_cookie_life; /* cookie life value */ } Ipsctp_sctp_assocparams; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.9. Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR) * * Requests that the peer mark the enclosed address as the association * primary. The enclosed address must be one of the association's * locally bound addresses. */ struct Ipsctp_setpeerprim { Ipsctp_assoc_t sspp_assoc_id; /* association id */ struct Ip_sockaddr_storage sspp_addr; /* peer address to set as primary */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.10. Set Primary Address (SCTP_PRIMARY_ADDR) * * Requests that the local SCTP stack use the enclosed peer address as * the association primary. The enclosed address must be one of the * association peer's addresses. */ struct Ipsctp_setprim { Ipsctp_assoc_t ssp_assoc_id; /* association id */ struct Ip_sockaddr_storage ssp_addr; /* address to set as primary */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.11. Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER) * * Requests that the local endpoint set the specified Adaptation Layer * Indication parameter for all future INIT and INIT-ACK exchanges. */ struct Ipsctp_setadaptation { Ip_u32 ssb_adaptation_ind; /* adaptation layer indicator */ }; /* *=========================================================================== * IPSCTP sctp sctp_paddrparams *=========================================================================== * spp_flags - These flags are used to control various features on an * association. The flag field is a bit mask which may contain zero * or more of the following options: * * SPP_HB_ENABLE - Enable heartbeats on the specified address. Note * that if the address field is empty all addresses for the * association have heartbeats enabled upon them. * SPP_HB_DISABLE - Disable heartbeats on the specified address. * Note that if the address field is empty all addresses for the * association will have their heartbeats disabled. Note also * that SPP_HB_ENABLE and SPP_HB_DISABLE are mutually exclusive, * only one of these two should be specified. Enabling both * fields will have undetermined results. * SPP_HB_DEMAND - Request a user initiated heartbeat to be made * immediately. * SPP_HB_TIME_IS_ZERO - Specify's that the time for heartbeat delay * is to be set to the value of 0 milliseconds. * SPP_PMTUD_ENABLE - This field will enable PMTU discovery upon the * specified address. Note that if the address field is empty * then all addresses on the association are effected. * SPP_PMTUD_DISABLE - This field will disable PMTU discovery upon * the specified address. Note that if the address field is empty * then all addresses on the association are effected. Not also * that SPP_PMTUD_ENABLE and SPP_PMTUD_DISABLE are mutually * exclusive. Enabling both will have undetermined results. * SPP_IPV6_FLOWLABEL - Setting this flag enables setting of the * IPV6 flowlabel value associated with either the association or * the specific address. If the address field is filled in, then * the specific destination address has this value set upon it. * If the association is specified, but not the address, then the * flowlabel value is set for any future destination addresses * that may be added. The value is obtained in the * spp_ipv6_flowlabel field. * Upon retrieval, this flag will be set to indicate that the * spp_ipv6_flowlabel field has a valid value returned. If a * specific destination addresses is set (in the spp_address * field) when called then the value returned is that of the * address. If just an association is specified (and no address) * then the association default flowlabel is returned. If neither * an association nor an destination is specified, then the * sockets default flowlabel is returned. For non IPv6 sockets, * then this flag will be left cleared. * SPP_IPV4_TOS - Setting this flag enables setting of the IPV4 tos * value associated with either the association or specific * address. If the address field is filled in, then the specific * destination address has this value set upon it. If the * association is specified, but not the address, then the tos * value is set for any future destination addresses that may be * added. The value is obtained in the spp_ipv4_tos field. * * Upon retrieval, this flag will be set to indicate that the * spp_ipv4_tos field has a valid value returned. If a specific * destination addresses is set when called (in the spp_address * field) then that specific destination addresses tos value is * returned. If just an association is specified then the * association default tos is returned. If neither an association * nor an destination is specified, then the sockets default tos * is returned. For non IPv4 sockets, then this flag will be left * cleared. */ #define IPSPP_HB_ENABLE 0x00000001 #define IPSPP_HB_DISABLE 0x00000002 #define IPSPP_HB_DEMAND 0x00000004 #define IPSPP_PMTUD_ENABLE 0x00000008 #define IPSPP_PMTUD_DISABLE 0x00000010 #define IPSPP_HB_TIME_IS_ZERO 0x00000020 #define IPSPP_IPV6_FLOWLABEL 0x00000040 #define IPSPP_IPV4_TOS 0x00000080 #define IPSPP_HB (IPSPP_HB_ENABLE | IPSPP_HB_DISABLE) #define IPSPP_PMTUD (IPSPP_PMTUD_ENABLE | IPSPP_PMTUD_DISABLE) /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.13. Peer Address Parameters (SCTP_PEER_ADDR_PARAMS) * * Applications can enable or disable heartbeats for any peer address of * an association, modify an address's heartbeat interval, force a * heartbeat to be sent immediately, and adjust the address's maximum * number of retransmissions sent before an address is considered * unreachable. */ struct Ipsctp_paddrparams { Ipsctp_assoc_t spp_assoc_id; /* association id */ struct Ip_sockaddr_storage spp_address; /* specifies address of interest */ Ip_u32 spp_hbinterval; /* heartbeat interval */ Ip_u16 spp_pathmaxrxt; /* max retransmissions */ Ip_u32 spp_pathmtu; /* address path mtu */ Ip_u32 spp_flags; /* control flags */ Ip_u32 spp_ipv6_flowlabel; /* IPv6 flow label */ Ip_u8 spp_ipv4_tos; /* IPv4 TOS */ }; typedef struct Ipsctp_sctp_paddrparams_struct { Ip_u32 spp_hbinterval; /* heartbeat interval */ Ip_u16 spp_pathmaxrxt; /* max retransmissions */ Ip_u32 spp_pathmtu; /* address path mtu */ Ip_u32 spp_flags; /* control flags */ Ip_u32 spp_ipv6_flowlabel; /* IPv6 flow label */ Ip_u8 spp_ipv4_tos; /* IPv4 TOS */ } Ipsctp_sctp_paddrparams; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.17. Get or set the maximum fragmentation size (SCTP_MAXSEG) * * This option will get or set the maximum size to put in any outgoing * SCTP DATA chunk. If a message is larger than this size it will be * fragmented by SCTP into the specified size. Note that the underlying * SCTP implementation may fragment into smaller sized chunks when the * PMTU of the underlying association is smaller than the value set by * the user. The default value for this option is '0' which indicates * the user is NOT limiting fragmentation and only the PMTU will effect * SCTP's choice of DATA chunk size. Note also that values set larger * than the maximum size of an IP datagram will effectively let SCTP * control fragmentation (i.e. the same as setting this option to 0). * * 7.1.28. Set or Get the maximum burst (SCTP_MAX_BURST) * * This option will allow a user to change the maximum burst of packets * that can be emitted by this association. Note that the default value * is 4, and some implementations may restrict this setting so that it * can only be lowered. * * 7.1.29. Set or Get the default context (SCTP_CONTEXT) * * The context field in the sctp_sndrcvinfo structure is normally only * used when a failed message is retrieved holding the value that was * sent down on the actual send call. This option allows the setting of * a default context on an association basis that will be received on * reading messages from the peer. This is especially helpful in the * one-2-many model for an application to keep some reference to an * internal state machine that is processing messages on the * association. Note that the setting of this value only effects * received messages from the peer and does not effect the value that is * saved with outbound messages. */ struct Ipsctp_assoc_value { Ipsctp_assoc_t assoc_id; /* association id */ Ip_u32 assoc_value; /* maximum size in bytes */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.18. Add a chunk that must be authenticated (SCTP_AUTH_CHUNK) * * This set option adds a chunk type that the user is requesting to be * received only in an authenticated way. Changes to the list of chunks * will only effect future associations on the socket. */ struct Ipsctp_authchunk { Ip_u8 sauth_chunk; /* chunk type to be authenticated */ }; /* *=========================================================================== * IPSCTP sctp sctp_hmacalgo *=========================================================================== * shmac_idents - This parameter contains an array of HMAC Identifiers * that the local endpoint is requesting the peer to use, in priority * order. The following identifiers are valid: * * 1) SCTP_AUTH_HMAC_ID_SHA1 * 2) SCTP_AUTH_HMAC_ID_SHA256 (optional) * 3) SCTP_AUTH_HMAC_ID_SHA224 (optional) * 4) SCTP_AUTH_HMAC_ID_SHA384 (optional) * 4) SCTP_AUTH_HMAC_ID_SHA512 (optional) */ #define IPSCTP_AUTH_HMAC_ID_SHA1 0x0001 #define IPSCTP_AUTH_HMAC_ID_SHA256 0x0002 /* optional */ #define IPSCTP_AUTH_HMAC_ID_SHA224 0x0003 /* optional */ #define IPSCTP_AUTH_HMAC_ID_SHA384 0x0004 /* optional */ #define IPSCTP_AUTH_HMAC_ID_SHA512 0x0005 /* optional */ /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.19. Get or set the list of supported HMAC Identifiers(SCTP_HMAC_IDENT) * * This option gets or sets the list of HMAC algorithms that the local * endpoint requires the peer to use. */ struct Ipsctp_hmacalgo { Ip_u32 shmac_number_of_idents; /* number of HMAC Identifiers */ Ip_u16 shmac_idents[0]; /* an array of HMAC Identifiers */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.20. Set a shared key (SCTP_AUTH_KEY) * * This option will set a shared secret key which is used to build an * association shared key. */ struct Ipsctp_authkey { Ipsctp_assoc_t sca_assoc_id; /* association id */ Ip_u16 sca_keynumber; /* shared key identifier */ Ip_u16 sca_keylength; /* shared key length */ Ip_u8 sca_key[0]; /* array of bytes for shared secret key */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.21. Get or set the active shared key (SCTP_AUTH_ACTIVE_KEY) * * This option will get or set the active shared key to be used to build * the association shared key. * * 7.1.22. Delete a shared key (SCTP_AUTH_DELETE_KEY) * * This set option will delete a shared secret key from use. */ struct Ipsctp_authkeyid { Ipsctp_assoc_t scact_assoc_id; /* association id */ Ip_u16 scact_keynumber; /* active shared key identifier */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK) * * This option will effect the way delayed acks are performed. This * option allows you to get or set the delayed ack time, in * milliseconds. It also allows changing the delayed ack frequency. * Changing the frequency to 1 disables the delayed sack algorithm. If * the assoc_id is 0, then this sets or gets the endpoints default * values. If the assoc_id field is non-zero, then the set or get * effects the specified association for the one to many model (the * assoc_id field is ignored by the one to one model). Note that if * sack_delay or sack_freq are 0 when setting this option, then the * current values will remain unchanged. */ struct Ipsctp_sack_info { Ipsctp_assoc_t sack_assoc_id; /* association id */ Ip_u32 sack_delay; /* delayed ACK timer in milliseconds */ Ip_u32 sack_freq; /* number of packets to be received */ }; typedef struct Ipsctp_sctp_sack_info_struct { Ip_u32 sack_delay; /* delayed ACK timer in milliseconds */ Ip_u32 sack_freq; /* number of packets to be received */ } Ipsctp_sctp_sack_info; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.2.2. Peer Address Information (SCTP_GET_PEER_ADDR_INFO) * * Applications can retrieve information about a specific peer address * of an association, including its reachability state, congestion * window, and retransmission timer values. This information is read- * only. The following structure is used to access this information: */ struct Ipsctp_paddrinfo { Ipsctp_assoc_t spinfo_assoc_id; /* association id */ struct Ip_sockaddr_storage spinfo_address; /* peer address of interest */ Ip_s32 spinfo_state; /* the peer addresses's state */ Ip_u32 spinfo_cwnd; /* current congestion window */ Ip_u32 spinfo_srtt; /* current smoothed round-trip time in ms */ Ip_u32 spinfo_rto; /* current retransmission timeout in ms */ Ip_u32 spinfo_mtu; /* current P-MTU of this address */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.2.1. Association Status (SCTP_STATUS) * * Applications can retrieve current status information about an * association, including association state, peer receiver window size, * number of unacked data chunks, and number of data chunks pending * receipt. This information is read-only. The following structure is * used to access this information: */ struct Ipsctp_status { Ipsctp_assoc_t sstat_assoc_id; /* association id */ Ip_s32 sstat_state; /* the association's current state */ Ip_u32 sstat_rwnd; /* current receiver window size */ Ip_u16 sstat_unackdata; /* number of unacked data chunks */ Ip_u16 sstat_penddata; /* number of data chunks pending receipt */ Ip_u16 sstat_instrms; /* number of inbound streams */ Ip_u16 sstat_outstrms; /* number of endpoint outbound streams */ Ip_u32 sstat_fragmentation_point; /* SCTP fragmentation point */ struct Ipsctp_paddrinfo sstat_primary; /* current primary peer address */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.2.3. Get the list of chunks the peer requires to be authenticated * (SCTP_PEER_AUTH_CHUNKS) * * This option gets a list of chunks for a specified association that * the peer requires to be received authenticated only. * * 7.2.4. Get the list of chunks the local endpoint requires to be * authenticated (SCTP_LOCAL_AUTH_CHUNKS) * * This option gets a list of chunks for a specified association that * the local endpoint requires to be received authenticated only. */ struct Ipsctp_authchunks { Ipsctp_assoc_t gauth_assoc_id; /* association id */ Ip_u32 gauth_number_of_chunks; /* */ Ip_u8 gauth_chunks[0]; /* array of chunks to be authenticated */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.2.6. Get the current identifiers of associations * (SCTP_GET_ASSOC_ID_LIST) * * This option gets the current list of SCTP association identifiers of * the SCTP associations handled by a one-to-many style socket. The * option value has the structure */ struct Ipsctp_assoc_ids { Ip_u32 gaids_number_of_ids; Ipsctp_assoc_t gaids_assoc_id[0]; /* buffer to hold all association ids */ }; /* *=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 7.3. Ancillary Data and Notification Interest Options * * Applications can receive per-message ancillary information and * notifications of certain SCTP events with recvmsg(). * * The following optional information is available to the application: * * 1. SCTP_SNDRCV (sctp_data_io_event): Per-message information (i.e. * stream number, TSN, SSN, etc. described in Section 5.2.2) * 2. SCTP_ASSOC_CHANGE (sctp_association_event): (described in * Section 5.3.1.1) * 3. SCTP_PEER_ADDR_CHANGE (sctp_address_event): (described in * Section 5.3.1.2) * 4. SCTP_SEND_FAILED (sctp_send_failure_event): (described in * Section 5.3.1.4) * 5. SCTP_REMOTE_ERROR (sctp_peer_error_event): (described in * Section 5.3.1.3) * 6. SCTP_SHUTDOWN_EVENT (sctp_shtudown_event): (described in * Section 5.3.1.5) * 7. SCTP_PARTIAL_DELIVERY_EVENT (sctp_partial_delivery_event): * (described in Section 5.3.1.7) * 8. SCTP_ADAPTATION_INDICATION (sctp_adaptation_layer_event): * (described in Section 5.3.1.6) * 9. SCTP_AUTHENTICATION_INDICATION (sctp_authentication_event): * (described in Section 5.3.1.8) * * To receive any ancillary data or notifications, first the application * registers it's interest by calling the SCTP_EVENTS setsockopt() with * the following structure. */ struct Ipsctp_event_subscribe { Ip_u8 Ipsctp_data_io_event; /* 1 for receive SCTP_SNDRCV information on a per message basis. */ Ip_u8 Ipsctp_association_event; /* 1 for receive association event notifications. */ Ip_u8 Ipsctp_address_event; /* 1 for receive address event notifications. */ Ip_u8 Ipsctp_send_failure_event; /* 1 for receive send failure event notifications. */ Ip_u8 Ipsctp_peer_error_event; /* 1 for receive peer error event notifications. */ Ip_u8 Ipsctp_shutdown_event; /* 1 for receive shutdown event notifications. */ Ip_u8 Ipsctp_partial_delivery_event; /* 1 for receive partial delivery notifications. */ Ip_u8 Ipsctp_adaptation_layer_event; /* 1 for receive adaption layer notifications. */ Ip_u8 Ipsctp_authentication_event; /* 1 for receive authentication layer notifications. */ }; /* for get local and peer address */ struct Ipsctp_getaddrs { Ipsctp_assoc_t sget_assoc_id; struct Ip_sockaddr sget_addrs[1]; }; struct Ipsctp_peeloff { Ipsctp_assoc_t assoc_id; /* association id */ Ip_fd fd; /* socket descriptor */ void *ret; }; #define IPSOL_SCTP 132 /*=========================================================================== * IPSCTP sctp parameters *=========================================================================== * 8.1.20. Get or Set Fragmented Interleave (SCTP_FRAGMENT_INTERLEAVE) * * Fragmented interleave controls how the presentation of messages * occurs for the message receiver. There are three levels of fragment * interleave defined. Two of the levels effect the one-to-one model, * while the one-to-many model is effected by all three levels. * * This option takes an integer value. It can be set to a value of 0, 1 * or 2. Attempting to set this level to other values will return an * error. * * Setting the three levels provides the following receiver * interactions: * * level 0: Prevents the interleaving of any messages. This means that * when a partial delivery begins, no other messages will be received * except the message being partially delivered. If another message * arrives on a different stream (or association) that could be * delivered, it will be blocked waiting for the user to read all of * the partially delivered message. * level 1: Allows interleaving of messages that are from different * associations. For the one-to-one model, level 0 and level 1 thus * have the same meaning since a one-to-one socket always receives * messages from the same association. Note that setting the one-to- * many model to this level may cause multiple partial delivers from * different associations but for any given association, only one * message will be delivered until all parts of a message have been * delivered. This means that one large message, being read with an * association identification of "X", will block other messages from * association "X" from being delivered. * level 2: Allows complete interleaving of messages. This level * requires that the sender carefully observe not only the peer * association identification (or address) but also must pay careful * attention to the stream number. With this option enabled a * partially delivered message may begin being delivered for * association "X" stream "Y" and the next subsequent receive may * return a message from association "X" stream "Z". Note that no * other messages would be delivered for association "X" stream "Y" * until all of stream "Y"'s partially delivered message was read. * Note that this option also effects the one-to-one model. Also * note that for the one-to-many model not only may another streams * message from the same association be delivered from the next * receive, some other associations message may be delivered upon the * next receive. * * An implementation should default the one-to-many model to level 1. * The reason for this is that otherwise it is possible that a peer * could begin sending a partial message and thus block all other peers * from sending data. However a setting of level 2 requires the * application to not only be aware of the association (via the * association id or peers address) but also the stream number. The * stream number is NOT present unless the user has subscribed to the * sctp_data_io_events (see Section 8.4). This is also why we recommend * that the one-to-one model be defaulted to level 0 (level 1 for the * one-to-one model has no effect). Note that an implementation should * return an error if a application attempts to set the level to 2 and * has NOT subscribed to the sctp_data_io_events. */ #define IPSCTP_FRAG_LEVEL_0 0x0000 #define IPSCTP_FRAG_LEVEL_1 0x0001 #define IPSCTP_FRAG_LEVEL_2 0x0002 /* **************************************************************************** * 6 PUBLIC FUNCTIONS **************************************************************************** */ /* *=========================================================================== * ipsctp_getaddrlen *=========================================================================== * Description: For application binary portability it is sometimes desirable to know * what the kernel thinks is the length of a socket address family. * * The function prototype is: * * int sctp_getaddrlen(sa_family_t family); * Parameters: domain - The address domain. * Returns: 0 < the length that the operating system uses in the specified family's * socket address structure. * -1 = error. * */ IP_PUBLIC int ipsctp_getaddrlen(Ip_sa_family_t domain); /* *=========================================================================== * ipsctp_getpaddrs *=========================================================================== * Description: sctp_getpaddrs() returns all peer addresses in an association. * * The function protoype is: * * int sctp_getpaddrs(int sd, * sctp_assoc_t id, * struct sockaddr **addrs); * * On return, addrs will point to an array dynamically allocated * sockaddr structures of the appropriate type for the socket type. The * caller should use sctp_freepaddrs() to free the memory. Note that * the in/out parameter addrs must not be NULL. * * If sd is an IPv4 socket, the addresses returned will be all IPv4 * addresses. If sd is an IPv6 socket, the addresses returned can be a * mix of IPv4 or IPv6 addresses. * Parameters: fd - The socket descriptor. * id - An association identification to get. * addrs - An (packed) array of peer addresses. * Returns: 0 < the number of peer addresses in the association, * 0 = no association on this socket. * -1 = error. * */ IP_PUBLIC int ipsctp_getpaddrs(Ip_fd fd, Ipsctp_assoc_t id, struct Ip_sockaddr **addrs); /* *=========================================================================== * ipsctp_getpaddrs *=========================================================================== * Description: sctp_freepaddrs() frees all resources allocated by sctp_getpaddrs(). * * The function prototype is * * void sctp_freepaddrs(struct sockaddr *addrs); * * and addrs is the array of peer addresses returned by * sctp_getpaddrs(). * Parameters: addrs - An (packed) array of addresses. * Returns: None. * */ IP_PUBLIC void ipsctp_freepaddrs(struct Ip_sockaddr *addrs); /* *=========================================================================== * ipsctp_getladdrs *=========================================================================== * Description: sctp_getladdrs() returns all locally bound address(es) on a socket. * * The function prototype is * * int sctp_getladdrs(int sd, * sctp_assoc_t id, * struct sockaddr **ss); * * On return, addrs will point to a dynamically allocated array of * sockaddr structures of the appropriate type for the socket type. The * caller should use sctp_freeladdrs() to free the memory. Note that * the in/out parameter addrs must not be NULL. * * If sd is an IPv4 socket, the addresses returned will be all IPv4 * addresses. If sd is an IPv6 socket, the addresses returned can be a * mix of IPv4 or IPv6 addresses. * Parameters: fd - The socket descriptor. * id - An association identification to get. * addrs - An (packed) array of locally bound addresses. * Returns: 0 < the number of peer addresses in the association, * 0 = no association on this socket. * -1 = error. * */ IP_PUBLIC int ipsctp_getladdrs(Ip_fd fd, Ipsctp_assoc_t id, struct Ip_sockaddr **addrs); /* *=========================================================================== * ipsctp_getladdrs *=========================================================================== * Description: sctp_freeladdrs() frees all resources allocated by sctp_getladdrs(). * * The function prototype is * * void sctp_freeladdrs(struct sockaddr *addrs); * * and addrs is the array of peer addresses returned by * sctp_getladdrs(). * Parameters: addrs - An (packed) array of locally bound addresses. * Returns: None. * */ IP_PUBLIC void ipsctp_freeladdrs(struct Ip_sockaddr *addrs); /* *=========================================================================== * ipsctp_opt_info *=========================================================================== * Description: The sctp_opt_info() call is a replacement for getsockopt() only and * will not set any options associated with the specified socket. A * setsockopt() must be used to set any writeable option. * * The syntax for sctp_opt_info() is * * int sctp_opt_info(int sd, * sctp_assoc_t id, * int opt, * void *arg, * socklen_t *size); * Parameters: fd - A socket descriptor. * id - An association identification. * optname - The option name. * optval - Data to set for the option. * optlen - The length of the buffer poited to by optval. * Returns: 0 = success, -1 = error. * */ IP_PUBLIC int ipsctp_opt_info(Ip_fd fd, Ipsctp_assoc_t id, int optname, void *optval, Ip_socklen_t *optlen); /* *=========================================================================== * ipsctp_bindx *=========================================================================== * Description: This function allows the user to bind a specific subset of addresses * or, if the SCTP extension described in [RFC5061] is supported, add or * delete specific addresses. * * The function prototype is * * int sctp_bindx(int sd, * struct sockaddr *addrs, * int addrcnt, * int flags); * * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses. * If the sd is an IPv6 socket, the addresses passed can either be IPv4 * or IPv6 addresses. * Parameters: fd - The socket to name. * addrs - The socket bind address list. * addrcnt - The socket bind address count. * flags - The flags parameter is formed from the bitwise OR of zero or * more of the following currently defined flags: * o SCTP_BINDX_ADD_ADDR * o SCTP_BINDX_REM_ADDR * SCTP_BINDX_ADD_ADDR directs SCTP to add the given addresses to the * association, and SCTP_BINDX_REM_ADDR directs SCTP to remove the given * addresses from the association. The two flags are mutually * exclusive; if both are given, sctp_bindx() will fail with EINVAL. A * caller may not remove all addresses from an association; sctp_bindx() * will reject such an attempt with EINVAL. * * An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate * additional addresses with an endpoint after calling bind(). Or use * sctp_bindx(SCTP_BINDX_REM_ADDR) to remove some addresses a listening * socket is associated with so that no new association accepted will be * associated with those addresses. If the endpoint supports dynamic * address a SCTP_BINDX_REM_ADDR or SCTP_BINDX_ADD_ADDR may cause a * endpoint to send the appropriate message to the peer to change the * peers address lists. * * Adding and removing addresses from a connected association is * optional functionality. Implementations that do not support this * functionality should return EOPNOTSUPP. * Returns: 0 = success, -1 = error * */ IP_PUBLIC int ipsctp_bindx(Ip_fd fd, struct Ip_sockaddr *addrs, int addrcnt, int flags); /* *=========================================================================== * ipsctp_connectx *=========================================================================== * Description: Much like sctp_bindx() this call allows a caller to * specify multiple addresses at which a peer can be reached. The way * the SCTP stack uses the list of addresses to set up the association * is implementation dependent. This function only specifies that the * stack will try to make use of all the addresses in the list when * needed. * * Note that the list of addresses passed in is only used for setting up * the association. It does not necessarily equal the set of addresses * the peer uses for the resulting association. If the caller wants to * find out the set of peer addresses, it must use sctp_getpaddrs() to * retrieve them after the association has been set up. * * sctp_connectx(). Its syntax is, * * int sctp_connectx(int sd, * struct sockaddr *addrs, * int addrcnt, * sctp_assoc_t *id) * * * sd - is the socket descriptor * addrs - is an array of addresses. * addrcnt - is the number of addresses in the array. * id - is an output parameter that if passed in as a non-NULL will * return the association identification for the newly created * association (if successful). * Parameters: pls refer to the Description. * Returns: 0= connection was successful, -1 = error. * */ IP_PUBLIC int ipsctp_connectx(Ip_fd fd, struct Ip_sockaddr *addrs, int addrcnt, Ipsctp_assoc_t *id); /* *=========================================================================== * ipsctp_send *=========================================================================== * Description: Provide another alternative function or system * call to assist an application with the sending of data without the * use of the CMSG header structures. * * The function prototype is * * ssize_t sctp_send(int sd, * const void *msg, * size_t len, * const struct sctp_sndrcvinfo *sinfo, * int flags); * * and the arguments are * sd: The socket descriptor. * msg: The message to be sent. * len: The length of the message. * sinfo: A pointer to a sctp_sndrcvinfo structure used as described in * Section 6.2.2 for a sendmsg call. * flags: The same flags as used by the sendmsg call flags (e.g. * MSG_DONTROUTE). * * This function call may also be used to terminate an association using * an association identification by setting the sinfo.sinfo_flags to * SCTP_EOF and the sinfo.sinfo_assoc_id to the association that needs * to be terminated. In such a case the len of the message would be * zero. * * Using sctp_send() on a non-connected one-to-one style socket for * implicit connection setup may or may not work depending on the SCTP * implementation. * * Sending a message using sctp_send() is atomic unless explicit EOR * marking is enabled on the socket specified by sd. * Parameters: pls refer to the Description. * Returns: >=0 = number of bytes sent, * -1 = error code is retrieved by using ipcom_errno. * */ IP_PUBLIC Ip_ssize_t ipsctp_send(Ip_fd fd, IP_CONST void *pbuf, Ip_size_t len, IP_CONST struct Ipsctp_sndrcvinfo *sinfo, int flags); /* *=========================================================================== * ipsctp_sendx *=========================================================================== * Description: Provide another alternative function or system * call to assist an application with the sending of data without the * use of the CMSG header structures that also gives a list of * addresses. The list of addresses is provided for implicit * association setup. In such a case the list of addresses serves the * same purpose as the addresses given in sctp_connectx() (see * Section 9.9). * * The function prototype is * * ssize_t sctp_sendx(int sd, * const void *msg, * size_t len, * struct sockaddr *addrs, * int addrcnt, * struct sctp_sndrcvinfo *sinfo, * int flags); * * and the arguments are: * sd: The socket descriptor. * msg: The message to be sent. * len: The length of the message. * addrs: is an array of addresses. * addrcnt: The number of addresses in the array. * sinfo: A pointer to a sctp_sndrcvinfo structure used as described in * Section 6.2.2 for a sendmsg call. * flags: The same flags as used by the sendmsg call flags (e.g. * MSG_DONTROUTE). * * Note that on return from this call the sinfo structure will have * changed in that the sinfo_assoc_id will be filled in with the new * association id. * * This function call may also be used to terminate an association using * an association identification by setting the sinfo.sinfo_flags to * SCTP_EOF and the sinfo.sinfo_assoc_id to the association that needs * to be terminated. In such a case the len of the message would be * zero. * * Sending a message using sctp_send() is atomic unless explicit EOR * marking is enabled on the socket specified by sd. * * Using sctp_sendx() on a non-connected one-to-one style socket for * implicit connection setup may or may not work depending on the SCTP * implementation. * Parameters: pls refer to the Description. * Returns: >=0 = number of bytes sent, * -1 = error code is retrieved by using ipcom_errno. * */ IP_PUBLIC Ip_ssize_t ipsctp_sendx(Ip_fd fd, IP_CONST void *msg, Ip_size_t len, struct Ip_sockaddr *addrs, int addrcnt, struct Ipsctp_sndrcvinfo *sinfo, int flags); /* *=========================================================================== * ipsctp_sendmsg *=========================================================================== * Description:Sending a message using sctp_sendmsg() is atomic unless explicit EOR * marking is enabled on the socket specified by sd. * * Using sctp_sendmsg() on a non-connected one-to-one style socket for * implicit connection setup may or may not work depending on the SCTP * implementation. * * The function prototype is * * ssize_t sctp_sendmsg(int sd, * const void *msg, * size_t len, * const struct sockaddr *to, * socklen_t tolen, * uint32_t ppid, * uint32_t flags, * uint16_t stream_no, * uint32_t pr_value, * uint32_t context); * Parameters: sd: The socket descriptor * msg: The message to be sent. * len: Yhe length of the message. * to: The destination address of the message. * tolen: The length of the destination address. * ppid: The same as sinfo_ppid (see Section 6.2.2) * flags: The same as sinfo_flags (see Section 6.2.2) * stream_no: The same as sinfo_stream (see Section 6.2.2) * pr_value: The same as sinfo_pr_value (see Section 6.2.2). * context: The same as sinfo_context (see Section 6.2.2) * Returns: >=0 = the number of characters sent, * IP_SOCKERR = error code is retrivered by using ipcom_errno. * */ IP_PUBLIC Ip_ssize_t ipsctp_sendmsg(Ip_fd fd, IP_CONST void *pbuf, Ip_size_t len, IP_CONST struct Ip_sockaddr *to, Ip_socklen_t tolen, Ip_u32 ppid, Ip_u32 flags, Ip_u32 stream_no, Ip_u32 pr_value, Ip_u32 context); /* *=========================================================================== * ipsctp_recvmsg *=========================================================================== * Description: Receives data from a socket. * Note that in order for the sctp_sndrcvinfo structure to be filled in by * sctp_recvmsg() the caller must enable the sctp_data_io_events with * the SCTP_EVENTS option. Note that the setting of the * SCTP_USE_EXT_RCVINFO will effect this function as well, causing the * sctp_sndrcvinfo information to be extended. * * The function prototype is * * ssize_t sctp_recvmsg(int sd, * void *msg, * size_t len, * struct sockaddr *from, * socklen_t *fromlen * struct sctp_sndrcvinfo *sinfo * int *msg_flags); * * and the arguments are * sd: The socket descriptor. * msg: The message buffer to be filled. * len: The length of the message buffer. * from: A pointer to a address to be filled with the sender of this * messages address. * fromlen: An in/out parameter describing the from length. * sinfo: A pointer to a sctp_sndrcvinfo structure to be filled upon * receipt of the message. * msg_flags: A pointer to a integer to be filled with any message * flags (e.g. MSG_NOTIFICATION). Note that this field is an in-out * field. Options for the receive may also be passed into the value * (e.g. MSG_PEEK). On return from the call, the msg_flags value * will be different than what was sent in to the call. If * implemented via a recvmsg() call, the msg_flags should only * contain the value of the flags from the recvmsg() call. * Parameters: pls refer to the Description. * Returns: 0 = the number of bytes received, -1 = error. * */ IP_PUBLIC Ip_ssize_t ipsctp_recvmsg(Ip_fd fd, void *pbuf, Ip_size_t len, struct Ip_sockaddr *from, Ip_socklen_t *fromlen, struct Ipsctp_sndrcvinfo *sinfo, int *msg_flags); /* *=========================================================================== * ipsctp_peeloff *=========================================================================== * Description: The application uses sctp_peeloff() call to branch off an association * into a separate socket (Note the semantics are somewhat changed from * the traditional one-to-one style accept() call). Note that the new * socket is a one-to-one style socket. Thus it will be confined to * operations allowed for a one-to-one style socket. * * The function prototype is * * int sctp_peeloff(int sd, * sctp_assoc_t id); * Parameters: fd - A socket descriptor. * id - An association identification. * Returns: 0 = success, -1 = error. * */ IP_PUBLIC int ipsctp_peeloff(Ip_fd fd, Ipsctp_assoc_t id); #ifdef __cplusplus } #endif #endif /* IPSCTP_SETUP_H */