draft-ietf-tsvwg-sctpsocket-32.txt   rfc6458.txt 
Network Working Group R. Stewart Internet Engineering Task Force (IETF) R. Stewart
Internet-Draft Adara Networks Request for Comments: 6458 Adara Networks
Intended status: Informational M. Tuexen Category: Informational M. Tuexen
Expires: April 13, 2012 Muenster Univ. of Appl. Sciences ISSN: 2070-1721 Muenster Univ. of Appl. Sciences
K. Poon K. Poon
Oracle Corporation Oracle Corporation
P. Lei P. Lei
Cisco Systems, Inc. Cisco Systems, Inc.
V. Yasevich V. Yasevich
HP HP
October 11, 2011 December 2011
Sockets API Extensions for Stream Control Transmission Protocol (SCTP) Sockets API Extensions
draft-ietf-tsvwg-sctpsocket-32.txt for the Stream Control Transmission Protocol (SCTP)
Abstract Abstract
This document describes a mapping of the Stream Control Transmission This document describes a mapping of the Stream Control Transmission
Protocol (SCTP) into a sockets API. The benefits of this mapping Protocol (SCTP) into a sockets API. The benefits of this mapping
include compatibility for TCP applications, access to new SCTP include compatibility for TCP applications, access to new SCTP
features and a consolidated error and event notification scheme. features, and a consolidated error and event notification scheme.
Status of this Memo
This Internet-Draft is submitted in full conformance with the Status of This Memo
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering This document is not an Internet Standards Track specification; it is
Task Force (IETF). Note that other groups may also distribute published for informational purposes.
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months This document is a product of the Internet Engineering Task Force
and may be updated, replaced, or obsoleted by other documents at any (IETF). It represents the consensus of the IETF community. It has
time. It is inappropriate to use Internet-Drafts as reference received public review and has been approved for publication by the
material or to cite them other than as "work in progress." Internet Engineering Steering Group (IESG). Not all documents
approved by the IESG are a candidate for any level of Internet
Standard; see Section 2 of RFC 5741.
This Internet-Draft will expire on April 13, 2012. Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc6458.
Copyright Notice Copyright Notice
Copyright (c) 2011 IETF Trust and the persons identified as the Copyright (c) 2011 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 3, line 7 skipping to change at page 3, line 7
modifications of such material outside the IETF Standards Process. modifications of such material outside the IETF Standards Process.
Without obtaining an adequate license from the person(s) controlling Without obtaining an adequate license from the person(s) controlling
the copyright in such materials, this document may not be modified the copyright in such materials, this document may not be modified
outside the IETF Standards Process, and derivative works of it may outside the IETF Standards Process, and derivative works of it may
not be created outside the IETF Standards Process, except to format not be created outside the IETF Standards Process, except to format
it for publication as an RFC or to translate it into languages other it for publication as an RFC or to translate it into languages other
than English. than English.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 7 1. Introduction ....................................................6
2. Data Types . . . . . . . . . . . . . . . . . . . . . . . . . 8 2. Data Types ......................................................8
3. One-to-Many Style Interface . . . . . . . . . . . . . . . . . 8 3. One-to-Many Style Interface .....................................8
3.1. Basic Operation . . . . . . . . . . . . . . . . . . . . . 8 3.1. Basic Operation ............................................8
3.1.1. socket() . . . . . . . . . . . . . . . . . . . . . . 10 3.1.1. socket() ............................................9
3.1.2. bind() . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.2. bind() .............................................10
3.1.3. listen() . . . . . . . . . . . . . . . . . . . . . . 12 3.1.3. listen() ...........................................11
3.1.4. sendmsg() and recvmsg() . . . . . . . . . . . . . . . 12 3.1.4. sendmsg() and recvmsg() ............................12
3.1.5. close() . . . . . . . . . . . . . . . . . . . . . . . 14 3.1.5. close() ............................................14
3.1.6. connect() . . . . . . . . . . . . . . . . . . . . . . 15 3.1.6. connect() ..........................................14
3.2. Non-blocking mode . . . . . . . . . . . . . . . . . . . . 16 3.2. Non-Blocking Mode .........................................15
3.3. Special considerations . . . . . . . . . . . . . . . . . 17 3.3. Special Considerations ....................................16
4. One-to-One Style Interface . . . . . . . . . . . . . . . . . 18 4. One-to-One Style Interface .....................................18
4.1. Basic Operation . . . . . . . . . . . . . . . . . . . . . 18 4.1. Basic Operation ...........................................18
4.1.1. socket() . . . . . . . . . . . . . . . . . . . . . . 19 4.1.1. socket() ...........................................19
4.1.2. bind() . . . . . . . . . . . . . . . . . . . . . . . 20 4.1.2. bind() .............................................19
4.1.3. listen() . . . . . . . . . . . . . . . . . . . . . . 21 4.1.3. listen() ...........................................21
4.1.4. accept() . . . . . . . . . . . . . . . . . . . . . . 21 4.1.4. accept() ...........................................21
4.1.5. connect() . . . . . . . . . . . . . . . . . . . . . . 22 4.1.5. connect() ..........................................22
4.1.6. close() . . . . . . . . . . . . . . . . . . . . . . . 23 4.1.6. close() ............................................23
4.1.7. shutdown() . . . . . . . . . . . . . . . . . . . . . 23 4.1.7. shutdown() .........................................23
4.1.8. sendmsg() and recvmsg() . . . . . . . . . . . . . . . 24 4.1.8. sendmsg() and recvmsg() ............................24
4.1.9. getpeername() . . . . . . . . . . . . . . . . . . . . 25 4.1.9. getpeername() ......................................24
5. Data Structures . . . . . . . . . . . . . . . . . . . . . . . 25 5. Data Structures ................................................25
5.1. The msghdr and cmsghdr Structures . . . . . . . . . . . . 25 5.1. The msghdr and cmsghdr Structures .........................25
5.2. Ancillary Data Considerations and Semantics . . . . . . . 26 5.2. Ancillary Data Considerations and Semantics ...............26
5.2.1. Multiple Items and Ordering . . . . . . . . . . . . . 26 5.2.1. Multiple Items and Ordering ........................27
5.2.2. Accessing and Manipulating Ancillary Data . . . . . . 27 5.2.2. Accessing and Manipulating Ancillary Data ..........27
5.2.3. Control Message Buffer Sizing . . . . . . . . . . . . 27 5.2.3. Control Message Buffer Sizing ......................28
5.3. SCTP msg_control Structures . . . . . . . . . . . . . . . 28 5.3. SCTP msg_control Structures ...............................28
5.3.1. SCTP Initiation Structure (SCTP_INIT) . . . . . . . . 29 5.3.1. SCTP Initiation Structure (SCTP_INIT) ..............29
5.3.2. SCTP Header Information Structure (SCTP_SNDRCV) - 5.3.2. SCTP Header Information Structure
DEPRECATED . . . . . . . . . . . . . . . . . . . . . 30 (SCTP_SNDRCV) - DEPRECATED .........................30
5.3.3. Extended SCTP Header Information Structure 5.3.3. Extended SCTP Header Information Structure
(SCTP_EXTRCV) - DEPRECATED . . . . . . . . . . . . . 33 (SCTP_EXTRCV) - DEPRECATED .........................33
5.3.4. SCTP Send Information Structure (SCTP_SNDINFO) . . . 34 5.3.4. SCTP Send Information Structure (SCTP_SNDINFO) .....35
5.3.5. SCTP Receive Information Structure (SCTP_RCVINFO) . . 36 5.3.5. SCTP Receive Information Structure (SCTP_RCVINFO) ..37
5.3.6. SCTP Next Receive Information Structure 5.3.6. SCTP Next Receive Information Structure
(SCTP_NXTINFO) . . . . . . . . . . . . . . . . . . . 37 (SCTP_NXTINFO) .....................................38
5.3.7. SCTP PR-SCTP Information Structure (SCTP_PRINFO) . . 39 5.3.7. SCTP PR-SCTP Information Structure (SCTP_PRINFO) ...39
5.3.8. SCTP AUTH Information Structure (SCTP_AUTHINFO) . . . 39 5.3.8. SCTP AUTH Information Structure (SCTP_AUTHINFO) ....40
5.3.9. SCTP Destination IPv4 Address Structure 5.3.9. SCTP Destination IPv4 Address Structure
(SCTP_DSTADDRV4) . . . . . . . . . . . . . . . . . . 40 (SCTP_DSTADDRV4) ...................................41
5.3.10. SCTP Destination IPv6 Address Structure 5.3.10. SCTP Destination IPv6 Address Structure
(SCTP_DSTADDRV6) . . . . . . . . . . . . . . . . . . 40 (SCTP_DSTADDRV6) ..................................41
6. SCTP Events and Notifications . . . . . . . . . . . . . . . . 40
6.1. SCTP Notification Structure . . . . . . . . . . . . . . . 41 6. SCTP Events and Notifications ..................................41
6.1.1. SCTP_ASSOC_CHANGE . . . . . . . . . . . . . . . . . . 43 6.1. SCTP Notification Structure ...............................42
6.1.2. SCTP_PEER_ADDR_CHANGE . . . . . . . . . . . . . . . . 44 6.1.1. SCTP_ASSOC_CHANGE ..................................43
6.1.3. SCTP_REMOTE_ERROR . . . . . . . . . . . . . . . . . . 46 6.1.2. SCTP_PEER_ADDR_CHANGE ..............................45
6.1.4. SCTP_SEND_FAILED - DEPRECATED . . . . . . . . . . . . 46 6.1.3. SCTP_REMOTE_ERROR ..................................46
6.1.5. SCTP_SHUTDOWN_EVENT . . . . . . . . . . . . . . . . . 48 6.1.4. SCTP_SEND_FAILED - DEPRECATED ......................47
6.1.6. SCTP_ADAPTATION_INDICATION . . . . . . . . . . . . . 48 6.1.5. SCTP_SHUTDOWN_EVENT ................................48
6.1.7. SCTP_PARTIAL_DELIVERY_EVENT . . . . . . . . . . . . . 49 6.1.6. SCTP_ADAPTATION_INDICATION .........................49
6.1.8. SCTP_AUTHENTICATION_EVENT . . . . . . . . . . . . . . 50 6.1.7. SCTP_PARTIAL_DELIVERY_EVENT ........................49
6.1.9. SCTP_SENDER_DRY_EVENT . . . . . . . . . . . . . . . . 51 6.1.8. SCTP_AUTHENTICATION_EVENT ..........................50
6.1.10. SCTP_NOTIFICATIONS_STOPPED_EVENT . . . . . . . . . . 51 6.1.9. SCTP_SENDER_DRY_EVENT ..............................51
6.1.11. SCTP_SEND_FAILED_EVENT . . . . . . . . . . . . . . . 52 6.1.10. SCTP_NOTIFICATIONS_STOPPED_EVENT ..................52
6.2. Notification Interest Options . . . . . . . . . . . . . . 53 6.1.11. SCTP_SEND_FAILED_EVENT ............................52
6.2.1. SCTP_EVENTS option - DEPRECATED . . . . . . . . . . . 53 6.2. Notification Interest Options .............................54
6.2.2. SCTP_EVENT option . . . . . . . . . . . . . . . . . . 55 6.2.1. SCTP_EVENTS Option - DEPRECATED ....................54
7. Common Operations for Both Styles . . . . . . . . . . . . . . 56 6.2.2. SCTP_EVENT Option ..................................56
7.1. send(), recv(), sendto(), and recvfrom() . . . . . . . . 56 7. Common Operations for Both Styles ..............................57
7.2. setsockopt() and getsockopt() . . . . . . . . . . . . . . 58 7.1. send(), recv(), sendto(), and recvfrom() ..................57
7.3. read() and write() . . . . . . . . . . . . . . . . . . . 60 7.2. setsockopt() and getsockopt() .............................59
7.4. getsockname() . . . . . . . . . . . . . . . . . . . . . . 60 7.3. read() and write() ........................................60
7.5. Implicit Association Setup . . . . . . . . . . . . . . . 60 7.4. getsockname() .............................................60
8. Socket Options . . . . . . . . . . . . . . . . . . . . . . . 61 7.5. Implicit Association Setup ................................61
8.1. Read / Write Options . . . . . . . . . . . . . . . . . . 63 8. Socket Options .................................................61
8.1.1. Retransmission Timeout Parameters (SCTP_RTOINFO) . . 63 8.1. Read/Write Options ........................................63
8.1.2. Association Parameters (SCTP_ASSOCINFO) . . . . . . . 64 8.1.1. Retransmission Timeout Parameters (SCTP_RTOINFO) ...63
8.1.3. Initialization Parameters (SCTP_INITMSG) . . . . . . 65 8.1.2. Association Parameters (SCTP_ASSOCINFO) ............64
8.1.4. SO_LINGER . . . . . . . . . . . . . . . . . . . . . . 66 8.1.3. Initialization Parameters (SCTP_INITMSG) ...........66
8.1.5. SCTP_NODELAY . . . . . . . . . . . . . . . . . . . . 66 8.1.4. SO_LINGER ..........................................66
8.1.6. SO_RCVBUF . . . . . . . . . . . . . . . . . . . . . . 67 8.1.5. SCTP_NODELAY .......................................66
8.1.7. SO_SNDBUF . . . . . . . . . . . . . . . . . . . . . . 67 8.1.6. SO_RCVBUF ..........................................67
8.1.8. Automatic Close of Associations (SCTP_AUTOCLOSE) . . 67 8.1.7. SO_SNDBUF ..........................................67
8.1.9. Set Primary Address (SCTP_PRIMARY_ADDR) . . . . . . . 68 8.1.8. Automatic Close of Associations (SCTP_AUTOCLOSE) ...67
8.1.10. Set Adaptation Layer Indicator 8.1.9. Set Primary Address (SCTP_PRIMARY_ADDR) ............68
(SCTP_ADAPTATION_LAYER) . . . . . . . . . . . . . . . 68 8.1.10. Set Adaptation Layer Indicator
8.1.11. Enable/Disable Message Fragmentation (SCTP_ADAPTATION_LAYER) ...........................68
(SCTP_DISABLE_FRAGMENTS) . . . . . . . . . . . . . . 68 8.1.11. Enable/Disable Message Fragmentation
8.1.12. Peer Address Parameters (SCTP_PEER_ADDR_PARAMS) . . . 69 (SCTP_DISABLE_FRAGMENTS) ..........................68
8.1.13. Set Default Send Parameters 8.1.12. Peer Address Parameters (SCTP_PEER_ADDR_PARAMS) ...69
(SCTP_DEFAULT_SEND_PARAM) - DEPRECATED . . . . . . . 71 8.1.13. Set Default Send Parameters
8.1.14. Set Notification and Ancillary Events (SCTP_DEFAULT_SEND_PARAM) - DEPRECATED ............71
(SCTP_EVENTS) - DEPRECATED . . . . . . . . . . . . . 72 8.1.14. Set Notification and Ancillary Events
8.1.15. Set/Clear IPv4 Mapped Addresses (SCTP_EVENTS) - DEPRECATED ........................72
(SCTP_I_WANT_MAPPED_V4_ADDR) . . . . . . . . . . . . 72 8.1.15. Set/Clear IPv4 Mapped Addresses
8.1.16. Get or Set the Maximum Fragmentation Size (SCTP_I_WANT_MAPPED_V4_ADDR) ......................72
(SCTP_MAXSEG) . . . . . . . . . . . . . . . . . . . . 72 8.1.16. Get or Set the Maximum Fragmentation Size
8.1.17. Get or Set the List of Supported HMAC Identifiers (SCTP_MAXSEG) .....................................72
(SCTP_HMAC_IDENT) . . . . . . . . . . . . . . . . . . 73 8.1.17. Get or Set the List of Supported HMAC
8.1.18. Get or Set the Active Shared Key Identifiers (SCTP_HMAC_IDENT) .....................73
(SCTP_AUTH_ACTIVE_KEY) . . . . . . . . . . . . . . . 73
8.1.19. Get or Set Delayed SACK Timer (SCTP_DELAYED_SACK) . . 74 8.1.18. Get or Set the Active Shared Key
8.1.20. Get or Set Fragmented Interleave (SCTP_AUTH_ACTIVE_KEY) ............................74
(SCTP_FRAGMENT_INTERLEAVE) . . . . . . . . . . . . . 75 8.1.19. Get or Set Delayed SACK Timer
8.1.21. Set or Get the SCTP Partial Delivery Point (SCTP_DELAYED_SACK) ...............................74
(SCTP_PARTIAL_DELIVERY_POINT) . . . . . . . . . . . . 76 8.1.20. Get or Set Fragmented Interleave
8.1.22. Set or Get the Use of Extended Receive Info (SCTP_FRAGMENT_INTERLEAVE) ........................75
(SCTP_USE_EXT_RCVINFO) - DEPRECATED . . . . . . . . . 77 8.1.21. Set or Get the SCTP Partial Delivery Point
8.1.23. Set or Get the Auto ASCONF Flag (SCTP_AUTO_ASCONF) . 77 (SCTP_PARTIAL_DELIVERY_POINT) .....................77
8.1.24. Set or Get the Maximum Burst (SCTP_MAX_BURST) . . . . 77 8.1.22. Set or Get the Use of Extended Receive Info
8.1.25. Set or Get the Default Context (SCTP_CONTEXT) . . . . 78 (SCTP_USE_EXT_RCVINFO) - DEPRECATED ...............77
8.1.26. Enable or Disable Explicit EOR Marking 8.1.23. Set or Get the Auto ASCONF Flag
(SCTP_EXPLICIT_EOR) . . . . . . . . . . . . . . . . . 78 (SCTP_AUTO_ASCONF) ................................77
8.1.27. Enable SCTP Port Reusage (SCTP_REUSE_PORT) . . . . . 79 8.1.24. Set or Get the Maximum Burst (SCTP_MAX_BURST) .....78
8.1.28. Set Notification Event (SCTP_EVENT) . . . . . . . . . 79 8.1.25. Set or Get the Default Context (SCTP_CONTEXT) .....78
8.1.29. Enable or Disable the Delivery of SCTP_RCVINFO as 8.1.26. Enable or Disable Explicit EOR Marking
Ancillary Data (SCTP_RECVRCVINFO) . . . . . . . . . . 79 (SCTP_EXPLICIT_EOR) ...............................79
8.1.30. Enable or Disable the Delivery of SCTP_NXTINFO as 8.1.27. Enable SCTP Port Reusage (SCTP_REUSE_PORT) ........79
Ancillary Data (SCTP_RECVNXTINFO) . . . . . . . . . . 79 8.1.28. Set Notification Event (SCTP_EVENT) ...............79
8.1.31. Set Default Send Parameters (SCTP_DEFAULT_SNDINFO) . 80 8.1.29. Enable or Disable the Delivery of SCTP_RCVINFO
8.1.32. Set Default PR-SCTP Parameters as Ancillary Data (SCTP_RECVRCVINFO) ..............79
(SCTP_DEFAULT_PRINFO) . . . . . . . . . . . . . . . . 80 8.1.30. Enable or Disable the Delivery of SCTP_NXTINFO
8.2. Read-Only Options . . . . . . . . . . . . . . . . . . . . 80 as Ancillary Data (SCTP_RECVNXTINFO) ..............80
8.2.1. Association Status (SCTP_STATUS) . . . . . . . . . . 80 8.1.31. Set Default Send Parameters
8.2.2. Peer Address Information (SCTP_GET_PEER_ADDR_INFO) . 82 (SCTP_DEFAULT_SNDINFO) ............................80
8.2.3. Get the List of Chunks the Peer Requires to be 8.1.32. Set Default PR-SCTP Parameters
Authenticated (SCTP_PEER_AUTH_CHUNKS) . . . . . . . . 83 (SCTP_DEFAULT_PRINFO) .............................80
8.2.4. Get the List of Chunks the Local Endpoint Requires 8.2. Read-Only Options .........................................81
to be Authenticated (SCTP_LOCAL_AUTH_CHUNKS) . . . . 84 8.2.1. Association Status (SCTP_STATUS) ...................81
8.2.5. Get the Current Number of Associations 8.2.2. Peer Address Information
(SCTP_GET_ASSOC_NUMBER) . . . . . . . . . . . . . . . 84 (SCTP_GET_PEER_ADDR_INFO) ..........................82
8.2.6. Get the Current Identifiers of Associations 8.2.3. Get the List of Chunks the Peer Requires to
(SCTP_GET_ASSOC_ID_LIST) . . . . . . . . . . . . . . 85 Be Authenticated (SCTP_PEER_AUTH_CHUNKS) ...........84
8.3. Write-Only Options . . . . . . . . . . . . . . . . . . . 85 8.2.4. Get the List of Chunks the Local Endpoint Requires
8.3.1. Set Peer Primary Address to Be Authenticated (SCTP_LOCAL_AUTH_CHUNKS) .......84
(SCTP_SET_PEER_PRIMARY_ADDR) . . . . . . . . . . . . 85 8.2.5. Get the Current Number of Associations
8.3.2. Add a Chunk that must be Authenticated (SCTP_GET_ASSOC_NUMBER) ............................85
(SCTP_AUTH_CHUNK) . . . . . . . . . . . . . . . . . . 86 8.2.6. Get the Current Identifiers of Associations
8.3.3. Set a Shared Key (SCTP_AUTH_KEY) . . . . . . . . . . 86 (SCTP_GET_ASSOC_ID_LIST) ...........................85
8.3.4. Deactivate a Shared Key (SCTP_AUTH_DEACTIVATE_KEY) . 87 8.3. Write-Only Options ........................................85
8.3.5. Delete a Shared Key (SCTP_AUTH_DELETE_KEY) . . . . . 87 8.3.1. Set Peer Primary Address
9. New Functions . . . . . . . . . . . . . . . . . . . . . . . . 88 (SCTP_SET_PEER_PRIMARY_ADDR) .......................86
9.1. sctp_bindx() . . . . . . . . . . . . . . . . . . . . . . 88 8.3.2. Add a Chunk That Must Be Authenticated
9.2. sctp_peeloff() . . . . . . . . . . . . . . . . . . . . . 90 (SCTP_AUTH_CHUNK) ..................................86
9.3. sctp_getpaddrs() . . . . . . . . . . . . . . . . . . . . 90 8.3.3. Set a Shared Key (SCTP_AUTH_KEY) ...................86
9.4. sctp_freepaddrs() . . . . . . . . . . . . . . . . . . . . 91 8.3.4. Deactivate a Shared Key
9.5. sctp_getladdrs() . . . . . . . . . . . . . . . . . . . . 91 (SCTP_AUTH_DEACTIVATE_KEY) .........................87
9.6. sctp_freeladdrs() . . . . . . . . . . . . . . . . . . . . 92 8.3.5. Delete a Shared Key (SCTP_AUTH_DELETE_KEY) .........88
9.7. sctp_sendmsg() - DEPRECATED . . . . . . . . . . . . . . . 92
9.8. sctp_recvmsg() - DEPRECATED . . . . . . . . . . . . . . . 93 9. New Functions ..................................................88
9.9. sctp_connectx() . . . . . . . . . . . . . . . . . . . . . 94 9.1. sctp_bindx() ..............................................88
9.10. sctp_send() - DEPRECATED . . . . . . . . . . . . . . . . 95 9.2. sctp_peeloff() ............................................90
9.11. sctp_sendx() - DEPRECATED . . . . . . . . . . . . . . . . 96 9.3. sctp_getpaddrs() ..........................................91
9.12. sctp_sendv() . . . . . . . . . . . . . . . . . . . . . . 97 9.4. sctp_freepaddrs() .........................................92
9.13. sctp_recvv() . . . . . . . . . . . . . . . . . . . . . . 100 9.5. sctp_getladdrs() ..........................................92
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 102 9.6. sctp_freeladdrs() .........................................93
11. Security Considerations . . . . . . . . . . . . . . . . . . . 102 9.7. sctp_sendmsg() - DEPRECATED ...............................93
12. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 103 9.8. sctp_recvmsg() - DEPRECATED ...............................94
13. References . . . . . . . . . . . . . . . . . . . . . . . . . 103 9.9. sctp_connectx() ...........................................95
13.1. Normative References . . . . . . . . . . . . . . . . . . 103 9.10. sctp_send() - DEPRECATED .................................96
13.2. Informative References . . . . . . . . . . . . . . . . . 104 9.11. sctp_sendx() - DEPRECATED ................................97
Appendix A. One-to-One Style Code Example . . . . . . . . . . . 104 9.12. sctp_sendv() .............................................98
Appendix B. One-to-Many Style Code Example . . . . . . . . . . . 107 9.13. sctp_recvv() ............................................101
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 112 10. Security Considerations ......................................103
11. Acknowledgments ..............................................103
12. References ...................................................104
12.1. Normative References ....................................104
12.2. Informative References ..................................104
Appendix A. Example Using One-to-One Style Sockets ...............106
Appendix B. Example Using One-to-Many Style Sockets ..............109
1. Introduction 1. Introduction
The sockets API has provided a standard mapping of the Internet The sockets API has provided a standard mapping of the Internet
Protocol suite to many operating systems. Both TCP [RFC0793] and UDP Protocol suite to many operating systems. Both TCP [RFC0793] and UDP
[RFC0768] have benefited from this standard representation and access [RFC0768] have benefited from this standard representation and access
method across many diverse platforms. SCTP is a new protocol that method across many diverse platforms. SCTP is a new protocol that
provides many of the characteristics of TCP but also incorporates provides many of the characteristics of TCP but also incorporates
semantics more akin to UDP. This document defines a method to map semantics more akin to UDP. This document defines a method to map
the existing sockets API for use with SCTP, providing both a base for the existing sockets API for use with SCTP, providing both a base for
access to new features and compatibility so that most existing TCP access to new features and compatibility so that most existing TCP
applications can be migrated to SCTP with few (if any) changes. applications can be migrated to SCTP with few (if any) changes.
There are three basic design objectives: There are three basic design objectives:
1. Maintain consistency with existing sockets APIs: We define a 1. Maintain consistency with existing sockets APIs: We define a
sockets mapping for SCTP that is consistent with other sockets sockets mapping for SCTP that is consistent with other sockets
API protocol mappings (for instance UDP, TCP, IPv4, and IPv6). API protocol mappings (for instance UDP, TCP, IPv4, and IPv6).
2. Support a one-to-many style interface: This set of semantics is 2. Support a one-to-many style interface: This set of semantics is
similar to that defined for connection-less protocols, such as similar to that defined for connectionless protocols, such as
UDP. A one-to-many style SCTP socket should be able to control UDP. A one-to-many style SCTP socket should be able to control
multiple SCTP associations. This is similar to a UDP socket, multiple SCTP associations. This is similar to a UDP socket,
which can communicate with many peer endpoints. Each of these which can communicate with many peer endpoints. Each of these
associations is assigned an association identifier so that an associations is assigned an association identifier so that an
application can use the ID to differentiate them. Note that SCTP application can use the ID to differentiate them. Note that SCTP
is connection-oriented in nature, and it does not support is connection-oriented in nature, and it does not support
broadcast or multicast communications, as UDP does. broadcast or multicast communications, as UDP does.
3. Support a one-to-one style interface: This interface supports a 3. Support a one-to-one style interface: This interface supports a
similar semantics as sockets for connection-oriented protocols, similar semantics as sockets for connection-oriented protocols,
skipping to change at page 7, line 52 skipping to change at page 7, line 27
should continue to work with this style of socket. Extensions should continue to work with this style of socket. Extensions
are added to this mapping to provide mechanisms to exploit new are added to this mapping to provide mechanisms to exploit new
features of SCTP. features of SCTP.
Goals 2 and 3 are not compatible, so this document defines two modes Goals 2 and 3 are not compatible, so this document defines two modes
of mapping, namely the one-to-many style mapping and the one-to-one of mapping, namely the one-to-many style mapping and the one-to-one
style mapping. These two modes share some common data structures and style mapping. These two modes share some common data structures and
operations, but will require the use of two different application operations, but will require the use of two different application
programming styles. Note that all new SCTP features can be used with programming styles. Note that all new SCTP features can be used with
both styles of socket. The decision on which one to use depends both styles of socket. The decision on which one to use depends
mainly on the nature of applications. mainly on the nature of the applications.
A mechanism is defined to extract a one-to-many style SCTP A mechanism is defined to extract an SCTP association from a one-to-
association into a one-to-one style socket. many style socket into a one-to-one style socket.
Some of the SCTP mechanisms cannot be adequately mapped to an Some of the SCTP mechanisms cannot be adequately mapped to an
existing socket interface. In some cases, it is more desirable to existing socket interface. In some cases, it is more desirable to
have a new interface instead of using existing socket calls. have a new interface instead of using existing socket calls.
Section 9 of this document describes these new interfaces. Section 9 of this document describes these new interfaces.
Please note that some elements of the SCTP socket API are declared as Please note that some elements of the SCTP sockets API are declared
deprecated. During the evolution of this document, elements of the as deprecated. During the evolution of this document, elements of
API were introduced, implemented and later on replaced by other the API were introduced, implemented, and later on replaced by other
elements. These replaced elements are declared as deprecated since elements. These replaced elements are declared as deprecated, since
they are still available in some implementations and the replacement they are still available in some implementations and the replacement
functions are not. This applies especially to older versions of functions are not. This applies especially to older versions of
operating systems supporting SCTP. New SCTP socket implementations operating systems supporting SCTP. New SCTP socket implementations
must implement at least the non deprecated elements. Implementations must implement at least the non-deprecated elements. Implementations
intending interoperability with older versions of the API should also intending interoperability with older versions of the API should also
include the deprecated functions. include the deprecated functions.
2. Data Types 2. Data Types
Whenever possible, POSIX data types defined in [IEEE-1003.1-2008] are Whenever possible, Portable Operating System Interface (POSIX) data
used: uintN_t means an unsigned integer of exactly N bits (e.g. types defined in [IEEE-1003.1-2008] are used: uintN_t means an
uint16_t). This document also assumes the argument data types from unsigned integer of exactly N bits (e.g., uint16_t). This document
POSIX when possible (e.g. the final argument to setsockopt() is a also assumes the argument data types from POSIX when possible (e.g.,
socklen_t value). Whenever buffer sizes are specified, the POSIX the final argument to setsockopt() is a socklen_t value). Whenever
size_t data type is used. buffer sizes are specified, the POSIX size_t data type is used.
3. One-to-Many Style Interface 3. One-to-Many Style Interface
In the one-to-many style interface there is a 1 to many relationship In the one-to-many style interface, there is a one-to-many
between sockets and associations. relationship between sockets and associations.
3.1. Basic Operation 3.1. Basic Operation
A typical server in this style uses the following socket calls in A typical server in this style uses the following socket calls in
sequence to prepare an endpoint for servicing requests: sequence to prepare an endpoint for servicing requests:
o socket() o socket()
o bind() o bind()
skipping to change at page 9, line 4 skipping to change at page 8, line 31
A typical server in this style uses the following socket calls in A typical server in this style uses the following socket calls in
sequence to prepare an endpoint for servicing requests: sequence to prepare an endpoint for servicing requests:
o socket() o socket()
o bind() o bind()
o listen() o listen()
o recvmsg() o recvmsg()
o sendmsg() o sendmsg()
o close() o close()
A typical client uses the following calls in sequence to setup an A typical client uses the following calls in sequence to set up an
association with a server to request services: association with a server to request services:
o socket() o socket()
o sendmsg() o sendmsg()
o recvmsg() o recvmsg()
o close() o close()
In this style, by default, all the associations connected to the In this style, by default, all of the associations connected to the
endpoint are represented with a single socket. Each association is endpoint are represented with a single socket. Each association is
assigned an association identifier (type is sctp_assoc_t) so that an assigned an association identifier (the type is sctp_assoc_t) so that
application can use it to differentiate among them. In some an application can use it to differentiate among them. In some
implementations, the peer endpoints' addresses can also be used for implementations, the peer endpoints' addresses can also be used for
this purpose. But this is not required for performance reasons. If this purpose. But this is not required for performance reasons. If
an implementation does not support using addresses to differentiate an implementation does not support using addresses to differentiate
between different associations, the sendto() call can only be used to between different associations, the sendto() call can only be used to
setup an association implicitly. It cannot be used to send data to set up an association implicitly. It cannot be used to send data to
an established association as the association identifier cannot be an established association, as the association identifier cannot be
specified. specified.
Once an association identifier is assigned to an SCTP association, Once an association identifier is assigned to an SCTP association,
that identifier will not be reused until the application explicitly that identifier will not be reused until the application explicitly
terminates the use of the association. The resources belonging to terminates the use of the association. The resources belonging to
that association will not be freed until that happens. This is that association will not be freed until that happens. This is
similar to the close() operation on a normal socket. The only similar to the close() operation on a normal socket. The only
exception is when the SCTP_AUTOCLOSE option (Section 8.1.8) is set. exception is when the SCTP_AUTOCLOSE option (Section 8.1.8) is set.
In this case, after the association is terminated gracefully and In this case, after the association is terminated gracefully and
automatically, the association identifier assigned to it can be automatically, the association identifier assigned to it can be
reused. All applications using this option should be aware of this reused. All applications using this option should be aware of this
to avoid the possible problem of sending data to an incorrect peer to avoid the possible problem of sending data to an incorrect peer
endpoint. endpoint.
If the server or client wishes to branch an existing association off If the server or client wishes to branch an existing association off
to a separate socket, it is required to call sctp_peeloff() and to to a separate socket, it is required to call sctp_peeloff() and to
specify the association identifier. The sctp_peeloff() call will specify the association identifier. The sctp_peeloff() call will
return a new one-to-one style socket which can then be used with return a new one-to-one style socket that can then be used with
recv() and send() functions for message passing. See Section 9.2 for recv() and send() functions for message passing. See Section 9.2 for
more on branched-off associations. more on branched-off associations.
Once an association is branched off to a separate socket, it becomes Once an association is branched off to a separate socket, it becomes
completely separated from the original socket. All subsequent completely separated from the original socket. All subsequent
control and data operations to that association must be done through control and data operations to that association must be done through
the new socket. For example, the close operation on the original the new socket. For example, the close() operation on the original
socket will not terminate any associations that have been branched socket will not terminate any associations that have been branched
off to a different socket. off to a different socket.
One-to-many style socket calls are discussed in more detail in the One-to-many style socket calls are discussed in more detail in the
following subsections. following subsections.
3.1.1. socket() 3.1.1. socket()
Applications use socket() to create a socket descriptor to represent Applications use socket() to create a socket descriptor to represent
an SCTP endpoint. an SCTP endpoint.
The function prototype is The function prototype is
int socket(int domain, int socket(int domain,
int type, int type,
int protocol); int protocol);
and one uses PF_INET or PF_INET6 as the domain, SOCK_SEQPACKET as the and one uses PF_INET or PF_INET6 as the domain, SOCK_SEQPACKET as the
type and IPPROTO_SCTP as the protocol. type, and IPPROTO_SCTP as the protocol.
Here, SOCK_SEQPACKET indicates the creation of a one-to-many style Here, SOCK_SEQPACKET indicates the creation of a one-to-many style
socket. socket.
The function returns a socket descriptor or -1 in case of an error. The function returns a socket descriptor, or -1 in case of an error.
Using the PF_INET domain indicates the creation of an endpoint which Using the PF_INET domain indicates the creation of an endpoint that
can use only IPv4 addresses, while PF_INET6 creates an endpoint which can use only IPv4 addresses, while PF_INET6 creates an endpoint that
can use both IPv6 and IPv4 addresses. can use both IPv6 and IPv4 addresses.
3.1.2. bind() 3.1.2. bind()
Applications use bind() to specify which local address and port the Applications use bind() to specify with which local address and port
SCTP endpoint should associate itself with. the SCTP endpoint should associate itself.
An SCTP endpoint can be associated with multiple addresses. To do An SCTP endpoint can be associated with multiple addresses. To do
this, sctp_bindx() is introduced in Section 9.1 to help applications this, sctp_bindx() is introduced in Section 9.1 to help applications
do the job of associating multiple addresses. But note that an do the job of associating multiple addresses. But note that an
endpoint can only be associated with one local port. endpoint can only be associated with one local port.
These addresses associated with a socket are the eligible transport These addresses associated with a socket are the eligible transport
addresses for the endpoint to send and receive data. The endpoint addresses for the endpoint to send and receive data. The endpoint
will also present these addresses to its peers during the association will also present these addresses to its peers during the association
initialization process, see [RFC4960]. initialization process; see [RFC4960].
After calling bind(), if the endpoint wishes to accept new After calling bind(), if the endpoint wishes to accept new
associations on the socket, it must call listen() (see associations on the socket, it must call listen() (see
Section 3.1.3). Section 3.1.3).
The function prototype of bind() is The function prototype of bind() is
int bind(int sd, int bind(int sd,
struct sockaddr *addr, struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
and the arguments are and the arguments are
sd: The socket descriptor returned by socket(). sd: The socket descriptor returned by socket().
addr: The address structure (struct sockaddr_in for an IPv4 address addr: The address structure (struct sockaddr_in for an IPv4 address
or struct sockaddr_in6 for an IPv6 address, see [RFC3493]). or struct sockaddr_in6 for an IPv6 address; see [RFC3493]).
addrlen: The size of the address structure. addrlen: The size of the address structure.
It returns 0 on success and -1 in case of an error. bind() returns 0 on success and -1 in case of an error.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv4 socket, the address passed must be an IPv4 address.
If the sd is an IPv6 socket, the address passed can either be an IPv4 If the sd is an IPv6 socket, the address passed can either be an IPv4
or an IPv6 address. or an IPv6 address.
Applications cannot call bind() multiple times to associate multiple Applications cannot call bind() multiple times to associate multiple
addresses to an endpoint. After the first call to bind(), all addresses to an endpoint. After the first call to bind(), all
subsequent calls will return an error. subsequent calls will return an error.
If the IP address part of addr is specified as a wildcard (INADDR_ANY If the IP address part of addr is specified as a wildcard (INADDR_ANY
for an IPv4 address, or as IN6ADDR_ANY_INIT or in6addr_any for an for an IPv4 address, or as IN6ADDR_ANY_INIT or in6addr_any for an
IPv6 address), the operating system will associate the endpoint with IPv6 address), the operating system will associate the endpoint with
an optimal address set of the available interfaces. If the IPv4 an optimal address set of the available interfaces. If the IPv4
sin_port or IPv6 sin6_port is set to 0, the operating system will sin_port or IPv6 sin6_port is set to 0, the operating system will
choose an ephemeral port for the endpoint. choose an ephemeral port for the endpoint.
If a bind() is not called prior to a sendmsg() call that initiates a If bind() is not called prior to a sendmsg() call that initiates a
new association, the system picks an ephemeral port and will choose new association, the system picks an ephemeral port and will choose
an address set equivalent to binding with a wildcard address. One of an address set equivalent to binding with a wildcard address. One of
those addresses will be the primary address for the association. those addresses will be the primary address for the association.
This automatically enables the multi-homing capability of SCTP. This automatically enables the multi-homing capability of SCTP.
The completion of this bind() process does not allow the SCTP The completion of this bind() process does not allow the SCTP
endpoint to accept inbound SCTP association requests. Until a endpoint to accept inbound SCTP association requests. Until a
listen() system call, described below, is performed on the socket, listen() system call, described below, is performed on the socket,
the SCTP endpoint will promptly reject an inbound SCTP INIT request the SCTP endpoint will promptly reject an inbound SCTP INIT request
with an SCTP ABORT. with an SCTP ABORT.
skipping to change at page 12, line 23 skipping to change at page 11, line 46
int listen(int sd, int listen(int sd,
int backlog); int backlog);
and the arguments are and the arguments are
sd: The socket descriptor of the endpoint. sd: The socket descriptor of the endpoint.
backlog: If backlog is non-zero, enable listening, else disable backlog: If backlog is non-zero, enable listening, else disable
listening. listening.
It returns 0 on success and -1 in case of an error. listen() returns 0 on success and -1 in case of an error.
Note that one-to-many style socket consumers do not need to call Note that one-to-many style socket consumers do not need to call
accept to retrieve new associations. Calling accept() on a one-to- accept() to retrieve new associations. Calling accept() on a one-to-
many style socket should return EOPNOTSUPP. Rather, new associations many style socket should return EOPNOTSUPP. Rather, new associations
are accepted automatically, and notifications of the new associations are accepted automatically, and notifications of the new associations
are delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if are delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if
these notifications are enabled). Clients will typically not call these notifications are enabled). Clients will typically not call
listen(), so that they can be assured that only actively initiated listen(), so that they can be assured that only actively initiated
associations are possible on the socket. Server or peer-to-peer associations are possible on the socket. Server or peer-to-peer
sockets, on the other hand, will always accept new associations, so a sockets, on the other hand, will always accept new associations, so a
well-written application using server one-to-many style sockets must well-written application using server one-to-many style sockets must
be prepared to handle new associations from unwanted peers. be prepared to handle new associations from unwanted peers.
Also note that the SCTP_ASSOC_CHANGE event provides the association Also note that the SCTP_ASSOC_CHANGE event provides the association
identifier for a new association, so if applications wish to use the identifier for a new association, so if applications wish to use the
association identifier as a parameter to other socket calls, they association identifier as a parameter to other socket calls, they
should ensure that the SCTP_ASSOC_CHANGE event is enabled. should ensure that the SCTP_ASSOC_CHANGE event is enabled.
3.1.4. sendmsg() and recvmsg() 3.1.4. sendmsg() and recvmsg()
An application uses the sendmsg() and recvmsg() call to transmit data An application uses the sendmsg() and recvmsg() calls to transmit
to and receive data from its peer. data to and receive data from its peer.
The function prototypes are The function prototypes are
ssize_t sendmsg(int sd, ssize_t sendmsg(int sd,
const struct msghdr *message, const struct msghdr *message,
int flags); int flags);
and and
ssize_t recvmsg(int sd, ssize_t recvmsg(int sd,
struct msghdr *message, struct msghdr *message,
int flags); int flags);
using the arguments: using the following arguments:
sd: The socket descriptor of the endpoint. sd: The socket descriptor of the endpoint.
message: Pointer to the msghdr structure which contains a single message: Pointer to the msghdr structure that contains a single user
user message and possibly some ancillary data. See Section 5 for message and possibly some ancillary data. See Section 5 for a
complete description of the data structures. complete description of the data structures.
flags: No new flags are defined for SCTP at this level. See flags: No new flags are defined for SCTP at this level. See
Section 5 for SCTP specific flags used in the msghdr structure. Section 5 for SCTP-specific flags used in the msghdr structure.
sendmsg() returns the number of bytes accepted by the kernel or -1 in sendmsg() returns the number of bytes accepted by the kernel or -1 in
case of an error. recvmsg() returns the number of bytes received or case of an error. recvmsg() returns the number of bytes received or
-1 in case of an error. -1 in case of an error.
As described in Section 5, different types of ancillary data can be As described in Section 5, different types of ancillary data can be
sent and received along with user data. When sending, the ancillary sent and received along with user data. When sending, the ancillary
data is used to specify the sent behavior, such as the SCTP stream data is used to specify the sent behavior, such as the SCTP stream
number to use. When receiving, the ancillary data is used to number to use. When receiving, the ancillary data is used to
describe the received data, such as the SCTP stream sequence number describe the received data, such as the SCTP stream sequence number
of the message. of the message.
When sending user data with sendmsg(), the msg_name field in the When sending user data with sendmsg(), the msg_name field in the
skipping to change at page 13, line 45 skipping to change at page 13, line 24
of the intended receiver. If there is no existing association of the intended receiver. If there is no existing association
between the sender and the intended receiver, the sender's SCTP stack between the sender and the intended receiver, the sender's SCTP stack
will set up a new association and then send the user data (see will set up a new association and then send the user data (see
Section 7.5 for more on implicit association setup). If sendmsg() is Section 7.5 for more on implicit association setup). If sendmsg() is
called with no data and there is no existing association, a new one called with no data and there is no existing association, a new one
will be established. The SCTP_INIT type ancillary data can be used will be established. The SCTP_INIT type ancillary data can be used
to change some of the parameters used to set up a new association. to change some of the parameters used to set up a new association.
If sendmsg() is called with NULL data, and there is no existing If sendmsg() is called with NULL data, and there is no existing
association but the SCTP_ABORT or SCTP_EOF flags are set as described association but the SCTP_ABORT or SCTP_EOF flags are set as described
in Section 5.3.4, then -1 is returned and errno is set to EINVAL. in Section 5.3.4, then -1 is returned and errno is set to EINVAL.
Sending a message using sendmsg() is atomic unless explicit EOR Sending a message using sendmsg() is atomic unless explicit end of
marking is enabled on the socket specified by sd (see record (EOR) marking is enabled on the socket specified by sd (see
Section 8.1.26). Section 8.1.26).
If a peer sends a SHUTDOWN, an SCTP_SHUTDOWN_EVENT notification will If a peer sends a SHUTDOWN, an SCTP_SHUTDOWN_EVENT notification will
be delivered if that notification has been enabled, and no more data be delivered if that notification has been enabled, and no more data
can be sent to that association. Any attempt to send more data will can be sent to that association. Any attempt to send more data will
cause sendmsg() to return with an ESHUTDOWN error. Note that the cause sendmsg() to return with an ESHUTDOWN error. Note that the
socket is still open for reading at this point so it is possible to socket is still open for reading at this point, so it is possible to
retrieve notifications. retrieve notifications.
When receiving a user message with recvmsg(), the msg_name field in When receiving a user message with recvmsg(), the msg_name field in
the msghdr structure will be populated with the source transport the msghdr structure will be populated with the source transport
address of the user data. The caller of recvmsg() can use this address of the user data. The caller of recvmsg() can use this
address information to determine to which association the received address information to determine to which association the received
user message belongs. Note that if SCTP_ASSOC_CHANGE events are user message belongs. Note that if SCTP_ASSOC_CHANGE events are
disabled, applications must use the peer transport address provided disabled, applications must use the peer transport address provided
in the msg_name field by recvmsg() to perform correlation to an in the msg_name field by recvmsg() to perform correlation to an
association, since they will not have the association identifier. association, since they will not have the association identifier.
skipping to change at page 14, line 30 skipping to change at page 14, line 11
receive a data message, MSG_EOR will not be set in msg_flags. receive a data message, MSG_EOR will not be set in msg_flags.
Successive reads will consume more of the same message until the Successive reads will consume more of the same message until the
entire message has been delivered, and MSG_EOR will be set. entire message has been delivered, and MSG_EOR will be set.
If the SCTP stack is running low on buffers, it may partially deliver If the SCTP stack is running low on buffers, it may partially deliver
a message. In this case, MSG_EOR will not be set, and more calls to a message. In this case, MSG_EOR will not be set, and more calls to
recvmsg() will be necessary to completely consume the message. Only recvmsg() will be necessary to completely consume the message. Only
one message at a time can be partially delivered in any stream. The one message at a time can be partially delivered in any stream. The
socket option SCTP_FRAGMENT_INTERLEAVE controls various aspects of socket option SCTP_FRAGMENT_INTERLEAVE controls various aspects of
what interlacing of messages occurs for both the one-to-one and the what interlacing of messages occurs for both the one-to-one and the
one-to-many model sockets. Please consult Section 8.1.20 for further one-to-many style sockets. Please consult Section 8.1.20 for further
details on message delivery options. details on message delivery options.
3.1.5. close() 3.1.5. close()
Applications use close() to perform graceful shutdown (as described Applications use close() to perform graceful shutdown (as described
in Section 10.1 of [RFC4960]) on all the associations currently in Section 10.1 of [RFC4960]) on all of the associations currently
represented by a one-to-many style socket. represented by a one-to-many style socket.
The function prototype is The function prototype is
int close(int sd); int close(int sd);
and the argument is and the argument is
sd: The socket descriptor of the associations to be closed. sd: The socket descriptor of the associations to be closed.
0 is returned on success and -1 in case of an error. 0 is returned on success and -1 in case of an error.
To gracefully shutdown a specific association represented by the one- To gracefully shut down a specific association represented by the
to-many style socket, an application should use the sendmsg() call, one-to-many style socket, an application should use the sendmsg()
and include the SCTP_EOF flag. A user may optionally terminate an call and include the SCTP_EOF flag. A user may optionally terminate
association non-gracefully by sending with the SCTP_ABORT flag set an association non-gracefully by using sendmsg() with the SCTP_ABORT
and possibly passing a user specified abort code in the data field. flag set and possibly passing a user-specified abort code in the data
Both flags SCTP_EOF and SCTP_ABORT are passed with ancillary data field. Both flags SCTP_EOF and SCTP_ABORT are passed with ancillary
(see Section 5.3.4) in the sendmsg() call. data (see Section 5.3.4) in the sendmsg() call.
If sd in the close() call is a branched-off socket representing only If sd in the close() call is a branched-off socket representing only
one association, the shutdown is performed on that association only. one association, the shutdown is performed on that association only.
3.1.6. connect() 3.1.6. connect()
An application may use the connect() call in the one-to-many style to An application may use the connect() call in the one-to-many style to
initiate an association without sending data. initiate an association without sending data.
The function prototype is The function prototype is
int connect(int sd, int connect(int sd,
const struct sockaddr *nam, const struct sockaddr *nam,
socklen_t len); socklen_t len);
and the arguments are and the arguments are
sd: The socket descriptor to have a new association added to. sd: The socket descriptor to which a new association is added.
nam: The address structure (struct sockaddr_in for an IPv4 address nam: The address structure (struct sockaddr_in for an IPv4 address
or struct sockaddr_in6 for an IPv6 address, see [RFC3493]). or struct sockaddr_in6 for an IPv6 address; see [RFC3493]).
len: The size of the address. len: The size of the address.
0 is returned on success and -1 in case of an error. 0 is returned on success and -1 in case of an error.
Multiple connect() calls can be made on the same socket to create Multiple connect() calls can be made on the same socket to create
multiple associations. This is different from the semantics of multiple associations. This is different from the semantics of
connect() on a UDP socket. connect() on a UDP socket.
Note that SCTP allows data exchange, similar to T/TCP [RFC1644], Note that SCTP allows data exchange, similar to T/TCP [RFC1644] (made
during the association set up phase. If an application wants to do Historic by [RFC6247]), during the association setup phase. If an
this, it cannot use the connect() call. Instead, it should use application wants to do this, it cannot use the connect() call.
sendto() or sendmsg() to initiate an association. If it uses Instead, it should use sendto() or sendmsg() to initiate an
sendto() and it wants to change the initialization behavior, it needs association. If it uses sendto() and it wants to change the
to use the SCTP_INITMSG socket option before calling sendto(). Or it initialization behavior, it needs to use the SCTP_INITMSG socket
can use sendmsg() with SCTP_INIT type ancillary data to initiate an option before calling sendto(). Or it can use sendmsg() with
association without calling setsockopt(). Note that the implicit SCTP_INIT type ancillary data to initiate an association without
setup is supported for the one-to-many style sockets. calling setsockopt(). Note that the implicit setup is supported for
the one-to-many style sockets.
SCTP does not support half close semantics. This means that unlike SCTP does not support half close semantics. This means that unlike
T/TCP, MSG_EOF should not be set in the flags parameter when calling T/TCP, MSG_EOF should not be set in the flags parameter when calling
sendto() or sendmsg() when the call is used to initiate a connection. sendto() or sendmsg() when the call is used to initiate a connection.
MSG_EOF is not an acceptable flag with an SCTP socket. MSG_EOF is not an acceptable flag with an SCTP socket.
3.2. Non-blocking mode 3.2. Non-Blocking Mode
Some SCTP application may wish to avoid being blocked when calling a Some SCTP applications may wish to avoid being blocked when calling a
socket interface function. socket interface function.
Once a bind() and/or subsequent sctp_bindx() calls are complete on a Once a bind() call and/or subsequent sctp_bindx() calls are complete
one-to-many style socket, an application may set the non-blocking on a one-to-many style socket, an application may set the
option by a fcntl() (such as O_NONBLOCK). After setting the socket non-blocking option via a fcntl() (such as O_NONBLOCK). After
to non-blocking mode, the sendmsg() function returns immediately. setting the socket to non-blocking mode, the sendmsg() function
The success or failure of sending the data message (with possible returns immediately. The success or failure of sending the data
SCTP_INITMSG ancillary data) will be signaled by the message (with possible SCTP_INITMSG ancillary data) will be signaled
SCTP_ASSOC_CHANGE event with SCTP_COMM_UP or SCTP_CANT_START_ASSOC. by the SCTP_ASSOC_CHANGE event with SCTP_COMM_UP or
If user data could not be sent (due to a SCTP_CANT_START_ASSOC), the SCTP_CANT_START_ASSOC. If user data could not be sent (due to an
sender will also receive an SCTP_SEND_FAILED_EVENT event. Events can SCTP_CANT_START_ASSOC), the sender will also receive an
be received by the user calling recvmsg(). A server (having called SCTP_SEND_FAILED_EVENT event. Events can be received by the user
listen()) is also notified of an association up event by the calling recvmsg(). A server (having called listen()) is also
reception of an SCTP_ASSOC_CHANGE with SCTP_COMM_UP via the calling notified of an association-up event via the reception of an
of recvmsg() and possibly the reception of the first data message. SCTP_ASSOC_CHANGE with SCTP_COMM_UP via the calling of recvmsg() and
possibly the reception of the first data message.
To shutdown the association gracefully, the user must call sendmsg() To shut down the association gracefully, the user must call sendmsg()
with no data and with the SCTP_EOF flag set as described in with no data and with the SCTP_EOF flag set as described in
Section 5.3.4. The function returns immediately, and completion of Section 5.3.4. The function returns immediately, and completion of
the graceful shutdown is indicated by an SCTP_ASSOC_CHANGE the graceful shutdown is indicated by an SCTP_ASSOC_CHANGE
notification of type SHUTDOWN_COMPLETE (see Section 6.1.1). Note notification of type SCTP_SHUTDOWN_COMP (see Section 6.1.1). Note
that this can also be done using the sctp_sendv() call described in that this can also be done using the sctp_sendv() call described in
Section 9.12. Section 9.12.
An application is recommended to use caution when using select() (or It is recommended that an application use caution when using select()
poll()) for writing on a one-to-many style socket. The reason being (or poll()) for writing on a one-to-many style socket, because the
that the interpretation of select on write is implementation interpretation of select() on write is implementation specific.
specific. Generally a positive return on a select on write would Generally, a positive return on a select() on write would only
only indicate that one of the associations represented by the one-to- indicate that one of the associations represented by the one-to-many
many socket is writable. An application that writes after the style socket is writable. An application that writes after the
select() returns may still block since the association that was select() returns may still block, since the association that was
writeable is not the destination association of the write call. writable is not the destination association of the write call.
Likewise select() (or poll()) for reading from a one-to-many socket Likewise, select() (or poll()) for reading from a one-to-many style
will only return an indication that one of the associations socket will only return an indication that one of the associations
represented by the socket has data to be read. represented by the socket has data to be read.
An application that wishes to know that a particular association is An application that wishes to know that a particular association is
ready for reading or writing should either use the one-to-one style ready for reading or writing should either use the one-to-one style
or use the sctp_peeloff() (see Section 9.2) function to separate the or use the sctp_peeloff() function (see Section 9.2) to separate the
association of interest from the one-to-many socket. association of interest from the one-to-many style socket.
Note some implementations may have an extended select call such as Note that some implementations may have an extended select call, such
epoll or kqueue that may escape this limitation and allow a select on as epoll or kqueue, that may escape this limitation and allow a
a specific association of a one-to-many socket, but this is an select on a specific association of a one-to-many style socket, but
implementation specific detail that a portable application cannot this is an implementation-specific detail that a portable application
depend on. cannot depend on.
3.3. Special considerations 3.3. Special Considerations
The fact that a one-to-many style socket can provide access to many The fact that a one-to-many style socket can provide access to many
SCTP associations through a single socket descriptor, has important SCTP associations through a single socket descriptor has important
implications for both application programmers and system programmers implications for both application programmers and system programmers
implementing this API. A key issue is how buffer space inside the implementing this API. A key issue is how buffer space inside the
sockets layer is managed. Because this implementation detail sockets layer is managed. Because this implementation detail
directly affects how application programmers must write their code to directly affects how application programmers must write their code to
ensure correct operation and portability, this section provides some ensure correct operation and portability, this section provides some
guidance to both implementers and application programmers. guidance to both implementers and application programmers.
An important feature that SCTP shares with TCP is flow control. An important feature that SCTP shares with TCP is flow control.
Specifically, a sender may not send data faster than the receiver can Specifically, a sender may not send data faster than the receiver can
consume it. consume it.
For TCP, flow control is typically provided for in the sockets API as For TCP, flow control is typically provided for in the sockets API as
follows. If the reader stops reading, the sender queues messages in follows. If the reader stops reading, the sender queues messages in
the socket layer until the send socket buffer is completely filled. the socket layer until the send socket buffer is completely filled.
This results in a "stalled connection". Further attempts to write to This results in a "stalled connection". Further attempts to write to
the socket will block or return the error EAGAIN or EWOULDBLOCK for a the socket will block or return the error EAGAIN or EWOULDBLOCK for a
non-blocking socket. At some point, either the connection is closed, non-blocking socket. At some point, either the connection is closed,
or the receiver begins to read again freeing space in the output or the receiver begins to read, again freeing space in the output
queue. queue.
For one-to-one style SCTP sockets (this includes sockets descriptors For one-to-one style SCTP sockets (this includes sockets descriptors
that were separated from a one-to-many style socket with that were separated from a one-to-many style socket with
sctp_peeloff()) the behavior is identical. For one-to-many style sctp_peeloff()), the behavior is identical. For one-to-many style
SCTP sockets there are multiple associations for a single socket, SCTP sockets, there are multiple associations for a single socket,
which makes the situation more complicated. If the implementation which makes the situation more complicated. If the implementation
uses a single buffer space allocation shared by all associations, a uses a single buffer space allocation shared by all associations, a
single stalled association can prevent the further sending of data on single stalled association can prevent the further sending of data on
all associations active on a particular one-to-many style socket. all associations active on a particular one-to-many style socket.
For a blocking socket, it should be clear that a single stalled For a blocking socket, it should be clear that a single stalled
association can block the entire socket. For this reason, association can block the entire socket. For this reason,
application programmers may want to use non-blocking one-to-many application programmers may want to use non-blocking one-to-many
style sockets. The application should at least be able to send style sockets. The application should at least be able to send
messages to the non-stalled associations. messages to the non-stalled associations.
skipping to change at page 18, line 11 skipping to change at page 17, line 47
non-stalled associations. non-stalled associations.
The API implementer can solve this problem by providing each The API implementer can solve this problem by providing each
association with its own allocation of outbound buffer space. Each association with its own allocation of outbound buffer space. Each
association should conceptually have as much buffer space as it would association should conceptually have as much buffer space as it would
have if it had its own socket. As a bonus, this simplifies the have if it had its own socket. As a bonus, this simplifies the
implementation of sctp_peeloff(). implementation of sctp_peeloff().
To ensure that a given stalled association will not prevent other To ensure that a given stalled association will not prevent other
non-stalled associations from being writable, application programmers non-stalled associations from being writable, application programmers
should either: should either
o demand that the underlying implementation dedicates independent o demand that the underlying implementation dedicates independent
buffer space reservation to each association (as suggested above), buffer space reservation to each association (as suggested
or above), or
o verify that their application layer protocol does not permit large o verify that their application-layer protocol does not permit large
amounts of unread data at the receiver (this is true of some amounts of unread data at the receiver (this is true of some
request-response protocols, for example), or request-response protocols, for example), or
o use one-to-one style sockets for association which may potentially o use one-to-one style sockets for association, which may
stall (either from the beginning, or by using sctp_peeloff before potentially stall (either from the beginning, or by using
sending large amounts of data that may cause a stalled condition). sctp_peeloff() before sending large amounts of data that may cause
a stalled condition).
4. One-to-One Style Interface 4. One-to-One Style Interface
The goal of this style is to follow as closely as possible the The goal of this style is to follow as closely as possible the
current practice of using the sockets interface for a connection current practice of using the sockets interface for a connection-
oriented protocol, such as TCP. This style enables existing oriented protocol such as TCP. This style enables existing
applications using connection oriented protocols to be ported to SCTP applications using connection-oriented protocols to be ported to SCTP
with very little effort. with very little effort.
One-to-one style sockets can be connected (explicitly or implicitly) One-to-one style sockets can be connected (explicitly or implicitly)
at most once, similar to TCP sockets. at most once, similar to TCP sockets.
Note that some new SCTP features and some new SCTP socket options can Note that some new SCTP features and some new SCTP socket options can
only be utilized through the use of sendmsg() and recvmsg() calls, only be utilized through the use of sendmsg() and recvmsg() calls;
see Section 4.1.8. see Section 4.1.8.
4.1. Basic Operation 4.1. Basic Operation
A typical server in one-to-one style uses the following system call A typical one-to-one style server uses the following system call
sequence to prepare an SCTP endpoint for servicing requests: sequence to prepare an SCTP endpoint for servicing requests:
o socket() o socket()
o bind() o bind()
o listen() o listen()
o accept() o accept()
The accept() call blocks until a new association is set up. It The accept() call blocks until a new association is set up. It
returns with a new socket descriptor. The server then uses the new returns with a new socket descriptor. The server then uses the new
socket descriptor to communicate with the client, using recv() and socket descriptor to communicate with the client, using recv() and
send() calls to get requests and send back responses. send() calls to get requests and send back responses.
Then it calls Then it calls
o close() o close()
skipping to change at page 19, line 17 skipping to change at page 19, line 5
returns with a new socket descriptor. The server then uses the new returns with a new socket descriptor. The server then uses the new
socket descriptor to communicate with the client, using recv() and socket descriptor to communicate with the client, using recv() and
send() calls to get requests and send back responses. send() calls to get requests and send back responses.
Then it calls Then it calls
o close() o close()
to terminate the association. to terminate the association.
A typical client uses the following system call sequence to setup an A typical client uses the following system call sequence to set up an
association with a server to request services: association with a server to request services:
o socket() o socket()
o connect() o connect()
After returning from connect(), the client uses send()/sendmsg() and After returning from the connect() call, the client uses send()/
recv()/recvmsg() calls to send out requests and receive responses sendmsg() and recv()/recvmsg() calls to send out requests and receive
from the server. responses from the server.
The client calls The client calls
o close() o close()
to terminate this association when done. to terminate this association when done.
4.1.1. socket() 4.1.1. socket()
Applications call socket() to create a socket descriptor to represent Applications call socket() to create a socket descriptor to represent
an SCTP endpoint. an SCTP endpoint.
The function prototype is The function prototype is
int socket(int domain, int socket(int domain,
int type, int type,
int protocol); int protocol);
and one uses PF_INET or PF_INET6 as the domain, SOCK_STREAM as the and one uses PF_INET or PF_INET6 as the domain, SOCK_STREAM as the
type and IPPROTO_SCTP as the protocol. type, and IPPROTO_SCTP as the protocol.
Here, SOCK_STREAM indicates the creation of a one-to-one style Here, SOCK_STREAM indicates the creation of a one-to-one style
socket. socket.
Using the PF_INET domain indicates the creation of an endpoint which Using the PF_INET domain indicates the creation of an endpoint that
can use only IPv4 addresses, while PF_INET6 creates an endpoint which can use only IPv4 addresses, while PF_INET6 creates an endpoint that
can use both IPv6 and IPv4 addresses. can use both IPv6 and IPv4 addresses.
4.1.2. bind() 4.1.2. bind()
Applications use bind() to specify which local address and port the Applications use bind() to specify with which local address and port
SCTP endpoint should associate itself with. the SCTP endpoint should associate itself.
An SCTP endpoint can be associated with multiple addresses. To do An SCTP endpoint can be associated with multiple addresses. To do
this, sctp_bindx() is introduced in Section 9.1 to help applications this, sctp_bindx() is introduced in Section 9.1 to help applications
do the job of associating multiple addresses. But note that an do the job of associating multiple addresses. But note that an
endpoint can only be associated with one local port. endpoint can only be associated with one local port.
These addresses associated with a socket are the eligible transport These addresses associated with a socket are the eligible transport
addresses for the endpoint to send and receive data. The endpoint addresses for the endpoint to send and receive data. The endpoint
will also present these addresses to its peers during the association will also present these addresses to its peers during the association
initialization process, see [RFC4960]. initialization process; see [RFC4960].
The function prototype of bind() is The function prototype of bind() is
int bind(int sd, int bind(int sd,
struct sockaddr *addr, struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
and the arguments are and the arguments are
sd: The socket descriptor returned by socket(). sd: The socket descriptor returned by socket().
addr: The address structure (struct sockaddr_in for an IPv4 address addr: The address structure (struct sockaddr_in for an IPv4 address
or struct sockaddr_in6 for an IPv6 address, see [RFC3493]). or struct sockaddr_in6 for an IPv6 address; see [RFC3493]).
addrlen: The size of the address structure. addrlen: The size of the address structure.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv4 socket, the address passed must be an IPv4 address.
If sd is an IPv6 socket, the address passed can either be an IPv4 or If sd is an IPv6 socket, the address passed can either be an IPv4 or
an IPv6 address. an IPv6 address.
Applications cannot call bind() multiple times to associate multiple Applications cannot call bind() multiple times to associate multiple
addresses to the endpoint. After the first call to bind(), all addresses to the endpoint. After the first call to bind(), all
subsequent calls will return an error. subsequent calls will return an error.
If the IP address part of addr is specified as a wildcard (INADDR_ANY If the IP address part of addr is specified as a wildcard (INADDR_ANY
for an IPv4 address, or as IN6ADDR_ANY_INIT or in6addr_any for an for an IPv4 address, or as IN6ADDR_ANY_INIT or in6addr_any for an
IPv6 address), the operating system will associate the endpoint with IPv6 address), the operating system will associate the endpoint with
an optimal address set of the available interfaces. If the IPv4 an optimal address set of the available interfaces. If the IPv4
sin_port or IPv6 sin6_port is set to 0, the operating system will sin_port or IPv6 sin6_port is set to 0, the operating system will
choose an ephemeral port for the endpoint. choose an ephemeral port for the endpoint.
If a bind() is not called prior to the connect() call, the system If bind() is not called prior to the connect() call, the system picks
picks an ephemeral port and will choose an address set equivalent to an ephemeral port and will choose an address set equivalent to
binding with a wildcard address. One of these addresses will be the binding with a wildcard address. One of these addresses will be the
primary address for the association. This automatically enables the primary address for the association. This automatically enables the
multi-homing capability of SCTP. multi-homing capability of SCTP.
The completion of this bind() process does not allow the SCTP The completion of this bind() process does not allow the SCTP
endpoint to accept inbound SCTP association requests. Until a endpoint to accept inbound SCTP association requests. Until a
listen() system call, described below, is performed on the socket, listen() system call, described below, is performed on the socket,
the SCTP endpoint will promptly reject an inbound SCTP INIT request the SCTP endpoint will promptly reject an inbound SCTP INIT request
with an SCTP ABORT. with an SCTP ABORT.
skipping to change at page 21, line 29 skipping to change at page 21, line 17
Applications use listen() to allow the SCTP endpoint to accept Applications use listen() to allow the SCTP endpoint to accept
inbound associations. inbound associations.
The function prototype is The function prototype is
int listen(int sd, int listen(int sd,
int backlog); int backlog);
and the arguments are and the arguments are
sd: the socket descriptor of the SCTP endpoint. sd: The socket descriptor of the SCTP endpoint.
backlog: this specifies the max number of outstanding associations backlog: Specifies the max number of outstanding associations
allowed in the socket's accept queue. These are the associations allowed in the socket's accept queue. These are the associations
that have finished the four-way initiation handshake (see Section that have finished the four-way initiation handshake (see
5 of [RFC4960]) and are in the ESTABLISHED state. Note, a backlog Section 5 of [RFC4960]) and are in the ESTABLISHED state. Note
of '0' indicates that the caller no longer wishes to receive new that a backlog of '0' indicates that the caller no longer wishes
associations. to receive new associations.
It returns 0 on success an -1 in case of an error. listen() returns 0 on success and -1 in case of an error.
4.1.4. accept() 4.1.4. accept()
Applications use the accept() call to remove an established SCTP Applications use the accept() call to remove an established SCTP
association from the accept queue of the endpoint. A new socket association from the accept queue of the endpoint. A new socket
descriptor will be returned from accept() to represent the newly descriptor will be returned from accept() to represent the newly
formed association. formed association.
The function prototype is The function prototype is
int accept(int sd, int accept(int sd,
struct sockaddr *addr, struct sockaddr *addr,
socklen_t *addrlen); socklen_t *addrlen);
and the arguments are and the arguments are
sd: The listening socket descriptor. sd: The listening socket descriptor.
addr: On return, addr (struct sockaddr_in for an IPv4 address or addr: On return, addr (struct sockaddr_in for an IPv4 address or
struct sockaddr_in6 for an IPv6 address, see [RFC3493]) will struct sockaddr_in6 for an IPv6 address; see [RFC3493]) will
contain the primary address of the peer endpoint. contain the primary address of the peer endpoint.
addrlen: On return, addrlen will contain the size of addr. addrlen: On return, addrlen will contain the size of addr.
The function returns the socket descriptor for the newly formed The function returns the socket descriptor for the newly formed
association on success and -1 in case of an error. association on success and -1 in case of an error.
4.1.5. connect() 4.1.5. connect()
Applications use connect() to initiate an association to a peer. Applications use connect() to initiate an association to a peer.
skipping to change at page 22, line 33 skipping to change at page 22, line 20
int connect(int sd, int connect(int sd,
const struct sockaddr *addr, const struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
and the arguments are and the arguments are
sd: The socket descriptor of the endpoint. sd: The socket descriptor of the endpoint.
addr: The peer's (struct sockaddr_in for an IPv4 address or struct addr: The peer's (struct sockaddr_in for an IPv4 address or struct
sockaddr_in6 for an IPv6 address, see [RFC3493]) address. sockaddr_in6 for an IPv6 address; see [RFC3493]) address.
addrlen: The size of the address. addrlen: The size of the address.
It returns 0 on success and -1 on error. connect() returns 0 on success and -1 on error.
This operation corresponds to the ASSOCIATE primitive described in This operation corresponds to the ASSOCIATE primitive described in
Section 10.1 of [RFC4960]. Section 10.1 of [RFC4960].
The number of outbound streams the new association has is stack The number of outbound streams the new association has is stack
dependent. Applications can use the SCTP_INITMSG option described in dependent. Before connecting, applications can use the SCTP_INITMSG
Section 8.1.3 before connecting to change the number of outbound option described in Section 8.1.3 to change the number of outbound
streams. streams.
If a bind() is not called prior to the connect() call, the system If bind() is not called prior to the connect() call, the system picks
picks an ephemeral port and will choose an address set equivalent to an ephemeral port and will choose an address set equivalent to
binding with INADDR_ANY and IN6ADDR_ANY_INIT for IPv4 and IPv6 socket binding with INADDR_ANY and IN6ADDR_ANY_INIT for IPv4 and IPv6
respectively. One of the addresses will be the primary address for sockets, respectively. One of the addresses will be the primary
the association. This automatically enables the multi-homing address for the association. This automatically enables the
capability of SCTP. multi-homing capability of SCTP.
Note that SCTP allows data exchange, similar to T/TCP [RFC1644], Note that SCTP allows data exchange, similar to T/TCP [RFC1644] (made
during the association set up phase. If an application wants to do Historic by [RFC6247]), during the association setup phase. If an
this, it cannot use the connect() call. Instead, it should use application wants to do this, it cannot use the connect() call.
sendto() or sendmsg() to initiate an association. If it uses Instead, it should use sendto() or sendmsg() to initiate an
sendto() and it wants to change the initialization behavior, it needs association. If it uses sendto() and it wants to change the
to use the SCTP_INITMSG socket option before calling sendto(). Or it initialization behavior, it needs to use the SCTP_INITMSG socket
can use sendmsg() with SCTP_INIT type ancillary data to initiate an option before calling sendto(). Or it can use sendmsg() with
association without calling setsockopt(). Note that the implicit SCTP_INIT type ancillary data to initiate an association without
setup is supported for the one-to-one style sockets. calling setsockopt(). Note that the implicit setup is supported for
the one-to-one style sockets.
SCTP does not support half close semantics. This means that unlike SCTP does not support half close semantics. This means that unlike
T/TCP, MSG_EOF should not be set in the flags parameter when calling T/TCP, MSG_EOF should not be set in the flags parameter when calling
sendto() or sendmsg() when the call is used to initiate a connection. sendto() or sendmsg() when the call is used to initiate a connection.
MSG_EOF is not an acceptable flag with an SCTP socket. MSG_EOF is not an acceptable flag with an SCTP socket.
4.1.6. close() 4.1.6. close()
Applications use close() to gracefully close down an association. Applications use close() to gracefully close down an association.
The function prototype is The function prototype is
int close(int sd); int close(int sd);
and the argument is and the argument is
sd: The socket descriptor of the association to be closed. sd: The socket descriptor of the association to be closed.
It returns 0 on success and -1 in case of an error. close() returns 0 on success and -1 in case of an error.
After an application calls close() on a socket descriptor, no further After an application calls close() on a socket descriptor, no further
socket operations will succeed on that descriptor. socket operations will succeed on that descriptor.
4.1.7. shutdown() 4.1.7. shutdown()
SCTP differs from TCP in that it does not have half closed semantics. SCTP differs from TCP in that it does not have half close semantics.
Hence the shutdown() call for SCTP is an approximation of the TCP Hence, the shutdown() call for SCTP is an approximation of the TCP
shutdown() call, and solves some different problems. Full TCP- shutdown() call, and solves some different problems. Full TCP
compatibility is not provided, so developers porting TCP applications compatibility is not provided, so developers porting TCP applications
to SCTP may need to recode sections that use shutdown(). (Note that to SCTP may need to recode sections that use shutdown(). (Note that
it is possible to achieve the same results as half close in SCTP it is possible to achieve the same results as half close in SCTP
using SCTP streams.) using SCTP streams.)
The function prototype is The function prototype is
int shutdown(int sd, int shutdown(int sd,
int how); int how);
skipping to change at page 24, line 14 skipping to change at page 24, line 5
sd: The socket descriptor of the association to be closed. sd: The socket descriptor of the association to be closed.
how: Specifies the type of shutdown. The values are as follows: how: Specifies the type of shutdown. The values are as follows:
SHUT_RD: Disables further receive operations. No SCTP protocol SHUT_RD: Disables further receive operations. No SCTP protocol
action is taken. action is taken.
SHUT_WR: Disables further send operations, and initiates the SCTP SHUT_WR: Disables further send operations, and initiates the SCTP
shutdown sequence. shutdown sequence.
SHUT_RDWR: Disables further send and receive operations and SHUT_RDWR: Disables further send and receive operations, and
initiates the SCTP shutdown sequence. initiates the SCTP shutdown sequence.
It returns 0 on success and -1 in case of an error. shutdown() returns 0 on success and -1 in case of an error.
The major difference between SCTP and TCP shutdown() is that SCTP The major difference between SCTP and TCP shutdown() is that SCTP
SHUT_WR initiates immediate and full protocol shutdown, whereas TCP SHUT_WR initiates immediate and full protocol shutdown, whereas TCP
SHUT_WR causes TCP to go into the half closed state. SHUT_RD behaves SHUT_WR causes TCP to go into the half close state. SHUT_RD behaves
the same for SCTP as TCP. The purpose of SCTP SHUT_WR is to close the same for SCTP as for TCP. The purpose of SCTP SHUT_WR is to
the SCTP association while still leaving the socket descriptor open. close the SCTP association while still leaving the socket descriptor
This allows the caller to receive back any data which SCTP is unable open. This allows the caller to receive back any data that SCTP is
to deliver (see Section 6.1.4 for more information) and receive event unable to deliver (see Section 6.1.4 for more information) and
notifications. receive event notifications.
To perform the ABORT operation described in [RFC4960] Section 10.1, To perform the ABORT operation described in Section 10.1 of
an application can use the socket option SO_LINGER. It is described [RFC4960], an application can use the socket option SO_LINGER.
in Section 8.1.4. SO_LINGER is described in Section 8.1.4.
4.1.8. sendmsg() and recvmsg() 4.1.8. sendmsg() and recvmsg()
With a one-to-one style socket, the application can also use With a one-to-one style socket, the application can also use
sendmsg() and recvmsg() to transmit data to and receive data from its sendmsg() and recvmsg() to transmit data to and receive data from its
peer. The semantics is similar to those used in the one-to-many peer. The semantics is similar to those used in the one-to-many
style (see Section 3.1.4), with the following differences: style (see Section 3.1.4), with the following differences:
1. When sending, the msg_name field in the msghdr is not used to 1. When sending, the msg_name field in the msghdr is not used to
specify the intended receiver, rather it is used to indicate a specify the intended receiver; rather, it is used to indicate a
preferred peer address if the sender wishes to discourage the preferred peer address if the sender wishes to discourage the
stack from sending the message to the primary address of the stack from sending the message to the primary address of the
receiver. If the socket is connected and the transport address receiver. If the socket is connected and the transport address
given is not part of the current association, the data will not given is not part of the current association, the data will not
be sent and an SCTP_SEND_FAILED_EVENT event will be delivered to be sent, and an SCTP_SEND_FAILED_EVENT event will be delivered to
the application if send failure events are enabled. the application if send failure events are enabled.
2. Using sendmsg() on a non-connected one-to-one style socket for 2. Using sendmsg() on a non-connected one-to-one style socket for
implicit connection setup may or may not work depending on the implicit connection setup may or may not work, depending on the
SCTP implementation. SCTP implementation.
4.1.9. getpeername() 4.1.9. getpeername()
Applications use getpeername() to retrieve the primary socket address Applications use getpeername() to retrieve the primary socket address
of the peer. This call is for TCP compatibility, and is not multi- of the peer. This call is for TCP compatibility and is not
homed. It may not work with one-to-many style sockets depending on multi-homed. It may not work with one-to-many style sockets,
the implementation. See Section 9.3 for a multi-homed style version depending on the implementation. See Section 9.3 for a multi-homed
of the call. style version of the call.
The function prototype is The function prototype is
int getpeername(int sd, int getpeername(int sd,
struct sockaddr *address, struct sockaddr *address,
socklen_t *len); socklen_t *len);
and the arguments are: and the arguments are
sd: The socket descriptor to be queried. sd: The socket descriptor to be queried.
address: On return, the peer primary address is stored in this address: On return, the peer primary address is stored in this
buffer. If the socket is an IPv4 socket, the address will be buffer. If the socket is an IPv4 socket, the address will be
IPv4. If the socket is an IPv6 socket, the address will be either IPv4. If the socket is an IPv6 socket, the address will be either
an IPv6 or IPv4 address. an IPv6 or IPv4 address.
len: The caller should set the length of address here. On return, len: The caller should set the length of address here. On return,
this is set to the length of the returned address. this is set to the length of the returned address.
It returns 0 on success and -1 in case of an error. getpeername() returns 0 on success and -1 in case of an error.
If the actual length of the address is greater than the length of the If the actual length of the address is greater than the length of the
supplied sockaddr structure, the stored address will be truncated. supplied sockaddr structure, the stored address will be truncated.
5. Data Structures 5. Data Structures
This section discusses important data structures which are specific This section discusses important data structures that are specific to
to SCTP and are used with sendmsg() and recvmsg() calls to control SCTP and are used with sendmsg() and recvmsg() calls to control SCTP
SCTP endpoint operations and to access ancillary information and endpoint operations and to access ancillary information and
notifications. notifications.
5.1. The msghdr and cmsghdr Structures 5.1. The msghdr and cmsghdr Structures
The msghdr structure used in the sendmsg() and recvmsg() calls, as The msghdr structure used in the sendmsg() and recvmsg() calls, as
well as the ancillary data carried in the structure, is the key for well as the ancillary data carried in the structure, is the key for
the application to set and get various control information from the the application to set and get various control information from the
SCTP endpoint. SCTP endpoint.
The msghdr and the related cmsghdr structures are defined and The msghdr and the related cmsghdr structures are defined and
discussed in detail in [RFC3542]. They are defined as: discussed in detail in [RFC3542]. They are defined as
struct msghdr { struct msghdr {
void *msg_name; /* ptr to socket address structure */ void *msg_name; /* ptr to socket address structure */
socklen_t msg_namelen; /* size of socket address structure */ socklen_t msg_namelen; /* size of socket address structure */
struct iovec *msg_iov; /* scatter/gather array */ struct iovec *msg_iov; /* scatter/gather array */
int msg_iovlen; /* # elements in msg_iov */ int msg_iovlen; /* # elements in msg_iov */
void *msg_control; /* ancillary data */ void *msg_control; /* ancillary data */
socklen_t msg_controllen; /* ancillary data buffer length */ socklen_t msg_controllen; /* ancillary data buffer length */
int msg_flags; /* flags on received message */ int msg_flags; /* flags on received message */
}; };
struct cmsghdr { struct cmsghdr {
socklen_t cmsg_len; /* #bytes, including this header */ socklen_t cmsg_len; /* # bytes, including this header */
int cmsg_level; /* originating protocol */ int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */ int cmsg_type; /* protocol-specific type */
/* followed by unsigned char cmsg_data[]; */ /* followed by unsigned char cmsg_data[]; */
}; };
In the msghdr structure, the usage of msg_name has been discussed in In the msghdr structure, the usage of msg_name has been discussed in
previous sections (see Section 3.1.4 and Section 4.1.8). previous sections (see Sections 3.1.4 and 4.1.8).
The scatter/gather buffers, or I/O vectors (pointed to by the msg_iov The scatter/gather buffers, or I/O vectors (pointed to by the msg_iov
field) are treated by SCTP as a single user message for both field) are treated by SCTP as a single user message for both
sendmsg() and recvmsg(). sendmsg() and recvmsg().
SCTP stack uses the ancillary data (msg_control field) to communicate The SCTP stack uses the ancillary data (msg_control field) to
the attributes, such as SCTP_RCVINFO, of the message stored in communicate the attributes, such as SCTP_RCVINFO, of the message
msg_iov to the socket end point. The different ancillary data types stored in msg_iov to the socket endpoint. The different ancillary
are described in Section 5.3. data types are described in Section 5.3.
The msg_flags are not used when sending a message with sendmsg(). The msg_flags are not used when sending a message with sendmsg().
If a notification has arrived, recvmsg() will return the notification If a notification has arrived, recvmsg() will return the notification
in msg_iov field and set MSG_NOTIFICATION flag in msg_flags. If the in the msg_iov field and set the MSG_NOTIFICATION flag in msg_flags.
MSG_NOTIFICATION flag is not set, recvmsg() will return data. See If the MSG_NOTIFICATION flag is not set, recvmsg() will return data.
Section 6 for more information about notifications. See Section 6 for more information about notifications.
If all portions of a data frame or notification have been read, If all portions of a data frame or notification have been read,
recvmsg() will return with MSG_EOR set in msg_flags. recvmsg() will return with MSG_EOR set in msg_flags.
5.2. Ancillary Data Considerations and Semantics 5.2. Ancillary Data Considerations and Semantics
Programming with ancillary socket data (msg_control) contains some Programming with ancillary socket data (msg_control) contains some
subtleties and pitfalls, which are discussed below. subtleties and pitfalls, which are discussed below.
5.2.1. Multiple Items and Ordering 5.2.1. Multiple Items and Ordering
Multiple ancillary data items may be included in any call to Multiple ancillary data items may be included in any call to
sendmsg() or recvmsg(); these may include multiple SCTP or non-SCTP, sendmsg() or recvmsg(); these may include multiple SCTP items,
such as IP level items, or both. non-SCTP items (such as IP-level items), or both.
The ordering of ancillary data items (either by SCTP or another The ordering of ancillary data items (either by SCTP or another
protocol) is not significant and is implementation-dependent, so protocol) is not significant and is implementation dependent, so
applications must not depend on any ordering. applications must not depend on any ordering.
SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO type ancillary data always SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO type ancillary data always
correspond to the data in the msghdr's msg_iov member. There can be corresponds to the data in the msghdr's msg_iov member. There can be
only one single such type ancillary data for each sendmsg() or only one such type of ancillary data for each sendmsg() or recvmsg()
recvmsg() call. call.
5.2.2. Accessing and Manipulating Ancillary Data 5.2.2. Accessing and Manipulating Ancillary Data
Applications can infer the presence of data or ancillary data by Applications can infer the presence of data or ancillary data by
examining the msg_iovlen and msg_controllen msghdr members, examining the msg_iovlen and msg_controllen msghdr members,
respectively. respectively.
Implementations may have different padding requirements for ancillary Implementations may have different padding requirements for ancillary
data, so portable applications should make use of the macros data, so portable applications should make use of the macros
CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_SPACE, and CMSG_LEN. See CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_SPACE, and CMSG_LEN. See
skipping to change at page 27, line 37 skipping to change at page 27, line 42
struct msghdr msg; struct msghdr msg;
struct cmsghdr *cmsgptr; struct cmsghdr *cmsgptr;
/* fill in msg */ /* fill in msg */
/* call recvmsg() */ /* call recvmsg() */
for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) { cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
if (cmsgptr->cmsg_len == 0) {
/* Error handling */
break;
}
if (cmsgptr->cmsg_level == ... && cmsgptr->cmsg_type == ... ) { if (cmsgptr->cmsg_level == ... && cmsgptr->cmsg_type == ... ) {
u_char *ptr; u_char *ptr;
ptr = CMSG_DATA(cmsgptr); ptr = CMSG_DATA(cmsgptr);
/* process data pointed to by ptr */ /* process data pointed to by ptr */
} }
} }
5.2.3. Control Message Buffer Sizing 5.2.3. Control Message Buffer Sizing
The information conveyed via SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO The information conveyed via SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO
ancillary data will often be fundamental to the correct and sane ancillary data will often be fundamental to the correct and sane
operation of the sockets application. This is particularly true of operation of the sockets application. This is particularly true for
the one-to-many semantics, but also of the one-to-one semantics. For one-to-many style sockets, but also for one-to-one style sockets.
example, if an application needs to send and receive data on For example, if an application needs to send and receive data on
different SCTP streams, SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO different SCTP streams, SCTP_SNDRCV/SCTP_SNDINFO/SCTP_RCVINFO
ancillary data is indispensable. ancillary data is indispensable.
Given that some ancillary data is critical, and that multiple Given that some ancillary data is critical, and that multiple
ancillary data items may appear in any order, applications should be ancillary data items may appear in any order, applications should be
carefully written to always provide a large enough buffer to contain carefully written to always provide a large enough buffer to contain
all possible ancillary data that can be presented by recvmsg(). If all possible ancillary data that can be presented by recvmsg(). If
the buffer is too small, and crucial data is truncated, it may pose a the buffer is too small, and crucial data is truncated, it may pose a
fatal error condition. fatal error condition.
Thus, it is essential that applications be able to deterministically Thus, it is essential that applications be able to deterministically
calculate the maximum required buffer size to pass to recvmsg(). One calculate the maximum required buffer size to pass to recvmsg(). One
constraint imposed on this specification that makes this possible is constraint imposed on this specification that makes this possible is
that all ancillary data definitions are of a fixed length. One way that all ancillary data definitions are of a fixed length. One way
to calculate the maximum required buffer size might be to take the to calculate the maximum required buffer size might be to take the
sum the sizes of all enabled ancillary data item structures, as sum of the sizes of all enabled ancillary data item structures, as
calculated by CMSG_SPACE. For example, if we enabled calculated by CMSG_SPACE. For example, if we enabled
SCTP_SNDRCV_INFO and IPV6_RECVPKTINFO [RFC3542], we would calculate SCTP_SNDRCV_INFO and IPV6_RECVPKTINFO [RFC3542], we would calculate
and allocate the buffer size as follows: and allocate the buffer size as follows:
size_t total; size_t total;
void *buf; void *buf;
total = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)) + total = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)) +
CMSG_SPACE(sizeof(struct in6_pktinfo)); CMSG_SPACE(sizeof(struct in6_pktinfo));
buf = malloc(total); buf = malloc(total);
We could then use this buffer (buf) for msg_control on each call to We could then use this buffer (buf) for msg_control on each call to
recvmsg() and be assured that we would not lose any ancillary data to recvmsg() and be assured that we would not lose any ancillary data to
truncation. truncation.
5.3. SCTP msg_control Structures 5.3. SCTP msg_control Structures
A key element of all SCTP specific socket extensions is the use of A key element of all SCTP-specific socket extensions is the use of
ancillary data to specify and access SCTP specific data via the ancillary data to specify and access SCTP-specific data via the
struct msghdr's msg_control member used in sendmsg() and recvmsg(). msghdr structure's msg_control member used in sendmsg() and
Fine-grained control over initialization and sending parameters are recvmsg(). Fine-grained control over initialization and sending
handled with ancillary data. parameters are handled with ancillary data.
Each ancillary data item is proceeded by a struct cmsghdr (see Each ancillary data item is preceded by a struct cmsghdr (see
Section 5.1), which defines the function and purpose of the data Section 5.1), which defines the function and purpose of the data
contained in the cmsg_data[] member. contained in the cmsg_data[] member.
By default on either style socket, SCTP will pass no ancillary data; By default, on either style of socket, SCTP will pass no ancillary
Specific ancillary data items can be enabled with socket options data. Specific ancillary data items can be enabled with socket
defined for SCTP; see Section 6.2. options defined for SCTP; see Section 6.2.
Note that all ancillary types are fixed length; see Section 5.2 for Note that all ancillary types are of fixed length; see Section 5.2
further discussion on this. These data structures use struct for further discussion on this. These data structures use struct
sockaddr_storage (defined in [RFC3493]) as a portable, fixed length sockaddr_storage (defined in [RFC3493]) as a portable, fixed-length
address format. address format.
Other protocols may also provide ancillary data to the socket layer Other protocols may also provide ancillary data to the socket layer
consumer. These ancillary data items from other protocols may consumer. These ancillary data items from other protocols may
intermingle with SCTP data. For example, the IPv6 socket API intermingle with SCTP data. For example, the IPv6 sockets API
definitions ([RFC3542] and [RFC3493]) define a number of ancillary definitions ([RFC3542] and [RFC3493]) define a number of ancillary
data items. If a socket API consumer enables delivery of both SCTP data items. If a sockets API consumer enables delivery of both SCTP
and IPv6 ancillary data, they both may appear in the same msg_control and IPv6 ancillary data, they both may appear in the same msg_control
buffer in any order. An application may thus need to handle other buffer in any order. An application may thus need to handle other
types of ancillary data besides those passed by SCTP. types of ancillary data besides those passed by SCTP.
The sockets application must provide a buffer large enough to The sockets application must provide a buffer large enough to
accommodate all ancillary data provided via recvmsg(). If the buffer accommodate all ancillary data provided via recvmsg(). If the buffer
is not large enough, the ancillary data will be truncated and the is not large enough, the ancillary data will be truncated and the
msghdr's msg_flags will include MSG_CTRUNC. msghdr's msg_flags will include MSG_CTRUNC.
5.3.1. SCTP Initiation Structure (SCTP_INIT) 5.3.1. SCTP Initiation Structure (SCTP_INIT)
skipping to change at page 29, line 44 skipping to change at page 30, line 4
+--------------+-----------+---------------------+ +--------------+-----------+---------------------+
The sctp_initmsg structure is defined below: The sctp_initmsg structure is defined below:
struct sctp_initmsg { struct sctp_initmsg {
uint16_t sinit_num_ostreams; uint16_t sinit_num_ostreams;
uint16_t sinit_max_instreams; uint16_t sinit_max_instreams;
uint16_t sinit_max_attempts; uint16_t sinit_max_attempts;
uint16_t sinit_max_init_timeo; uint16_t sinit_max_init_timeo;
}; };
sinit_num_ostreams: This is an integer representing the number of
sinit_num_ostreams: This is an integer number representing the streams to which the application wishes to be able to send. This
number of streams that the application wishes to be able to send number is confirmed in the SCTP_COMM_UP notification and must be
to. This number is confirmed in the SCTP_COMM_UP notification and verified, since it is a negotiated number with the remote
must be verified since it is a negotiated number with the remote endpoint. The default value of 0 indicates the use of the
endpoint. The default value of 0 indicates to use the endpoint endpoint's default value.
default value.
sinit_max_instreams: This value represents the maximum number of sinit_max_instreams: This value represents the maximum number of
inbound streams the application is prepared to support. This inbound streams the application is prepared to support. This
value is bounded by the actual implementation. In other words the value is bounded by the actual implementation. In other words,
user may be able to support more streams than the Operating the user may be able to support more streams than the operating
System. In such a case, the Operating System limit overrides the system. In such a case, the operating-system limit overrides the
value requested by the user. The default value of 0 indicates to value requested by the user. The default value of 0 indicates the
use the endpoints default value. use of the endpoint's default value.
sinit_max_attempts: This integer specifies how many attempts the sinit_max_attempts: This integer specifies how many attempts the
SCTP endpoint should make at resending the INIT. This value SCTP endpoint should make at resending the INIT. This value
overrides the system SCTP 'Max.Init.Retransmits' value. The overrides the system SCTP 'Max.Init.Retransmits' value. The
default value of 0 indicates to use the endpoints default value. default value of 0 indicates the use of the endpoint's default
This is normally set to the system's default 'Max.Init.Retransmit' value. This is normally set to the system's default
value. 'Max.Init.Retransmit' value.
sinit_max_init_timeo: This value represents the largest Time-Out or sinit_max_init_timeo: This value represents the largest timeout or
RTO value (in milliseconds) to use in attempting an INIT. retransmission timeout (RTO) value (in milliseconds) to use in
Normally the 'RTO.Max' is used to limit the doubling of the RTO attempting an INIT. Normally, the 'RTO.Max' is used to limit the
upon timeout. For the INIT message this value may override doubling of the RTO upon timeout. For the INIT message, this
'RTO.Max'. This value must not influence 'RTO.Max' during data value may override 'RTO.Max'. This value must not influence
transmission and is only used to bound the initial setup time. A 'RTO.Max' during data transmission and is only used to bound the
default value of 0 indicates to use the endpoints default value. initial setup time. A default value of 0 indicates the use of the
This is normally set to the system's 'RTO.Max' value (60 seconds). endpoint's default value. This is normally set to the system's
'RTO.Max' value (60 seconds).
5.3.2. SCTP Header Information Structure (SCTP_SNDRCV) - DEPRECATED 5.3.2. SCTP Header Information Structure (SCTP_SNDRCV) - DEPRECATED
This cmsghdr structure specifies SCTP options for sendmsg() and This cmsghdr structure specifies SCTP options for sendmsg() and
describes SCTP header information about a received message through describes SCTP header information about a received message through
recvmsg(). This structure mixes the send and receive path. recvmsg(). This structure mixes the send and receive path.
SCTP_SNDINFO described in Section 5.3.4 and SCTP_RCVINFO described in SCTP_SNDINFO (described in Section 5.3.4) and SCTP_RCVINFO (described
Section 5.3.5 split this information. These structures should be in Section 5.3.5) split this information. These structures should be
used, when possible, since SCTP_SNDRCV is deprecated. used, when possible, since SCTP_SNDRCV is deprecated.
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
| IPPROTO_SCTP | SCTP_SNDRCV | struct sctp_sndrcvinfo | | IPPROTO_SCTP | SCTP_SNDRCV | struct sctp_sndrcvinfo |
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
The sctp_sndrcvinfo structure is defined below: The sctp_sndrcvinfo structure is defined below:
skipping to change at page 31, line 17 skipping to change at page 31, line 19
uint16_t sinfo_ssn; uint16_t sinfo_ssn;
uint16_t sinfo_flags; uint16_t sinfo_flags;
uint32_t sinfo_ppid; uint32_t sinfo_ppid;
uint32_t sinfo_context; uint32_t sinfo_context;
uint32_t sinfo_timetolive; uint32_t sinfo_timetolive;
uint32_t sinfo_tsn; uint32_t sinfo_tsn;
uint32_t sinfo_cumtsn; uint32_t sinfo_cumtsn;
sctp_assoc_t sinfo_assoc_id; sctp_assoc_t sinfo_assoc_id;
}; };
sinfo_stream: For recvmsg() the SCTP stack places the message's sinfo_stream: For recvmsg(), the SCTP stack places the message's
stream number in this value. For sendmsg() this value holds the stream number in this value. For sendmsg(), this value holds the
stream number that the application wishes to send this message to. stream number to which the application wishes to send this
If a sender specifies an invalid stream number an error indication message. If a sender specifies an invalid stream number, an error
is returned and the call fails. indication is returned and the call fails.
sinfo_ssn: For recvmsg() this value contains the stream sequence sinfo_ssn: For recvmsg(), this value contains the stream sequence
number that the remote endpoint placed in the DATA chunk. For number that the remote endpoint placed in the DATA chunk. For
fragmented messages this is the same number for all deliveries of fragmented messages, this is the same number for all deliveries of
the message (if more than one recvmsg() is needed to read the the message (if more than one recvmsg() is needed to read the
message). The sendmsg() call will ignore this parameter. message). The sendmsg() call will ignore this parameter.
sinfo_flags: This field may contain any of the following flags and sinfo_flags: This field may contain any of the following flags and
is composed of a bitwise OR of these values. is composed of a bitwise OR of these values.
recvmsg() flags: recvmsg() flags:
SCTP_UNORDERED: This flag is present when the message was sent SCTP_UNORDERED: This flag is present when the message was sent
un-ordered. unordered.
sendmsg() flags: sendmsg() flags:
SCTP_UNORDERED: This flag requests the un-ordered delivery of SCTP_UNORDERED: This flag requests the unordered delivery of
the message. If this flag is clear the datagram is the message. If this flag is clear, the datagram is
considered an ordered send. considered an ordered send.
SCTP_ADDR_OVER: This flag, in the one-to-many style, requests SCTP_ADDR_OVER: This flag, for a one-to-many style socket,
the SCTP stack to override the primary destination address requests that the SCTP stack override the primary
with the address found with the sendto/sendmsg call. destination address with the address found with the sendto/
sendmsg call.
SCTP_ABORT: Setting this flag causes the specified association SCTP_ABORT: Setting this flag causes the specified association
to abort by sending an ABORT message to the peer. The ABORT to abort by sending an ABORT message to the peer. The ABORT
chunk will contain an error cause 'User Initiated Abort' chunk will contain an error cause of 'User Initiated Abort'
with cause code 12. The cause specific information of this with cause code 12. The cause-specific information of this
error cause is provided in msg_iov. error cause is provided in msg_iov.
SCTP_EOF: Setting this flag invokes the SCTP graceful shutdown SCTP_EOF: Setting this flag invokes the SCTP graceful shutdown
procedure on the specified association. Graceful shutdown procedure on the specified association. Graceful shutdown
assures that all data queued by both endpoints is assures that all data queued by both endpoints is
successfully transmitted before closing the association. successfully transmitted before closing the association.
SCTP_SENDALL: This flag, if set, will cause a one-to-many SCTP_SENDALL: This flag, if set, will cause a one-to-many
model socket to send the message to all associations that style socket to send the message to all associations that
are currently established on this socket. For the one-to- are currently established on this socket. For the one-to-
one socket, this flag has no effect. one style socket, this flag has no effect.
sinfo_ppid: This value in sendmsg() is an unsigned integer that is sinfo_ppid: This value in sendmsg() is an unsigned integer that is
passed to the remote end in each user message. In recvmsg() this passed to the remote end in each user message. In recvmsg(), this
value is the same information that was passed by the upper layer value is the same information that was passed by the upper layer
in the peer application. Please note that the SCTP stack performs in the peer application. Please note that the SCTP stack performs
no byte order modification of this field. For example, if the no byte order modification of this field. For example, if the
DATA chunk has to contain a given value in network byte order, the DATA chunk has to contain a given value in network byte order, the
SCTP user has to perform the htonl() computation. SCTP user has to perform the htonl() computation.
sinfo_context: This value is an opaque 32 bit context datum that is sinfo_context: This value is an opaque 32-bit context datum that is
used in the sendmsg() function. This value is passed back to the used in the sendmsg() function. This value is passed back to the
upper layer if an error occurs on the send of a message and is upper layer if an error occurs on the send of a message and is
retrieved with each undelivered message. retrieved with each undelivered message.
sinfo_timetolive: For the sending side, this field contains the sinfo_timetolive: For the sending side, this field contains the
message time to live in milliseconds. The sending side will message's time to live, in milliseconds. The sending side will
expire the message within the specified time period if the message expire the message within the specified time period if the message
as not been sent to the peer within this time period. This value has not been sent to the peer within this time period. This value
will override any default value set using any socket option. Also will override any default value set using any socket option. Also
note that the value of 0 is special in that it indicates no note that the value of 0 is special in that it indicates no
timeout should occur on this message. timeout should occur on this message.
sinfo_tsn: For the receiving side, this field holds a TSN that was sinfo_tsn: For the receiving side, this field holds a Transmission
assigned to one of the SCTP Data Chunks. For the sending side it Sequence Number (TSN) that was assigned to one of the SCTP DATA
is ignored. chunks. For the sending side, it is ignored.
sinfo_cumtsn: This field will hold the current cumulative TSN as sinfo_cumtsn: This field will hold the current cumulative TSN as
known by the underlying SCTP layer. Note this field is ignored known by the underlying SCTP layer. Note that this field is
when sending. ignored when sending.
sinfo_assoc_id: The association handle field, sinfo_assoc_id, holds sinfo_assoc_id: The association handle field, sinfo_assoc_id, holds
the identifier for the association announced in the SCTP_COMM_UP the identifier for the association announced in the SCTP_COMM_UP
notification. All notifications for a given association have the notification. All notifications for a given association have the
same identifier. Ignored for one-to-one style sockets. same identifier. This field is ignored for one-to-one style
sockets.
An sctp_sndrcvinfo item always corresponds to the data in msg_iov. An sctp_sndrcvinfo item always corresponds to the data in msg_iov.
5.3.3. Extended SCTP Header Information Structure (SCTP_EXTRCV) - 5.3.3. Extended SCTP Header Information Structure (SCTP_EXTRCV) -
DEPRECATED DEPRECATED
This cmsghdr structure specifies SCTP options for SCTP header This cmsghdr structure specifies SCTP options for SCTP header
information about a received message via recvmsg(). Note that this information about a received message via recvmsg(). Note that this
structure is an extended version of SCTP_SNDRCV (see Section 5.3.2) structure is an extended version of SCTP_SNDRCV (see Section 5.3.2)
and will only be received if the user has set the socket option 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 SCTP_USE_EXT_RCVINFO (see Section 8.1.22) to true in addition to any
needed to receive ancillary data. See Section 8.1.22 on this socket event subscription needed to receive ancillary data. Note that data
option. Note that next message data is not valid unless the current in the next message is not valid unless the current message is
message is completely read, i.e. the MSG_EOR is set, in other words completely read, i.e., unless the MSG_EOR is set; in other words, if
if the application has more data to read from the current message the application has more data to read from the current message, then
then no next message information will be available. no next-message information will be available.
SCTP_NXTINFO described in Section 5.3.6 should be used when possible, SCTP_NXTINFO (described in Section 5.3.6) should be used when
since SCTP_EXTRCV is considered deprecated. possible, since SCTP_EXTRCV is considered deprecated.
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
| IPPROTO_SCTP | SCTP_EXTRCV | struct sctp_extrcvinfo | | IPPROTO_SCTP | SCTP_EXTRCV | struct sctp_extrcvinfo |
+--------------+-------------+------------------------+ +--------------+-------------+------------------------+
The sctp_extrcvinfo structure is defined below: The sctp_extrcvinfo structure is defined below:
struct sctp_extrcvinfo { struct sctp_extrcvinfo {
skipping to change at page 33, line 47 skipping to change at page 34, line 24
uint32_t sinfo_tsn; uint32_t sinfo_tsn;
uint32_t sinfo_cumtsn; uint32_t sinfo_cumtsn;
uint16_t serinfo_next_flags; uint16_t serinfo_next_flags;
uint16_t serinfo_next_stream; uint16_t serinfo_next_stream;
uint32_t serinfo_next_aid; uint32_t serinfo_next_aid;
uint32_t serinfo_next_length; uint32_t serinfo_next_length;
uint32_t serinfo_next_ppid; uint32_t serinfo_next_ppid;
sctp_assoc_t sinfo_assoc_id; sctp_assoc_t sinfo_assoc_id;
}; };
sinfo_*: Please see Section 5.3.2 for the details for these fields. sinfo_*: Please see Section 5.3.2 for details for these fields.
serinfo_next_flags: This bitmask will hold one or more of the serinfo_next_flags: This bitmask will hold one or more of the
following values: following values:
SCTP_NEXT_MSG_AVAIL: This bit, when set to 1, indicates that next SCTP_NEXT_MSG_AVAIL: This bit, when set to 1, indicates that
message information is available i.e.: next_stream, next-message information is available; i.e., next_stream,
next_asocid, next_length and next_ppid fields all have valid next_aid, next_length, and next_ppid fields all have valid
values. If this bit is set to 0, then these fields are not values. If this bit is set to 0, then these fields are not
valid and should be ignored. valid and should be ignored.
SCTP_NEXT_MSG_ISCOMPLETE: This bit, when set, indicates that the SCTP_NEXT_MSG_ISCOMPLETE: This bit, when set, indicates that the
next message is completely in the receive buffer. The next message is completely in the receive buffer. The
next_length field thus contains the entire message size. If next_length field thus contains the entire message size. If
this flag is set to 0, then the next_length field only contains this flag is set to 0, then the next_length field only contains
part of the message size since the message is still being part of the message size, since the message is still being
received (it is being partially delivered). received (it is being partially delivered).
SCTP_NEXT_MSG_IS_UNORDERED: This bit, when set, indicates that SCTP_NEXT_MSG_IS_UNORDERED: This bit, when set, indicates that
the next message to be received was sent by the peer as 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 unordered. If this bit is not set (i.e., the bit is 0) the
message to be read is an ordered message in the stream next message to be read is an ordered message in the stream
specified. specified.
SCTP_NEXT_MSG_IS_NOTIFICATION: This bit, when set, indicates that SCTP_NEXT_MSG_IS_NOTIFICATION: This bit, when set, indicates that
the next message to be received is not a message from the peer, the next message to be received is not a message from the peer,
but instead is a MSG_NOTIFICATION from the local SCTP stack. but instead is a MSG_NOTIFICATION from the local SCTP stack.
serinfo_next_stream: This value, when valid (see serinfo_next_stream: This value, when valid (see
serinfo_next_flags), contains the next stream number that will be serinfo_next_flags), contains the next stream number that will be
received on a subsequent call to one of the receive message received on a subsequent call to one of the receive message
functions. functions.
serinfo_next_aid: This value, when valid (see serinfo_next_flags), serinfo_next_aid: This value, when valid (see serinfo_next_flags),
contains the next association identifier that will be received on contains the next association identifier that will be received on
a subsequent call to one of the receive message functions. a subsequent call to one of the receive message functions.
serinfo_next_length: This value, when valid (see serinfo_next_length: This value, when valid (see
serinfo_next_flags), contains the length of the next message that serinfo_next_flags), contains the length of the next message that
will be received on a subsequent call to one of the receive will be received on a subsequent call to one of the receive
message functions. Note that this length may be a partial length message functions. Note that this length may be a partial length,
depending on the settings of next_flags. depending on the settings of next_flags.
serinfo_next_ppid: This value, when valid (see serinfo_next_flags), serinfo_next_ppid: This value, when valid (see serinfo_next_flags),
contains the ppid of the next message that will be received on a contains the ppid of the next message that will be received on a
subsequent call to one of the receive message functions. subsequent call to one of the receive message functions.
5.3.4. SCTP Send Information Structure (SCTP_SNDINFO) 5.3.4. SCTP Send Information Structure (SCTP_SNDINFO)
This cmsghdr structure specifies SCTP options for sendmsg(). This cmsghdr structure specifies SCTP options for sendmsg().
skipping to change at page 35, line 21 skipping to change at page 35, line 44
The sctp_sndinfo structure is defined below: The sctp_sndinfo structure is defined below:
struct sctp_sndinfo { struct sctp_sndinfo {
uint16_t snd_sid; uint16_t snd_sid;
uint16_t snd_flags; uint16_t snd_flags;
uint32_t snd_ppid; uint32_t snd_ppid;
uint32_t snd_context; uint32_t snd_context;
sctp_assoc_t snd_assoc_id; sctp_assoc_t snd_assoc_id;
}; };
snd_sid: This value holds the stream number that the application snd_sid: This value holds the stream number to which the application
wishes to send this message to. If a sender specifies an invalid wishes to send this message. If a sender specifies an invalid
stream number an error indication is returned and the call fails. stream number, an error indication is returned and the call fails.
snd_flags: This field may contain any of the following flags and is snd_flags: This field may contain any of the following flags and is
composed of a bitwise OR of these values. composed of a bitwise OR of these values.
SCTP_UNORDERED: This flag requests the un-ordered delivery of the SCTP_UNORDERED: This flag requests the unordered delivery of the
message. If this flag is clear the datagram is considered an message. If this flag is clear, the datagram is considered an
ordered send. ordered send.
SCTP_ADDR_OVER: This flag, in the one-to-many style, requests the SCTP_ADDR_OVER: This flag, for a one-to-many style socket,
SCTP stack to override the primary destination address with the requests that the SCTP stack override the primary destination
address found with the sendto()/sendmsg call. address with the address found with the sendto()/sendmsg call.
SCTP_ABORT: Setting this flag causes the specified association to SCTP_ABORT: Setting this flag causes the specified association to
abort by sending an ABORT message to the peer. The ABORT chunk abort by sending an ABORT message to the peer. The ABORT chunk
will contain an error cause 'User Initiated Abort' with cause will contain an error cause of 'User Initiated Abort' with
code 12. The cause specific information of this error cause is cause code 12. The cause-specific information of this error
provided in msg_iov. cause is provided in msg_iov.
SCTP_EOF: Setting this flag invokes the SCTP graceful shutdown SCTP_EOF: Setting this flag invokes the SCTP graceful shutdown
procedures on the specified association. Graceful shutdown procedures on the specified association. Graceful shutdown
assures that all data queued by both endpoints is successfully assures that all data queued by both endpoints is successfully
transmitted before closing the association. transmitted before closing the association.
SCTP_SENDALL: This flag, if set, will cause a one-to-many model SCTP_SENDALL: This flag, if set, will cause a one-to-many style
socket to send the message to all associations that are socket to send the message to all associations that are
currently established on this socket. For the one-to-one currently established on this socket. For the one-to-one style
socket, this flag has no effect. socket, this flag has no effect.
snd_ppid: This value in sendmsg() is an unsigned integer that is snd_ppid: This value in sendmsg() is an unsigned integer that is
passed to the remote end in each user message. Please note that passed to the remote end in each user message. Please note that
the SCTP stack performs no byte order modification of this field. the SCTP stack performs no byte order modification of this field.
For example, if the DATA chunk has to contain a given value in For example, if the DATA chunk has to contain a given value in
network byte order, the SCTP user has to perform the htonl() network byte order, the SCTP user has to perform the htonl()
computation. computation.
snd_context: This value is an opaque 32 bit context datum that is snd_context: This value is an opaque 32-bit context datum that is
used in the sendmsg() function. This value is passed back to the used in the sendmsg() function. This value is passed back to the
upper layer if an error occurs on the send of a message and is upper layer if an error occurs on the send of a message and is
retrieved with each undelivered message. retrieved with each undelivered message.
snd_assoc_id: The association handle field, sinfo_assoc_id, holds snd_assoc_id: The association handle field, sinfo_assoc_id, holds
the identifier for the association announced in the SCTP_COMM_UP the identifier for the association announced in the SCTP_COMM_UP
notification. All notifications for a given association have the notification. All notifications for a given association have the
same identifier. Ignored for one-to-one style sockets. same identifier. This field is ignored for one-to-one style
sockets.
An sctp_sndinfo item always corresponds to the data in msg_iov. An sctp_sndinfo item always corresponds to the data in msg_iov.
5.3.5. SCTP Receive Information Structure (SCTP_RCVINFO) 5.3.5. SCTP Receive Information Structure (SCTP_RCVINFO)
This cmsghdr structure describes SCTP receive information about a This cmsghdr structure describes SCTP receive information about a
received message through recvmsg(). received message through recvmsg().
To enable the delivery of this information an application must use To enable the delivery of this information, an application must use
the SCTP_RECVRCVINFO socket option (see Section 8.1.29). the SCTP_RECVRCVINFO socket option (see Section 8.1.29).
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
| IPPROTO_SCTP | SCTP_RCVINFO | struct sctp_rcvinfo | | IPPROTO_SCTP | SCTP_RCVINFO | struct sctp_rcvinfo |
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
The sctp_rcvinfo structure is defined below: The sctp_rcvinfo structure is defined below:
skipping to change at page 37, line 4 skipping to change at page 37, line 31
struct sctp_rcvinfo { struct sctp_rcvinfo {
uint16_t rcv_sid; uint16_t rcv_sid;
uint16_t rcv_ssn; uint16_t rcv_ssn;
uint16_t rcv_flags; uint16_t rcv_flags;
uint32_t rcv_ppid; uint32_t rcv_ppid;
uint32_t rcv_tsn; uint32_t rcv_tsn;
uint32_t rcv_cumtsn; uint32_t rcv_cumtsn;
uint32_t rcv_context; uint32_t rcv_context;
sctp_assoc_t rcv_assoc_id; sctp_assoc_t rcv_assoc_id;
}; };
rcv_sid: The SCTP stack places the message's stream number in this rcv_sid: The SCTP stack places the message's stream number in this
value. value.
rcv_ssn: This value contains the stream sequence number that the rcv_ssn: This value contains the stream sequence number that the
remote endpoint placed in the DATA chunk. For fragmented messages remote endpoint placed in the DATA chunk. For fragmented
this is the same number for all deliveries of the message (if more messages, this is the same number for all deliveries of the
than one recvmsg() is needed to read the message). message (if more than one recvmsg() is needed to read the
message).
rcv_flags: This field may contain any of the following flags and is rcv_flags: This field may contain any of the following flags and is
composed of a bitwise OR of these values. composed of a bitwise OR of these values.
SCTP_UNORDERED: This flag is present when the message was sent SCTP_UNORDERED: This flag is present when the message was sent
un-ordered. unordered.
rcv_ppid: This value is the same information that was passed by the rcv_ppid: This value is the same information that was passed by the
upper layer in the peer application. Please note that the SCTP upper layer in the peer application. Please note that the SCTP
stack performs no byte order modification of this field. For stack performs no byte order modification of this field. For
example, if the DATA chunk has to contain a given value in network example, if the DATA chunk has to contain a given value in network
byte order, the SCTP user has to perform the ntohl() computation. byte order, the SCTP user has to perform the ntohl() computation.
rcv_tsn: This field holds a TSN that was assigned to one of the SCTP rcv_tsn: This field holds a TSN that was assigned to one of the SCTP
Data Chunks. DATA chunks.
rcv_cumtsn: This field will hold the current cumulative TSN as known rcv_cumtsn: This field will hold the current cumulative TSN as known
by the underlying SCTP layer. by the underlying SCTP layer.
rcv_assoc_id: The association handle field, sinfo_assoc_id, holds rcv_context: This value is an opaque 32-bit context datum that was
the identifier for the association announced in the SCTP_COMM_UP
notification. All notifications for a given association have the
same identifier. Ignored for one-to-one style sockets.
rcv_context: This value is an opaque 32 bit context datum that was
set by the user with the SCTP_CONTEXT socket option. This value set by the user with the SCTP_CONTEXT socket option. This value
is passed back to the upper layer if an error occurs on the send is passed back to the upper layer if an error occurs on the send
of a message and is retrieved with each undelivered message. of a message and is retrieved with each undelivered message.
rcv_assoc_id: The association handle field, sinfo_assoc_id, holds
the identifier for the association announced in the SCTP_COMM_UP
notification. All notifications for a given association have the
same identifier. This field is ignored for one-to-one style
sockets.
An sctp_rcvinfo item always corresponds to the data in msg_iov. An sctp_rcvinfo item always corresponds to the data in msg_iov.
5.3.6. SCTP Next Receive Information Structure (SCTP_NXTINFO) 5.3.6. SCTP Next Receive Information Structure (SCTP_NXTINFO)
This cmsghdr structure describes SCTP receive information of the next This cmsghdr structure describes SCTP receive information of the next
message which will be delivered through recvmsg() if this information message that will be delivered through recvmsg() if this information
is already available when delivering the current message. is already available when delivering the current message.
To enable the delivery of this information an application must use To enable the delivery of this information, an application must use
the SCTP_RECVNXTINFO socket option (see Section 8.1.30). the SCTP_RECVNXTINFO socket option (see Section 8.1.30).
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
| IPPROTO_SCTP | SCTP_NXTINFO | struct sctp_nxtinfo | | IPPROTO_SCTP | SCTP_NXTINFO | struct sctp_nxtinfo |
+--------------+--------------+---------------------+ +--------------+--------------+---------------------+
The sctp_nxtinfo structure is defined below: The sctp_nxtinfo structure is defined below:
skipping to change at page 38, line 20 skipping to change at page 39, line 4
The sctp_nxtinfo structure is defined below: The sctp_nxtinfo structure is defined below:
struct sctp_nxtinfo { struct sctp_nxtinfo {
uint16_t nxt_sid; uint16_t nxt_sid;
uint16_t nxt_flags; uint16_t nxt_flags;
uint32_t nxt_ppid; uint32_t nxt_ppid;
uint32_t nxt_length; uint32_t nxt_length;
sctp_assoc_t nxt_assoc_id; sctp_assoc_t nxt_assoc_id;
}; };
nxt_sid: The SCTP stack places the next message's stream number in nxt_sid: The SCTP stack places the next message's stream number in
this value. this value.
nxt_flags: This field may contain any of the following flags and is nxt_flags: This field may contain any of the following flags and is
composed of a bitwise OR of these values. composed of a bitwise OR of these values.
SCTP_UNORDERED: This flag is present when the next message was SCTP_UNORDERED: This flag is present when the next message was
sent un-ordered. sent unordered.
SCTP_COMPLETE: This flag indicates that the entire message has SCTP_COMPLETE: This flag indicates that the entire message has
been received and is in the socket buffer. Note that this has been received and is in the socket buffer. Note that this has
special implications with respect to the nxt_length field, see special implications with respect to the nxt_length field; see
nxt_length description below. the description for nxt_length below.
SCTP_NOTIFICATION: This flag is present when the next message is SCTP_NOTIFICATION: This flag is present when the next message is
not a user message but instead is a notification. not a user message but instead is a notification.
nxt_ppid: This value is the same information that was passed by the nxt_ppid: This value is the same information that was passed by the
upper layer in the peer application for the next message. Please upper layer in the peer application for the next message. Please
note that the SCTP stack performs no byte order modification of note that the SCTP stack performs no byte order modification of
this field. For example, if the DATA chunk has to contain a given this field. For example, if the DATA chunk has to contain a given
value in network byte order, the SCTP user has to perform the value in network byte order, the SCTP user has to perform the
ntohl() computation. ntohl() computation.
nxt_length: This value is the length of the message currently within nxt_length: This value is the length of the message currently within
the socket buffer. This might NOT be the entire length of the the socket buffer. This might NOT be the entire length of the
message since a partial delivery may be in progress. Only if the message, since a partial delivery may be in progress. Only if the
flag SCTP_COMPLETE is set in the nxt_flags field does this field flag SCTP_COMPLETE is set in the nxt_flags field does this field
represent the entire next message size. represent the size of the entire next message.
nxt_assoc_id: The association handle field of the next message, nxt_assoc_id: The association handle field of the next message,
nxt_assoc_id, holds the identifier for the association announced nxt_assoc_id, holds the identifier for the association announced
in the SCTP_COMM_UP notification. All notifications for a given in the SCTP_COMM_UP notification. All notifications for a given
association have the same identifier. Ignored for one-to-one association have the same identifier. This field is ignored for
style sockets. one-to-one style sockets.
5.3.7. SCTP PR-SCTP Information Structure (SCTP_PRINFO) 5.3.7. SCTP PR-SCTP Information Structure (SCTP_PRINFO)
This cmsghdr structure specifies SCTP options for sendmsg(). This cmsghdr structure specifies SCTP options for sendmsg().
+--------------+-------------+--------------------+ +--------------+-------------+--------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+-------------+--------------------+ +--------------+-------------+--------------------+
| IPPROTO_SCTP | SCTP_PRINFO | struct sctp_prinfo | | IPPROTO_SCTP | SCTP_PRINFO | struct sctp_prinfo |
+--------------+-------------+--------------------+ +--------------+-------------+--------------------+
The sctp_prinfo structure is defined below: The sctp_prinfo structure is defined below:
struct sctp_prinfo { struct sctp_prinfo {
uint16_t pr_policy; uint16_t pr_policy;
uint32_t pr_value; uint32_t pr_value;
}; };
pr_policy: This specifies which PR-SCTP policy is used. Using pr_policy: This specifies which Partially Reliable SCTP (PR-SCTP)
SCTP_PR_SCTP_NONE results in a reliable transmission. When policy is used. Using SCTP_PR_SCTP_NONE results in a reliable
SCTP_PR_SCTP_TTL is used, the PR-SCTP policy "timed reliability" transmission. When SCTP_PR_SCTP_TTL is used, the PR-SCTP policy
defined in [RFC3758] is used. In this case, the lifetime is "timed reliability" defined in [RFC3758] is used. In this case,
provided in pr_value. the lifetime is provided in pr_value.
pr_value: The meaning of this field depends on the PR-SCTP policy pr_value: The meaning of this field depends on the PR-SCTP policy
specified by the pr_policy field. It is ignored when specified by the pr_policy field. It is ignored when
SCTP_PR_SCTP_NONE is specified. In case of SCTP_PR_SCTP_TTL the SCTP_PR_SCTP_NONE is specified. In the case of SCTP_PR_SCTP_TTL,
lifetime in milliseconds is specified. the lifetime in milliseconds is specified.
An sctp_prinfo item always corresponds to the data in msg_iov. An sctp_prinfo item always corresponds to the data in msg_iov.
5.3.8. SCTP AUTH Information Structure (SCTP_AUTHINFO) 5.3.8. SCTP AUTH Information Structure (SCTP_AUTHINFO)
This cmsghdr structure specifies SCTP options for sendmsg(). This cmsghdr structure specifies SCTP options for sendmsg().
+--------------+---------------+----------------------+ +--------------+---------------+----------------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+---------------+----------------------+ +--------------+---------------+----------------------+
skipping to change at page 40, line 14 skipping to change at page 40, line 46
struct sctp_authinfo { struct sctp_authinfo {
uint16_t auth_keynumber; uint16_t auth_keynumber;
}; };
auth_keynumber: This specifies the shared key identifier used for auth_keynumber: This specifies the shared key identifier used for
sending the user message. sending the user message.
An sctp_authinfo item always corresponds to the data in msg_iov. An sctp_authinfo item always corresponds to the data in msg_iov.
Please note that the SCTP implementation must not bundle user Please note that the SCTP implementation must not bundle user
messages that needs to be authenticated using different shared key messages that need to be authenticated using different shared key
identifiers. identifiers.
5.3.9. SCTP Destination IPv4 Address Structure (SCTP_DSTADDRV4) 5.3.9. SCTP Destination IPv4 Address Structure (SCTP_DSTADDRV4)
This cmsghdr structure specifies SCTP options for sendmsg(). This cmsghdr structure specifies SCTP options for sendmsg().
+--------------+----------------+----------------+ +--------------+----------------+----------------+
| cmsg_level | cmsg_type | cmsg_data[] | | cmsg_level | cmsg_type | cmsg_data[] |
+--------------+----------------+----------------+ +--------------+----------------+----------------+
| IPPROTO_SCTP | SCTP_DSTADDRV4 | struct in_addr | | IPPROTO_SCTP | SCTP_DSTADDRV4 | struct in_addr |
skipping to change at page 40, line 49 skipping to change at page 41, line 37
+--------------+----------------+-----------------+ +--------------+----------------+-----------------+
This ancillary data can be used to provide more than one destination This ancillary data can be used to provide more than one destination
address to sendmsg(). It can be used to implement sctp_sendv() using address to sendmsg(). It can be used to implement sctp_sendv() using
sendmsg(). sendmsg().
6. SCTP Events and Notifications 6. SCTP Events and Notifications
An SCTP application may need to understand and process events and An SCTP application may need to understand and process events and
errors that happen on the SCTP stack. These events include network errors that happen on the SCTP stack. These events include network
status changes, association startups, remote operational errors and status changes, association startups, remote operational errors, and
undeliverable messages. All of these can be essential for the undeliverable messages. All of these can be essential for the
application. application.
When an SCTP application layer does a recvmsg() the message read is When an SCTP application layer does a recvmsg(), the message read is
normally a data message from a peer endpoint. If the application normally a data message from a peer endpoint. If the application
wishes to have the SCTP stack deliver notifications of non-data wishes to have the SCTP stack deliver notifications of non-data
events, it sets the appropriate socket option for the notifications events, it sets the appropriate socket option for the notifications
it wants. See Section 6.2 for these socket options. When a it wants. See Section 6.2 for these socket options. When a
notification arrives, recvmsg() returns the notification in the notification arrives, recvmsg() returns the notification in the
application-supplied data buffer via msg_iov, and sets application-supplied data buffer via msg_iov, and sets
MSG_NOTIFICATION in msg_flags. MSG_NOTIFICATION in msg_flags.
This section details the notification structures. Every notification This section details the notification structures. Every notification
structure carries some common fields which provide general structure carries some common fields that provide general
information. information.
A recvmsg() call will return only one notification at a time. Just A recvmsg() call will return only one notification at a time. Just
as when reading normal data, it may return part of a notification if as when reading normal data, it may return part of a notification if
the msg_iov buffer is not large enough. If a single read is not the msg_iov buffer is not large enough. If a single read is not
sufficient, msg_flags will have MSG_EOR clear. The user must finish sufficient, msg_flags will have MSG_EOR clear. The user must finish
reading the notification before subsequent data can arrive. reading the notification before subsequent data can arrive.
6.1. SCTP Notification Structure 6.1. SCTP Notification Structure
skipping to change at page 42, line 11 skipping to change at page 42, line 43
sn_type: The following list describes the SCTP notification and sn_type: The following list describes the SCTP notification and
event types for the field sn_type. event types for the field sn_type.
SCTP_ASSOC_CHANGE: This tag indicates that an association has SCTP_ASSOC_CHANGE: This tag indicates that an association has
either been opened or closed. Refer to Section 6.1.1 for either been opened or closed. Refer to Section 6.1.1 for
details. details.
SCTP_PEER_ADDR_CHANGE: This tag indicates that an address that is SCTP_PEER_ADDR_CHANGE: This tag indicates that an address that is
part of an existing association has experienced a change of part of an existing association has experienced a change of
state (e.g. a failure or return to service of the reachability state (e.g., a failure or return to service of the reachability
of an endpoint via a specific transport address). Please see of an endpoint via a specific transport address). Please see
Section 6.1.2 for data structure details. Section 6.1.2 for data structure details.
SCTP_REMOTE_ERROR: The attached error message is an Operational SCTP_REMOTE_ERROR: The attached error message is an Operation
Error received from the remote peer. It includes the complete Error message received from the remote peer. It includes the
TLV sent by the remote endpoint. See Section 6.1.3 for the complete TLV sent by the remote endpoint. See Section 6.1.3
detailed format. for the detailed format.
SCTP_SEND_FAILED_EVENT: The attached datagram could not be sent SCTP_SEND_FAILED_EVENT: The attached datagram could not be sent
to the remote endpoint. This structure includes the original to the remote endpoint. This structure includes the original
SCTP_SNDINFO that was used in sending this message i.e. this SCTP_SNDINFO that was used in sending this message; i.e., this
structure uses the sctp_sndinfo per Section 6.1.11. structure uses the sctp_sndinfo per Section 6.1.11.
SCTP_SHUTDOWN_EVENT: The peer has sent a SHUTDOWN. No further SCTP_SHUTDOWN_EVENT: The peer has sent a SHUTDOWN. No further
data should be sent on this socket. data should be sent on this socket.
SCTP_ADAPTATION_INDICATION: This notification holds the peer's SCTP_ADAPTATION_INDICATION: This notification holds the peer's
indicated adaptation layer. Please see Section 6.1.6. indicated adaptation layer. Please see Section 6.1.6.
SCTP_PARTIAL_DELIVERY_EVENT: This notification is used to tell a SCTP_PARTIAL_DELIVERY_EVENT: This notification is used to tell a
receiver that the partial delivery has been aborted. This may receiver that the partial delivery has been aborted. This may
indicate the association is about to be aborted. Please see indicate that the association is about to be aborted. Please
Section 6.1.7. see Section 6.1.7.
SCTP_AUTHENTICATION_EVENT: This notification is used to tell a SCTP_AUTHENTICATION_EVENT: This notification is used to tell a
receiver that either an error occurred on authentication, or a receiver that either an error occurred on authentication, or a
new key was made active. See Section 6.1.8. new key was made active. See Section 6.1.8.
SCTP_SENDER_DRY_EVENT: This notification is used to inform the SCTP_SENDER_DRY_EVENT: This notification is used to inform the
application that the sender has no more user data queued for application that the sender has no more user data queued for
transmission nor retransmission. See Section 6.1.9. transmission or retransmission. See Section 6.1.9.
sn_flags: These are notification-specific flags. sn_flags: These are notification-specific flags.
sn_length: This is the length of the whole sctp_notification sn_length: This is the length of the whole sctp_notification
structure including the sn_type, sn_flags, and sn_length fields. structure, including the sn_type, sn_flags, and sn_length fields.
6.1.1. SCTP_ASSOC_CHANGE 6.1.1. SCTP_ASSOC_CHANGE
Communication notifications inform the application that an SCTP Communication notifications inform the application that an SCTP
association has either begun or ended. The identifier for a new association has either begun or ended. The identifier for a new
association is provided by this notification. The notification association is provided by this notification. The notification
information has the following format: information has the following format:
struct sctp_assoc_change { struct sctp_assoc_change {
uint16_t sac_type; uint16_t sac_type;
uint16_t sac_flags; uint16_t sac_flags;
uint32_t sac_length; uint32_t sac_length;
uint16_t sac_state; uint16_t sac_state;
uint16_t sac_error; uint16_t sac_error;
uint16_t sac_outbound_streams; uint16_t sac_outbound_streams;
uint16_t sac_inbound_streams; uint16_t sac_inbound_streams;
sctp_assoc_t sac_assoc_id; sctp_assoc_t sac_assoc_id;
uint8_t sac_info[]; uint8_t sac_info[];
}; };
sac_type: This field should be set to SCTP_ASSOC_CHANGE.
sac_type: It should be SCTP_ASSOC_CHANGE. sac_flags: This field is currently unused.
sac_flags: Currently unused.
sac_length: This field is the total length of the notification data, sac_length: This field is the total length of the notification data,
including the notification header. including the notification header.
sac_state: This field holds one of a number of values that sac_state: This field holds one of a number of values that
communicate the event that happened to the association. They communicate the event that happened to the association. These
include: values include
SCTP_COMM_UP: A new association is now ready and data may be SCTP_COMM_UP: A new association is now ready, and data may be
exchanged with this peer. When an association has been exchanged with this peer. When an association has been
established successfully, this notification should be the first established successfully, this notification should be the
one. first one.
SCTP_COMM_LOST: The association has failed. The association is SCTP_COMM_LOST: The association has failed. The association is
now in the closed state. If SEND_FAILED notifications are now in the closed state. If SEND_FAILED notifications are
turned on, an SCTP_COMM_LOST is accompanied by a series of turned on, an SCTP_COMM_LOST is accompanied by a series of
SCTP_SEND_FAILED_EVENT events, one for each outstanding SCTP_SEND_FAILED_EVENT events, one for each outstanding
message. message.
SCTP_RESTART: SCTP has detected that the peer has restarted. SCTP_RESTART: SCTP has detected that the peer has restarted.
SCTP_SHUTDOWN_COMP: The association has gracefully closed. SCTP_SHUTDOWN_COMP: The association has gracefully closed.
SCTP_CANT_STR_ASSOC: The association failed to setup. If non SCTP_CANT_STR_ASSOC: The association setup failed. If
blocking mode is set and data was sent (on a one-to-many style non-blocking mode is set and data was sent (on a one-to-many
socket), an SCTP_CANT_STR_ASSOC is accompanied by a series of style socket), an SCTP_CANT_STR_ASSOC is accompanied by a
SCTP_SEND_FAILED_EVENT events, one for each outstanding series of SCTP_SEND_FAILED_EVENT events, one for each
message. outstanding message.
sac_error: If the state was reached due to an error condition (e.g. sac_error: If the state was reached due to an error condition (e.g.,
SCTP_COMM_LOST) any relevant error information is available in SCTP_COMM_LOST), any relevant error information is available in
this field. This corresponds to the protocol error codes defined this field. This corresponds to the protocol error codes defined
in [RFC4960]. in [RFC4960].
sac_outbound_streams: sac_outbound_streams and sac_inbound_streams: The maximum number of
streams allowed in each direction is available in
sac_inbound_streams: The maximum number of streams allowed in each sac_outbound_streams and sac_inbound streams.
direction are available in sac_outbound_streams and sac_inbound
streams.
sac_assoc_id: The sac_assoc_id field holds the identifier for the sac_assoc_id: The sac_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket, this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
sac_info: If the sac_state is SCTP_COMM_LOST and an ABORT chunk was sac_info: If sac_state is SCTP_COMM_LOST and an ABORT chunk was
received for this association, sac_info[] contains the complete received for this association, sac_info[] contains the complete
ABORT chunk as defined in the SCTP specification [RFC4960] Section ABORT chunk as defined in Section 3.3.7 of the SCTP specification
3.3.7. If the sac_state is SCTP_COMM_UP or SCTP_RESTART, sac_info [RFC4960]. If sac_state is SCTP_COMM_UP or SCTP_RESTART, sac_info
may contain an array of uint8_t describing the features that the may contain an array of uint8_t describing the features that the
current association supports. Features may include current association supports. Features may include
SCTP_ASSOC_SUPPORTS_PR: Both endpoints support the protocol SCTP_ASSOC_SUPPORTS_PR: Both endpoints support the protocol
extension described in [RFC3758]. extension described in [RFC3758].
SCTP_ASSOC_SUPPORTS_AUTH: Both endpoints support the protocol SCTP_ASSOC_SUPPORTS_AUTH: Both endpoints support the protocol
extension described in [RFC4895]. extension described in [RFC4895].
SCTP_ASSOC_SUPPORTS_ASCONF: Both endpoints support the protocol SCTP_ASSOC_SUPPORTS_ASCONF: Both endpoints support the protocol
extension described in [RFC5061]. extension described in [RFC5061].
SCTP_ASSOC_SUPPORTS_MULTIBUF: For a one-to-many style socket, the SCTP_ASSOC_SUPPORTS_MULTIBUF: For a one-to-many style socket, the
local endpoints use separate send and/or receive buffers for local endpoints use separate send and/or receive buffers for
each SCTP association. each SCTP association.
6.1.2. SCTP_PEER_ADDR_CHANGE 6.1.2. SCTP_PEER_ADDR_CHANGE
When a destination address of a multi-homed peer encounters a state When a destination address of a multi-homed peer encounters a state
change a peer address change event is sent. The notification has the change, a peer address change event is sent. The notification has
following format: the following format:
struct sctp_paddr_change { struct sctp_paddr_change {
uint16_t spc_type; uint16_t spc_type;
uint16_t spc_flags; uint16_t spc_flags;
uint32_t spc_length; uint32_t spc_length;
struct sockaddr_storage spc_aaddr; struct sockaddr_storage spc_aaddr;
uint32_t spc_state; uint32_t spc_state;
uint32_t spc_error; uint32_t spc_error;
sctp_assoc_t spc_assoc_id; sctp_assoc_t spc_assoc_id;
} }
spc_type: It should be SCTP_PEER_ADDR_CHANGE. spc_type: This field should be set to SCTP_PEER_ADDR_CHANGE.
spc_flags: Currently unused. spc_flags: This field is currently unused.
spc_length: This field is the total length of the notification data, spc_length: This field is the total length of the notification data,
including the notification header. including the notification header.
spc_aaddr: The affected address field holds the remote peer's spc_aaddr: The affected address field holds the remote peer's
address that is encountering the change of state. address that is encountering the change of state.
spc_state: This field holds one of a number of values that spc_state: This field holds one of a number of values that
communicate the event that happened to the address. They include: communicate the event that happened to the address. They include
SCTP_ADDR_AVAILABLE: This address is now reachable. This SCTP_ADDR_AVAILABLE: This address is now reachable. This
notification is provided whenever an address becomes reachable. notification is provided whenever an address becomes reachable.
SCTP_ADDR_UNREACHABLE: The address specified can no longer be SCTP_ADDR_UNREACHABLE: The address specified can no longer be
reached. Any data sent to this address is rerouted to an reached. Any data sent to this address is rerouted to an
alternate until this address becomes reachable. This alternate until this address becomes reachable. This
notification is provided whenever an address becomes notification is provided whenever an address becomes
unreachable. unreachable.
SCTP_ADDR_REMOVED: The address is no longer part of the SCTP_ADDR_REMOVED: The address is no longer part of the
association. association.
SCTP_ADDR_ADDED: The address is now 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 SCTP_ADDR_MADE_PRIM: This address has now been made the primary
primary destination address. This notification is provided destination address. This notification is provided whenever an
whenever an address is made primary. address is made primary.
spc_error: If the state was reached due to any error condition (e.g. spc_error: If the state was reached due to any error condition
SCTP_ADDR_UNREACHABLE) any relevant error information is available (e.g., SCTP_ADDR_UNREACHABLE), any relevant error information is
in this field. available in this field.
spc_assoc_id: The spc_assoc_id field holds the identifier for the spc_assoc_id: The spc_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket, this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
6.1.3. SCTP_REMOTE_ERROR 6.1.3. SCTP_REMOTE_ERROR
A remote peer may send an Operational Error message to its peer. A remote peer may send an Operation Error message to its peer. This
This message indicates a variety of error conditions on an message indicates a variety of error conditions on an association.
association. The entire ERROR chunk as it appears on the wire is The entire ERROR chunk as it appears on the wire is included in an
included in an SCTP_REMOTE_ERROR event. Please refer to the SCTP SCTP_REMOTE_ERROR event. Please refer to the SCTP specification
specification [RFC4960] and any extensions for a list of possible [RFC4960] and any extensions for a list of possible error formats.
error formats. An SCTP error notification has the following format: An SCTP error notification has the following format:
struct sctp_remote_error { struct sctp_remote_error {
uint16_t sre_type; uint16_t sre_type;
uint16_t sre_flags; uint16_t sre_flags;
uint32_t sre_length; uint32_t sre_length;
uint16_t sre_error; uint16_t sre_error;
sctp_assoc_t sre_assoc_id; sctp_assoc_t sre_assoc_id;
uint8_t sre_data[]; uint8_t sre_data[];
}; };
sre_type: This field should be set to SCTP_REMOTE_ERROR.
sre_type: It should be SCTP_REMOTE_ERROR. sre_flags: This field is currently unused.
sre_flags: Currently unused.
sre_length: This field is the total length of the notification data, sre_length: This field is the total length of the notification data,
including the notification header and the contents of sre_data. including the notification header and the contents of sre_data.
sre_error: This value represents one of the Operational Error causes sre_error: This value represents one of the Operation Error causes
defined in the SCTP specification, in network byte order. defined in the SCTP specification [RFC4960], in network byte
order.
sre_assoc_id: The sre_assoc_id field holds the identifier for the sre_assoc_id: The sre_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket, this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
sre_data: This contains the ERROR chunk as defined in the SCTP sre_data: This contains the ERROR chunk as defined in Section 3.3.10
specification [RFC4960] Section 3.3.10. of the SCTP specification [RFC4960].
6.1.4. SCTP_SEND_FAILED - DEPRECATED 6.1.4. SCTP_SEND_FAILED - DEPRECATED
Please note that this notification is deprecated. Use Please note that this notification is deprecated. Use
SCTP_SEND_FAILED_EVENT instead. SCTP_SEND_FAILED_EVENT instead.
If SCTP cannot deliver a message, it can return back the message as a If SCTP cannot deliver a message, it can return back the message as a
notification if the SCTP_SEND_FAILED event is enabled. The notification if the SCTP_SEND_FAILED event is enabled. The
notification has the following format: notification has the following format:
struct sctp_send_failed { struct sctp_send_failed {
uint16_t ssf_type; uint16_t ssf_type;
uint16_t ssf_flags; uint16_t ssf_flags;
uint32_t ssf_length; uint32_t ssf_length;
uint32_t ssf_error; uint32_t ssf_error;
struct sctp_sndrcvinfo ssf_info; struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id; sctp_assoc_t ssf_assoc_id;
uint8_t ssf_data[]; uint8_t ssf_data[];
}; };
ssf_type: It should be SCTP_SEND_FAILED. ssf_type: This field should be set to SCTP_SEND_FAILED.
ssf_flags: The flag value will take one of the following values: ssf_flags: The flag value will take one of the following values:
SCTP_DATA_UNSENT: Indicates that the data was never put on the SCTP_DATA_UNSENT: This value indicates that the data was never
wire. put on the wire.
SCTP_DATA_SENT: Indicates that the data was put on the wire. SCTP_DATA_SENT: This value indicates that the data was put on the
Note that this does not necessarily mean that the data was (or wire. Note that this does not necessarily mean that the data
was not) successfully delivered. was (or was not) successfully delivered.
ssf_length: This field is the total length of the notification data, ssf_length: This field is the total length of the notification data,
including the notification header and the payload in ssf_data. including the notification header and the payload in ssf_data.
ssf_error: This value represents the reason why the send failed, and ssf_error: This value represents the reason why the send failed, and
if set, will be an SCTP protocol error code as defined in if set, will be an SCTP protocol error code as defined in
[RFC4960] Section 3.3.10. Section 3.3.10 of [RFC4960].
ssf_info: The ancillary data (struct sctp_sndrcvinfo) used to send ssf_info: This field includes the ancillary data (struct
the undelivered message. Regardless of if ancillary data is used sctp_sndrcvinfo) used to send the undelivered message. Regardless
or not, the ssf_info.sinfo_flags field indicates if the complete of whether ancillary data is used or not, the ssf_info.sinfo_flags
message or only part of the message is returned in ssf_data. If field indicates whether the complete message or only part of the
only part of the message is returned, it means that the part which message is returned in ssf_data. If only part of the message is
is not present has been sent successfully to the peer. returned, it means that the part that is not present has been sent
successfully to the peer.
If the complete message cannot be sent, the SCTP_DATA_NOT_FRAG If the complete message cannot be sent, the SCTP_DATA_NOT_FRAG
flags is set in ssf_info.sinfo_flags. If the first part of the flag is set in ssf_info.sinfo_flags. If the first part of the
message is sent successfully, the SCTP_DATA_LAST_FRAG is set. message is sent successfully, SCTP_DATA_LAST_FRAG is set. This
This means that the tail end of the message is returned in means that the tail end of the message is returned in ssf_data.
ssf_data.
ssf_assoc_id: The ssf_assoc_id field, ssf_assoc_id, holds the ssf_assoc_id: The ssf_assoc_id field, ssf_assoc_id, holds the
identifier for the association. All notifications for a given identifier for the association. All notifications for a given
association have the same association identifier. For a one-to- association have the same association identifier. For a one-to-
one style socket, this field is ignored. one style socket, this field is ignored.
ssf_data: The undelivered message or part of the undelivered message ssf_data: The undelivered message or part of the undelivered message
will be present in the ssf_data field. Note that the will be present in the ssf_data field. Note that the
ssf_info.sinfo_flags field as noted above should be used to ssf_info.sinfo_flags field as noted above should be used to
determine if a complete message is present or just a piece of the determine whether a complete message or just a piece of the
message. Note that only user data is present in this field, any message is present. Note that only user data is present in this
chunk headers or SCTP common headers must be removed by the SCTP field; any chunk headers or SCTP common headers must be removed by
stack. the SCTP stack.
6.1.5. SCTP_SHUTDOWN_EVENT 6.1.5. SCTP_SHUTDOWN_EVENT
When a peer sends a SHUTDOWN, SCTP delivers this notification to When a peer sends a SHUTDOWN, SCTP delivers this notification to
inform the application that it should cease sending data. inform the application that it should cease sending data.
struct sctp_shutdown_event { struct sctp_shutdown_event {
uint16_t sse_type; uint16_t sse_type;
uint16_t sse_flags; uint16_t sse_flags;
uint32_t sse_length; uint32_t sse_length;
sctp_assoc_t sse_assoc_id; sctp_assoc_t sse_assoc_id;
}; };
sse_type: It should be SCTP_SHUTDOWN_EVENT. sse_type: This field should be set to SCTP_SHUTDOWN_EVENT.
sse_flags: Currently unused. sse_flags: This field is currently unused.
sse_length: This field is the total length of the notification data, sse_length: This field is the total length of the notification data,
including the notification header. It will generally be including the notification header. It will generally be
sizeof(struct sctp_shutdown_event). sizeof(struct sctp_shutdown_event).
sse_flags: Currently unused.
sse_assoc_id: The sse_assoc_id field holds the identifier for the sse_assoc_id: The sse_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket, this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
6.1.6. SCTP_ADAPTATION_INDICATION 6.1.6. SCTP_ADAPTATION_INDICATION
When a peer sends an Adaptation Layer Indication parameter as When a peer sends an Adaptation Layer Indication parameter as
described in [RFC5061], SCTP delivers this notification to inform the described in [RFC5061], SCTP delivers this notification to inform the
application about the peer's adaptation layer indication. application about the peer's adaptation layer indication.
struct sctp_adaptation_event { struct sctp_adaptation_event {
uint16_t sai_type; uint16_t sai_type;
uint16_t sai_flags; uint16_t sai_flags;
uint32_t sai_length; uint32_t sai_length;
uint32_t sai_adaptation_ind; uint32_t sai_adaptation_ind;
sctp_assoc_t sai_assoc_id; sctp_assoc_t sai_assoc_id;
}; };
sai_type: It should be SCTP_ADAPTATION_INDICATION.
sai_flags: Currently unused. sai_type: This field should be set to SCTP_ADAPTATION_INDICATION.
sai_flags: This field is currently unused.
sai_length: This field is the total length of the notification data, sai_length: This field is the total length of the notification data,
including the notification header. It will generally be including the notification header. It will generally be
sizeof(struct sctp_adaptation_event). sizeof(struct sctp_adaptation_event).
sai_adaptation_ind: This field holds the bit array sent by the peer sai_adaptation_ind: This field holds the bit array sent by the peer
in the adaptation layer indication parameter. in the Adaptation Layer Indication parameter.
sai_assoc_id: The sai_assoc_id field holds the identifier for the sai_assoc_id: The sai_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket, this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
6.1.7. SCTP_PARTIAL_DELIVERY_EVENT 6.1.7. SCTP_PARTIAL_DELIVERY_EVENT
When a receiver is engaged in a partial delivery of a message this When a receiver is engaged in a partial delivery of a message, this
notification will be used to indicate various events. notification will be used to indicate various events.
struct sctp_pdapi_event { struct sctp_pdapi_event {
uint16_t pdapi_type; uint16_t pdapi_type;
uint16_t pdapi_flags; uint16_t pdapi_flags;
uint32_t pdapi_length; uint32_t pdapi_length;
uint32_t pdapi_indication; uint32_t pdapi_indication;
uint32_t pdapi_stream; uint32_t pdapi_stream;
uint32_t pdapi_seq; uint32_t pdapi_seq;
sctp_assoc_t pdapi_assoc_id; sctp_assoc_t pdapi_assoc_id;
}; };
pdapi_type: It should be SCTP_PARTIAL_DELIVERY_EVENT. pdapi_type: This field should be set to SCTP_PARTIAL_DELIVERY_EVENT.
pdapi_flags: Currently unused. pdapi_flags: This field is currently unused.
pdapi_length: This field is the total length of the notification pdapi_length: This field is the total length of the notification
data, including the notification header. It will generally be data, including the notification header. It will generally be
sizeof(struct sctp_pdapi_event). sizeof(struct sctp_pdapi_event).
pdapi_indication: This field holds the indication being sent to the pdapi_indication: This field holds the indication being sent to the
application. Currently there is only one defined value: application. Currently, there is only one defined value:
SCTP_PARTIAL_DELIVERY_ABORTED: This indicates that the partial SCTP_PARTIAL_DELIVERY_ABORTED: This indicates that the partial
delivery of a user message has been aborted. This happens, for delivery of a user message has been aborted. This happens, for
example, if an association is aborted while a partial delivery example, if an association is aborted while a partial delivery
is going on or the user message gets abandoned using PR-SCTP is going on or the user message gets abandoned using PR-SCTP
while the partial delivery of this message is going on. while the partial delivery of this message is going on.
pdapi_stream: This field holds the stream on which the partial pdapi_stream: This field holds the stream on which the partial
delivery event happened. delivery event happened.
pdapi_seq: This field holds the stream sequence number which was pdapi_seq: This field holds the stream sequence number that was
being partially delivered. being partially delivered.
pdapi_assoc_id: The pdapi_assoc_id field holds the identifier for pdapi_assoc_id: The pdapi_assoc_id field holds the identifier for
the association. All notifications for a given association have the association. All notifications for a given association have
the same association identifier. For a one-to-one style socket the same association identifier. For a one-to-one style socket,
this field is ignored. this field is ignored.
6.1.8. SCTP_AUTHENTICATION_EVENT 6.1.8. SCTP_AUTHENTICATION_EVENT
[RFC4895] defines an extension to authenticate SCTP messages. The [RFC4895] defines an extension to authenticate SCTP messages. The
following notification is used to report different events relating to following notification is used to report different events relating to
the use of this extension. the use of this extension.
struct sctp_authkey_event { struct sctp_authkey_event {
uint16_t auth_type; uint16_t auth_type;
uint16_t auth_flags; uint16_t auth_flags;
uint32_t auth_length; uint32_t auth_length;
uint16_t auth_keynumber; uint16_t auth_keynumber;
uint32_t auth_indication; uint32_t auth_indication;
sctp_assoc_t auth_assoc_id; sctp_assoc_t auth_assoc_id;
}; };
auth_type: This field should be set to SCTP_AUTHENTICATION_EVENT.
auth_type: It should be SCTP_AUTHENTICATION_EVENT. auth_flags: This field is currently unused.
auth_flags: Currently unused.
auth_length: This field is the total length of the notification auth_length: This field is the total length of the notification
data, including the notification header. It will generally be data, including the notification header. It will generally be
sizeof(struct sctp_authkey_event). sizeof(struct sctp_authkey_event).
auth_keynumber: This field holds the keynumber for the affected key auth_keynumber: This field holds the key number for the affected key
indicated in the event (depends on auth_indication). indicated in the event (depends on auth_indication).
auth_indication: This field holds the error or indication being auth_indication: This field holds the error or indication being
reported. The following values are currently defined: reported. The following values are currently defined:
SCTP_AUTH_NEW_KEY: This report indicates that a new key has been SCTP_AUTH_NEW_KEY: This report indicates that a new key has been
made active (used for the first time by the peer) and is now made active (used for the first time by the peer) and is now
the active key. The auth_keynumber field holds the user the active key. The auth_keynumber field holds the user-
specified key number. specified key number.
SCTP_AUTH_NO_AUTH: This report indicates that the peer does not SCTP_AUTH_NO_AUTH: This report indicates that the peer does not
support SCTP AUTH as defined in [RFC4895]. support SCTP authentication as defined in [RFC4895].
SCTP_AUTH_FREE_KEY: This report indicates that the SCTP SCTP_AUTH_FREE_KEY: This report indicates that the SCTP
implementation will no longer use the key identifier specified implementation will no longer use the key identifier specified
in auth_keynumber. in auth_keynumber.
auth_assoc_id: The auth_assoc_id field holds the identifier for the auth_assoc_id: The auth_assoc_id field holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the
same association identifier. For a one-to-one style socket this same association identifier. For a one-to-one style socket, this
field is ignored. field is ignored.
6.1.9. SCTP_SENDER_DRY_EVENT 6.1.9. SCTP_SENDER_DRY_EVENT
When the SCTP stack has no more user data to send or retransmit, this When the SCTP stack has no more user data to send or retransmit, this
notification is given to the user. Also, at the time when a user app notification is given to the user. Also, at the time when a user app
subscribes to this event, if there is no data to be sent or subscribes to this event, if there is no data to be sent or
retransmit, the stack will immediately send up this notification. retransmit, the stack will immediately send up this notification.
struct sctp_sender_dry_event { struct sctp_sender_dry_event {
uint16_t sender_dry_type; uint16_t sender_dry_type;
uint16_t sender_dry_flags; uint16_t sender_dry_flags;
uint32_t sender_dry_length; uint32_t sender_dry_length;
sctp_assoc_t sender_dry_assoc_id; sctp_assoc_t sender_dry_assoc_id;
}; };
sender_dry_type: It should be SCTP_SENDER_DRY_EVENT. sender_dry_type: This field should be set to SCTP_SENDER_DRY_EVENT.
sender_dry_flags: Currently unused. sender_dry_flags: This field is currently unused.
sender_dry_length: This field is the total length of the sender_dry_length: This field is the total length of the
notification data, including the notification header. It will notification data, including the notification header. It will
generally be sizeof(struct sctp_sender_dry_event). generally be sizeof(struct sctp_sender_dry_event).
sender_dry_assoc_id: The sender_dry_assoc_id field holds the sender_dry_assoc_id: The sender_dry_assoc_id field holds the
identifier for the association. All notifications for a given identifier for the association. All notifications for a given
association have the same association identifier. For a one-to- association have the same association identifier. For a one-to-
one style socket this field is ignored. one style socket, this field is ignored.
6.1.10. SCTP_NOTIFICATIONS_STOPPED_EVENT 6.1.10. SCTP_NOTIFICATIONS_STOPPED_EVENT
SCTP notifications, when subscribed to, are reliable. They are SCTP notifications, when subscribed to, are reliable. They are
always delivered as long as there is space in the socket receive always delivered as long as there is space in the socket receive
buffer. However, if an implementation experiences a notification buffer. However, if an implementation experiences a notification
storm, it may run out of socket buffer space. When this occurs it storm, it may run out of socket buffer space. When this occurs, it
may wish to disable notifications. If the implementation chooses to may wish to disable notifications. If the implementation chooses to
do this, it will append a final notification do this, it will append a final notification
SCTP_NOTIFICATIONS_STOPPED_EVENT. This notification is a union SCTP_NOTIFICATIONS_STOPPED_EVENT. This notification is a union
sctp_notification, where only the struct sctp_tlv (see the union sctp_notification, where only the sctp_tlv structure (see the union
above) is used. It only contains this type in the sn_type field, the above) is used. It only contains this type in the sn_type field, the
sn_length field set to the size of an sctp_tlv structure and the sn_length field set to the size of an sctp_tlv structure, and the
sn_flags set to 0. If an application receives this notification, it sn_flags set to 0. If an application receives this notification, it
will need to re-subscribe to any notifications of interest to it, will need to re-subscribe to any notifications of interest to it,
except for the sctp_data_io_event (note that SCTP_EVENTS is except for the sctp_data_io_event (note that SCTP_EVENTS is
deprecated). deprecated).
An endpoint is automatically subscribed to this event as soon as it An endpoint is automatically subscribed to this event as soon as it
is subscribed to any event other than data io events. is subscribed to any event other than data io events.
6.1.11. SCTP_SEND_FAILED_EVENT 6.1.11. SCTP_SEND_FAILED_EVENT
skipping to change at page 52, line 28 skipping to change at page 52, line 47
notification if the SCTP_SEND_FAILED_EVENT event is enabled. The notification if the SCTP_SEND_FAILED_EVENT event is enabled. The
notification has the following format: notification has the following format:
struct sctp_send_failed_event { struct sctp_send_failed_event {
uint16_t ssfe_type; uint16_t ssfe_type;
uint16_t ssfe_flags; uint16_t ssfe_flags;
uint32_t ssfe_length; uint32_t ssfe_length;
uint32_t ssfe_error; uint32_t ssfe_error;
struct sctp_sndinfo ssfe_info; struct sctp_sndinfo ssfe_info;
sctp_assoc_t ssfe_assoc_id; sctp_assoc_t ssfe_assoc_id;
uint8_t ssfe_data[]; uint8_t ssfe_data[];
}; };
ssfe_type: This field should be set to SCTP_SEND_FAILED_EVENT.
ssfe_type: It should be SCTP_SEND_FAILED_EVENT.
ssfe_flags: The flag value will take one of the following values: ssfe_flags: The flag value will take one of the following values:
SCTP_DATA_UNSENT: Indicates that the data was never put on the SCTP_DATA_UNSENT: This value indicates that the data was never
wire. put on the wire.
SCTP_DATA_SENT: Indicates that the data was put on the wire. SCTP_DATA_SENT: This value indicates that the data was put on the
Note that this does not necessarily mean that the data was (or wire. Note that this does not necessarily mean that the data
was not) successfully delivered. was (or was not) successfully delivered.
ssfe_length: This field is the total length of the notification ssfe_length: This field is the total length of the notification
data, including the notification header and the payload in data, including the notification header and the payload in
ssf_data. ssf_data.
ssfe_error: This value represents the reason why the send failed, ssfe_error: This value represents the reason why the send failed,
and if set, will be an SCTP protocol error code as defined in and if set, will be an SCTP protocol error code as defined in
[RFC4960] Section 3.3.10. Section 3.3.10 of [RFC4960].
ssfe_info: The ancillary data (struct sctp_sndinfo) used to send the ssfe_info: This field includes the ancillary data (struct
undelivered message. Regardless of if ancillary data is used or sctp_sndinfo) used to send the undelivered message. Regardless of
not, the ssfe_info.sinfo_flags field indicates if the complete whether ancillary data is used or not, the ssfe_info.sinfo_flags
message or only part of the message is returned in ssf_data. If field indicates whether the complete message or only part of the
only part of the message is returned, it means that the part which message is returned in ssf_data. If only part of the message is
is not present has been sent successfully to the peer. returned, it means that the part that is not present has been sent
successfully to the peer.
If the complete message cannot be sent, the SCTP_DATA_NOT_FRAG If the complete message cannot be sent, the SCTP_DATA_NOT_FRAG
flags is set in ssfe_info.sinfo_flags. If the first part of the flag is set in ssfe_info.sinfo_flags. If the first part of the
message is sent successfully, the SCTP_DATA_LAST_FRAG is set. message is sent successfully, SCTP_DATA_LAST_FRAG is set. This
This means that the tail end of the message is returned in means that the tail end of the message is returned in ssf_data.
ssf_data.
ssfe_assoc_id: The ssfe_assoc_id field, ssf_assoc_id, holds the ssfe_assoc_id: The ssfe_assoc_id field, ssf_assoc_id, holds the
identifier for the association. All notifications for a given identifier for the association. All notifications for a given
association have the same association identifier. For a one-to- association have the same association identifier. For a one-to-
one style socket, this field is ignored. one style socket, this field is ignored.
ssfe_data: The undelivered message or part of the undelivered ssfe_data: The undelivered message or part of the undelivered
message will be present in the ssf_data field. Note that the message will be present in the ssf_data field. Note that the
ssf_info.sinfo_flags field as noted above should be used to ssf_info.sinfo_flags field as noted above should be used to
determine if a complete message is present or just a piece of the determine whether a complete message or just a piece of the
message. Note that only user data is present in this field, any message is present. Note that only user data is present in this
chunk headers or SCTP common headers must be removed by the SCTP field; any chunk headers or SCTP common headers must be removed by
stack. the SCTP stack.
6.2. Notification Interest Options 6.2. Notification Interest Options
6.2.1. SCTP_EVENTS option - DEPRECATED 6.2.1. SCTP_EVENTS Option - DEPRECATED
Please note that this option is deprecated. Use the SCTP_EVENT Please note that this option is deprecated. Use the SCTP_EVENT
option described in Section 6.2.2 instead. option described in Section 6.2.2 instead.
To receive SCTP event notifications, an application registers its To receive SCTP event notifications, an application registers its
interest by setting the SCTP_EVENTS socket option. The application interest by setting the SCTP_EVENTS socket option. The application
then uses recvmsg() to retrieve notifications. A notification is then uses recvmsg() to retrieve notifications. A notification is
stored in the data part (msg_iov) of the struct msghdr. The socket stored in the data part (msg_iov) of the msghdr structure. The
option uses the following structure: socket option uses the following structure:
struct sctp_event_subscribe { struct sctp_event_subscribe {
uint8_t sctp_data_io_event; uint8_t sctp_data_io_event;
uint8_t sctp_association_event; uint8_t sctp_association_event;
uint8_t sctp_address_event; uint8_t sctp_address_event;
uint8_t sctp_send_failure_event; uint8_t sctp_send_failure_event;
uint8_t sctp_peer_error_event; uint8_t sctp_peer_error_event;
uint8_t sctp_shutdown_event; uint8_t sctp_shutdown_event;
uint8_t sctp_partial_delivery_event; uint8_t sctp_partial_delivery_event;
uint8_t sctp_adaptation_layer_event; uint8_t sctp_adaptation_layer_event;
uint8_t sctp_authentication_event; uint8_t sctp_authentication_event;
uint8_t sctp_sender_dry_event; uint8_t sctp_sender_dry_event;
}; };
sctp_data_io_event: Setting this flag to 1 will cause the reception sctp_data_io_event: Setting this flag to 1 will cause the reception
of SCTP_SNDRCV information on a per message basis. The of SCTP_SNDRCV information on a per-message basis. The
application will need to use the recvmsg() interface so that it application will need to use the recvmsg() interface so that it
can receive the event information contained in the msg_control can receive the event information contained in the msg_control
field. Setting the flag to 0 will disable the reception of the field. Setting the flag to 0 will disable the reception of the
message control information. Note that this is not really a message control information. Note that this flag is not really a
notification and this is stored in the ancillary data notification and is stored in the ancillary data (msg_control),
(msg_control), not in the data part (msg_iov). not in the data part (msg_iov).
sctp_association_event: Setting this flag to 1 will enable the sctp_association_event: Setting this flag to 1 will enable the
reception of association event notifications. Setting the flag to reception of association event notifications. Setting the flag to
0 will disable association event notifications. 0 will disable association event notifications.
sctp_address_event: Setting this flag to 1 will enable the reception sctp_address_event: Setting this flag to 1 will enable the reception
of address event notifications. Setting the flag to 0 will of address event notifications. Setting the flag to 0 will
disable address event notifications. disable address event notifications.
sctp_send_failure_event: Setting this flag to 1 will enable the sctp_send_failure_event: Setting this flag to 1 will enable the
skipping to change at page 54, line 48 skipping to change at page 55, line 14
sctp_peer_error_event: Setting this flag to 1 will enable the sctp_peer_error_event: Setting this flag to 1 will enable the
reception of peer error event notifications. Setting the flag to reception of peer error event notifications. Setting the flag to
0 will disable peer error event notifications. 0 will disable peer error event notifications.
sctp_shutdown_event: Setting this flag to 1 will enable the sctp_shutdown_event: Setting this flag to 1 will enable the
reception of shutdown event notifications. Setting the flag to 0 reception of shutdown event notifications. Setting the flag to 0
will disable shutdown event notifications. will disable shutdown event notifications.
sctp_partial_delivery_event: Setting this flag to 1 will enable the sctp_partial_delivery_event: Setting this flag to 1 will enable the
reception of partial delivery notifications. Setting the flag to reception of partial delivery event notifications. Setting the
0 will disable partial delivery event notifications. flag to 0 will disable partial delivery event notifications.
sctp_adaptation_layer_event: Setting this flag to 1 will enable the sctp_adaptation_layer_event: Setting this flag to 1 will enable the
reception of adaptation layer notifications. Setting the flag to reception of adaptation layer event notifications. Setting the
0 will disable adaptation layer event notifications. flag to 0 will disable adaptation layer event notifications.
sctp_authentication_event: Setting this flag to 1 will enable the sctp_authentication_event: Setting this flag to 1 will enable the
reception of authentication layer notifications. Setting the flag reception of authentication layer event notifications. Setting
to 0 will disable authentication layer event notifications. the flag to 0 will disable authentication layer event
notifications.
sctp_sender_dry_event: Setting this flag to 1 will enable the sctp_sender_dry_event: Setting this flag to 1 will enable the
reception of sender dry notifications. Setting the flag to 0 will reception of sender dry event notifications. Setting the flag to
disable sender dry event notifications. 0 will disable sender dry event notifications.
An example where an application would like to receive data_io_events An example where an application would like to receive data_io_events
and association_events but no others would be as follows: and association_events but no others would be as follows:
{ {
struct sctp_event_subscribe events; struct sctp_event_subscribe events;
memset(&events, 0, sizeof(events)); memset(&events, 0, sizeof(events));
events.sctp_data_io_event = 1; events.sctp_data_io_event = 1;
skipping to change at page 55, line 37 skipping to change at page 55, line 50
setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(events)); setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &events, sizeof(events));
} }
Note that for one-to-many style SCTP sockets, the caller of recvmsg() Note that for one-to-many style SCTP sockets, the caller of recvmsg()
receives ancillary data and notifications for all associations bound receives ancillary data and notifications for all associations bound
to the file descriptor. For one-to-one style SCTP sockets, the to the file descriptor. For one-to-one style SCTP sockets, the
caller receives ancillary data and notifications only for the single caller receives ancillary data and notifications only for the single
association bound to the file descriptor. association bound to the file descriptor.
By default both the one-to-one style and the one-to-many style socket By default, both the one-to-one style and the one-to-many style
do not subscribe to any notification. socket do not subscribe to any notification.
6.2.2. SCTP_EVENT option 6.2.2. SCTP_EVENT Option
The SCTP_EVENTS socket option has one issue for future compatibility. The SCTP_EVENTS socket option has one issue for future compatibility.
As new features are added the structure (sctp_event_subscribe) must As new features are added, the structure (sctp_event_subscribe) must
be expanded. This can cause an application binary interface (ABI) be expanded. This can cause an application binary interface (ABI)
issue unless an implementation has added padding at the end of the issue unless an implementation has added padding at the end of the
structure. To avoid this problem, SCTP_EVENTS has been deprecated structure. To avoid this problem, SCTP_EVENTS has been deprecated
and a new socket option SCTP_EVENT has taken its place. The option and a new socket option SCTP_EVENT has taken its place. The option
is used with the following structure: is used with the following structure:
struct sctp_event { struct sctp_event {
sctp_assoc_t se_assoc_id; sctp_assoc_t se_assoc_id;
uint16_t se_type; uint16_t se_type;
uint8_t se_on; uint8_t se_on;
}; };
se_assoc_id: The se_assoc_id field is ignored for one-to-one style se_assoc_id: The se_assoc_id field is ignored for one-to-one style
sockets. For one-to-many style sockets this field can be a sockets. For one-to-many style sockets, this field can be a
particular association identifier or SCTP_{FUTURE|CURRENT| particular association identifier or SCTP_{FUTURE|CURRENT|
ALL}_ASSOC. ALL}_ASSOC.
se_type: The se_type field can be filled with any value that would se_type: The se_type field can be filled with any value that would
show up in the respective sn_type field (in the sctp_tlv structure show up in the respective sn_type field (in the sctp_tlv structure
of the notification). of the notification).
se_on: The se_on field is set to 1 to turn on an event and set to 0 se_on: The se_on field is set to 1 to turn on an event and set to 0
to turn off an event. to turn off an event.
To use this option the user fills in this structure and then calls To use this option, the user fills in this structure and then calls
the setsockopt() to turn on or off an individual event. The setsockopt() to turn on or off an individual event. The following is
following is an example use of this option: an example use of this option:
{ {
struct sctp_event event; struct sctp_event event;
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.se_assoc_id = SCTP_FUTURE_ASSOC; event.se_assoc_id = SCTP_FUTURE_ASSOC;
event.se_type = SCTP_SENDER_DRY_EVENT; event.se_type = SCTP_SENDER_DRY_EVENT;
event.se_on = 1; event.se_on = 1;
setsockopt(sd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)); setsockopt(sd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event));
} }
By default both the one-to-one style and the one-to-many style socket By default, both the one-to-one style and the one-to-many style
do not subscribe to any notification. socket do not subscribe to any notification.
7. Common Operations for Both Styles 7. Common Operations for Both Styles
7.1. send(), recv(), sendto(), and recvfrom() 7.1. send(), recv(), sendto(), and recvfrom()
Applications can use send() and sendto() to transmit data to the peer Applications can use send() and sendto() to transmit data to the peer
of an SCTP endpoint. recv() and recvfrom() can be used to receive of an SCTP endpoint. recv() and recvfrom() can be used to receive
data from the peer. data from the peer.
The function prototypes are The function prototypes are
ssize_t send(int sd, ssize_t send(int sd,
const void *msg, const void *msg,
size_t len, size_t len,
int flags); int flags);
ssize_t sendto(int sd, ssize_t sendto(int sd,
const void *msg, const void *msg,
size_t len, size_t len,
int flags, int flags,
const struct sockaddr *to, const struct sockaddr *to,
skipping to change at page 58, line 11 skipping to change at page 58, line 14
from: The buffer to store the peer address used to send the received from: The buffer to store the peer address used to send the received
message. message.
fromlen: The size of the from address. fromlen: The size of the from address.
flags: (described below). flags: (described below).
These calls give access to only basic SCTP protocol features. If These calls give access to only basic SCTP protocol features. If
either peer in the association uses multiple streams, or sends either peer in the association uses multiple streams, or sends
unordered data, these calls will usually be inadequate, and may unordered data, these calls will usually be inadequate and may
deliver the data in unpredictable ways. deliver the data in unpredictable ways.
SCTP has the concept of multiple streams in one association. The SCTP has the concept of multiple streams in one association. The
above calls do not allow the caller to specify on which stream a above calls do not allow the caller to specify on which stream a
message should be sent. The system uses stream 0 as the default message should be sent. The system uses stream 0 as the default
stream for send() and sendto(). recv() and recvfrom() return data stream for send() and sendto(). recv() and recvfrom() return data
from any stream, but the caller can not distinguish the different from any stream, but the caller cannot distinguish the different
streams. This may result in data seeming to arrive out of order. streams. This may result in data seeming to arrive out of order.
Similarly, if a data chunk is sent unordered, recv() and recvfrom() Similarly, if a DATA chunk is sent unordered, recv() and recvfrom()
provide no indication. provide no indication.
SCTP is message based. The msg buffer above in send() and sendto() SCTP is message based. The msg buffer above in send() and sendto()
is considered to be a single message. This means that if the caller is considered to be a single message. This means that if the caller
wants to send a message that is composed by several buffers, the wants to send a message that is composed by several buffers, the
caller needs to combine them before calling send() or sendto(). caller needs to combine them before calling send() or sendto().
Alternately, the caller can use sendmsg() to do that without Alternately, the caller can use sendmsg() to do that without
combining them. Sending a message using send() or sendto() is atomic combining them. Sending a message using send() or sendto() is atomic
unless explicit EOR marking is enabled on the socket specified by sd. unless explicit EOR marking is enabled on the socket specified by sd.
Using sendto() on a non-connected one-to-one style socket for Using sendto() on a non-connected one-to-one style socket for
implicit connection setup may or may not work depending on the SCTP implicit connection setup may or may not work, depending on the SCTP
implementation. recv() and recvfrom() cannot distinguish message implementation. recv() and recvfrom() cannot distinguish message
boundaries (i.e. there is no way to observe the MSG_EOR flag to boundaries (i.e., there is no way to observe the MSG_EOR flag to
detect partial delivery). detect partial delivery).
In receiving, if the buffer supplied is not large enough to hold a When receiving, if the buffer supplied is not large enough to hold a
complete message, the receive call acts like a stream socket and complete message, the receive call acts like a stream socket and
returns as much data as will fit in the buffer. returns as much data as will fit in the buffer.
Note, the send() and recv() calls may not be used for a one-to-many Note that the send() and recv() calls may not be used for a one-to-
style socket. many style socket.
Note, if an application calls a send() or sendto() function with no Note that if an application calls a send() or sendto() function with
user data the SCTP implementation should reject the request with an no user data, the SCTP implementation should reject the request with
appropriate error message. An implementation is not allowed to send an appropriate error message. An implementation is not allowed to
a DATA chunk with no user data [RFC4960]. send a DATA chunk with no user data [RFC4960].
7.2. setsockopt() and getsockopt() 7.2. setsockopt() and getsockopt()
Applications use setsockopt() and getsockopt() to set or retrieve Applications use setsockopt() and getsockopt() to set or retrieve
socket options. Socket options are used to change the default socket options. Socket options are used to change the default
behavior of socket calls. They are described in Section 8. behavior of socket calls. They are described in Section 8.
The function prototypes are The function prototypes are
int getsockopt(int sd, int getsockopt(int sd,
skipping to change at page 59, line 34 skipping to change at page 59, line 40
level: Set to IPPROTO_SCTP for all SCTP options. level: Set to IPPROTO_SCTP for all SCTP options.
optname: The option name. optname: The option name.
optval: The buffer to store the value of the option. optval: The buffer to store the value of the option.
optlen: The size of the buffer (or the length of the option optlen: The size of the buffer (or the length of the option
returned). returned).
They return 0 on success and -1 in case of an error. These functions return 0 on success and -1 in case of an error.
All socket options set on a one-to-one style listening socket also All socket options set on a one-to-one style listening socket also
apply to all future accepted sockets. For one-to-many style sockets apply to all future accepted sockets. For one-to-many style sockets,
often a socket option will pass a structure that includes an assoc_id often a socket option will pass a structure that includes an assoc_id
field. This field can be filled with the association identifier of a field. This field can be filled with the association identifier of a
particular association and unless otherwise specified can be filled particular association and unless otherwise specified can be filled
with one of the following constants: with one of the following constants:
SCTP_FUTURE_ASSOC: Specifies that only future associations created SCTP_FUTURE_ASSOC: Specifies that only future associations created
after this socket option will be affected by this call. after this socket option will be affected by this call.
SCTP_CURRENT_ASSOC: Specifies that only currently existing SCTP_CURRENT_ASSOC: Specifies that only currently existing
associations will be affected by this call, future associations associations will be affected by this call, and future
will still receive the previous default value. associations will still receive the previous default value.
SCTP_ALL_ASSOC: Specifies that all current and future associations SCTP_ALL_ASSOC: Specifies that all current and future associations
will be affected by this call. will be affected by this call.
7.3. read() and write() 7.3. read() and write()
Applications can use read() and write() to send and receive data to Applications can use read() and write() to receive and send data from
and from a peer. They have the same semantics as send() and recv() and to a peer. They have the same semantics as recv() and send(),
except that the flags parameter cannot be used. except that the flags parameter cannot be used.
7.4. getsockname() 7.4. getsockname()
Applications use getsockname() to retrieve the locally-bound socket Applications use getsockname() to retrieve the locally bound socket
address of the specified socket. This is especially useful if the address of the specified socket. This is especially useful if the
caller let SCTP choose a local port. This call is for single homed caller let SCTP choose a local port. This call is for single-homed
endpoints. It does not work well with multi-homed endpoints. See endpoints. It does not work well with multi-homed endpoints. See
Section 9.5 for a multi-homed version of the call. Section 9.5 for a multi-homed version of the call.
The function prototype is The function prototype is
int getsockname(int sd, int getsockname(int sd,
struct sockaddr *address, struct sockaddr *address,
socklen_t *len); socklen_t *len);
and the arguments are and the arguments are
skipping to change at page 60, line 40 skipping to change at page 60, line 44
sd: The socket descriptor to be queried. sd: The socket descriptor to be queried.
address: On return, one locally bound address (chosen by the SCTP address: On return, one locally bound address (chosen by the SCTP
stack) is stored in this buffer. If the socket is an IPv4 socket, stack) is stored in this buffer. If the socket is an IPv4 socket,
the address will be IPv4. If the socket is an IPv6 socket, the the address will be IPv4. If the socket is an IPv6 socket, the
address will be either an IPv6 or IPv4 address. address will be either an IPv6 or IPv4 address.
len: The caller should set the length of the address here. On len: The caller should set the length of the address here. On
return, this is set to the length of the returned address. return, this is set to the length of the returned address.
It returns 0 on success and -1 in case of an error. getsockname() returns 0 on success and -1 in case of an error.
If the actual length of the address is greater than the length of the If the actual length of the address is greater than the length of the
supplied sockaddr structure, the stored address will be truncated. supplied sockaddr structure, the stored address will be truncated.
If the socket has not been bound to a local name, the value stored in If the socket has not been bound to a local name, the value stored in
the object pointed to by address is unspecified. the object pointed to by address is unspecified.
7.5. Implicit Association Setup 7.5. Implicit Association Setup
The application can begin sending and receiving data using the The application can begin sending and receiving data using the
sendmsg()/recvmsg() or sendto()/recvfrom() calls, without going sendmsg()/recvmsg() or sendto()/recvfrom() calls, without going
through any explicit association setup procedures (i.e., no connect() through any explicit association setup procedures (i.e., no connect()
calls required). calls required).
Whenever sendmsg() or sendto() is called and the SCTP stack at the Whenever sendmsg() or sendto() is called and the SCTP stack at the
sender finds that no association exists between the sender and the sender finds that no association exists between the sender and the
intended receiver (identified by the address passed either in the intended receiver (identified by the address passed either in the
msg_name field of msghdr structure in the sendmsg() call or the msg_name field of the msghdr structure in the sendmsg() call or the
dest_addr field in the sendto() call), the SCTP stack will dest_addr field in the sendto() call), the SCTP stack will
automatically setup an association to the intended receiver. automatically set up an association to the intended receiver.
Upon the successful association setup an SCTP_COMM_UP notification Upon successful association setup, an SCTP_COMM_UP notification will
will be dispatched to the socket at both the sender and receiver be dispatched to the socket at both the sender and receiver side.
side. This notification can be read by the recvmsg() system call This notification can be read by the recvmsg() system call (see
(see Section 3.1.4). Section 3.1.4).
Note, if the SCTP stack at the sender side supports bundling, the Note that if the SCTP stack at the sender side supports bundling, the
first user message may be bundled with the COOKIE ECHO message first user message may be bundled with the COOKIE ECHO message
[RFC4960]. [RFC4960].
When the SCTP stack sets up a new association implicitly, the When the SCTP stack sets up a new association implicitly, the
SCTP_INIT type ancillary data may also be passed along (see SCTP_INIT type ancillary data may also be passed along (see
Section 5.3.1 for details of the data structures) to change some Section 5.3.1 for details of the data structures) to change some
parameters used in setting up a new association. parameters used in setting up a new association.
If this information is not present in the sendmsg() call, or if the If this information is not present in the sendmsg() call, or if the
implicit association setup is triggered by a sendto() call, the implicit association setup is triggered by a sendto() call, the
default association initialization parameters will be used. These default association initialization parameters will be used. These
default association parameters may be set with respective default association parameters may be set with respective
setsockopt() calls or be left to the system defaults. setsockopt() calls or be left to the system defaults.
Implicit association setup cannot be initiated by send() calls. Implicit association setup cannot be initiated by send() calls.
8. Socket Options 8. Socket Options
The following sub-section describes various SCTP level socket options The following subsection describes various SCTP-level socket options
that are common to both styles. SCTP associations can be multi- that are common to both styles. SCTP associations can be
homed. Therefore, certain option parameters include a multi-homed. Therefore, certain option parameters include a
sockaddr_storage structure to select which peer address the option sockaddr_storage structure to select to which peer address the option
should be applied to. should be applied.
For the one-to-many style sockets, an sctp_assoc_t (association For the one-to-many style sockets, an sctp_assoc_t (association
identifier) parameter is used to identify the association instance identifier) parameter is used to identify the association instance
that the operation affects. So it must be set when using this style. 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 For the one-to-one style sockets and branched-off one-to-many style
sockets (see Section 9.2) this association ID parameter is ignored. sockets (see Section 9.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, the options will be Note that socket- or IP-level options are set or retrieved per
applied to all associations (similar to using SCTP_ALL_ASSOC as the socket. This means that for one-to-many style sockets, the options
association identifier) belonging to the socket. For one-to-one will be applied to all associations (similar to using SCTP_ALL_ASSOC
style, these options will be applied to all peer addresses of the as the association identifier) belonging to the socket. For the one-
association controlled by the socket. Applications should be careful to-one style, these options will be applied to all peer addresses of
in setting those options. the association controlled by the socket. Applications should be
careful in setting those options.
For some IP stacks getsockopt() is read-only; so a new interface will For some IP stacks, getsockopt() is read-only, so a new interface
be needed when information must be passed both into and out of the will be needed when information must be passed both into and out of
SCTP stack. The syntax for sctp_opt_info() is the SCTP stack. The syntax for sctp_opt_info() is
int sctp_opt_info(int sd, int sctp_opt_info(int sd,
sctp_assoc_t id, sctp_assoc_t id,
int opt, int opt,
void *arg, void *arg,
socklen_t *size); socklen_t *size);
The sctp_opt_info() call is a replacement for getsockopt() only and The sctp_opt_info() call is a replacement for getsockopt() only and
will not set any options associated with the specified socket. A will not set any options associated with the specified socket. A
setsockopt() must be used to set any writeable option. setsockopt() call must be used to set any writable option.
For one-to-many style sockets, id specifies the association to query. For one-to-many style sockets, id specifies the association to query.
For one-to-one style sockets, id is ignored. For one-to-many For one-to-one style sockets, id is ignored. For one-to-many style
sockets, any association identifier in the structure provided as arg sockets, any association identifier in the structure provided as arg
is ignored and id takes precedence. is ignored, and id takes precedence.
Note that SCTP_CURRENT_ASSOC and SCTP_ALL_ASSOC cannot be used with Note that SCTP_CURRENT_ASSOC and SCTP_ALL_ASSOC cannot be used with
sctp_opt_info() or in getsockopt() calls. Using them will result in sctp_opt_info() or in getsockopt() calls. Using them will result in
an error (returning -1 and errno set to EINVAL). SCTP_FUTURE_ASSOC an error (returning -1 and errno set to EINVAL). SCTP_FUTURE_ASSOC
can be used to query information for future associations. can be used to query information for future associations.
The field opt specifies which SCTP socket option to get. It can get The field opt specifies which SCTP socket option to get. It can get
any socket option currently supported that requests information any socket option currently supported that requests information
(either read/write options or read only) such as: (either read/write options or read-only) such as
SCTP_RTOINFO SCTP_RTOINFO
SCTP_ASSOCINFO SCTP_ASSOCINFO
SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
skipping to change at page 63, line 29 skipping to change at page 63, line 29
SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
SCTP_PEER_AUTH_CHUNKS SCTP_PEER_AUTH_CHUNKS
SCTP_LOCAL_AUTH_CHUNKS SCTP_LOCAL_AUTH_CHUNKS
The arg field is an option-specific structure buffer provided by the The arg field is an option-specific structure buffer provided by the
caller. See the rest of this sections subsections for more caller. See the rest of this section for more information on these
information on these options and option-specific structures. options and option-specific structures.
sctp_opt_info() returns 0 on success, or on failure returns -1 and sctp_opt_info() returns 0 on success, or on failure returns -1 and
sets errno to the appropriate error code. sets errno to the appropriate error code.
8.1. Read / Write Options 8.1. Read/Write Options
8.1.1. Retransmission Timeout Parameters (SCTP_RTOINFO) 8.1.1. Retransmission Timeout Parameters (SCTP_RTOINFO)
The protocol parameters used to initialize and limit the The protocol parameters used to initialize and limit the
retransmission timeout (RTO) are tunable. See [RFC4960] for more retransmission timeout (RTO) are tunable. See [RFC4960] for more
information on how these parameters are used in RTO calculation. information on how these parameters are used in RTO calculation.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_rtoinfo { struct sctp_rtoinfo {
sctp_assoc_t srto_assoc_id; sctp_assoc_t srto_assoc_id;
uint32_t srto_initial; uint32_t srto_initial;
uint32_t srto_max; uint32_t srto_max;
uint32_t srto_min; uint32_t srto_min;
}; };
srto_initial: This contains the initial RTO value.
srto_max and srto_min: These contain the maximum and minimum bounds
for all RTOs.
srto_assoc_id: This parameter is ignored for one-to-one style srto_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets the application may fill sockets. For one-to-many style sockets, the application may fill
in an association identifier or SCTP_FUTURE_ASSOC. It is an error in an association identifier or SCTP_FUTURE_ASSOC. It is an error
to use SCTP_{CURRENT|ALL}_ASSOC in srto_assoc_id. to use SCTP_{CURRENT|ALL}_ASSOC in srto_assoc_id.
srto_initial: This parameter contains the initial RTO value.
srto_max and srto_min: These parameters contain the maximum and
minimum bounds for all RTOs.
All times are given in milliseconds. A value of 0, when modifying All times are given in milliseconds. A value of 0, when modifying
the parameters, indicates that the current value should not be the parameters, indicates that the current value should not be
changed. changed.
To access or modify these parameters, the application should call To access or modify these parameters, the application should call
getsockopt() or setsockopt() respectively with the option name getsockopt() or setsockopt(), respectively, with the option name
SCTP_RTOINFO. SCTP_RTOINFO.
8.1.2. Association Parameters (SCTP_ASSOCINFO) 8.1.2. Association Parameters (SCTP_ASSOCINFO)
This option is used to both examine and set various association and This option is used to both examine and set various association and
endpoint parameters. See [RFC4960] for more information on how this endpoint parameters. See [RFC4960] for more information on how these
parameter is used. parameters are used.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_assocparams { struct sctp_assocparams {
sctp_assoc_t sasoc_assoc_id; sctp_assoc_t sasoc_assoc_id;
uint16_t sasoc_asocmaxrxt; uint16_t sasoc_asocmaxrxt;
uint16_t sasoc_number_peer_destinations; uint16_t sasoc_number_peer_destinations;
uint32_t sasoc_peer_rwnd; uint32_t sasoc_peer_rwnd;
uint32_t sasoc_local_rwnd; uint32_t sasoc_local_rwnd;
uint32_t sasoc_cookie_life; uint32_t sasoc_cookie_life;
}; };
sasoc_assoc_id: This parameter is ignored for one-to-one style sasoc_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets the application may fill sockets. For one-to-many style sockets, the application may fill
in an association identifier or SCTP_FUTURE_ASSOC. It is an error in an association identifier or SCTP_FUTURE_ASSOC. It is an error
to use SCTP_{CURRENT|ALL}_ASSOC in sasoc_assoc_id. to use SCTP_{CURRENT|ALL}_ASSOC in sasoc_assoc_id.
sasoc_asocmaxrxt: This contains the maximum retransmission attempts sasoc_asocmaxrxt: This parameter contains the maximum retransmission
to make for the association. attempts to make for the association.
sasoc_number_peer_destinations: This is the number of destination sasoc_number_peer_destinations: This parameter is the number of
addresses that the peer has. destination addresses that the peer has.
sasoc_peer_rwnd: This holds the current value of the peers rwnd sasoc_peer_rwnd: This parameter holds the current value of the
(reported in the last SACK) minus any outstanding data (i.e. data peer's rwnd (reported in the last selective acknowledgment (SACK))
in flight). minus any outstanding data (i.e., data in flight).
sasoc_local_rwnd: This holds the last reported rwnd that was sent to sasoc_local_rwnd: This parameter holds the last reported rwnd that
the peer. was sent to the peer.
sasoc_cookie_life: This is the association's cookie life value used sasoc_cookie_life: This parameter is the association's cookie life
when issuing cookies. value used when issuing cookies.
The values of the sasoc_peer_rwnd is meaningless when examining The value of sasoc_peer_rwnd is meaningless when examining endpoint
endpoint information (i.e. it is only valid when examining information (i.e., it is only valid when examining information on a
information on a specific association). specific association).
All time values are given in milliseconds. A value of 0, when All time values are given in milliseconds. A value of 0, when
modifying the parameters, indicates that the current value should not modifying the parameters, indicates that the current value should not
be changed. be changed.
The values of the sasoc_asocmaxrxt and sasoc_cookie_life may be set The values of sasoc_asocmaxrxt and sasoc_cookie_life may be set on
on either an endpoint or association basis. The rwnd and destination either an endpoint or association basis. The rwnd and destination
counts (sasoc_number_peer_destinations, sasoc_peer_rwnd, counts (sasoc_number_peer_destinations, sasoc_peer_rwnd,
sasoc_local_rwnd) are not settable and any value placed in these is sasoc_local_rwnd) are not settable, and any value placed in these is
ignored. ignored.
To access or modify these parameters, the application should call To access or modify these parameters, the application should call
getsockopt() or setsockopt() respectively with the option name getsockopt() or setsockopt(), respectively, with the option name
SCTP_ASSOCINFO. SCTP_ASSOCINFO.
The maximum number of retransmissions before an address is considered The maximum number of retransmissions before an address is considered
unreachable is also tunable, but is address-specific, so it is unreachable is also tunable, but is address-specific, so it is
covered in a separate option. If an application attempts to set the covered in a separate option. If an application attempts to set the
value of the association maximum retransmission parameter to more value of the association's maximum retransmission parameter to more
than the sum of all maximum retransmission parameters, setsockopt() than the sum of all maximum retransmission parameters, setsockopt()
may return an error. The reason for this, from [RFC4960] Section may return an error. The reason for this, from Section 8.2 of
8.2: [RFC4960], is as follows:
Note: When configuring the SCTP endpoint, the user should avoid Note: When configuring the SCTP endpoint, the user should avoid
having the value of 'Association.Max.Retrans' (sasoc_maxrxt in this having the value of 'Association.Max.Retrans' (sasoc_maxrxt in
option) larger than the summation of the 'Path.Max.Retrans' (see this option) larger than the summation of the 'Path.Max.Retrans'
Section 8.1.12 on spp_pathmaxrxt) of all the destination addresses (see spp_pathmaxrxt in Section 8.1.12) of all of the destination
for the remote endpoint. Otherwise, all the destination addresses addresses for the remote endpoint. Otherwise, all of the
may become inactive while the endpoint still considers the peer destination addresses may become inactive while the endpoint still
endpoint reachable. considers the peer endpoint reachable.
8.1.3. Initialization Parameters (SCTP_INITMSG) 8.1.3. Initialization Parameters (SCTP_INITMSG)
Applications can specify protocol parameters for the default Applications can specify protocol parameters for the default
association initialization. The structure used to access and modify association initialization. The structure used to access and modify
these parameters is defined in Section 5.3.1. The option name these parameters is defined in Section 5.3.1. The option name
argument to setsockopt() and getsockopt() is SCTP_INITMSG. argument to setsockopt() and getsockopt() is SCTP_INITMSG.
Setting initialization parameters is effective only on an unconnected Setting initialization parameters is effective only on an unconnected
socket (for one-to-many style sockets only future associations are socket (for one-to-many style sockets, only future associations are
affected by the change). affected by the change).
8.1.4. SO_LINGER 8.1.4. SO_LINGER
An application can use this option to perform the SCTP ABORT An application can use this option to perform the SCTP ABORT
primitive. This option affects all associations related to the primitive. This option affects all associations related to the
socket. socket.
The linger option structure is: The linger option structure is
struct linger { struct linger {
int l_onoff; /* option on/off */ int l_onoff; /* option on/off */
int l_linger; /* linger time */ int l_linger; /* linger time */
}; };
To enable the option, set l_onoff to 1. If the l_linger value is set To enable the option, set l_onoff to 1. If the l_linger value is set
to 0, calling close() is the same as the ABORT primitive. If the to 0, calling close() is the same as the ABORT primitive. If the
value is set to a negative value, the setsockopt() call will return value is set to a negative value, the setsockopt() call will return
an error. If the value is set to a positive value linger_time, the an error. If the value is set to a positive value linger_time, the
close() can be blocked for at most linger_time. Please note that the close() can be blocked for at most linger_time. Please note that the
time unit is seconds according to POSIX, but might be different on time unit is in seconds, according to POSIX, but might be different
specific platforms. If the graceful shutdown phase does not finish on specific platforms. If the graceful shutdown phase does not
during this period, close() will return but the graceful shutdown finish during this period, close() will return, but the graceful
phase will continue in the system. shutdown phase will continue in the system.
Note, this is a socket level option, not an SCTP level option. When Note that this is a socket-level option, not an SCTP-level option.
using this option, an application must specify a level of SOL_SOCKET When using this option, an application must specify a level of
in the call. SOL_SOCKET in the call.
8.1.5. SCTP_NODELAY 8.1.5. SCTP_NODELAY
Turn on/off any Nagle-like algorithm. This means that packets are This option turns on/off any Nagle-like algorithm. This means that
generally sent as soon as possible and no unnecessary delays are packets are generally sent as soon as possible, and no unnecessary
introduced, at the cost of more packets in the network. In delays are introduced, at the cost of more packets in the network.
particular, not using any Nagle-like algorithm might reduce the In particular, not using any Nagle-like algorithm might reduce the
bundling of small user messages in cases where this would require an bundling of small user messages in cases where this would require an
additional delay. additional delay.
Turning this option on disables any Nagle-like algorithm. Turning this option on disables any Nagle-like algorithm.
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
8.1.6. SO_RCVBUF 8.1.6. SO_RCVBUF
Sets the receive buffer size in octets. For SCTP one-to-one style This option sets the receive buffer size in octets. For SCTP one-to-
sockets, this controls the receiver window size. For one-to-many one style sockets, this option controls the receiver window size.
style sockets the meaning is implementation dependent. It might For one-to-many style sockets, the meaning is implementation
control the receive buffer for each association bound to the socket dependent. It might control the receive buffer for each association
descriptor or it might control the receive buffer for the whole bound to the socket descriptor, or it might control the receive
socket. This option expects an integer. buffer for the whole socket. This option expects an integer.
Note, this is a socket level option, not an SCTP level option. When Note that this is a socket-level option, not an SCTP-level option.
using this option, an application must specify a level of SOL_SOCKET When using this option, an application must specify a level of
in the call. SOL_SOCKET in the call.
8.1.7. SO_SNDBUF 8.1.7. SO_SNDBUF
Sets the send buffer size. For SCTP one-to-one style sockets, this This option sets the send buffer size. For SCTP one-to-one style
controls the amount of data SCTP may have waiting in internal buffers sockets, this option controls the amount of data SCTP may have
to be sent. This option therefore bounds the maximum size of data waiting in internal buffers to be sent. This option therefore bounds
that can be sent in a single send call. For one-to-many style the maximum size of data that can be sent in a single send call. For
sockets, the effect is the same, except that it applies to one or all one-to-many style sockets, the effect is the same, except that it
associations (see Section 3.3) bound to the socket descriptor used in applies to one or all associations (see Section 3.3) bound to the
the setsockopt() or getsockopt() call. The option applies to each socket descriptor used in the setsockopt() or getsockopt() call. The
association's window size separately. This option expects an option applies to each association's window size separately. This
integer. option expects an integer.
Note, this is a socket level option, not an SCTP level option. When Note that this is a socket-level option, not an SCTP-level option.
using this option, an application must specify a level of SOL_SOCKET When using this option, an application must specify a level of
in the call. SOL_SOCKET in the call.
8.1.8. Automatic Close of Associations (SCTP_AUTOCLOSE) 8.1.8. Automatic Close of Associations (SCTP_AUTOCLOSE)
This socket option is applicable to the one-to-many style socket This socket option is applicable to the one-to-many style socket
only. When set it will cause associations that are idle for more only. When set, it will cause associations that are idle for more
than the specified number of seconds to automatically close using the than the specified number of seconds to automatically close using the
graceful shutdown procedure. An association being idle is defined as graceful shutdown procedure. An idle association is defined as an
an association that has not sent or received user data. The special association that has not sent or received user data. The special
value of '0' indicates that no automatic close of any association value of '0' indicates that no automatic close of any association
should be performed, this is the default value. This option expects should be performed; this is the default value. This option expects
an integer defining the number of seconds of idle time before an an integer defining the number of seconds of idle time before an
association is closed. association is closed.
An application using this option should enable receiving the An application using this option should enable the ability to receive
association change notification. This is the only mechanism an the association change notification. This is the only mechanism by
application is informed about the closing of an association. After which an application is informed about the closing of an association.
an association is closed, the association identifier assigned to it After an association is closed, the association identifier assigned
can be reused. An application should be aware of this to avoid the to it can be reused. An application should be aware of this to avoid
possible problem of sending data to an incorrect peer endpoint. the possible problem of sending data to an incorrect peer endpoint.
8.1.9. Set Primary Address (SCTP_PRIMARY_ADDR) 8.1.9. Set Primary Address (SCTP_PRIMARY_ADDR)
Requests that the local SCTP stack uses the enclosed peer address as This option requests that the local SCTP stack uses the enclosed peer
the association's primary. The enclosed address must be one of the address as the association's primary. The enclosed address must be
association peer's addresses. one of the association peer's addresses.
The following structure is used to make a set peer primary request: The following structure is used to make a set peer primary request:
struct sctp_setprim { struct sctp_setprim {
sctp_assoc_t ssp_assoc_id; sctp_assoc_t ssp_assoc_id;
struct sockaddr_storage ssp_addr; struct sockaddr_storage ssp_addr;
}; };
ssp_addr: The address to set as primary. No wildcard address is
allowed.
ssp_assoc_id: This parameter is ignored for one-to-one style ssp_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets it identifies the sockets. For one-to-many style sockets, it identifies the
association for this request. Note that the special sctp_assoc_t association for this request. Note that the special sctp_assoc_t
SCTP_{FUTURE|ALL|CURRENT}_ASSOC are not allowed. SCTP_{FUTURE|ALL|CURRENT}_ASSOC are not allowed.
ssp_addr: This parameter is the address to set as primary. No
wildcard address is allowed.
8.1.10. Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER) 8.1.10. Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER)
Requests that the local endpoint set the specified Adaptation Layer This option requests that the local endpoint set the specified
Indication parameter for all future INIT and INIT-ACK exchanges. Adaptation Layer Indication parameter for all future INIT and
INIT-ACK exchanges.
The following structure is used to access and modify this parameter: The following structure is used to access and modify this parameter:
struct sctp_setadaptation { struct sctp_setadaptation {
uint32_t ssb_adaptation_ind; uint32_t ssb_adaptation_ind;
}; };
ssb_adaptation_ind: The adaptation layer indicator that will be ssb_adaptation_ind: The adaptation layer indicator that will be
included in any outgoing Adaptation Layer Indication parameter. included in any outgoing Adaptation Layer Indication parameter.
8.1.11. Enable/Disable Message Fragmentation (SCTP_DISABLE_FRAGMENTS) 8.1.11. Enable/Disable Message Fragmentation (SCTP_DISABLE_FRAGMENTS)
This option is a on/off flag and is passed as an integer where a non- This option is an on/off flag and is passed as an integer, where a
zero is on and a zero is off. If enabled no SCTP message non-zero is on and a zero is off. If enabled, no SCTP message
fragmentation will be performed. The effect of enabling this option fragmentation will be performed. The effect of enabling this option
are that if a message being sent exceeds the current PMTU size, the is that if a message being sent exceeds the current Path MTU (PMTU)
message will not be sent and instead an error will be indicated to size, the message will not be sent and instead an error will be
the user. If this option is disabled (the default) then a message indicated to the user. If this option is disabled (the default),
exceeding the size of the PMTU will be fragmented and reassembled by then a message exceeding the size of the PMTU will be fragmented and
the peer. reassembled by the peer.
8.1.12. Peer Address Parameters (SCTP_PEER_ADDR_PARAMS) 8.1.12. Peer Address Parameters (SCTP_PEER_ADDR_PARAMS)
Applications can enable or disable heartbeats for any peer address of Applications can enable or disable heartbeats for any peer address of
an association, modify an address's heartbeat interval, force a an association, modify an address's heartbeat interval, force a
heartbeat to be sent immediately, and adjust the address's maximum heartbeat to be sent immediately, and adjust the address's maximum
number of retransmissions sent before an address is considered number of retransmissions sent before an address is considered
unreachable. unreachable.
The following structure is used to access and modify an address's The following structure is used to access and modify an address's
parameters: parameters:
struct sctp_paddrparams { struct sctp_paddrparams {
sctp_assoc_t spp_assoc_id; sctp_assoc_t spp_assoc_id;
struct sockaddr_storage spp_address; struct sockaddr_storage spp_address;
uint32_t spp_hbinterval; uint32_t spp_hbinterval;
uint16_t spp_pathmaxrxt; uint16_t spp_pathmaxrxt;
uint32_t spp_pathmtu; uint32_t spp_pathmtu;
uint32_t spp_flags; uint32_t spp_flags;
uint32_t spp_ipv6_flowlabel; uint32_t spp_ipv6_flowlabel;
uint8_t spp_dscp; uint8_t spp_dscp;
}; };
spp_assoc_id: This parameter is ignored for one-to-one style spp_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets the application may fill sockets. For one-to-many style sockets, the application may fill
in an association identifier or SCTP_FUTURE_ASSOC for this query. in an association identifier or SCTP_FUTURE_ASSOC for this query.
It is an error to use SCTP_{CURRENT|ALL}_ASSOC in spp_assoc_id. It is an error to use SCTP_{CURRENT|ALL}_ASSOC in spp_assoc_id.
spp_address: This specifies which address is of interest. If a spp_address: This specifies which address is of interest. If a
wildcard address is provided it applies to all current and future wildcard address is provided, it applies to all current and future
paths. paths.
spp_hbinterval: This contains the value of the heartbeat interval, spp_hbinterval: This contains the value of the heartbeat interval,
in milliseconds (HB.Interval in [RFC4960]). Note that unless the in milliseconds (HB.Interval in [RFC4960]). Note that unless the
spp_flag is set to SPP_HB_ENABLE the value of this field is spp_flags field is set to SPP_HB_ENABLE, the value of this field
ignored. Note also that a value of zero indicates the current is ignored. Note also that a value of zero indicates that the
setting should be left unchanged. To set an actual value of zero current setting should be left unchanged. To set an actual value
the use of the flag SPP_HB_TIME_IS_ZERO should be used. Even when of zero, the SPP_HB_TIME_IS_ZERO flag should be used. Even when
it is set to 0, it does not mean that SCTP will continuously send it is set to 0, it does not mean that SCTP will continuously send
out heartbeat since the actual interval also includes the current out heartbeats, since the actual interval also includes the
RTO and jitter (see Section 8.3 in [RFC4960]). current RTO and jitter (see Section 8.3 of [RFC4960]).
spp_pathmaxrxt: This contains the maximum number of retransmissions spp_pathmaxrxt: This contains the maximum number of retransmissions
before this address shall be considered unreachable. Note that a before this address shall be considered unreachable. Note that a
value of zero indicates the current setting should be left value of zero indicates that the current setting should be left
unchanged. unchanged.
spp_pathmtu: The current path MTU of the peer address. It is the spp_pathmtu: This field contains the current Path MTU of the peer
number of bytes available in an SCTP packet for chunks. Providing address. It is the number of bytes available in an SCTP packet
a value of 0 does not change the current setting. If a positive for chunks. Providing a value of 0 does not change the current
value is provided and SPP_PMTUD_DISABLE is set in the spp_flags, setting. If a positive value is provided and SPP_PMTUD_DISABLE is
the given value is used as the path MTU. If SPP_PMTUD_ENABLE is set in the spp_flags field, the given value is used as the Path
set in the spp_flags, the spp_pathmtu field is ignored. MTU. If SPP_PMTUD_ENABLE is set in the spp_flags field, the
spp_pathmtu field is ignored.
spp_ipv6_flowlabel: This field is used in conjunction with the
SPP_IPV6_FLOWLABEL flag and contains the IPv6 flowlabel. The 20
least significant bits are used for the flowlabel. This setting
has precedence over any IPv6 layer setting.
spp_dscp: This field is used in conjunction with the SPP_DSCP flag
and contains the Differentiated Services Code Point (DSCP). The 6
most significant bits are used for the DSCP. This setting has
precedence over any IPv4 or IPv6 layer setting.
spp_flags: These flags are used to control various features on an spp_flags: These flags are used to control various features on an
association. The flag field is a bit mask which may contain zero association. The flag field is a bitmask that may contain zero or
or more of the following options: more of the following options:
SPP_HB_ENABLE: Enable heartbeats on the specified address. SPP_HB_ENABLE: This field enables heartbeats on the specified
address.
SPP_HB_DISABLE: Disable heartbeats on the specified address. SPP_HB_DISABLE: This field disables heartbeats on the specified
Note that SPP_HB_ENABLE and SPP_HB_DISABLE are mutually address. Note that SPP_HB_ENABLE and SPP_HB_DISABLE are
exclusive, only one of these two should be specified. Enabling mutually exclusive; only one of these two should be specified.
both fields will have undetermined results. Enabling both fields will yield undetermined results.
SPP_HB_DEMAND: Request a user initiated heartbeat to be made SPP_HB_DEMAND: This field requests that a user-initiated
immediately. This must not be used in conjunction with a heartbeat be made immediately. This must not be used in
wildcard address. conjunction with a wildcard address.
SPP_HB_TIME_IS_ZERO: Specifies that the time for heartbeat delay SPP_HB_TIME_IS_ZERO: This field specifies that the time for
is to be set to the value of 0 milliseconds. heartbeat delay is to be set to 0 milliseconds.
SPP_PMTUD_ENABLE: This field will enable PMTU discovery upon the SPP_PMTUD_ENABLE: This field will enable PMTU discovery on the
specified address. specified address.
SPP_PMTUD_DISABLE: This field will disable PMTU discovery upon SPP_PMTUD_DISABLE: This field will disable PMTU discovery on the
the specified address. Note that if the address field is empty specified address. Note that if the address field is empty,
then all addresses on the association are affected. Note also then all addresses on the association are affected. Note also
that SPP_PMTUD_ENABLE and SPP_PMTUD_DISABLE are mutually that SPP_PMTUD_ENABLE and SPP_PMTUD_DISABLE are mutually
exclusive. Enabling both will have undetermined results. exclusive. Enabling both fields will yield undetermined
results.
SPP_IPV6_FLOWLABEL: Setting this flag enables the setting of the SPP_IPV6_FLOWLABEL: Setting this flag enables the setting of the
IPV6 flowlabel value. The value is contained in the IPV6 flow label value. The value is contained in the
spp_ipv6_flowlabel field. spp_ipv6_flowlabel field.
Upon retrieval, this flag will be set to indicate that the Upon retrieval, this flag will be set to indicate that the
spp_ipv6_flowlabel field has a valid value returned. If a spp_ipv6_flowlabel field has a valid value returned. If a
specific destination address is set (in the spp_address field), specific destination address is set (in the spp_address field),
then the value returned is that of the address. If just an then the value returned is that of the address. If just an
association is specified (and no address), then the association is specified (and no address), then the
association's default flowlabel is returned. If neither an association's default flow label is returned. If neither an
association nor a destination is specified, then the socket's association nor a destination is specified, then the socket's
default flowlabel is returned. For non IPv6 sockets, this flag default flow label is returned. For non-IPv6 sockets, this
will be left cleared. flag will be left cleared.
SPP_DSCP: Setting this flag enables the setting of the DSCP value SPP_DSCP: Setting this flag enables the setting of the
associated with either the association or a specific address. Differentiated Services Code Point (DSCP) value associated with
The value is obtained in the spp_dscp field. either the association or a specific address. The value is
obtained in the spp_dscp field.
Upon retrieval, this flag will be set to indicate that the Upon retrieval, this flag will be set to indicate that the
spp_dscp field has a valid value returned. If a specific spp_dscp field has a valid value returned. If a specific
destination address is set when called (in the spp_address destination address is set when called (in the spp_address
field) then that specific destination address' DSCP value is field), then that specific destination address's DSCP value is
returned. If just an association is specified then the returned. If just an association is specified, then the
association default DSCP is returned. If neither an association's default DSCP is returned. If neither an
association nor a destination is specified, then the sockets association nor a destination is specified, then the socket's
default DSCP is returned. default DSCP is returned.
Please note that changing the flowlabel or DSCP value will affect all spp_ipv6_flowlabel: This field is used in conjunction with the
packets sent by the SCTP stack after setting these parameters. The SPP_IPV6_FLOWLABEL flag and contains the IPv6 flow label. The 20
flowlabel might also be set via the sin6_flowinfo field of the least significant bits are used for the flow label. This setting
has precedence over any IPv6-layer setting.
spp_dscp: This field is used in conjunction with the SPP_DSCP flag
and contains the DSCP. The 6 most significant bits are used for
the DSCP. This setting has precedence over any IPv4- or IPv6-
layer setting.
Please note that changing the flow label or DSCP value will affect
all packets sent by the SCTP stack after setting these parameters.
The flow label might also be set via the sin6_flowinfo field of the
sockaddr_in6 structure. sockaddr_in6 structure.
8.1.13. Set Default Send Parameters (SCTP_DEFAULT_SEND_PARAM) - 8.1.13. Set Default Send Parameters (SCTP_DEFAULT_SEND_PARAM) -
DEPRECATED DEPRECATED
Please note that this options is deprecated. Section 8.1.31 should Please note that this option is deprecated. SCTP_DEFAULT_SNDINFO
be used instead. (Section 8.1.31) should be used instead.
Applications that wish to use the sendto() system call may wish to Applications that wish to use the sendto() system call may wish to
specify a default set of parameters that would normally be supplied specify a default set of parameters that would normally be supplied
through the inclusion of ancillary data. This socket option allows through the inclusion of ancillary data. This socket option allows
such an application to set the default sctp_sndrcvinfo structure. such an application to set the default sctp_sndrcvinfo structure.
The application that wishes to use this socket option simply passes The application that wishes to use this socket option simply passes
the sctp_sndrcvinfo structure defined in Section 5.3.2 to this call. the sctp_sndrcvinfo structure (defined in Section 5.3.2) to this
The input parameters accepted by this call include sinfo_stream, call. The input parameters accepted by this call include
sinfo_flags, sinfo_ppid, sinfo_context, and sinfo_timetolive. The sinfo_stream, sinfo_flags, sinfo_ppid, sinfo_context, and
sinfo_flags is composed of a bitwise OR of SCTP_UNORDERED, SCTP_EOF, sinfo_timetolive. The sinfo_flags field is composed of a bitwise OR
and SCTP_SENDALL. The sinfo_assoc_id field specifies the association of SCTP_UNORDERED, SCTP_EOF, and SCTP_SENDALL. The sinfo_assoc_id
to apply the parameters to. For a one-to-many style socket any of field specifies the association to which to apply the parameters.
the predefined constants are also allowed in this field. The field For a one-to-many style socket, any of the predefined constants are
is ignored on the one-to-one style. also allowed in this field. The field is ignored for one-to-one
style sockets.
8.1.14. Set Notification and Ancillary Events (SCTP_EVENTS) - 8.1.14. Set Notification and Ancillary Events (SCTP_EVENTS) -
DEPRECATED DEPRECATED
This socket option is used to specify various notifications and This socket option is used to specify various notifications and
ancillary data the user wishes to receive. Please see Section 6.2.1 ancillary data the user wishes to receive. Please see Section 6.2.1
for a full description of this option and its usage. Note that this for a full description of this option and its usage. Note that this
option is considered deprecated and present for backward option is considered deprecated and is present for backward
compatibility. New applications should use the SCTP_EVENT option. compatibility. New applications should use the SCTP_EVENT option.
See Section 6.2.2 for a full description of that option as well. See Section 6.2.2 for a full description of that option as well.
8.1.15. Set/Clear IPv4 Mapped Addresses (SCTP_I_WANT_MAPPED_V4_ADDR) 8.1.15. Set/Clear IPv4 Mapped Addresses (SCTP_I_WANT_MAPPED_V4_ADDR)
This socket option is a boolean flag which turns on or off the This socket option is a boolean flag that turns on or off the mapping
mapping of IPv4 addresses. If this option is turned on, then IPv4 of IPv4 addresses. If this option is turned on, then IPv4 addresses
addresses will be mapped to V6 representation. If this option is will be mapped to IPv6 representation. If this option is turned off,
turned off, then no mapping will be done of V4 addresses and a user then no mapping will be done of IPv4 addresses, and a user will
will receive both PF_INET6 and PF_INET type addresses on the socket. receive both PF_INET6 and PF_INET type addresses on the socket. See
See [RFC3542] for more details on mapped V6 addresses. [RFC3542] for more details on mapped IPv6 addresses.
If this socket option is used on a socket of type PF_INET an error is If this socket option is used on a socket of type PF_INET, an error
returned. is returned.
By default this option is turned off and expects an integer to be By default, this option is turned off and expects an integer to be
passed where a non-zero value turns on the option and a zero value passed where a non-zero value turns on the option and a zero value
turns off the option. turns off the option.
8.1.16. Get or Set the Maximum Fragmentation Size (SCTP_MAXSEG) 8.1.16. Get or Set the Maximum Fragmentation Size (SCTP_MAXSEG)
This option will get or set the maximum size to put in any outgoing 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 SCTP DATA chunk. If a message is larger than this maximum size, it
fragmented by SCTP into the specified size. Note that the underlying will be fragmented by SCTP into the specified size. Note that the
SCTP implementation may fragment into smaller sized chunks when the underlying SCTP implementation may fragment into smaller sized chunks
PMTU of the underlying association is smaller than the value set by when the PMTU of the underlying association is smaller than the value
the user. The default value for this option is '0' which indicates set by the user. The default value for this option is '0', which
the user is not limiting fragmentation and only the PMTU will affect indicates that the user is not limiting fragmentation and only the
SCTP's choice of DATA chunk size. Note also that values set larger PMTU will affect SCTP's choice of DATA chunk size. Note also that
than the maximum size of an IP datagram will effectively let SCTP values set larger than the maximum size of an IP datagram will
control fragmentation (i.e. the same as setting this option to 0). effectively let SCTP control fragmentation (i.e., the same as setting
this option to 0).
The following structure is used to access and modify this parameter: The following structure is used to access and modify this parameter:
struct sctp_assoc_value { struct sctp_assoc_value {
sctp_assoc_t assoc_id; sctp_assoc_t assoc_id;
uint32_t assoc_value; uint32_t assoc_value;
}; };
assoc_id: This parameter is ignored for one-to-one style sockets. assoc_id: This parameter is ignored for one-to-one style sockets.
For one-to-many style sockets this parameter indicates which For one-to-many style sockets, this parameter indicates upon which
association the user is performing an action upon. It is an error association the user is performing an action. It is an error to
to use SCTP_{CURRENT|ALL}_ASSOC in assoc_id. use SCTP_{CURRENT|ALL}_ASSOC in assoc_id.
assoc_value: This parameter specifies the maximum size in bytes. assoc_value: This parameter specifies the maximum size in bytes.
8.1.17. Get or Set the List of Supported HMAC Identifiers 8.1.17. Get or Set the List of Supported HMAC Identifiers
(SCTP_HMAC_IDENT) (SCTP_HMAC_IDENT)
This option gets or sets the list of HMAC algorithms that the local This option gets or sets the list of Hashed Message Authentication
endpoint requires the peer to use. Code (HMAC) algorithms that the local endpoint requires the peer
to use.
The following structure is used to get or set these identifiers: The following structure is used to get or set these identifiers:
struct sctp_hmacalgo { struct sctp_hmacalgo {
uint32_t shmac_number_of_idents; uint32_t shmac_number_of_idents;
uint16_t shmac_idents[]; uint16_t shmac_idents[];
}; };
shmac_number_of_idents: This field gives the number of elements shmac_number_of_idents: This field gives the number of elements
present in the array shmac_idents. present in the array shmac_idents.
skipping to change at page 73, line 38 skipping to change at page 74, line 4
that the local endpoint is requesting the peer to use, in priority that the local endpoint is requesting the peer to use, in priority
order. The following identifiers are valid: order. The following identifiers are valid:
* SCTP_AUTH_HMAC_ID_SHA1 * SCTP_AUTH_HMAC_ID_SHA1
* SCTP_AUTH_HMAC_ID_SHA256 * SCTP_AUTH_HMAC_ID_SHA256
Note that the list supplied must include SCTP_AUTH_HMAC_ID_SHA1 and Note that the list supplied must include SCTP_AUTH_HMAC_ID_SHA1 and
may include any of the other values in its preferred order (lowest may include any of the other values in its preferred order (lowest
list position has the highest preference in algorithm selection). list position has the highest preference in algorithm selection).
Note also that the lack of SCTP_AUTH_HMAC_ID_SHA1, or the inclusion Note also that the lack of SCTP_AUTH_HMAC_ID_SHA1, or the inclusion
of an unknown HMAC identifier (including optional identifiers unknown of an unknown HMAC identifier (including optional identifiers unknown
to the implementation) will cause the set option to fail and return to the implementation), will cause the set option to fail and return
an error. an error.
8.1.18. Get or Set the Active Shared Key (SCTP_AUTH_ACTIVE_KEY) 8.1.18. 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 This option will get or set the active shared key to be used to build
the association shared key. the association shared key.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_authkeyid { struct sctp_authkeyid {
sctp_assoc_t scact_assoc_id; sctp_assoc_t scact_assoc_id;
uint16_t scact_keynumber; uint16_t scact_keynumber;
}; };
scact_assoc_id: This parameter sets the active key of the specified scact_assoc_id: This parameter sets the active key of the specified
association. The special SCTP_{FUTURE|CURRENT|ALL}_ASSOC can be association. The special SCTP_{FUTURE|CURRENT|ALL}_ASSOC can be
used. For one-to-one sockets, this parameter is ignored. Note, used. For one-to-one style sockets, this parameter is ignored.
however, that this option will set the active key on the Note, however, that this option will set the active key on the
association if the socket is connected, otherwise this will set association if the socket is connected; otherwise, this option
the default active key for the endpoint. will set the default active key for the endpoint.
scact_keynumber: This parameter is the shared key identifier which scact_keynumber: This parameter is the shared key identifier that
the application is requesting to become the active shared key to the application is requesting to become the active shared key to
be used for sending authenticated chunks. The key identifier must be used for sending authenticated chunks. The key identifier must
correspond to an existing shared key. Note that shared key correspond to an existing shared key. Note that shared key
identifier '0' defaults to a null key. identifier '0' defaults to a null key.
When used with setsockopt() the SCTP implementation must use the When used with setsockopt(), the SCTP implementation must use the
indicated shared key identifier for all messages being given to an indicated shared key identifier for all messages being given to an
SCTP implementation via a send call after the setsockopt() call until SCTP implementation via a send call after the setsockopt() call,
changed again. Therefore, the SCTP implementation must not bundle until changed again. Therefore, the SCTP implementation must not
user messages which should be authenticated using different shared bundle user messages that should be authenticated using different
key identifiers. shared key identifiers.
Initially the key with key identifier 0 is the active key. Initially, the key with key identifier 0 is the active key.
8.1.19. Get or Set Delayed SACK Timer (SCTP_DELAYED_SACK) 8.1.19. Get or Set Delayed SACK Timer (SCTP_DELAYED_SACK)
This option will affect the way delayed sacks are performed. This This option will affect the way delayed SACKs are performed. This
option allows the application to get or set the delayed sack time, in option allows the application to get or set the delayed SACK time, in
milliseconds. It also allows changing the delayed sack frequency. milliseconds. It also allows changing the delayed SACK frequency.
Changing the frequency to 1 disables the delayed sack algorithm. Changing the frequency to 1 disables the delayed SACK algorithm.
Note that if sack_delay or sack_freq are 0 when setting this option, Note that if sack_delay or sack_freq is 0 when setting this option,
the current values will remain unchanged. the current values will remain unchanged.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_sack_info { struct sctp_sack_info {
sctp_assoc_t sack_assoc_id; sctp_assoc_t sack_assoc_id;
uint32_t sack_delay; uint32_t sack_delay;
uint32_t sack_freq; uint32_t sack_freq;
}; };
skipping to change at page 75, line 4 skipping to change at page 75, line 13
the current values will remain unchanged. the current values will remain unchanged.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_sack_info { struct sctp_sack_info {
sctp_assoc_t sack_assoc_id; sctp_assoc_t sack_assoc_id;
uint32_t sack_delay; uint32_t sack_delay;
uint32_t sack_freq; uint32_t sack_freq;
}; };
sack_assoc_id: This parameter is ignored for one-to-one style sack_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets this parameter indicates sockets. For one-to-many style sockets, this parameter indicates
which association the user is performing an action upon. The upon which association the user is performing an action. The
special SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used. special SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used.
sack_delay: This parameter contains the number of milliseconds that sack_delay: This parameter contains the number of milliseconds the
the user is requesting the delayed SACK timer to be set to. Note user is requesting that the delayed SACK timer be set to. Note
that this value is defined in the standard to be between 200 and that this value is defined in [RFC4960] to be between 200 and 500
500 milliseconds. milliseconds.
sack_freq: This parameter contains the number of packets that must sack_freq: This parameter contains the number of packets that must
be received before a sack is sent without waiting for the delay be received before a SACK is sent without waiting for the delay
timer to expire. The default value is 2, setting this value to 1 timer to expire. The default value is 2; setting this value to 1
will disable the delayed sack algorithm. will disable the delayed SACK algorithm.
8.1.20. Get or Set Fragmented Interleave (SCTP_FRAGMENT_INTERLEAVE) 8.1.20. Get or Set Fragmented Interleave (SCTP_FRAGMENT_INTERLEAVE)
Fragmented interleave controls how the presentation of messages Fragmented interleave controls how the presentation of messages
occurs for the message receiver. There are three levels of fragment occurs for the message receiver. There are three levels of fragment
interleave defined. Two of the levels affect the one-to-one model, interleave defined. Two of the levels affect one-to-one style
while the one-to-many model is affected by all three levels. sockets, while one-to-many style sockets are affected by all three
levels.
This option takes an integer value. It can be set to a value of 0, 1 This option takes an integer value. It can be set to a value of 0,
or 2. Attempting to set this level to other values will return an 1, or 2. Attempting to set this level to other values will return an
error. error.
Setting the three levels provides the following receiver Setting the three levels provides the following receiver
interactions: interactions:
level 0: Prevents the interleaving of any messages. This means that level 0: Prevents the interleaving of any messages. This means that
when a partial delivery begins, no other messages will be received when a partial delivery begins, no other messages will be received
except the message being partially delivered. If another message except the message being partially delivered. If another message
arrives on a different stream (or association) that could be arrives on a different stream (or association) that could be
delivered, it will be blocked waiting for the user to read all of delivered, it will be blocked waiting for the user to read all of
the partially delivered message. the partially delivered message.
level 1: Allows interleaving of messages that are from different level 1: Allows interleaving of messages that are from different
associations. For the one-to-one model, level 0 and level 1 thus associations. For one-to-one style sockets, level 0 and level 1
have the same meaning since a one-to-one socket always receives thus have the same meaning, since a one-to-one style socket always
messages from the same association. Note that setting the one-to- receives messages from the same association. Note that setting a
many model to this level may cause multiple partial deliveries one-to-many style socket to this level may cause multiple partial
from different associations but for any given association, only deliveries from different associations, but for any given
one message will be delivered until all parts of a message have association, only one message will be delivered until all parts of
been delivered. This means that one large message, being read a message have been delivered. This means that one large message,
with an association identifier of "X", will block other messages being read with an association identifier of "X", will block other
from association "X" from being delivered. messages from association "X" from being delivered.
level 2: Allows complete interleaving of messages. This level level 2: Allows complete interleaving of messages. This level
requires that the sender carefully observes not only the peer requires that the sender not only carefully observe the peer
association identifier (or address) but must also pay careful association identifier (or address) but also pay careful attention
attention to the stream number. With this option enabled a to the stream number. With this option enabled, a partially
partially delivered message may begin being delivered for delivered message may begin being delivered for association "X"
association "X" stream "Y" and the next subsequent receive may stream "Y", and the next subsequent receive may return a message
return a message from association "X" stream "Z". Note that no from association "X" stream "Z". Note that no other messages
other messages would be delivered for association "X" stream "Y" would be delivered for association "X" stream "Y" until all of
until all of stream "Y"'s partially delivered message was read. stream "Y"'s partially delivered message was read. Note that this
Note that this option also affects the one-to-one model. Also option also affects one-to-one style sockets. Also note that for
note that for the one-to-many model not only another stream's one-to-many style sockets, not only another stream's message from
message from the same association may be delivered upon the next the same association may be delivered upon the next receive, but
receive, some other association's message may be delivered upon some other association's message may also be delivered upon the
the next receive. next receive.
An implementation should default the one-to-many model to level 1. An implementation should default one-to-many style sockets to level
The reason for this is that otherwise it is possible that a peer 1, because otherwise, it is possible that a peer could begin sending
could begin sending a partial message and thus block all other peers a partial message and thus block all other peers from sending data.
from sending data. However a setting of level 2 requires the However, a setting of level 2 requires that the application not only
application to not only be aware of the association (via the be aware of the association (via the association identifier or peer's
association identifier or peer's address) but also the stream number. address) but also the stream number. The stream number is not
The stream number is not present unless the user has subscribed to present unless the user has subscribed to the sctp_data_io_event (see
the sctp_data_io_event (see Section 6.2), which is deprecated, or has Section 6.2), which is deprecated, or has enabled the
enabled the SCTP_RECVRCVINFO socket option (see Section 8.1.29). SCTP_RECVRCVINFO socket option (see Section 8.1.29). This is also
This is also why we recommend that the one-to-one model be defaulted why we recommend that one-to-one style sockets be defaulted to level
to level 0 (level 1 for the one-to-one model has no effect). Note 0 (level 1 for one-to-one style sockets has no effect). Note that an
that an implementation should return an error if an application implementation should return an error if an application attempts to
attempts to set the level to 2 and has not subscribed to the set the level to 2 and has not subscribed to the sctp_data_io_event
sctp_data_io_event event, which is deprecated, or has enabled the event, which is deprecated, or has enabled the SCTP_RECVRCVINFO
SCTP_RECVRCVINFO socket option. socket option.
For applications that have subscribed to events, those events appear For applications that have subscribed to events, those events appear
in the normal socket buffer data stream. This means that unless the in the normal socket buffer data stream. This means that unless the
user has set the fragmentation interleave level to 0, notifications user has set the fragmentation interleave level to 0, notifications
may also be interleaved with partially delivered messages. may also be interleaved with partially delivered messages.
8.1.21. Set or Get the SCTP Partial Delivery Point 8.1.21. Set or Get the SCTP Partial Delivery Point
(SCTP_PARTIAL_DELIVERY_POINT) (SCTP_PARTIAL_DELIVERY_POINT)
This option will set or get the SCTP partial delivery point. This This option will set or get the SCTP partial delivery point. This
point is the size of a message where the partial delivery API will be point is the size of a message where the partial delivery API will be
invoked to help free up rwnd space for the peer. Setting this to a invoked to help free up rwnd space for the peer. Setting this to a
lower value will cause partial deliveries to happen more often. This lower value will cause partial deliveries to happen more often. This
option expects an integer that sets or gets the partial delivery option expects an integer that sets or gets the partial delivery
point in bytes. Note also that the call will fail if the user point in bytes. Note also that the call will fail if the user
attempts to set this value larger than the socket receive buffer attempts to set this value larger than the socket receive buffer
size. size.
Note that any single message having a length smaller than or equal to Note that any single message having a length smaller than or equal to
the SCTP partial delivery point will be delivered in one single read the SCTP partial delivery point will be delivered in a single read
call as long as the user provided buffer is large enough to hold the call as long as the user-provided buffer is large enough to hold the
message. message.
8.1.22. Set or Get the Use of Extended Receive Info 8.1.22. Set or Get the Use of Extended Receive Info
(SCTP_USE_EXT_RCVINFO) - DEPRECATED (SCTP_USE_EXT_RCVINFO) - DEPRECATED
This option will enable or disable the use of the extended version of This option will enable or disable the use of the extended version of
the sctp_sndrcvinfo structure. If this option is disabled, then the the sctp_sndrcvinfo structure. If this option is disabled, then the
normal sctp_sndrcvinfo structure is returned in all receive message normal sctp_sndrcvinfo structure is returned in all receive message
calls. If this option is enabled then the sctp_extrcvinfo structure calls. If this option is enabled, then the sctp_extrcvinfo structure
is returned in all receive message calls. The default is off. is returned in all receive message calls. The default is off.
Note that the sctp_extrcvinfo structure is never used in any send Note that the sctp_extrcvinfo structure is never used in any send
call. call.
This option is present for compatibility with older applications and This option is present for compatibility with older applications and
is deprecated. Future applications should use SCTP_NXTINFO to is deprecated. Future applications should use SCTP_NXTINFO to
retrieve this same information via ancillary data. retrieve this same information via ancillary data.
8.1.23. Set or Get the Auto ASCONF Flag (SCTP_AUTO_ASCONF) 8.1.23. Set or Get the Auto ASCONF Flag (SCTP_AUTO_ASCONF)
This option will enable or disable the use of the automatic This option will enable or disable the use of the automatic
generation of ASCONF chunks to add and delete addresses to an generation of ASCONF chunks to add and delete addresses to an
existing association. Note that this option has two caveats namely: existing association. Note that this option has two caveats, namely
a) it only affects sockets that are bound to all addresses available a) it only affects sockets that are bound to all addresses available
to the SCTP stack, and b) the system administrator may have an to the SCTP stack, and b) the system administrator may have an
overriding control that turns the ASCONF feature off no matter what overriding control that turns the ASCONF feature off no matter what
setting the socket option may have. setting the socket option may have.
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
8.1.24. Set or Get the Maximum Burst (SCTP_MAX_BURST) 8.1.24. Set or Get the Maximum Burst (SCTP_MAX_BURST)
This option will allow a user to change the maximum burst of packets 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 that can be emitted by this association. Note that the default value
is 4, and some implementations may restrict this setting so that it is 4, and some implementations may restrict this setting so that it
can only be lowered to positive values. can only be lowered to positive values.
To set or get this option the user fills in the following structure: To set or get this option, the user fills in the following structure:
struct sctp_assoc_value { struct sctp_assoc_value {
sctp_assoc_t assoc_id; sctp_assoc_t assoc_id;
uint32_t assoc_value; uint32_t assoc_value;
}; };
assoc_id: This parameter is ignored for one-to-one style sockets. assoc_id: This parameter is ignored for one-to-one style sockets.
For one-to-many style sockets this parameter indicates which For one-to-many style sockets, this parameter indicates upon which
association the user is performing an action upon. The special association the user is performing an action. The special
SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used. SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used.
assoc_value: This parameter contains the maximum burst. Setting the assoc_value: This parameter contains the maximum burst. Setting the
value to 0 disables burst mitigation. value to 0 disables burst mitigation.
8.1.25. Set or Get the Default Context (SCTP_CONTEXT) 8.1.25. Set or Get the Default Context (SCTP_CONTEXT)
The context field in the sctp_sndrcvinfo structure is normally only The context field in the sctp_sndrcvinfo structure is normally only
used when a failed message is retrieved holding the value that was 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 sent down on the actual send call. This option allows the setting,
a default context on an association basis that will be received on on an association basis, of a default context that will be received
reading messages from the peer. This is especially helpful in the on reading messages from the peer. This is especially helpful for an
one-to-many model for an application to keep some reference to an application when using one-to-many style sockets to keep some
internal state machine that is processing messages on the reference to an internal state machine that is processing messages on
association. Note that the setting of this value only affects the association. Note that the setting of this value only affects
received messages from the peer and does not affect the value that is received messages from the peer and does not affect the value that is
saved with outbound messages. saved with outbound messages.
To set or get this option the user fills in the following structure: To set or get this option, the user fills in the following structure:
struct sctp_assoc_value { struct sctp_assoc_value {
sctp_assoc_t assoc_id; sctp_assoc_t assoc_id;
uint32_t assoc_value; uint32_t assoc_value;
}; };
assoc_id: This parameter is ignored for one-to-one style sockets. assoc_id: This parameter is ignored for one-to-one style sockets.
For one-to-many style sockets this parameter indicates which For one-to-many style sockets, this parameter indicates upon which
association the user is performing an action upon. The special association the user is performing an action. The special
SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used. SCTP_{FUTURE|CURRENT|ALL}_ASSOC can also be used.
assoc_value: This parameter contains the context. assoc_value: This parameter contains the context.
8.1.26. Enable or Disable Explicit EOR Marking (SCTP_EXPLICIT_EOR) 8.1.26. Enable or Disable Explicit EOR Marking (SCTP_EXPLICIT_EOR)
This boolean flag is used to enable or disable explicit end of record This boolean flag is used to enable or disable explicit end of record
(EOR) marking. When this option is enabled, a user may make multiple (EOR) marking. When this option is enabled, a user may make multiple
send system calls to send a record and must indicate that they are send system calls to send a record and must indicate that they are
finished sending a particular record by including the SCTP_EOR flag. finished sending a particular record by including the SCTP_EOR flag.
If this boolean flag is disabled then each individual send system If this boolean flag is disabled, then each individual send system
call is considered to have an SCTP_EOR indicator set on it implicitly call is considered to have an SCTP_EOR indicator set on it implicitly
without the user having to explicitly add this flag. The default is without the user having to explicitly add this flag. The default
off. is off.
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
8.1.27. Enable SCTP Port Reusage (SCTP_REUSE_PORT) 8.1.27. Enable SCTP Port Reusage (SCTP_REUSE_PORT)
This option only supports one-to-one style SCTP sockets. If used on This option only supports one-to-one style SCTP sockets. If used on
a one-to-many style SCTP socket an error is indicated. a one-to-many style SCTP socket, an error is indicated.
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
This socket option must not be used after calling bind() or This socket option must not be used after calling bind() or
sctp_bindx() for a one-to-one style SCTP socket. If using bind() or sctp_bindx() for a one-to-one style SCTP socket. If using bind() or
sctp_bindx() on a socket with the SCTP_REUSE_PORT option, all other sctp_bindx() on a socket with the SCTP_REUSE_PORT option, all other
SCTP sockets bound to the same port must have set the SCTP sockets bound to the same port must have set the SCTP_REUSE_PORT
SCTP_REUSE_PORT. Calling bind() or sctp_bindx() for a socket without option. Calling bind() or sctp_bindx() for a socket without having
having set the SCTP_REUSE_PORT option will fail if there are other set the SCTP_REUSE_PORT option will fail if there are other sockets
sockets bound to the same port. At most one socket being bound to bound to the same port. At most one socket being bound to the same
the same port may be listening. port may be listening.
It should be noted that the behavior of the socket level socket It should be noted that the behavior of the socket-level socket
option to reuse ports and/or addresses for SCTP sockets is option to reuse ports and/or addresses for SCTP sockets is
unspecified. unspecified.
8.1.28. Set Notification Event (SCTP_EVENT) 8.1.28. Set Notification Event (SCTP_EVENT)
This socket option is used to set a specific notification option. This socket option is used to set a specific notification option.
Please see Section 6.2.2 for a full description of this option and Please see Section 6.2.2 for a full description of this option and
its usage. its usage.
8.1.29. Enable or Disable the Delivery of SCTP_RCVINFO as Ancillary 8.1.29. Enable or Disable the Delivery of SCTP_RCVINFO as Ancillary
Data (SCTP_RECVRCVINFO) Data (SCTP_RECVRCVINFO)
Setting this option specifies that SCTP_RCVINFO defined in Setting this option specifies that SCTP_RCVINFO (defined in
Section 5.3.5 is returned as ancillary data by recvmsg(). Section 5.3.5) is returned as ancillary data by recvmsg().
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
8.1.30. Enable or Disable the Delivery of SCTP_NXTINFO as Ancillary 8.1.30. Enable or Disable the Delivery of SCTP_NXTINFO as Ancillary
Data (SCTP_RECVNXTINFO) Data (SCTP_RECVNXTINFO)
Setting this option specifies that SCTP_NXTINFO defined in Setting this option specifies that SCTP_NXTINFO (defined in
Section 5.3.6 is returned as ancillary data by recvmsg(). Section 5.3.6) is returned as ancillary data by recvmsg().
This option expects an integer boolean flag, where a non-zero value This option expects an integer boolean flag, where a non-zero value
turns on the option, and a zero value turns off the option. turns on the option, and a zero value turns off the option.
8.1.31. Set Default Send Parameters (SCTP_DEFAULT_SNDINFO) 8.1.31. Set Default Send Parameters (SCTP_DEFAULT_SNDINFO)
Applications that wish to use the sendto() system call may wish to Applications that wish to use the sendto() system call may wish to
specify a default set of parameters that would normally be supplied specify a default set of parameters that would normally be supplied
through the inclusion of ancillary data. This socket option allows through the inclusion of ancillary data. This socket option allows
such an application to set the default sctp_sndinfo structure. The such an application to set the default sctp_sndinfo structure. The
application that wishes to use this socket option simply passes the application that wishes to use this socket option simply passes the
sctp_sndinfo structure defined in Section 5.3.4 to this call. The sctp_sndinfo structure (defined in Section 5.3.4) to this call. The
input parameters accepted by this call include snd_sid, snd_flags, input parameters accepted by this call include snd_sid, snd_flags,
snd_ppid, snd_context. The snd_flags is composed of a bitwise OR of snd_ppid, and snd_context. The snd_flags parameter is composed of a
SCTP_UNORDERED, SCTP_EOF, and SCTP_SENDALL. The snd_assoc_id field bitwise OR of SCTP_UNORDERED, SCTP_EOF, and SCTP_SENDALL. The
specifies the association to apply the parameters to. For a one-to- snd_assoc_id field specifies the association to which to apply the
many style socket any of the predefined constants are also allowed in parameters. For a one-to-many style socket, any of the predefined
this field. The field is ignored on the one-to-one style. constants are also allowed in this field. The field is ignored for
one-to-one style sockets.
8.1.32. Set Default PR-SCTP Parameters (SCTP_DEFAULT_PRINFO) 8.1.32. Set Default PR-SCTP Parameters (SCTP_DEFAULT_PRINFO)
This option sets and gets the default parameters for PR-SCTP. They This option sets and gets the default parameters for PR-SCTP. They
can be overwritten by specific information provided in send calls. can be overwritten by specific information provided in send calls.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_default_prinfo { struct sctp_default_prinfo {
uint16_t pr_policy; uint16_t pr_policy;
uint32_t pr_value; uint32_t pr_value;
sctp_assoc_t pr_assoc_id; sctp_assoc_t pr_assoc_id;
}; };
pr_policy: Same as described in Section 5.3.7. pr_policy: This field is the same as that described in
Section 5.3.7.
pr_value: Same as described in Section 5.3.7. pr_value: This field is the same as that described in Section 5.3.7.
pr_assoc_id: This field is ignored for one-to-one style sockets. pr_assoc_id: This field is ignored for one-to-one style sockets.
For one-to-many style sockets pr_assoc_id can be a particular For one-to-many style sockets, pr_assoc_id can be a particular
association identifier or SCTP_{FUTURE|CURRENT|ALL}_ASSOC. association identifier or SCTP_{FUTURE|CURRENT|ALL}_ASSOC.
8.2. Read-Only Options 8.2. Read-Only Options
The options defined in this subsection are read-only. Using this The options defined in this subsection are read-only. Using this
option in a setsockopt() call will result in an error indicating option in a setsockopt() call will result in an error indicating
EOPNOTSUPP. EOPNOTSUPP.
8.2.1. Association Status (SCTP_STATUS) 8.2.1. Association Status (SCTP_STATUS)
Applications can retrieve current status information about an Applications can retrieve current status information about an
association, including association state, peer receiver window size, association, including association state, peer receiver window size,
number of unacknowledged data chunks, and number of data chunks number of unacknowledged DATA chunks, and number of DATA chunks
pending receipt. This information is read-only. pending receipt. This information is read-only.
The following structure is used to access this information: The following structure is used to access this information:
struct sctp_status { struct sctp_status {
sctp_assoc_t sstat_assoc_id; sctp_assoc_t sstat_assoc_id;
int32_t sstat_state; int32_t sstat_state;
uint32_t sstat_rwnd; uint32_t sstat_rwnd;
uint16_t sstat_unackdata; uint16_t sstat_unackdata;
uint16_t sstat_penddata; uint16_t sstat_penddata;
uint16_t sstat_instrms; uint16_t sstat_instrms;
uint16_t sstat_outstrms; uint16_t sstat_outstrms;
uint32_t sstat_fragmentation_point; uint32_t sstat_fragmentation_point;
struct sctp_paddrinfo sstat_primary; struct sctp_paddrinfo sstat_primary;
}; };
sstat_assoc_id: This parameter is ignored for one-to-one style sstat_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets it holds the identifier sockets. For one-to-many style sockets, it holds the identifier
for the association. All notifications for a given association for the association. All notifications for a given association
have the same association identifier. The special SCTP_{FUTURE| have the same association identifier. The special SCTP_{FUTURE|
CURRENT|ALL}_ASSOC cannot be used. CURRENT|ALL}_ASSOC cannot be used.
sstat_state: This contains the association's current state, i.e. one sstat_state: This contains the association's current state, i.e.,
of the following values: one of the following values:
* SCTP_CLOSED * SCTP_CLOSED
* SCTP_BOUND * SCTP_BOUND
* SCTP_LISTEN * SCTP_LISTEN
* SCTP_COOKIE_WAIT * SCTP_COOKIE_WAIT
* SCTP_COOKIE_ECHOED * SCTP_COOKIE_ECHOED
* SCTP_ESTABLISHED * SCTP_ESTABLISHED
* SCTP_SHUTDOWN_PENDING * SCTP_SHUTDOWN_PENDING
* SCTP_SHUTDOWN_SENT * SCTP_SHUTDOWN_SENT
* SCTP_SHUTDOWN_RECEIVED * SCTP_SHUTDOWN_RECEIVED
skipping to change at page 82, line 8 skipping to change at page 82, line 19
* SCTP_SHUTDOWN_SENT * SCTP_SHUTDOWN_SENT
* SCTP_SHUTDOWN_RECEIVED * SCTP_SHUTDOWN_RECEIVED
* SCTP_SHUTDOWN_ACK_SENT * SCTP_SHUTDOWN_ACK_SENT
sstat_rwnd: This contains the association peer's current receiver sstat_rwnd: This contains the association peer's current receiver
window size. window size.
sstat_unackdata: This is the number of unacknowledged data chunks. sstat_unackdata: This is the number of unacknowledged DATA chunks.
sstat_penddata: This is the number of data chunks pending receipt. sstat_penddata: This is the number of DATA chunks pending receipt.
sstat_instrms: The number of streams that the peer will be using sstat_instrms: This is the number of streams that the peer will be
outbound. using outbound.
sstat_outstrms: The number of streams that the endpoint is allowed sstat_outstrms: This is the number of outbound streams that the
to use outbound. endpoint is allowed to use.
sstat_fragmentation_point: The size at which SCTP fragmentation will sstat_fragmentation_point: This is the size at which SCTP
occur. fragmentation will occur.
sstat_primary: This is information on the current primary peer sstat_primary: This is information on the current primary peer
address. address.
To access these status values, the application calls getsockopt() To access these status values, the application calls getsockopt()
with the option name SCTP_STATUS. with the option name SCTP_STATUS.
8.2.2. Peer Address Information (SCTP_GET_PEER_ADDR_INFO) 8.2.2. Peer Address Information (SCTP_GET_PEER_ADDR_INFO)
Applications can retrieve information about a specific peer address Applications can retrieve information about a specific peer address
of an association, including its reachability state, congestion of an association, including its reachability state, congestion
window, and retransmission timer values. This information is read- window, and retransmission timer values. This information is
only. read-only.
The following structure is used to access this information: The following structure is used to access this information:
struct sctp_paddrinfo { struct sctp_paddrinfo {
sctp_assoc_t spinfo_assoc_id; sctp_assoc_t spinfo_assoc_id;
struct sockaddr_storage spinfo_address; struct sockaddr_storage spinfo_address;
int32_t spinfo_state; int32_t spinfo_state;
uint32_t spinfo_cwnd; uint32_t spinfo_cwnd;
uint32_t spinfo_srtt; uint32_t spinfo_srtt;
uint32_t spinfo_rto; uint32_t spinfo_rto;
uint32_t spinfo_mtu; uint32_t spinfo_mtu;
}; };
spinfo_assoc_id: This parameter is ignored for one-to-one style spinfo_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets the following applies: sockets.
This field may be filled by the application, if so, this field
will have priority in looking up the association instead of using
the address specified in spinfo_address. Note that if the address
does not belong to the association specified then this call will
fail. If the application does not fill in the spinfo_assoc_id,
then the address will be used to lookup the association and on
return this field will have the valid association identifier. In
other words, this call can be used to translate an address into an
association identifier. Note that the predefined constants are
not allowed on this option.
spinfo_address: This is filled by the application, and contains the For one-to-many style sockets, this field may be filled by the
application, and if so, this field will have priority in looking
up the association instead of using the address specified in
spinfo_address. Note that if the address does not belong to the
association specified, then this call will fail. If the
application does not fill in the spinfo_assoc_id, then the address
will be used to look up the association, and on return, this field
will have the valid association identifier. In other words, this
call can be used to translate an address into an association
identifier. Note that the predefined constants are not allowed
for this option.
spinfo_address: This is filled by the application and contains the
peer address of interest. peer address of interest.
spinfo_state: This contains the peer address' state: spinfo_state: This contains the peer address's state:
SCTP_UNCONFIRMED: The initial state of a peer address. SCTP_UNCONFIRMED: This is the initial state of a peer address.
SCTP_ACTIVE: The state is entered the first time after path SCTP_ACTIVE: This state is entered the first time after path
verification. It can also be entered if the state is verification. It can also be entered if the state is
SCTP_INACTIVE and the path supervision detects that the peer SCTP_INACTIVE and the path supervision detects that the peer
address is reachable again. address is reachable again.
SCTP_INACTIVE: This state is entered whenever a path failure is SCTP_INACTIVE: This state is entered whenever a path failure is
detected. detected.
spinfo_cwnd: This contains the peer address' current congestion spinfo_cwnd: This contains the peer address's current congestion
window. window.
spinfo_srtt: This contains the peer address' current smoothed round- spinfo_srtt: This contains the peer address's current smoothed
trip time calculation in milliseconds. round-trip time calculation in milliseconds.
spinfo_rto: This contains the peer address' current retransmission spinfo_rto: This contains the peer address's current retransmission
timeout value in milliseconds. timeout value in milliseconds.
spinfo_mtu: The current path MTU of the peer address. It is the spinfo_mtu: This is the current Path MTU of the peer address. It is
number of bytes available in an SCTP packet for chunks. the number of bytes available in an SCTP packet for chunks.
8.2.3. Get the List of Chunks the Peer Requires to be Authenticated 8.2.3. Get the List of Chunks the Peer Requires to Be Authenticated
(SCTP_PEER_AUTH_CHUNKS) (SCTP_PEER_AUTH_CHUNKS)
This option gets a list of chunk types (see [RFC4960]) for a This option gets a list of chunk types (see [RFC4960]) for a
specified association that the peer requires to be received specified association that the peer requires to be received
authenticated only. authenticated only.
The following structure is used to access these parameters: The following structure is used to access these parameters:
struct sctp_authchunks { struct sctp_authchunks {
sctp_assoc_t gauth_assoc_id; sctp_assoc_t gauth_assoc_id;
uint32_t gauth_number_of_chunks uint32_t gauth_number_of_chunks
uint8_t gauth_chunks[]; uint8_t gauth_chunks[];
}; };
gauth_assoc_id: This parameter indicates for which association the gauth_assoc_id: This parameter indicates for which association the
user is requesting the list of peer authenticated chunks. For user is requesting the list of peer-authenticated chunks. For
one-to-one sockets, this parameter is ignored. Note that the one-to-one style sockets, this parameter is ignored. Note that
predefined constants are not allowed with this option. the predefined constants are not allowed with this option.
gauth_number_of_chunks: This parameter gives the number of elements gauth_number_of_chunks: This parameter gives the number of elements
in the array gauth_chunks. in the array gauth_chunks.
gauth_chunks: This parameter contains an array of chunk types that gauth_chunks: This parameter contains an array of chunk types that
the peer is requesting to be authenticated. If the passed in the peer is requesting to be authenticated. If the passed-in
buffer size is not large enough to hold the list of chunk types, buffer size is not large enough to hold the list of chunk types,
ENOBUFS is returned. ENOBUFS is returned.
8.2.4. Get the List of Chunks the Local Endpoint Requires to be 8.2.4. Get the List of Chunks the Local Endpoint Requires to Be
Authenticated (SCTP_LOCAL_AUTH_CHUNKS) Authenticated (SCTP_LOCAL_AUTH_CHUNKS)
This option gets a list of chunk types (see [RFC4960]) for a This option gets a list of chunk types (see [RFC4960]) for a
specified association that the local endpoint requires to be received specified association that the local endpoint requires to be received
authenticated only. authenticated only.
The following structure is used to access these parameters: The following structure is used to access these parameters:
struct sctp_authchunks { struct sctp_authchunks {
sctp_assoc_t gauth_assoc_id; sctp_assoc_t gauth_assoc_id;
uint32_t gauth_number_of_chunks; uint32_t gauth_number_of_chunks;
uint8_t gauth_chunks[]; uint8_t gauth_chunks[];
}; };
gauth_assoc_id: This parameter is ignored for one-to-one style gauth_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets the application may fill sockets. For one-to-many style sockets, the application may fill
in an association identifier or SCTP_FUTURE_ASSOC. It is an error in an association identifier or SCTP_FUTURE_ASSOC. It is an error
to use SCTP_{CURRENT|ALL}_ASSOC in gauth_assoc_id. to use SCTP_{CURRENT|ALL}_ASSOC in gauth_assoc_id.
gauth_number_of_chunks: This parameter gives the number of elements gauth_number_of_chunks: This parameter gives the number of elements
in the array gauth_chunks. in the array gauth_chunks.
gauth_chunks: This parameter contains an array of chunk types that gauth_chunks: This parameter contains an array of chunk types that
the local endpoint is requesting to be authenticated. If the the local endpoint is requesting to be authenticated. If the
passed in buffer is not large enough to hold the list of chunk passed-in buffer is not large enough to hold the list of chunk
types, ENOBUFS is returned. types, ENOBUFS is returned.
8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER) 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER)
This option gets the current number of associations that are attached This option gets the current number of associations that are attached
to a one-to-many style socket. The option value is an uint32_t. to a one-to-many style socket. The option value is an uint32_t.
Note that this number is only a snap shot. This means that the Note that this number is only a snapshot. This means that the number
number of associations may have changed when the caller gets back the of associations may have changed when the caller gets back the option
option result. result.
For a one-to-one style socket, this socket option results in an For a one-to-one style socket, this socket option results in an
error. error.
8.2.6. Get the Current Identifiers of Associations 8.2.6. Get the Current Identifiers of Associations
(SCTP_GET_ASSOC_ID_LIST) (SCTP_GET_ASSOC_ID_LIST)
This option gets the current list of SCTP association identifiers of This option gets the current list of SCTP association identifiers of
the SCTP associations handled by a one-to-many style socket. the SCTP associations handled by a one-to-many style socket.
The option value has the structure The option value has the structure
struct sctp_assoc_ids { struct sctp_assoc_ids {
uint32_t gaids_number_of_ids; uint32_t gaids_number_of_ids;
sctp_assoc_t gaids_assoc_id[]; sctp_assoc_t gaids_assoc_id[];
}; };
The caller must provide a large enough buffer to hold all association The caller must provide a large enough buffer to hold all association
identifiers. If the buffer is too small, an error must be returned. identifiers. If the buffer is too small, an error must be returned.
The user can use the SCTP_GET_ASSOC_NUMBER socket option to get an The user can use the SCTP_GET_ASSOC_NUMBER socket option to get an
idea how large the buffer has to be. gaids_number_of_ids gives the idea of how large the buffer has to be. gaids_number_of_ids gives
number of elements in the array gaids_assoc_id. Note also that some the number of elements in the array gaids_assoc_id. Note also that
or all of sctp_assoc_t returned in the array may become invalid by some or all of sctp_assoc_t returned in the array may become invalid
the time the caller gets back the result. by the time the caller gets back the result.
For a one-to-one style socket, this socket option results in an For a one-to-one style socket, this socket option results in an
error. error.
8.3. Write-Only Options 8.3. Write-Only Options
The options defined in this subsection are write-only. Using this The options defined in this subsection are write-only. Using this
option in a getsockopt() or sctp_opt_info() call will result in an option in a getsockopt() or sctp_opt_info() call will result in an
error indicating EOPNOTSUPP. error indicating EOPNOTSUPP.
8.3.1. Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR) 8.3.1. Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
Requests that the peer marks the enclosed address as the association This call requests that the peer mark the enclosed address as the
primary (see [RFC5061]). The enclosed address must be one of the association primary (see [RFC5061]). The enclosed address must be
association's locally bound addresses. one of the association's locally bound addresses.
The following structure is used to make a set peer primary request: The following structure is used to make a set peer primary request:
struct sctp_setpeerprim { struct sctp_setpeerprim {
sctp_assoc_t sspp_assoc_id; sctp_assoc_t sspp_assoc_id;
struct sockaddr_storage sspp_addr; struct sockaddr_storage sspp_addr;
}; };
sspp_assoc_id: This parameter is ignored for one-to-one style sspp_assoc_id: This parameter is ignored for one-to-one style
sockets. For one-to-many style sockets it identifies the sockets. For one-to-many style sockets, it identifies the
association for this request. Note that the predefined constants association for this request. Note that the predefined constants
are not allowed on this option. are not allowed for this option.
sspp_addr: The address to set as primary. sspp_addr: The address to set as primary.
8.3.2. Add a Chunk that must be Authenticated (SCTP_AUTH_CHUNK) 8.3.2. Add a Chunk That Must Be Authenticated (SCTP_AUTH_CHUNK)
This set option adds a chunk type that the user is requesting to be 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 received only in an authenticated way. Changes to the list of chunks
will only affect future associations on the socket. will only affect future associations on the socket.
The following structure is used to add a chunk: The following structure is used to add a chunk:
struct sctp_authchunk { struct sctp_authchunk {
uint8_t sauth_chunk; uint8_t sauth_chunk;
}; };
sauth_chunk: This parameter contains a chunk type that the user is sauth_chunk: This parameter contains a chunk type that the user is
requesting to be authenticated. requesting to be authenticated.
The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE, and AUTH The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE, and AUTH
chunks must not be used. If they are used, an error must be chunks must not be used. If they are used, an error must be
returned. The usage of this option enables SCTP AUTH in cases where returned. The usage of this option enables SCTP AUTH in cases where
it is not required by other means (for example the use of dynamic it is not required by other means (for example, the use of dynamic
address reconfiguration). address reconfiguration).
8.3.3. Set a Shared Key (SCTP_AUTH_KEY) 8.3.3. Set a Shared Key (SCTP_AUTH_KEY)
This option will set a shared secret key that is used to build an This option will set a shared secret key that is used to build an
association shared key. association shared key.
The following structure is used to access and modify these The following structure is used to access and modify these
parameters: parameters:
struct sctp_authkey { struct sctp_authkey {
sctp_assoc_t sca_assoc_id; sctp_assoc_t sca_assoc_id;
uint16_t sca_keynumber; uint16_t sca_keynumber;
uint16_t sca_keylength; uint16_t sca_keylength;
uint8_t sca_key[]; uint8_t sca_key[];
}; };
sca_assoc_id: This parameter indicates what association the shared sca_assoc_id: This parameter indicates on what association the
key is being set upon. The special SCTP_{FUTURE|CURRENT| shared key is being set. The special SCTP_{FUTURE|CURRENT|
ALL}_ASSOC can be used. For one-to-one sockets, this parameter is ALL}_ASSOC can be used. For one-to-one style sockets, this
ignored. Note, however on one to one sockets, that this option parameter is ignored. Note, however, that on one-to-one style
will set a key on the association if the socket is connected, sockets, this option will set a key on the association if the
otherwise this will set a key on the endpoint. socket is connected; otherwise, this option will set a key on the
endpoint.
sca_keynumber: This parameter is the shared key identifier by which sca_keynumber: This parameter is the shared key identifier by which
the application will refer to this shared key. If a key of the the application will refer to this shared key. If a key of the
specified index already exists, then this new key will replace the specified index already exists, then this new key will replace the
old existing key. Note that shared key identifier '0' defaults to old existing key. Note that shared key identifier '0' defaults to
a null key. a null key.
sca_keylength: This parameter is the length of the array sca_key. sca_keylength: This parameter is the length of the array sca_key.
sca_key: This parameter contains an array of bytes that is to be sca_key: This parameter contains an array of bytes that is to be
used by the endpoint (or association) as the shared secret key. used by the endpoint (or association) as the shared secret key.
Note, if the length of this field is zero, a null key is set. Note that if the length of this field is zero, a null key is set.
8.3.4. Deactivate a Shared Key (SCTP_AUTH_DEACTIVATE_KEY) 8.3.4. Deactivate a Shared Key (SCTP_AUTH_DEACTIVATE_KEY)
This set option indicates that the application will no longer send This set option indicates that the application will no longer send
user messages using the indicated key identifier. user messages using the indicated key identifier.
struct sctp_authkeyid { struct sctp_authkeyid {
sctp_assoc_t scact_assoc_id; sctp_assoc_t scact_assoc_id;
uint16_t scact_keynumber; uint16_t scact_keynumber;
}; };
scact_assoc_id: This parameter indicates which association the scact_assoc_id: This parameter indicates from which association the
shared key identifier is being deleted from. The special shared key identifier is being deleted. The special SCTP_{FUTURE|
SCTP_{FUTURE|CURRENT|ALL}_ASSOC can be used. For one-to-one CURRENT|ALL}_ASSOC can be used. For one-to-one style sockets,
sockets, this parameter is ignored. Note, however, that this this parameter is ignored. Note, however, that this option will
option will deactivate the key from the association if the socket deactivate the key from the association if the socket is
is connected, otherwise this will deactivate the key from the connected; otherwise, this option will deactivate the key from the
endpoint. endpoint.
scact_keynumber: This parameter is the shared key identifier which scact_keynumber: This parameter is the shared key identifier that
the application is requesting to be deactivated. The key the application is requesting to be deactivated. The key
identifier must correspond to an existing shared key. Note if identifier must correspond to an existing shared key. Note that
this parameter is zero, use of the null key identifier '0' is if this parameter is zero, use of the null key identifier '0' is
deactivated on the endpoint and/or association. deactivated on the endpoint and/or association.
The currently active key cannot be deactivated. The currently active key cannot be deactivated.
8.3.5. Delete a Shared Key (SCTP_AUTH_DELETE_KEY) 8.3.5. Delete a Shared Key (SCTP_AUTH_DELETE_KEY)
This set option will delete a shared secret key which has been This set option will delete an SCTP association's shared secret key
deactivated of an SCTP association. that has been deactivated.
struct sctp_authkeyid { struct sctp_authkeyid {
sctp_assoc_t scact_assoc_id; sctp_assoc_t scact_assoc_id;
uint16_t scact_keynumber; uint16_t scact_keynumber;
}; };
scact_assoc_id: This parameter indicates which association the scact_assoc_id: This parameter indicates from which association the
shared key identifier is being deleted from. The special shared key identifier is being deleted. The special SCTP_{FUTURE|
SCTP_{FUTURE|CURRENT|ALL}_ASSOC can be used. For one-to-one CURRENT|ALL}_ASSOC can be used. For one-to-one style sockets,
sockets, this parameter is ignored. Note, however, that this this parameter is ignored. Note, however, that this option will
option will delete the key from the association if the socket is delete the key from the association if the socket is connected;
connected, otherwise this will delete the key from the endpoint. otherwise, this option will delete the key from the endpoint.
scact_keynumber: This parameter is the shared key identifier which scact_keynumber: This parameter is the shared key identifier that
the application is requesting to be deleted. The key identifier the application is requesting to be deleted. The key identifier
must correspond to an existing shared key and must not be in use must correspond to an existing shared key and must not be in use
for any packet being sent by the SCTP implementation. This means for any packet being sent by the SCTP implementation. This means,
in particular, that it must be deactivated first. Note if this in particular, that it must be deactivated first. Note that if
parameter is zero, use of the null key identifier '0' is deleted this parameter is zero, use of the null key identifier '0' is
from the endpoint and/or association. deleted from the endpoint and/or association.
Only deactivated keys that are no longer used by an association can Only deactivated keys that are no longer used by an association can
be deleted. be deleted.
9. New Functions 9. New Functions
Depending on the system, the following interface can be implemented Depending on the system, the following interface can be implemented
as a system call or library function. as a system call or library function.
9.1. sctp_bindx() 9.1. sctp_bindx()
skipping to change at page 88, line 47 skipping to change at page 89, line 16
int sctp_bindx(int sd, int sctp_bindx(int sd,
struct sockaddr *addrs, struct sockaddr *addrs,
int addrcnt, int addrcnt,
int flags); int flags);
If sd is an IPv4 socket, the addresses passed must be IPv4 addresses. 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 If the sd is an IPv6 socket, the addresses passed can either be IPv4
or IPv6 addresses. or IPv6 addresses.
A single address may be specified as INADDR_ANY or IN6ADDR_ANY, see A single address may be specified as INADDR_ANY for an IPv4 address,
or as IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address; see
Section 3.1.2 for this usage. Section 3.1.2 for this usage.
addrs is a pointer to an array of one or more socket addresses. Each addrs is a pointer to an array of one or more socket addresses. Each
address is contained in its appropriate structure. For an IPv6 address is contained in its appropriate structure. For an IPv6
socket, an array of sockaddr_in6 is used. For a IPv4 socket, an socket, an array of sockaddr_in6 is used. For an IPv4 socket, an
array of sockaddr_in is used. The caller specifies the number of array of sockaddr_in is used. The caller specifies the number of
addresses in the array with addrcnt. Note that the wildcard addresses in the array with addrcnt. Note that the wildcard
addresses cannot be used in combination with non wildcard addresses addresses cannot be used in combination with non-wildcard addresses
on a socket with this function, doing so will result in an error. on a socket with this function; doing so will result in an error.
On success, sctp_bindx() returns 0. On failure, sctp_bindx() returns On success, sctp_bindx() returns 0. On failure, sctp_bindx() returns
-1 and sets errno to the appropriate error code. -1 and sets errno to the appropriate error code.
For SCTP, the port given in each socket address must be the same, or For SCTP, the port given in each socket address must be the same, or
sctp_bindx() will fail, setting errno to EINVAL. sctp_bindx() will fail, setting errno to EINVAL.
The flags parameter is formed from the bitwise OR of zero or more of The flags parameter is formed from the bitwise OR of zero or more of
the following currently defined flags: the following currently defined flags:
o SCTP_BINDX_ADD_ADDR o SCTP_BINDX_ADD_ADDR
o SCTP_BINDX_REM_ADDR o SCTP_BINDX_REM_ADDR
SCTP_BINDX_ADD_ADDR directs SCTP to add the given addresses to the SCTP_BINDX_ADD_ADDR directs SCTP to add the given addresses to the
socket (i.e. endpoint), and SCTP_BINDX_REM_ADDR directs SCTP to socket (i.e., endpoint), and SCTP_BINDX_REM_ADDR directs SCTP to
remove the given addresses from the socket. The two flags are remove the given addresses from the socket. The two flags are
mutually exclusive; if both are given, sctp_bindx() will fail with mutually exclusive; if both are given, sctp_bindx() will fail with
EINVAL. A caller may not remove all addresses from a socket; EINVAL. A caller may not remove all addresses from a socket;
sctp_bindx() will reject such an attempt with EINVAL. sctp_bindx() will reject such an attempt with EINVAL.
An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate
additional addresses with an endpoint after calling bind(). Or use additional addresses with an endpoint after calling bind(). Or, an
sctp_bindx(SCTP_BINDX_REM_ADDR) to remove some addresses a listening application can use sctp_bindx(SCTP_BINDX_REM_ADDR) to remove some
socket is associated with, so that no new association accepted will addresses with which a listening socket is associated, so that no new
be associated with these addresses. If the endpoint supports dynamic association accepted will be associated with these addresses. If the
address reconfiguration, an SCTP_BINDX_REM_ADDR or endpoint supports dynamic address reconfiguration, an
SCTP_BINDX_ADD_ADDR may cause an endpoint to send the appropriate SCTP_BINDX_REM_ADDR or SCTP_BINDX_ADD_ADDR may cause an endpoint to
message to its peers to change the peers' address lists. send the appropriate message to its peers to change the peers'
address lists.
Adding and removing addresses from established associations is an Adding and removing addresses from established associations is an
optional functionality. Implementations that do not support this optional functionality. Implementations that do not support this
functionality should return -1 and set errno to EOPNOTSUPP. functionality should return -1 and set errno to EOPNOTSUPP.
sctp_bindx() can be called on an already bound socket or on an sctp_bindx() can be called on an already bound socket or on an
unbound socket. If the socket is unbound and the first port number unbound socket. If the socket is unbound and the first port number
in the addrs is zero, the kernel will choose a port number. All port in the addrs parameter is zero, the kernel will choose a port number.
numbers after the first one being 0 must also be zero. If the first All port numbers after the first one being 0 must also be zero. If
port number is not zero, the following port numbers must be zero or the first port number is not zero, the following port numbers must be
have the same value as the first one. For an already bound socket, zero or have the same value as the first one. For an already bound
all port numbers provided must be the bound one or 0. socket, all port numbers provided must be the bound one or 0.
sctp_bindx() is an atomic operation. Therefore, the binding will be sctp_bindx() is an atomic operation. Therefore, the binding will
either successful on all addresses or fail on all addresses. If either succeed on all addresses or fail on all addresses. If
multiple addresses are provided and the sctp_bindx() call fails there multiple addresses are provided and the sctp_bindx() call fails,
is no indication which address is responsible for the failure. The there is no indication of which address is responsible for the
only way to identify the specific error indication is to call failure. The only way to identify the specific error indication is
sctp_bindx() sequentially with only one address per call. to call sctp_bindx() sequentially with only one address per call.
9.2. sctp_peeloff() 9.2. sctp_peeloff()
After an association is established on a one-to-many style socket, After an association is established on a one-to-many style socket,
the application may wish to branch off the association into a the application may wish to branch off the association into a
separate socket/file descriptor. separate socket/file descriptor.
This is particularly desirable when, for instance, the application This is particularly desirable when, for instance, the application
wishes to have a number of sporadic message senders/receivers remain wishes to have a number of sporadic message senders/receivers remain
under the original one-to-many style socket, but branch off these under the original one-to-many style socket but branch off these
associations carrying high volume data traffic into their own associations carrying high-volume data traffic into their own
separate socket descriptors. separate socket descriptors.
The application uses the sctp_peeloff() call to branch off an The application uses the sctp_peeloff() call to branch off an
association into a separate socket (Note the semantics are somewhat association into a separate socket. (Note that the semantics are
changed from the traditional one-to-one style accept() call). Note somewhat changed from the traditional one-to-one style accept()
that the new socket is a one-to-one style socket. Thus it will be call.) Note also that the new socket is a one-to-one style socket.
confined to operations allowed for 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 The function prototype is
int sctp_peeloff(int sd, int sctp_peeloff(int sd,
sctp_assoc_t assoc_id); sctp_assoc_t assoc_id);
and the arguments are and the arguments are
sd: The original one-to-many style socket descriptor returned from sd: The original one-to-many style socket descriptor returned from
the socket() system call (see Section 3.1.1). the socket() system call (see Section 3.1.1).
assoc_id: the specified identifier of the association that is to be assoc_id: The specified identifier of the association that is to be
branched off to a separate file descriptor (Note, in a traditional branched off to a separate file descriptor. (Note that in a
one-to-one style accept() call, this would be an out parameter, traditional one-to-one style accept() call, this would be an out
but for the one-to-many style call, this is an in parameter). parameter, but for the one-to-many style call, this is an in
parameter.)
The function returns a non-negative file descriptor representing the The function returns a non-negative file descriptor representing the
branched-off association, or -1 if an error occurred. The variable branched-off association, or -1 if an error occurred. The variable
errno is then set appropriately. errno is then set appropriately.
9.3. sctp_getpaddrs() 9.3. sctp_getpaddrs()
sctp_getpaddrs() returns all peer addresses in an association. sctp_getpaddrs() returns all peer addresses in an association.
The function prototype is: The function prototype is
int sctp_getpaddrs(int sd, int sctp_getpaddrs(int sd,
sctp_assoc_t id, sctp_assoc_t id,
struct sockaddr **addrs); struct sockaddr **addrs);
On return, addrs will point to a dynamically allocated array of On return, addrs will point to a dynamically allocated array of
sockaddr structures of the appropriate type for the socket type. The sockaddr structures of the appropriate type for the socket type. The
caller should use sctp_freepaddrs() to free the memory. Note that caller should use sctp_freepaddrs() to free the memory. Note that
the in/out parameter addrs must not be NULL. the in/out parameter addrs must not be NULL.
skipping to change at page 91, line 41 skipping to change at page 92, line 18
The function prototype is The function prototype is
void sctp_freepaddrs(struct sockaddr *addrs); void sctp_freepaddrs(struct sockaddr *addrs);
and addrs is the array of peer addresses returned by and addrs is the array of peer addresses returned by
sctp_getpaddrs(). sctp_getpaddrs().
9.5. sctp_getladdrs() 9.5. sctp_getladdrs()
sctp_getladdrs() returns all locally bound address(es) on a socket. sctp_getladdrs() returns all locally bound addresses on a socket.
The function prototype is The function prototype is
int sctp_getladdrs(int sd, int sctp_getladdrs(int sd,
sctp_assoc_t id, sctp_assoc_t id,
struct sockaddr **addrs); struct sockaddr **addrs);
On return, addrs will point to a dynamically allocated array of On return, addrs will point to a dynamically allocated array of
sockaddr structures of the appropriate type for the socket type. The sockaddr structures of the appropriate type for the socket type. The
caller should use sctp_freeladdrs() to free the memory. Note that caller should use sctp_freeladdrs() to free the memory. Note that
the in/out parameter addrs must not be NULL. the in/out parameter addrs must not be NULL.
If sd is an IPv4 socket, the addresses returned will be all IPv4 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 addresses. If sd is an IPv6 socket, the addresses returned can be a
mix of IPv4 or IPv6 addresses, with IPv4 addresses returned according mix of IPv4 or IPv6 addresses, with IPv4 addresses returned according
to the SCTP_I_WANT_MAPPED_V4_ADDR option setting. to the SCTP_I_WANT_MAPPED_V4_ADDR option setting.
For one-to-many style sockets, id specifies the association to query. For one-to-many style sockets, id specifies the association to query.
For one-to-one style sockets, id is ignored. For one-to-one style sockets, id is ignored.
If the id field is set to the value '0' then the locally bound If the id field is set to the value '0', then the locally bound
addresses are returned without regard to any particular association. addresses are returned without regard to any particular association.
On success, sctp_getladdrs() returns the number of local addresses On success, sctp_getladdrs() returns the number of local addresses
bound to the socket. If the socket is unbound, sctp_getladdrs() bound to the socket. If the socket is unbound, sctp_getladdrs()
returns 0, and the value of *addrs is undefined. If an error occurs, returns 0, and the value of *addrs is undefined. If an error occurs,
sctp_getladdrs() returns -1, and the value of *addrs is undefined. sctp_getladdrs() returns -1, and the value of *addrs is undefined.
9.6. sctp_freeladdrs() 9.6. sctp_freeladdrs()
sctp_freeladdrs() frees all resources allocated by sctp_getladdrs(). sctp_freeladdrs() frees all resources allocated by sctp_getladdrs().
The function prototype is The function prototype is
void sctp_freeladdrs(struct sockaddr *addrs); void sctp_freeladdrs(struct sockaddr *addrs);
and addrs is the array of local addresses returned by and addrs is the array of local addresses returned by
sctp_getladdrs(). sctp_getladdrs().
9.7. sctp_sendmsg() - DEPRECATED 9.7. sctp_sendmsg() - DEPRECATED
This function is deprecated, sctp_sendv() (see Section 9.12) should This function is deprecated; sctp_sendv() (see Section 9.12) should
be used instead. be used instead.
An implementation may provide a library function (or possibly system An implementation may provide a library function (or possibly system
call) to assist the user with the advanced features of SCTP. call) to assist the user with the advanced features of SCTP.
The function prototype is The function prototype is
ssize_t sctp_sendmsg(int sd, ssize_t sctp_sendmsg(int sd,
const void *msg, const void *msg,
size_t len, size_t len,
const struct sockaddr *to, const struct sockaddr *to,
socklen_t tolen, socklen_t tolen,
uint32_t ppid, uint32_t ppid,
uint32_t flags, uint32_t flags,
uint16_t stream_no, uint16_t stream_no,
uint32_t timetolive, uint32_t timetolive,
uint32_t context); uint32_t context);
and the arguments are: and the arguments are
sd: The socket descriptor. sd: The socket descriptor.
msg: The message to be sent. msg: The message to be sent.
len: The length of the message. len: The length of the message.
to: The destination address of the message. to: The destination address of the message.
tolen: The length of the destination address. tolen: The length of the destination address.
skipping to change at page 93, line 34 skipping to change at page 94, line 18
context: The same as sinfo_context (see Section 5.3.2). context: The same as sinfo_context (see Section 5.3.2).
The call returns the number of characters sent, or -1 if an error The call returns the number of characters sent, or -1 if an error
occurred. The variable errno is then set appropriately. occurred. The variable errno is then set appropriately.
Sending a message using sctp_sendms