draft-ietf-tsvwg-sctpsocket-04.txt   draft-ietf-tsvwg-sctpsocket-05.txt 
Network Working Group R. R. Stewart Network Working Group R. Stewart
INTERNET-DRAFT Cisco Internet-Draft Cisco Systems, Inc.
Q. Xie Expires: April 2, 2003 Q. Xie
L Yarroll L. Yarroll
Motorola Motorola, Inc.
J. Wood J. Wood
DoCoMo USA Labs DoCoMo USA Labs
K. Poon K. Poon
Sun Microsystems Sun Microsystems, Inc.
K. Fujita K. Fujita
NEC NEC USA, Inc.
M. Tuexen
expires in six months May 12, 2002 Siemens AG
October 2, 2002
Sockets API Extensions for Stream Control Transmission Protocol Sockets API Extensions for Stream Control Transmission Protocol
<draft-ietf-tsvwg-sctpsocket-04.txt> (SCTP)
draft-ietf-tsvwg-sctpsocket-05.txt
Status of This Memo Status of this Memo
This document is an Internet-Draft and is in full conformance with This document is an Internet-Draft and is in full conformance with
all provisions of Section 10 of [RFC2026]. Internet-Drafts are all provisions of Section 10 of RFC2026.
working documents of the Internet Engineering Task Force (IETF), its
areas, and its working groups. Note that other groups may also
distribute working documents as Internet-Drafts.
The list of current Internet-Drafts can be accessed at Internet-Drafts are working documents of the Internet Engineering
http://www.ietf.org/ietf/1id-abstracts.txt Task Force (IETF), its areas, and its working groups. Note that
other groups may also distribute working documents as Internet-
Drafts.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
The list of current Internet-Drafts can be accessed at http://
www.ietf.org/ietf/1id-abstracts.txt.
The list of Internet-Draft Shadow Directories can be accessed at The list of Internet-Draft Shadow Directories can be accessed at
http://www.ietf.org/shadow.html. http://www.ietf.org/shadow.html.
Abstract This Internet-Draft will expire on April 2, 2003.
Copyright Notice
Copyright (C) The Internet Society (2002). All Rights Reserved.
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 RFC2960 [8] into a sockets API. The benefits of this
include compatibility for TCP applications, access to new SCTP mapping include compatibility for TCP applications, access to new
features and a consolidated error and event notification scheme. SCTP features and a consolidated error and event notification scheme.
Table of Contents Table of Contents
1. Introduction............................................ 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . 5
2. Conventions............................................. 4 2. Conventions . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Data Types............................................ 4 2.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . 7
3. UDP-style Interface..................................... 4 3. UDP-style Interface . . . . . . . . . . . . . . . . . . . 8
3.1 Basic Operation....................................... 4 3.1 3.1 Basic Operation . . . . . . . . . . . . . . . . . . . 8
3.1.1 socket() - UDP Style Syntax...................... 5 3.1.1 socket() - UDP Style Syntax . . . . . . . . . . . . . . . 9
3.1.2 bind() - UDP Style Syntax........................ 5 3.1.2 bind() - UDP Style Syntax . . . . . . . . . . . . . . . . 9
3.1.3 listen() - UDP Style Syntax...................... 6 3.1.3 listen() - UDP Style Syntax . . . . . . . . . . . . . . . 10
3.1.4 sendmsg() and recvmsg() - UDP Style Syntax....... 7 3.1.4 sendmsg() and recvmsg() - UDP Style Syntax . . . . . . . . 11
3.1.5 close() - UDP Style Syntax....................... 8 3.1.5 close() - UDP Style Syntax . . . . . . . . . . . . . . . . 12
3.1.6 connect() - UDP Style Syntax..................... 8 3.1.6 connect() - UDP Style Syntax . . . . . . . . . . . . . . . 13
3.2 Implicit Association Setup............................ 9 3.2 Implicit Association Setup . . . . . . . . . . . . . . . . 13
3.3 Non-blocking mode..................................... 9 3.3 Non-blocking mode . . . . . . . . . . . . . . . . . . . . 14
4. TCP-style Interface.....................................10 3.4 Special considerations . . . . . . . . . . . . . . . . . . 14
4.1 Basic Operation.......................................10 4. TCP-style Interface . . . . . . . . . . . . . . . . . . . 17
4.1.1 socket() - TCP Style Syntax........................11 4.1 Basic Operation . . . . . . . . . . . . . . . . . . . . . 17
4.1.2 bind() - TCP Style Syntax..........................11 4.1.1 socket() - TCP Style Syntax . . . . . . . . . . . . . . . 18
4.1.3 listen() - TCP Style Syntax........................12 4.1.2 bind() - TCP Style Syntax . . . . . . . . . . . . . . . . 18
4.1.4 accept() - TCP Style Syntax........................13 4.1.3 listen() - TCP Style Syntax . . . . . . . . . . . . . . . 19
4.1.5 connect() - TCP Style Syntax.......................13 4.1.4 accept() - TCP Style Syntax . . . . . . . . . . . . . . . 19
4.1.6 close() - TCP Style Syntax.........................14 4.1.5 connect() - TCP Style Syntax . . . . . . . . . . . . . . . 20
4.1.7 shutdown() - TCP Style Syntax......................14 4.1.6 close() - TCP Style Syntax . . . . . . . . . . . . . . . . 21
4.1.8 sendmsg() and recvmsg() - TCP Style Syntax.........15 4.1.7 shutdown() - TCP Style Syntax . . . . . . . . . . . . . . 21
4.1.9 getpeername() .....................................15 4.1.8 sendmsg() and recvmsg() - TCP Style Syntax . . . . . . . . 22
5. Data Structures..........................................16 4.1.9 getpeername() . . . . . . . . . . . . . . . . . . . . . . 23
5.1 The msghdr and cmsghdr Structures......................16 5. Data Structures . . . . . . . . . . . . . . . . . . . . . 24
5.2 SCTP msg_control Structures............................17 5.1 The msghdr and cmsghdr Structures . . . . . . . . . . . . 24
5.2.1 SCTP Initiation Structure (SCTP_INIT)...............17 5.2 SCTP msg_control Structures . . . . . . . . . . . . . . . 25
5.2.2 SCTP Header Information Structure (SCTP_SNDRCV).....19 5.2.1 SCTP Initiation Structure (SCTP_INIT) . . . . . . . . . . 26
5.3 SCTP Events and Notifications..........................21 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV) . . . . . 27
5.3.1 SCTP Notification Structure.........................21 5.3 SCTP Events and Notifications . . . . . . . . . . . . . . 30
5.3.1.1 SCTP_ASSOC_CHANGE................................23 5.3.1 SCTP Notification Structure . . . . . . . . . . . . . . . 30
5.3.1.2 SCTP_PEER_ADDR_CHANGE............................24 5.3.1.1 SCTP_ASSOC_CHANGE . . . . . . . . . . . . . . . . . . . . 32
5.3.1.3 SCTP_REMOTE_ERROR................................25 5.3.1.2 SCTP_PEER_ADDR_CHANGE . . . . . . . . . . . . . . . . . . 34
5.3.1.4 SCTP_SEND_FAILED.................................26 5.3.1.3 SCTP_REMOTE_ERROR . . . . . . . . . . . . . . . . . . . . 35
5.3.1.5 SCTP_SHUTDOWN_EVENT..............................27 5.3.1.4 SCTP_SEND_FAILED . . . . . . . . . . . . . . . . . . . . . 36
5.3.1.6 SCTP_ADAPTION_INDICATION.........................28 5.3.1.5 SCTP_SHUTDOWN_EVENT . . . . . . . . . . . . . . . . . . . 38
5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT......................29 5.3.1.6 SCTP_ADAPTION_INDICATION . . . . . . . . . . . . . . . . . 38
5.4 Ancillary Data Considerations and Semantics...........30 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT . . . . . . . . . . . . . . . 39
5.4.1 Multiple Items and Ordering........................30 5.4 Ancillary Data Considerations and Semantics . . . . . . . 40
5.4.2 Accessing and Manipulating Ancillary Data..........30 5.4.1 Multiple Items and Ordering . . . . . . . . . . . . . . . 40
5.4.3 Control Message Buffer Sizing......................31 5.4.2 Accessing and Manipulating Ancillary Data . . . . . . . . 40
6. Common Operations for Both Styles.......................31 5.4.3 Control Message Buffer Sizing . . . . . . . . . . . . . . 41
6.1 send(), recv(), sendto(), recvfrom()..................31 6. Common Operations for Both Styles . . . . . . . . . . . . 43
6.2 setsockopt(), getsockopt()............................32 6.1 send(), recv(), sendto(), recvfrom() . . . . . . . . . . . 43
6.3 read() and write()....................................33 6.2 setsockopt(), getsockopt() . . . . . . . . . . . . . . . . 44
6.4 getsockname().........................................33 6.3 read() and write() . . . . . . . . . . . . . . . . . . . . 44
7. Socket Options..........................................34 6.4 getsockname() . . . . . . . . . . . . . . . . . . . . . . 44
7.1 Read / Write Options..................................36 7. Socket Options . . . . . . . . . . . . . . . . . . . . . . 46
7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)...36 7.1 Read / Write Options . . . . . . . . . . . . . . . . . . . 48
7.1.2 Association Retransmission Parameter 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO) . . . . . 48
(SCTP_ASSOCRTXINFO)................................36 7.1.2 Association Parameters (SCTP_ASSOCINFO) . . . . . . . . . 49
7.1.3 Initialization Parameters (SCTP_INITMSG)...........38 7.1.3 Initialization Parameters (SCTP_INITMSG) . . . . . . . . . 50
7.1.4 SO_LINGER..........................................38 7.1.4 SO_LINGER . . . . . . . . . . . . . . . . . . . . . . . . 50
7.1.5 SO_NODELAY.........................................38 7.1.5 SCTP_NODELAY . . . . . . . . . . . . . . . . . . . . . . . 51
7.1.6 SO_RCVBUF..........................................38 7.1.6 SO_RCVBUF . . . . . . . . . . . . . . . . . . . . . . . . 51
7.1.7 SO_SNDBUF..........................................38 7.1.7 SO_SNDBUF . . . . . . . . . . . . . . . . . . . . . . . . 51
7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE)...39 7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE) . . . . . 51
7.1.9 SCTP_SET_PRIMARY_ADDR..............................39 7.1.9 Set Primary Address (SCTP_SET_PRIMARY_ADDR) . . . . . . . 51
7.1.10 SCTP_SET_PEER_PRIMARY_ADDR........................39 7.1.10 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR) . . 52
7.1.11 Set Adaption Layer Bits...........................40 7.1.11 Set Adaption Layer Indicator (SCTP_SET_ADAPTION_LAYER) . . 52
7.1.12 Set default message time outs 7.1.12 Set default message time outs (SCTP_SET_STREAM_TIMEOUTS) . 52
(SCTP_SET_STREAM_TIMEOUTS)........................40
7.1.13 Enable/Disable message fragmentation 7.1.13 Enable/Disable message fragmentation
(SCTP_DISABLE_FRAGMENTS)..........................40 (SCTP_DISABLE_FRAGMENTS) . . . . . . . . . . . . . . . . . 53
7.1.14 Peer Address Parameters 7.1.14 Peer Address Parameters (SCTP_SET_PEER_ADDR_PARAMS) . . . 53
(SCTP_SET_PEER_ADDR_PARAMS).......................40 7.1.15 Set default send parameters (SET_DEFAULT_SEND_PARAM) . . . 54
7.1.15 Set default send parameters.......................41 7.1.16 Set notification and ancillary events (SCTP_SET_EVENTS) . 54
7.1.16 Set notification and ancillary events 7.2 Read-Only Options . . . . . . . . . . . . . . . . . . . . 54
(SCTP_SET_EVENTS).................................41 7.2.1 Association Status (SCTP_STATUS) . . . . . . . . . . . . . 55
7.2 Read-Only Options.....................................41 7.2.2 Peer Address Information (SCTP_GET_PEER_ADDR_INFO) . . . . 56
7.2.1 Association Status (SCTP_STATUS)...................42 7.3 Ancillary Data and Notification Interest Options . . . . . 57
7.2.2 Peer Address Information (SCTP_GET_PEER_ADDR_INFO).43 8. New Interfaces . . . . . . . . . . . . . . . . . . . . . . 60
7.3. Ancillary Data and Notification Interest Options.....43 8.1 sctp_bindx() . . . . . . . . . . . . . . . . . . . . . . . 60
8. New Interfaces..........................................45 8.2 Branched-off Association . . . . . . . . . . . . . . . . . 61
8.1 sctp_bindx()..........................................45 8.3 sctp_getpaddrs() . . . . . . . . . . . . . . . . . . . . . 61
8.2 Branched-off Association, sctp_peeloff()..............46 8.4 sctp_freepaddrs() . . . . . . . . . . . . . . . . . . . . 62
8.3 sctp_getpaddrs()......................................47 8.5 sctp_getladdrs() . . . . . . . . . . . . . . . . . . . . . 62
8.4 sctp_freepaddrs().....................................47 8.6 sctp_freeladdrs() . . . . . . . . . . . . . . . . . . . . 63
8.5 sctp_getladdrs()......................................48 9. Security Considerations . . . . . . . . . . . . . . . . . 64
8.6 sctp_freeladdrs().....................................48 10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . 65
9. Security Considerations.................................48 References . . . . . . . . . . . . . . . . . . . . . . . . 66
10. Acknowledgments.......................................49 Authors' Addresses . . . . . . . . . . . . . . . . . . . . 66
11. Authors' Addresses....................................49 A. TCP-style Code Example . . . . . . . . . . . . . . . . . . 69
12. References............................................49 B. UDP-style Code Example . . . . . . . . . . . . . . . . . . 75
Appendix A: TCP-style Code Example.........................50 Full Copyright Statement . . . . . . . . . . . . . . . . . 77
Appendix B: UDP-style Code Example.........................55
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 [RFC793] and UDP Protocol suite to many operating systems. Both TCP RFC793 [1] and
[RFC768] have benefited from this standard representation and access UDP RFC768 [2] have benefited from this standard representation and
method across many diverse platforms. SCTP is a new protocol that access method across many diverse platforms. SCTP is a new protocol
provides many of the characteristics of TCP but also incorporates that provides many of the characteristics of TCP but also
semantics more akin to UDP. This document defines a method to map incorporates semantics more akin to UDP. This document defines a
the existing sockets API for use with SCTP, providing both a base method to map the existing sockets API for use with SCTP, providing
for access to new features and compatibility so that most existing both a base for access to new features and compatibility so that most
TCP applications can be migrated to SCTP with few (if any) changes. existing TCP 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: 1) Maintain consistency with existing sockets APIs:
We define a sockets mapping for SCTP that is consistent with other We define a sockets mapping for SCTP that is consistent with other
sockets API protocol mappings (for instance, UDP, TCP, IPv4, and sockets API protocol mappings (for instance, UDP, TCP, IPv4, and
IPv6). IPv6).
2) Support a UDP-style interface 2) Support a UDP-style interface
This set of semantics is similar to that defined for connection less This set of semantics is similar to that defined for connection
protocols, such as UDP. It is more efficient than a TCP-like less protocols, such as UDP. It is more efficient than a TCP-like
connection-oriented interface in terms of exploring the new features connection-oriented interface in terms of exploring the new
of SCTP. features of SCTP.
Note that SCTP is connection-oriented in nature, and it does not Note that SCTP is connection-oriented in nature, and it does not
support broadcast or multicast communications, as UDP does. support broadcast or multicast communications, as UDP does.
3) Support a TCP-style interface 3) Support a TCP-style interface
This interface supports the same basic semantics as sockets for This interface supports the same basic semantics as sockets for
connection-oriented protocols, such as TCP. connection-oriented protocols, such as TCP.
The purpose of defining this interface is to allow existing The purpose of defining this interface is to allow existing
applications built on connection-oriented protocols be ported to applications built on connection-oriented protocols be ported to
use SCTP with very little effort, and developers familiar with those use SCTP with very little effort, and developers familiar with
semantics can easily adapt to SCTP. those semantics can easily adapt to SCTP.
Extensions will be added to this mapping to provide mechanisms to Extensions will be added to this mapping to provide mechanisms to
exploit new features of SCTP. exploit new features of SCTP.
Goals 2 and 3 are not compatible, so in this document we define two Goals 2 and 3 are not compatible, so in this document we define two
modes of mapping, namely the UDP-style mapping and the TCP-style modes of mapping, namely the UDP-style mapping and the TCP-style
mapping. These two modes share some common data structures and mapping. These two modes share some common data structures and
operations, but will require the use of two different programming operations, but will require the use of two different application
models. programming models.
A mechanism is defined to convert a UDP-style SCTP socket into a A mechanism is defined to convert a UDP-style SCTP association into a
TCP-style socket. TCP-style socket.
Some of the SCTP mechanisms cannot be adequately mapped to existing Some of the SCTP mechanisms cannot be adequately mapped to existing
socket interface. In some cases, it is more desirable to have new socket interface. In some cases, it is more desirable to have new
interface instead of using existing socket calls. This document interface instead of using existing socket calls. This document also
also describes those new interface. describes those new interface.
2. Conventions 2. Conventions
2.1 Data Types 2.1 Data Types
Whenever possible, data types from Draft 6.6 (March 1997) of POSIX Whenever possible, data types from Draft 6.6 (March 1997) of POSIX
1003.1g are used: uintN_t means an unsigned integer of exactly N 1003.1g are used: uintN_t means an unsigned integer of exactly N bits
bits (e.g., uint16_t). We also assume the argument data types from (e.g., uint16_t). We also assume the argument data types from
1003.1g when possible (e.g., the final argument to setsockopt() is a 1003.1g when possible (e.g., the final argument to setsockopt() is a
size_t value). Whenever buffer sizes are specified, the POSIX size_t value). Whenever buffer sizes are specified, the POSIX 1003.1
1003.1 size_t data type is used. size_t data type is used.
3. UDP-style Interface 3. UDP-style Interface
The UDP-style interface has the following characteristics: The UDP-style interface has the following characteristics:
A) Outbound association setup is implicit. A) Outbound association setup is implicit.
B) Messages are delivered in complete messages (with one notable B) Messages are delivered in complete messages (with one notable
exception). exception).
3.1 Basic Operation C) There is a 1 to MANY relationship between socket and association.
3.1 3.1 Basic Operation
A typical server in this model uses the following socket calls in A typical server in this model uses the following socket calls in
sequence to prepare an endpoint for servicing requests: sequence to prepare an endpoint for servicing requests:
1. socket() 1. socket()
2. bind() 2. bind()
3. listen() 3. listen()
4. recvmsg() 4. recvmsg()
5. sendmsg() 5. sendmsg()
6. close() 6. close()
A typical client uses the following calls in sequence to setup an A typical client uses the following calls in sequence to setup an
association with a server to request services: association with a server to request services:
1. socket() 1. socket()
2. sendmsg() 2. sendmsg()
3. recvmsg() 3. recvmsg()
4. close() 4. close()
In this model, by default, all the associations connected to the In this model, by default, all the associations connected to the
endpoint are represented with a single socket. endpoint are represented with a single socket.
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 in to a separate socket, it is required to call sctp_peeloff() and in
the parameter specifies one of the transport addresses of the the parameter specifies one of the transport addresses of the
association. The sctp_peeloff() call will return a new socket which association. The sctp_peeloff() call will return a new socket which
can then be used with recv() and send() functions for message can then be used with recv() and send() functions for message
skipping to change at page 5, line 18 skipping to change at page 7, line 52
4. close() 4. close()
In this model, by default, all the associations connected to the In this model, by default, all the associations connected to the
endpoint are represented with a single socket. endpoint are represented with a single socket.
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 in to a separate socket, it is required to call sctp_peeloff() and in
the parameter specifies one of the transport addresses of the the parameter specifies one of the transport addresses of the
association. The sctp_peeloff() call will return a new socket which association. The sctp_peeloff() call will return a new socket which
can then be used with recv() and send() functions for message can then be used with recv() and send() functions for message
passing. See Section 8.2 for more on branched-off associations. passing. See Section Section 8.2 for 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.
We will discuss the UDP-style socket calls in more details in the We will discuss the UDP-style socket calls in more details in the
following subsections. following subsections.
skipping to change at page 5, line 45 skipping to change at page 8, line 31
The syntax is, The syntax is,
sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
or, or,
sd = socket(PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP); sd = socket(PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP);
Here, SOCK_SEQPACKET indicates the creation of a UDP-style socket. Here, SOCK_SEQPACKET indicates the creation of a UDP-style socket.
The first form creates an endpoint which can use only IPv4 The first form creates an endpoint which can use only IPv4 addresses,
addresses, while, the second form creates an endpoint which can use while, the second form creates an endpoint which can use both IPv6
both IPv6 and IPv4 mapped addresses. and IPv4 addresses.
3.1.2 bind() - UDP Style Syntax 3.1.2 bind() - UDP Style Syntax
Applications use bind() to specify which local address the SCTP Applications use bind() to specify which local address the SCTP
endpoint should associate itself with. endpoint should associate itself with.
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 8.1 to help applications this, sctp_bindx() is introduced in section Section 8.1 to help
do the job of associating multiple addresses. applications do the job of associating multiple addresses.
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 will also present these addresses to its peers during the association
association initialization process, see [SCTP]. initialization process, see RFC2960 [8].
After calling bind() or sctp_bindx(), if the endpoint wishes to After calling bind() or sctp_bindx(), if the endpoint wishes to
accept new associations on the socket, it must call listen() (see accept new associations on the socket, it must call listen() (see
section 3.1.3). section Section 3.1.3).
The syntax of bind() is, The syntax of bind() is,
ret = bind(int sd, struct sockaddr *addr, int addrlen); ret = bind(int sd, struct sockaddr *addr, socklen_t addrlen);
sd - the socket descriptor returned by socket(). sd: the socket descriptor returned by socket().
addr - the address structure (struct sockaddr_in or struct
sockaddr_in6 [RFC 2553]), addr: the address structure (struct sockaddr_in or struct
addrlen - the size of the address structure. sockaddr_in6 RFC2553 [7]).
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 the sd is an IPv6 socket, the address passed can either be an If the sd is an IPv6 socket, the address passed can either be an IPv4
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 addr is specified as a wildcard (INADDR_ANY for an IPv4 address, If addr is specified as a wildcard (INADDR_ANY for an IPv4 address,
or as IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address), the or as IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address), the
operating system will associate the endpoint with an optimal address operating system will associate the endpoint with an optimal address
set of the available interfaces. set of the available interfaces.
If a bind() or sctp_bindx() is not called prior to a sendmsg() call If a bind() or sctp_bindx() is not called prior to a sendmsg() call
that initiates a new association, the system picks an ephemeral port that initiates a new association, the system picks an ephemeral port
and will choose an address set equivalent to binding with a wildcard and will choose an address set equivalent to binding with a wildcard
address. One of those addresses will be the primary address for the address. One of those addresses will be the primary address for the
association. This automatically enables the multi-homing capability association. This automatically enables the multi-homing capability
of SCTP. of SCTP.
3.1.3 listen() - UDP Style Syntax 3.1.3 listen() - UDP Style Syntax
By default, new associations are not accepted for UDP style sockets. By default, new associations are not accepted for UDP style sockets.
An application uses listen() to mark a socket as being able to An application uses listen() to mark a socket as being able to accept
accept new associations. The syntax is, new associations. The syntax is,
int listen(int socket, int backlog); int listen(int socket, int backlog);
socket - the socket descriptor of the endpoint. socket - the socket descriptor of the endpoint.
backlog - ignored for UDP-style sockets. backlog - ignored for UDP-style sockets.
Note that UDP-style socket consumers do not need to call accept to Note that UDP-style socket consumers do not need to call accept to
retrieve new associations. Calling accept() on a UDP-style socket retrieve new associations. Calling accept() on a UDP-style socket
should return EOPNOTSUPP. Rather, new associations are accepted should return EOPNOTSUPP. Rather, new associations are accepted
automatically, and notifications of the new associations are automatically, and notifications of the new associations are
delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if these delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if these
notifications are enabled). Clients will typically not call listen, notifications are enabled). Clients will typically not call listen,
so that they can be assured that the only associations on the socket so that they can be assured that the only associations on the socket
skipping to change at page 7, line 6 skipping to change at page 10, line 5
backlog - ignored for UDP-style sockets. backlog - ignored for UDP-style sockets.
Note that UDP-style socket consumers do not need to call accept to Note that UDP-style socket consumers do not need to call accept to
retrieve new associations. Calling accept() on a UDP-style socket retrieve new associations. Calling accept() on a UDP-style socket
should return EOPNOTSUPP. Rather, new associations are accepted should return EOPNOTSUPP. Rather, new associations are accepted
automatically, and notifications of the new associations are automatically, and notifications of the new associations are
delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if these delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if these
notifications are enabled). Clients will typically not call listen, notifications are enabled). Clients will typically not call listen,
so that they can be assured that the only associations on the socket so that they can be assured that the only associations on the socket
will be ones they actively initiated. Server or peer-to-peer will be ones they actively initiated. Server or peer-to-peer
sockets, on the other hand, will always accept new associations, so sockets, on the other hand, will always accept new associations, so a
a well-written application using server UDP-style sockets must be well-written application using server UDP-style sockets must be
prepared to handle new associations from unwanted peers. 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
ID for a new association, so if applications wish to use the ID for a new association, so if applications wish to use the
association ID as input to other socket calls, they should ensure association ID as input to other socket calls, they should ensure
that the SCTP_ASSOC_CHANGE event is enabled (it is enabled by that the SCTP_ASSOC_CHANGE event is enabled (it is enabled by
default). default).
3.1.4 sendmsg() and recvmsg() - UDP Style Syntax 3.1.4 sendmsg() and recvmsg() - UDP Style Syntax
An application uses sendmsg() and recvmsg() call to transmit data to An application uses sendmsg() and recvmsg() call to transmit data to
and receive data from its peer. and receive data from its peer.
ssize_t sendmsg(int socket, const struct msghdr *message, ssize_t sendmsg(int socket, const struct msghdr *message, int flags);
int flags);
ssize_t recvmsg(int socket, struct msghdr *message, ssize_t recvmsg(int socket, struct msghdr *message, int flags);
int flags);
socket - the socket descriptor of the endpoint. socket: the socket descriptor of the endpoint.
message - pointer to the msghdr structure which contains a single
user message and possibly some ancillary data.
See Section 5 for complete description of the data message: pointer to the msghdr structure which contains a single user
structures. message and possibly some ancillary data. See Section 5 for
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
Section 5 for SCTP-specific flags used in the msghdr 5 for SCTP-specific flags used in the msghdr structure.
structure.
As we will see in Section 5, along with the user data, the ancillary As we will see in Section 5, along with the user data, the ancillary
data field is used to carry the sctp_sndrcvinfo and/or the data field is used to carry the sctp_sndrcvinfo and/or the
sctp_initmsg structures to perform various SCTP functions including sctp_initmsg structures to perform various SCTP functions including
specifying options for sending each user message. Those options, specifying options for sending each user message. Those options,
depending on whether sending or receiving, include stream number, depending on whether sending or receiving, include stream number,
stream sequence number, TOS, various flags, context and payload stream sequence number, various flags, context and payload protocol
protocol Id, etc. Id, etc.
When sending user data with sendmsg(), the msg_name field in msghdr When sending user data with sendmsg(), the msg_name field in msghdr
structure will be filled with one of the transport addresses of the structure will be filled with one of the transport addresses of the
intended receiver. If there is no association existing between the intended receiver. If there is no association existing between the
sender and the intended receiver, the sender's SCTP stack will set sender and the intended receiver, the sender's SCTP stack will set up
up a new association and then send the user data (see Section 3.2 a new association and then send the user data (see Section 3.2 for
for more on implicit association setup). more on implicit association setup).
If a peer sends a SHUTDOWN, a SCTP_SHUTDOWN_EVENT notification will If a peer sends a SHUTDOWN, a 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
msghdr structure will be populated with the source transport address 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 user information to determine to which association the received user
message belongs. Note that if SCTP_ASSOC_CHANGE events are disabled, message belongs. Note that if SCTP_ASSOC_CHANGE events are disabled,
applications must use the peer transport address provided in the applications must use the peer transport address provided in the
msg_name field by recvmsg() to perform correlation to an msg_name field by recvmsg() to perform correlation to an association,
association, since they will not have the association ID. since they will not have the association ID.
If all data in a single message has been delivered, MSG_EOR will be If all data in a single message has been delivered, MSG_EOR will be
set in the msg_flags field of the msghdr structure (see section set in the msg_flags field of the msghdr structure (see section
5.1). Section 5.1).
If the application does not provide enough buffer space to If the application does not provide enough buffer space to completely
completely receive a data message, MSG_EOR will not be set in receive a data message, MSG_EOR will not be set in msg_flags.
msg_flags. Successive reads will consume more of the same message Successive reads will consume more of the same message until the
until the entire message has been delivered, and MSG_EOR will be entire message has been delivered, and MSG_EOR will be set.
set.
If the SCTP stack is running low on buffers, it may partially If the SCTP stack is running low on buffers, it may partially deliver
deliver a message. In this case, MSG_EOR will not be set, and more a message. In this case, MSG_EOR will not be set, and more calls to
calls to recvmsg() will be necessary to completely consume the recvmsg() will be necessary to completely consume the message. Only
message. Only one message at a time can be partially delivered. one message at a time can be partially delivered.
Note, if the socket is a branched-off socket that only represents Note, if the socket is a branched-off socket that only represents one
one association (see Section 3.1), the msg_name field is not used association (see Section 3.1), the msg_name field is not used when
when sending data (i.e., ignored by the SCTP stack). sending data (i.e., ignored by the SCTP stack).
3.1.5 close() - UDP Style Syntax 3.1.5 close() - UDP Style Syntax
Applications use close() to perform graceful shutdown (as described Applications use close() to perform graceful shutdown (as described
in Section 10.1 of [SCTP]) on ALL the associations currently in Section 10.1 of RFC2960 [8]) on ALL the associations currently
represented by a UDP-style socket. represented by a UDP-style socket.
The syntax is The syntax is:
ret = close(int sd); ret = close(int sd);
sd - the socket descriptor of the associations to be closed. sd - the socket descriptor of the associations to be closed.
To gracefully shutdown a specific association represented by the To gracefully shutdown a specific association represented by the UDP-
UDP-style socket, an application should use the sendmsg() call, style socket, an application should use the sendmsg() call, passing
passing no user data, but including the MSG_EOF flag in the no user data, but including the MSG_EOF flag in the ancillary data
ancillary data (see Section 5.2.2). (see Section 5.2.2).
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() - UDP Style Syntax 3.1.6 connect() - UDP Style Syntax
An application may use the connect() call in the UDP model to An application may use the connect() call in the UDP model to
initiate an association without sending data. initiate an association without sending data.
The syntax is The syntax is:
ret = connect(int sd, const struct sockaddr *nam, int len); ret = connect(int sd, const struct sockaddr *nam, socklen_t len);
sd - the socket descriptor to have a new association added sd: the socket descriptor to have a new association added to.
to.
nam - the address structure (either struct sockaddr_in or struct nam: the address structure (either struct sockaddr_in or struct
sockaddr_in6 defined in [RFC 2553]). sockaddr_in6 defined in RFC2553 [7]).
len - the size of the address. len: the size of the address.
3.2 Implicit Association Setup 3.2 Implicit Association Setup
Once all bind() calls are complete on a UDP-style socket, the Once all bind() calls are complete on a UDP-style socket, the
application can begin sending and receiving data using the application can begin sending and receiving data using the sendmsg()/
sendmsg()/recvmsg() or sendto()/recvfrom() calls, without going recvmsg() or sendto()/recvfrom() calls, without going through any
through any explicit association setup procedures (i.e., no explicit association setup procedures (i.e., no connect() calls
connect() calls required). 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 there is no association existing between the sender finds that there is no association existing between the sender
sender and the intended receiver (identified by the address passed and the intended receiver (identified by the address passed either in
either in the msg_name field of msghdr structure in the sendmsg() the msg_name field of msghdr structure in the sendmsg() call or the
call or the dest_addr field in the sendto() call), the SCTP stack dest_addr field in the sendto() call), the SCTP stack will
will automatically setup an association to the intended receiver. automatically setup an association to the intended receiver.
Upon the successful association setup a SCTP_COMM_UP Upon the successful association setup a SCTP_COMM_UP notification
notification will be dispatched to the socket at both the sender and will be dispatched to the socket at both the sender and receiver
receiver side. This notification can be read by the recvmsg() system side. This notification can be read by the recvmsg() system call
call (see Section 3.1.3). (see Section 3.1.3).
Note, if the SCTP stack at the sender side supports bundling, the Note, 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
[SCTP]. RFC2960 [8].
When the SCTP stack sets up a new association implicitly, it first When the SCTP stack sets up a new association implicitly, it first
consults the sctp_initmsg structure, which is passed along within consults the sctp_initmsg structure, which is passed along within the
the ancillary data in the sendmsg() call (see Section 5.2.1 for ancillary data in the sendmsg() call (see Section 5.2.1 for details
details of the data structures), for any special options to be used of the data structures), for any special options to be used on the
on the new association. 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()/recv() Implicit association setup cannot be initiated by send()/recv()
calls. calls.
3.3 Non-blocking mode 3.3 Non-blocking mode
Some SCTP users might want to avoid blocking when they call
socket interface function. Some SCTP users might want to avoid blocking when they call socket
interface function.
Whenever the user which want to avoid blocking must call select() Whenever the user which want to avoid blocking must call select()
before calling sendmsg()/sendto() and recvmsg()/recvfrom(), and before calling sendmsg()/sendto() and recvmsg()/recvfrom(), and check
check the socket status is writable or readable. If the socket the socket status is writable or readable. If the socket status
status isn't writeable or readable, the user should not call isn't writeable or readable, the user should not call sendmsg()/
sendmsg()/sendto() and recvmsg()/recvfrom(). sendto() and recvmsg()/recvfrom().
Once all bind() calls are complete on a UDP-style socket, the Once all bind() calls are complete on a UDP-style socket, the
application must set the non-blocking option by a fcntl() (such as application must set the non-blocking option by a fcntl() (such as
O_NONBLOCK). After which the sendmsg() function returns O_NONBLOCK). After which the sendmsg() function returns immediately,
immediately, and the success or failure of the data message (and and the success or failure of the data message (and possible
possible SCTP_INITMSG parameters) will be signaled by the SCTP_INITMSG parameters) will be signaled by the SCTP_ASSOC_CHANGE
SCTP_ASSOC_CHANGE event with SCTP_COMM_UP or event with SCTP_COMM_UP or CANT_START_ASSOC. If user data could not
CANT_START_ASSOC. If user data could not be sent (due to a be sent (due to a CANT_START_ASSOC), the sender will also receive a
CANT_START_ASSOC), the sender will also receive a SCTP_SEND_FAILED SCTP_SEND_FAILED event. Those event(s) can be received by the user
event. Those event(s) can be received by the user calling of calling of recvmsg(). A server (having called listen()) is also
recvmsg(). A server (having called listen()) is also notified of an notified of an association up event by the reception of a
association up event by the reception of a SCTP_ASSOC_CHANGE with SCTP_ASSOC_CHANGE with SCTP_COMM_UP via the calling of recvmsg() and
SCTP_COMM_UP via the calling of recvmsg() and possibly the possibly the reception of the first data message.
reception of the first data message.
In order to shutdown the association gracefully, the user must call In order to shutdown the association gracefully, the user must call
sendmsg() with no data and with the MSG_EOF flag set. The function sendmsg() with no data and with the MSG_EOF flag set. The function
returns immediately, and completion of the graceful shutdown is returns immediately, and completion of the graceful shutdown is
indicated by an SCTP_ASSOC_CHANGE notification of type indicated by an SCTP_ASSOC_CHANGE notification of type
SHUTDOWN_COMPLETE (see section 5.3.1.1). SHUTDOWN_COMPLETE (see Section 5.3.1.1).
3.4 Special considerations
The fact that a UDP-style socket can provide access to many SCTP
associations through a single socket descriptor has important
implications for both application programmers and system programmers
implementing this API. A key issue is how buffer space inside the
sockets layer is managed. Because this implementation detail
directly affects how application programmers must write their code to
ensure correct operation and portability, this section provides some
guidance to both implementors and application programmers.
An important feature that SCTP shares with TCP is flow control:
specifically, a sender may not send data faster than the receiver can
consume it.
For TCP, flow control is typically provided for in the sockets API as
follows. If the reader stops reading, the sender queues messages in
the socket layer until it uses all of its socket buffer space
allocation creating a "stalled connection". Further attempts to
write to the socket will block or return the error EAGAIN (for a non-
blocking socket). At some point, either the connection is closed, or
the receiver begins to read again freeing space in the output queue.
For TCP-style SCTP sockets (this includes sockets descriptors that
were separated from a UDP style socket with sctp_peeloff()) the
behavior is identical. For UDP-style SCTP sockets, the fact that we
have multiple associations on a single socket makes the situation
more complicated. If the implementation uses a single buffer space
allocation shared by all associations, a single stalled association
can prevent the further sending of data on all associations active on
a particular UDP-style socket.
For a blocking socket, it should be clear that a single stalled
association can block the entire socket. For this reason,
application programmers may want to use non-blocking UDP-style
sockets. The application should at least be able to send messages to
the non-stalled associations.
But a non-blocking socket is not sufficient if the API implementor
has chosen a single shared buffer allocation for the socket. A
single stalled association would eventually cause the shared
allocation to fill, and it would become impossible to send even to
non-stalled associations.
The API implementor can solve this problem by providing each
association with its own allocation of outbound buffer space. Each
association should conceptually have as much buffer space as it would
have if it had its own socket. As a bonus, this simplifies the
implementation of sctp_peeloff().
To ensure that a given stalled association will not prevent other
non-stalled associations from being writable, application programmers
should either:
(a) demand that the underlying implementation dedicates independent
buffer space allotments to each association (as suggested above),
or
(b) verify that their application layer protocol does not permit
large amounts of unread data at the receiver (this is true of some
request-response protocols, for example), or
(c) use TCP-style sockets for association which may potentially stall
(either from the beginning, or by using sctp_peeloff before
sending large amounts of data that may cause a stalled condition).
4. TCP-style Interface 4. TCP-style Interface
The goal of this model is to follow as closely as possible the The goal of this model 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 model enables existing oriented protocol, such as TCP. This model enables existing
applications using connection oriented protocols to be ported to applications using connection oriented protocols to be ported to SCTP
SCTP with very little effort. with very little effort.
Note that some new SCTP features and some new SCTP socket options Note that some new SCTP features and some new SCTP socket options can
can only be utilized through the use of sendmsg() and recvmsg() only be utilized through the use of sendmsg() and recvmsg() calls,
calls, see Section 4.1.8. see Section 4.1.8.
4.1 Basic Operation 4.1 Basic Operation
A typical server in TCP-style model uses the following system call A typical server in TCP-style model uses the following system call
sequence to prepare an SCTP endpoint for servicing requests: sequence to prepare an SCTP endpoint for servicing requests:
1. socket() 1. socket()
2. bind() 2. bind()
3. listen() 3. listen()
4. accept() 4. 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
5. close() 5. close()
skipping to change at page 11, line 44 skipping to change at page 17, line 23
The syntax is: The syntax is:
int socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); int socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
or, or,
int socket(PF_INET6, SOCK_STREAM, IPPROTO_SCTP); int socket(PF_INET6, SOCK_STREAM, IPPROTO_SCTP);
Here, SOCK_STREAM indicates the creation of a TCP-style socket. Here, SOCK_STREAM indicates the creation of a TCP-style socket.
The first form creates an endpoint which can use only IPv4 The first form creates an endpoint which can use only IPv4 addresses,
addresses, while the second form creates an endpoint which can use while the second form creates an endpoint which can use both IPv6 and
both IPv6 and mapped IPv4 addresses. IPv4 addresses.
4.1.2 bind() - TCP Style Syntax 4.1.2 bind() - TCP Style Syntax
Applications use bind() to pass an address to be associated with an Applications use bind() to pass an address to be associated with an
SCTP endpoint to the system. bind() allows only either a single SCTP endpoint to the system. bind() allows only either a single
address or a IPv4 or IPv6 wildcard address to be bound. An SCTP address or a IPv4 or IPv6 wildcard address to be bound. An SCTP
endpoint can be associated with multiple addresses. To do this, endpoint can be associated with multiple addresses. To do this,
sctp_bindx() is introduced in section 8.1 to help applications do sctp_bindx() is introduced in Section 8.1 to help applications do
the job of associating multiple addresses. the job of associating multiple addresses.
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 will also present these addresses to its peers during the association
association initialization process, see [SCTP]. initialization process, see RFC2960 [8].
The syntax is: The syntax is:
int bind(int sd, struct sockaddr *addr, int addrlen); int bind(int sd, struct sockaddr *addr, socklen_t addrlen);
sd - the socket descriptor returned by socket() call. sd: the socket descriptor returned by socket() call.
addr - the address structure (either struct sockaddr_in or struct
sockaddr_in6 defined in [RFC 2553]). addr: the address structure (either struct sockaddr_in or struct
addrlen - the size of the address structure. sockaddr_in6 defined in RFC2553 [7]).
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.
Otherwise, i.e., the sd is an IPv6 socket, the address passed can Otherwise, i.e., the sd is an IPv6 socket, the address passed can
either be an IPv4 or an IPv6 address. either be an IPv4 or 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 addr is specified as a wildcard (INADDR_ANY for an IPv4 address, If addr is specified as a wildcard (INADDR_ANY for an IPv4 address,
skipping to change at page 12, line 51 skipping to change at page 18, line 39
4.1.3 listen() - TCP Style Syntax 4.1.3 listen() - TCP Style Syntax
Applications use listen() to ready the SCTP endpoint for accepting Applications use listen() to ready the SCTP endpoint for accepting
inbound associations. inbound associations.
The syntax is: The syntax is:
int listen(int sd, int backlog); int listen(int sd, int backlog);
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
allowed in the socket's accept queue. These are the backlog: this specifies the max number of outstanding associations
associations that have finished the four-way initiation allowed in the socket's accept queue. These are the associations
handshake (see Section 5 of [SCTP]) and are in the that have finished the four-way initiation handshake (see Section
ESTABLISHED state. Note, a backlog of '0' indicates 5 of RFC2960 [8]) and are in the ESTABLISHED state. Note, a
that the caller no longer wishes to receive new backlog of '0' indicates that the caller no longer wishes to
associations. receive new associations.
4.1.4 accept() - TCP Style Syntax 4.1.4 accept() - TCP Style Syntax
Applications use accept() call to remove an established SCTP Applications use 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 syntax is: The syntax is:
new_sd = accept(int sd, struct sockaddr *addr, socklen_t *addrlen); new_sd = accept(int sd, struct sockaddr *addr, socklen_t *addrlen);
new_sd - the socket descriptor for the newly formed association. new_sd: the socket descriptor for the newly formed association.
sd - the listening socket descriptor.
addr - on return, will contain the primary address of the peer sd the listening socket descriptor.
addr on return, will contain the primary address of the peer
endpoint. endpoint.
addrlen - on return, will contain the size of addr.
addrlen on return, will contain the size of addr.
4.1.5 connect() - TCP Style Syntax 4.1.5 connect() - TCP Style Syntax
Applications use connect() to initiate an association to a peer. Applications use connect() to initiate an association to a peer.
The syntax is The syntax is:
int connect(int sd, const struct sockaddr *addr, int addrlen); int connect(int sd, const struct sockaddr *addr, socklen_t addrlen);
sd - the socket descriptor of the endpoint. sd: the socket descriptor of the endpoint.
addr - the peer's address.
addrlen - the size of the address. addr the peer's address.
addrlen the size of the address.
This operation corresponds to the ASSOCIATE primitive described in This operation corresponds to the ASSOCIATE primitive described in
section 10.1 of [SCTP]. section 10.1 of RFC2960 [8].
By default, the new association created has only one outbound By default, the new association created has only one outbound stream.
stream. The SCTP_INITMSG option described in Section 7.1.3 should be The SCTP_INITMSG option described in Section 7.1.3 should be used
used before connecting to change the number of outbound streams. before connecting to change the number of outbound streams.
If a bind() or sctp_bindx() is not called prior to the connect() If a bind() or sctp_bindx() is not called prior to the connect()
call, the system picks an ephemeral port and will choose an address call, the system picks an ephemeral port and will choose an address
set equivalent to binding with INADDR_ANY and IN6ADDR_ANY for IPv4 set equivalent to binding with INADDR_ANY and IN6ADDR_ANY for IPv4
and IPv6 socket respectively. One of those addresses will be the and IPv6 socket respectively. One of those 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.
Note that SCTP allows data exchange, similar to T/TCP [RFC1644], Note that SCTP allows data exchange, similar to T/TCP RFC1644 [3],
during the association set up phase. If an application wants to do during the association set up phase. If an application wants to do
this, it cannot use connect() call. Instead, it should use sendto() this, it cannot use connect() call. Instead, it should use sendto()
or sendmsg() to initiate an association. If it uses sendto() and it or sendmsg() to initiate an association. If it uses sendto() and it
wants to change initialization behavior, it needs to use the wants to change initialization behavior, it needs to use the
SCTP_INITMSG socket option before calling sendto(). Or it can use SCTP_INITMSG socket option before calling sendto(). Or it can use
SCTP_INIT type sendmsg() to initiate an association without doing SCTP_INIT type sendmsg() to initiate an association without doing the
the setsockopt(). setsockopt().
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 sendto() or sendmsg() when the call is used to initiate a connection.
connection. MSG_EOF is not an acceptable flag with SCTP socket. MSG_EOF is not an acceptable flag with SCTP socket.
4.1.6 close() - TCP Style Syntax 4.1.6 close() - TCP Style Syntax
Applications use close() to gracefully close down an association. Applications use close() to gracefully close down an association.
The syntax is: The syntax is:
int close(int sd); int close(int sd);
sd - the socket descriptor of the association to be closed. sd - the socket descriptor of the association to be closed.
After an application calls close() on a socket descriptor, no After an application calls close() on a socket descriptor, no further
further socket operations will succeed on that descriptor. socket operations will succeed on that descriptor.
4.1.7 shutdown() - TCP Style Syntax 4.1.7 shutdown() - TCP Style Syntax
SCTP differs from TCP in that it does not have half closed SCTP differs from TCP in that it does not have half closed semantics.
semantics. Hence the shutdown() call for SCTP is an approximation Hence the shutdown() call for SCTP is an approximation of the TCP
of the TCP shutdown() call, and solves some different problems. shutdown() call, and solves some different problems. Full TCP-
Full TCP-compatibility is not provided, so developers porting TCP compatibility is not provided, so developers porting TCP applications
applications to SCTP may need to recode sections that use to SCTP may need to recode sections that use shutdown(). (Note that
shutdown(). (Note that it is possible to achieve the same results it is possible to achieve the same results as half close in SCTP
as half close in SCTP using SCTP streams.) using SCTP streams.)
The syntax is: The syntax is:
int shutdown(int socket, int how); int shutdown(int socket, int how);
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 how - Specifies the type of shutdown. The values are
as follows: as follows:
skipping to change at page 15, line 5 skipping to change at page 21, line 30
SHUT_RDWR SHUT_RDWR
Disables further send and receive operations Disables further send and receive operations
and initiates the SCTP shutdown sequence. and initiates the SCTP shutdown sequence.
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 closed state. SHUT_RD behaves
the same for SCTP as TCP. The purpose of SCTP SHUT_WR is to close the same for SCTP as TCP. The purpose of SCTP SHUT_WR is to close
the SCTP association while still leaving the socket descriptor open, the SCTP association while still leaving the socket descriptor open,
so that the caller can receive back any data SCTP was unable to so that the caller can receive back any data SCTP was unable to
deliver (see section 5.3.1.4 for more information). deliver (see Section 5.3.1.4 for more information).
To perform the ABORT operation described in [SCTP] section 10.1, an To perform the ABORT operation described in RFC2960 [8] section 10.1,
application can use the socket option SO_LINGER. It is described in an application can use the socket option SO_LINGER. It is described
section 7.1.4. in Section 7.1.4.
4.1.8 sendmsg() and recvmsg() - TCP Style Syntax 4.1.8 sendmsg() and recvmsg() - TCP Style Syntax
With a TCP-style socket, the application can also use sendmsg() and With a TCP-style socket, the application can also use sendmsg() and
recvmsg() to transmit data to and receive data from its peer. The recvmsg() to transmit data to and receive data from its peer. The
semantics is similar to those used in the UDP-style model (section semantics is similar to those used in the UDP-style model (section
3.1.3), with the following differences: Section 3.1.3), 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
different peer address if the sender does not want to send the different peer address if the sender does not want to send the
message over the primary address of the receiver. If the transport message over the primary address of the receiver. If the transport
address given is not part of the current association, the data will address given is not part of the current association, the data will
not be sent and a SCTP_SEND_FAILED event will be delivered to the not be sent and a SCTP_SEND_FAILED event will be delivered to the
application if send failure events are enabled. application if send failure events are enabled.
When receiving, if a message is not received from the primary When receiving, if a message is not received from the primary
address, the SCTP stack will fill in the msg_name field on return so address, the SCTP stack will fill in the msg_name field on return so
that the application can retrieve the source address information of that the application can retrieve the source address information of
the received message. the received message.
2) An application must use close() to gracefully shutdown an 2) An application must use close() to gracefully shutdown an
association, or use SO_LINGER option with close() to abort an association, or use SO_LINGER option with close() to abort an
association. It must not use the MSG_ABORT or MSG_EOF flag in association. It must not use the MSG_ABORT or MSG_EOF flag in
sendmsg(). The system returns an error if an application tries to sendmsg(). The system returns an error if an application tries to do
do so. so.
4.1.9 getpeername() 4.1.9 getpeername()
Applications use getpeername() to retrieve the primary socket Applications use getpeername() to retrieve the primary socket address
address of the peer. This call is for TCP compatibility, and is not of the peer. This call is for TCP compatibility, and is not multi-
multi-homed.It does not work with UDP-style sockets. See section 8.3 homed. It does not work with UDP-style sockets. See Section 8.3 for
for a multi-homed/UDP-sockets version of the call. a multi-homed/UDP-sockets version of the call.
The syntax is: The syntax is:
int getpeername(int socket, struct sockaddr *address, int getpeername(int socket, struct sockaddr *address,
socklen_t *len); socklen_t *len);
sd - the socket descriptor to be queried. sd - the socket descriptor to be queried.
address - On return, the peer primary address is stored in address - On return, the peer primary address is stored in
this buffer. If the socket is an IPv4 socket, the this buffer. If the socket is an IPv4 socket, the
address will be IPv4. If the socket is an IPv6 socket, address will be IPv4. If the socket is an IPv6 socket,
the address will be either an IPv6 or mapped IPv4 the address will be either an IPv6 or IPv4
address. address.
len - The caller should set the length of address here. len - The caller should set the length of address here.
On return, this is set to the length of the returned On return, this is set to the length of the returned
address. address.
If the actual length of the address is greater than the length of If the actual length of the address is greater than the length of the
the supplied sockaddr structure, the stored address will be supplied sockaddr structure, the stored address will be truncated.
truncated.
5. Data Structures 5. Data Structures
We discuss in this section important data structures which are We discuss in this section important data structures which are
specific to SCTP and are used with sendmsg() and recvmsg() calls to specific to SCTP and are used with sendmsg() and recvmsg() calls to
control SCTP endpoint operations and to access ancillary control SCTP endpoint operations and to access ancillary information
information and notifications. and 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 details in [RFC2292]. Here we will cite their discussed in details in RFC2292 [6]. Here we will cite their
definitions from [RFC2292]. definitions from RFC2292 [6].
The msghdr structure: The msghdr structure:
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 */
size_t msg_iovlen; /* # elements in msg_iov */ size_t 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 */
skipping to change at page 16, line 52 skipping to change at page 23, line 45
The cmsghdr structure: The cmsghdr structure:
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 Sections 3.1.3 and 4.1.8). previous sections (see Section 3.1.3 and Section 4.1.8).
The scatter/gather buffers, or I/O vectors (pointed to by the The scatter/gather buffers, or I/O vectors (pointed to by the msg_iov
msg_iov field) are treated as a single SCTP data chunk, rather than field) are treated as a single SCTP data chunk, rather than multiple
multiple chunks, for both sendmsg() and recvmsg(). chunks, for both sendmsg() and recvmsg().
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 If a notification has arrived, recvmsg() will return the notification
notification with the MSG_NOTIFICATION flag set in msg_flags. If the with the MSG_NOTIFICATION flag set in msg_flags. If the
MSG_NOTIFICATION flag is not set, recvmsg() will return data. See MSG_NOTIFICATION flag is not set, recvmsg() will return data. See
section 5.3 for more information about notifications. Section 5.3 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 SCTP msg_control Structures 5.2 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(). struct msghdr's msg_control member used in sendmsg() and recvmsg().
Fine-grained control over initialization and sending parameters are Fine-grained control over initialization and sending parameters are
handled with ancillary data. handled with ancillary data.
Each ancillary data item is proceeded by a struct cmsghdr (see Each ancillary data item is proceeded 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 in the cmsg_data[] member. contained in in the cmsg_data[] member.
There are two kinds of ancillary data used by SCTP: initialization There are two kinds of ancillary data used by SCTP: initialization
data, and, header information (SNDRCV). Initialization data data, and, header information (SNDRCV). Initialization data (UDP-
(UDP-style only) sets protocol parameters for new associations. style only) sets protocol parameters for new associations. Section
Section 5.2.1 provides more details. Header information can set or 5.2.1 provides more details. Header information can set or report
report parameters on individual messages in a stream. See section parameters on individual messages in a stream. See Section 5.2.2 for
5.2.2 for how to use SNDRCV ancillary data. how to use SNDRCV ancillary data.
By default on a TCP-style socket, SCTP will pass no ancillary data; By default on a TCP-style socket, SCTP will pass no ancillary data;
on a UDP-style socket, SCTP will only pass SCTP_SNDRCV and on a UDP-style socket, SCTP will only pass SCTP_SNDRCV and
SCTP_ASSOC_CHANGE information. Specific ancillary data items can be SCTP_ASSOC_CHANGE information. Specific ancillary data items can be
enabled with socket options defined for SCTP; see section 7.3. enabled with socket options defined for SCTP; see Section 7.3.
Note that all ancillary types are fixed length; see section 5.4 for Note that all ancillary types are fixed length; see Section 5.4 for
further discussion on this. These data structures use struct further discussion on this. These data structures use struct
sockaddr_storage (defined in [RFC2553]) as a portable, fixed length sockaddr_storage (defined in RFC2553 [7]) 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 socket API
definitions ([RFC2292] and [RFC2553]) define a number of ancillary definitions (RFC2292 [6] and RFC2553 [7]) define a number of
data items. If a socket API consumer enables delivery of both SCTP ancillary data items. If a socket API consumer enables delivery of
and IPv6 ancillary data, they both may appear in the same both SCTP and IPv6 ancillary data, they both may appear in the same
msg_control buffer in any order. An application may thus need to msg_control buffer in any order. An application may thus need to
handle other types of ancillary data besides that passed by SCTP. handle other types of ancillary data besides that 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.2.1 SCTP Initiation Structure (SCTP_INIT) 5.2.1 SCTP Initiation Structure (SCTP_INIT)
This cmsghdr structure provides information for initializing new
SCTP associations with sendmsg(). The SCTP_INITMSG socket option This cmsghdr structure provides information for initializing new SCTP
uses this same data structure. This structure is not used for associations with sendmsg(). The SCTP_INITMSG socket option uses
recvmsg(). this same data structure. This structure is not used for recvmsg().
cmsg_level cmsg_type cmsg_data[] cmsg_level cmsg_type cmsg_data[]
------------ ------------ ---------------------- ------------ ------------ ----------------------
IPPROTO_SCTP SCTP_INIT struct sctp_initmsg IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
Here is the definition of the sctp_initmsg structure: Here is the definition of the sctp_initmsg structure:
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: 16 bits (unsigned integer) sinit_num_ostreams: 16 bits (unsigned integer)
This is an integer number representing the number of streams that This is an integer number representing the number of streams that the
the application wishes to be able to send to. This number is application wishes to be able to send to. This number is confirmed
confirmed in the SCTP_COMM_UP notification and must be verified in the SCTP_COMM_UP notification and must be verified since it is a
since it is a negotiated number with the remote endpoint. The negotiated number with the remote endpoint. The default value of 0
default value of 0 indicates to use the endpoint default value. indicates to use the endpoint default value.
sinit_max_instreams: 16 bits (unsigned integer) sinit_max_instreams: 16 bits (unsigned integer)
This value represents the maximum number of inbound streams the This value represents the maximum number of inbound streams the
application is prepared to support. This value is bounded by the application is prepared to support. This value is bounded by the
actual implementation. In other words the user MAY be able to actual implementation. In other words the user MAY be able to
support more streams than the Operating System. In such a case, the support more streams than the Operating System. In such a case, the
Operating System limit overrides the value requested by the Operating System limit overrides the value requested by the user.
user. The default value of 0 indicates to use the endpoint's default The default value of 0 indicates to use the endpoint's default value.
value.
sinit_max_attempts: 16 bits (unsigned integer) sinit_max_attempts: 16 bits (unsigned integer)
This integer specifies how many attempts the SCTP endpoint should This integer specifies how many attempts the SCTP endpoint should
make at resending the INIT. This value overrides the system SCTP make at resending the INIT. This value overrides the system SCTP
'Max.Init.Retransmits' value. The default value of 0 indicates to 'Max.Init.Retransmits' value. The default value of 0 indicates to
use the endpoint's default value. This is normally set to the use the endpoint's default value. This is normally set to the
system's default 'Max.Init.Retransmit' value. system's default 'Max.Init.Retransmit' value.
sinit_max_init_timeo: 16 bits (unsigned integer) sinit_max_init_timeo: 16 bits (unsigned integer)
skipping to change at page 19, line 25 skipping to change at page 26, line 33
Here is the definition of sctp_sndrcvinfo: Here is the definition of sctp_sndrcvinfo:
struct sctp_sndrcvinfo { struct sctp_sndrcvinfo {
uint16_t sinfo_stream; uint16_t sinfo_stream;
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;
sctp_assoc_t sinfo_assoc_id; sctp_assoc_t sinfo_assoc_id;
}; };
sinfo_stream: 16 bits (unsigned integer) sinfo_stream: 16 bits (unsigned integer)
For recvmsg() the SCTP stack places the message's stream number in For recvmsg() the SCTP stack places the message's stream number in
this value. For sendmsg() this value holds the stream number that this value. For sendmsg() this value holds the stream number that
the application wishes to send this message to. If a sender the application wishes to send this message to. If a sender
specifies an invalid stream number an error indication is returned specifies an invalid stream number an error indication is returned
and the call fails. and the call fails.
sinfo_ssn: 16 bits (unsigned integer) sinfo_ssn: 16 bits (unsigned integer)
For recvmsg() this value contains the stream sequence number that For recvmsg() this value contains the stream sequence number that the
the remote endpoint placed in the DATA chunk. For fragmented remote endpoint placed in the DATA chunk. For fragmented messages
messages this is the same number for all deliveries of the message this is the same number for all deliveries of the message (if more
(if more than one recvmsg() is needed to read the message). The than one recvmsg() is needed to read the message). The sendmsg()
sendmsg() call will ignore this parameter. call will ignore this parameter.
sinfo_ppid: 32 bits (unsigned integer) sinfo_ppid: 32 bits (unsigned integer)
This value in sendmsg() is an opaque unsigned value that is passed This value in sendmsg() is an opaque unsigned value that is passed to
to the remote end in each user message. In recvmsg() this value is the remote end in each user message. In recvmsg() this value is the
the same information that was passed by the upper layer in the peer same information that was passed by the upper layer in the peer
application. Please note that byte order issues are NOT accounted application. Please note that byte order issues are NOT accounted
for and this information is passed opaquely by the SCTP stack from for and this information is passed opaquely by the SCTP stack from
one end to the other. one end to the other.
sinfo_context: 32 bits (unsigned integer) sinfo_context: 32 bits (unsigned integer)
This value is an opaque 32 bit context datum that is used in the This value is an opaque 32 bit context datum that is used in the
sendmsg() function. This value is passed back to the upper layer if sendmsg() function. This value is passed back to the upper layer if
a error occurs on the send of a message and is retrieved with each a error occurs on the send of a message and is retrieved with each
undelivered message (Note: if a endpoint has done multiple sends, all undelivered message (Note: if a endpoint has done multiple sends, all
skipping to change at page 20, line 31 skipping to change at page 28, line 23
message. If this flag is clear the datagram is message. If this flag is clear the datagram is
considered an ordered send. considered an ordered send.
MSG_ADDR_OVER - This flag, in the UDP model, requests the SCTP MSG_ADDR_OVER - This flag, in the UDP model, requests the SCTP
stack to override the primary destination address stack to override the primary destination address
with the address found with the sendto/sendmsg with the address found with the sendto/sendmsg
call. call.
MSG_ABORT - Setting this flag causes the specified association MSG_ABORT - Setting this flag causes the specified association
to abort by sending an ABORT message to the peer to abort by sending an ABORT message to the peer
(UDP-style only). (UDP-style only). The ABORT chunk will contain an
error cause 'User Initiated Abort' with cause code 12.
The cause specific information of this error cause is
provided in msg_iov.
MSG_EOF - Setting this flag invokes the SCTP graceful shutdown MSG_EOF - Setting this flag invokes the SCTP graceful shutdown
procedures on the specified association. Graceful procedures on the specified association. Graceful
shutdown assures that all data enqueued by both shutdown assures that all data enqueued by both
endpoints is successfully transmitted before closing endpoints is successfully transmitted before closing
the association (UDP-style only). the association (UDP-style only).
sinfo_timetolive: 32 bit (unsigned integer) sinfo_timetolive: 32 bit (unsigned integer)
For the sending side, this field contains the message time For the sending side, this field contains the message time to live in
to live in milliseconds. The sending side will expire the milliseconds. The sending side will expire the message within the
message within the specified time period if the message as specified time period if the message as not been sent to the peer
not been sent to the peer within this time period. This value within this time period. This value will override any default value
will override any default value set using any socket option. set using any socket option. Also note that the value of 0 is
Also note that the value of 0 is special in that it indicates special in that it indicates no timeout should occur on this message.
no timeout should occur on this message.
sinfo_tsn: 32 bit (unsigned integer) sinfo_tsn: 32 bit (unsigned integer)
For the receiving side, this field holds a TSN that was For the receiving side, this field holds a TSN that was assigned to
assigned to one of the SCTP Data Chunks. one of the SCTP Data Chunks.
sinfo_cumtsn: 32 bit (unsigned integer)
This field will hold the current cumulative TSN as known by the
underlying SCTP layer. Note this field is ignored when sending and
only valid for a receive operation when sinfo_flags are set to
MSG_UNORDERED.
sinfo_assoc_id: sizeof (sctp_assoc_t) sinfo_assoc_id: sizeof (sctp_assoc_t)
The association handle field, sinfo_assoc_id, holds the identifier The association handle field, sinfo_assoc_id, holds the identifier
for the association announced in the SCTP_COMM_UP notification. for the association announced in the SCTP_COMM_UP notification. All
notifications for a given association have the same identifier.
All notifications for a given association have the same identifier.
Ignored for TCP-style sockets. Ignored for TCP-style sockets.
A sctp_sndrcvinfo item always corresponds to the data in msg_iov. A sctp_sndrcvinfo item always corresponds to the data in msg_iov.
5.3 SCTP Events and Notifications 5.3 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 7.3 for these socket options. When a it wants. See Section 7.3 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.
Multiple notifications may be returned to a single recvmsg() This section details the notification structures. Every notification
call. structure carries some common fields which provides general
information.
This section details the notification structures. Every
notification structure carries some common fields which provides
general 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.
5.3.1 SCTP Notification Structure 5.3.1 SCTP Notification Structure
The notification structure is defined as the union of all The notification structure is defined as the union of all
skipping to change at page 22, line 8 skipping to change at page 30, line 22
struct sctp_paddr_change sn_padr_change; struct sctp_paddr_change sn_padr_change;
struct sctp_remote_error sn_remote_error; struct sctp_remote_error sn_remote_error;
struct sctp_send_failed sn_send_failed; struct sctp_send_failed sn_send_failed;
struct sctp_shutdown_event sn_shutdown_event; struct sctp_shutdown_event sn_shutdown_event;
struct sctp_adaption_event sn_adaption_event; struct sctp_adaption_event sn_adaption_event;
struct sctp_rcv_pdapi_event sn_rcv_pdapi_event; struct sctp_rcv_pdapi_event sn_rcv_pdapi_event;
}; };
sn_type: 16 bits (unsigned integer) sn_type: 16 bits (unsigned integer)
The following table describes the SCTP notification and event types The following list describes the SCTP notification and event types
for the field sn_type. for the field sn_type.
sn_type Description SCTP_ASSOC_CHANGE: This tag indicates that an association has either
--------- --------------------------- been opened or closed. Refer to Section 5.3.1.1 for details.
SCTP_ASSOC_CHANGE This tag indicates that an
association has either been
opened or closed. Refer to
5.3.1.1 for details.
SCTP_PEER_ADDR_CHANGE This tag indicates that an SCTP_PEER_ADDR_CHANGE: This tag indicates that an address that is
address that is part of an existing part of an existing association has experienced a change of state
association has experienced a (e.g. a failure or return to service of the reachability of a
change of state (e.g. a failure endpoint via a specific transport address). Please see Section
or return to service of the 5.3.1.2 for data structure details.
reachability of a endpoint
via a specific transport
address). Please see 5.3.1.2
for data structure details.
SCTP_REMOTE_ERROR The attached error message SCTP_REMOTE_ERROR: The attached error message is an Operational Error
is an Operational Error received from received from the remote peer. It includes the complete TLV sent
the remote peer. It includes the complete by the remote endpoint. See Section 5.3.1.3 for the detailed
TLV sent by the remote endpoint. format.
See section 5.3.1.3 for the detailed format.
SCTP_SEND_FAILED The attached datagram SCTP_SEND_FAILED: The attached datagram could not be sent to the
could not be sent to the remote endpoint. remote endpoint. This structure includes the original
This structure includes the SCTP_SNDRCVINFO that was used in sending this message i.e. this
original SCTP_SNDRCVINFO structure uses the sctp_sndrecvinfo per Section 5.3.1.4.
that was used in sending this
message i.e. this structure
uses the sctp_sndrecvinfo per
section 5.3.1.4.
SCTP_SHUTDOWN_EVENT The peer has sent a SHUTDOWN. No further SCTP_SHUTDOWN_EVENT: The peer has sent a SHUTDOWN. No further data
data should be sent on this socket. should be sent on this socket.
SCTP_ADAPTION_INDICATION This notification holds the SCTP_ADAPTION_INDICATION: This notification holds the peers indicated
peers indicated adaption layer. adaption layer. Please see Section 5.3.1.6.
Please see 5.3.1.6.
SCTP_PARTIAL_DELIVERY_EVENT This notification is used to SCTP_PARTIAL_DELIVERY_EVENT: This notification is used to tell a
tell a receiver that the partial receiver that the partial delivery has been aborted. This may
delivery has been aborted. This indicate the association is about to be aborted. Please see
may indicate the association is Section 5.3.1.7
about to be aborted. Please see
5.3.1.7.
All standard values for sn_type flags are greater than 2^15. All standard values for sn_type flags are greater than 2^15. Values
Values from 2^15 and down are reserved. from 2^15 and down are reserved.
sn_flags: 16 bits (unsigned integer) sn_flags: 16 bits (unsigned integer)
These are notification-specific flags. These are notification-specific flags.
sn_length: 32 bits (unsigned integer) sn_length: 32 bits (unsigned integer)
This is the length of the whole sctp_notification structure This is the length of the whole sctp_notification structure including
including the sn_type, sn_flags, and sn_length fields. the sn_type, sn_flags, and sn_length fields.
5.3.1.1 SCTP_ASSOC_CHANGE 5.3.1.1 SCTP_ASSOC_CHANGE
Communication notifications inform the ULP that an SCTP association Communication notifications inform the ULP that an SCTP association
has either begun or ended. The identifier for a new association is has either begun or ended. The identifier for a new association is
provided by this notification. The notification information has the provided by this notification. The notification information has the
following format: 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[0];
}; };
sac_type: sac_type:
It should be SCTP_ASSOC_CHANGE. It should be SCTP_ASSOC_CHANGE.
sac_flags: 16 bits (unsigned integer) sac_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sac_length: 32 bits (unsigned integer) sac_length: 32 bits (unsigned integer)
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header. the notification header.
sac_state: 16 bits (signed integer) sac_state: 16 bits (signed integer)
This field holds one of a number of values that communicate the event
This field holds one of a number of values that communicate the that happened to the association. They include:
event that happened to the association. They include:
Event Name Description Event Name Description
---------------- --------------- ---------------- ---------------
SCTP_COMM_UP A new association is now ready SCTP_COMM_UP A new association is now ready
and data may be exchanged with this and data may be exchanged with this
peer. peer.
SCTP_COMM_LOST The association has failed. The association SCTP_COMM_LOST The association has failed. The association
is now in the closed state. If SEND FAILED is now in the closed state. If SEND FAILED
notifications are turned on, a SCTP_COMM_LOST notifications are turned on, a SCTP_COMM_LOST
skipping to change at page 24, line 25 skipping to change at page 32, line 32
SCTP_CANT_STR_ASSOC The association failed to setup. If non blocking SCTP_CANT_STR_ASSOC The association failed to setup. If non blocking
mode is set and data was sent (in the udp mode), mode is set and data was sent (in the udp mode),
a SCTP_CANT_STR_ASSOC is followed by a series of a SCTP_CANT_STR_ASSOC is followed by a series of
SCTP_SEND_FAILED events, one for each outstanding SCTP_SEND_FAILED events, one for each outstanding
message. message.
sac_error: 16 bits (signed integer) sac_error: 16 bits (signed integer)
If the state was reached due to a error condition (e.g. If the state was reached due to a 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
this field. This corresponds to the protocol error codes defined in field. This corresponds to the protocol error codes defined in
[SCTP]. RFC2960 [8].
sac_outbound_streams: 16 bits (unsigned integer) sac_outbound_streams: 16 bits (unsigned integer)
sac_inbound_streams: 16 bits (unsigned integer) sac_inbound_streams: 16 bits (unsigned integer)
The maximum number of streams allowed in each direction are The maximum number of streams allowed in each direction are available
available in sac_outbound_streams and sac_inbound streams. in sac_outbound_streams and sac_inbound streams.
sac_assoc_id: sizeof (sctp_assoc_t) sac_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
sac_data: variable
If the sac_state is SCTP_COMM_LOST and an ABORT chunk was received
for this association, sac_data[] contains the complete ABORT chunk as
defined in the SCTP specification RFC2960 [8] section 3.3.7.
5.3.1.2 SCTP_PEER_ADDR_CHANGE 5.3.1.2 SCTP_PEER_ADDR_CHANGE
When a destination address on a multi-homed peer encounters a change When a destination address on a multi-homed peer encounters a change
an interface details event is sent. The information has the an interface details event is sent. The information has the
following structure: following structure:
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;
skipping to change at page 25, line 23 skipping to change at page 33, line 43
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header. the notification header.
spc_aaddr: sizeof (struct sockaddr_storage) spc_aaddr: sizeof (struct sockaddr_storage)
The affected address field, holds the remote peer's address that is The affected address field, holds the remote peer's address that is
encountering the change of state. encountering the change of state.
spc_state: 32 bits (signed integer) spc_state: 32 bits (signed integer)
This field holds one of a number of values that communicate the This field holds one of a number of values that communicate the event
event that happened to the address. They include: that happened to the address. They include:
Event Name Description Event Name Description
---------------- --------------- ---------------- ---------------
SCTP_ADDR_AVAILABLE This address is now reachable. SCTP_ADDR_AVAILABLE This address is now reachable.
SCTP_ADDR_UNREACHABL The address specified can no SCTP_ADDR_UNREACHABL The address specified can no
longer be reached. Any data sent longer be reached. Any data sent
to this address is rerouted to an to this address is rerouted to an
alternate until this address becomes alternate until this address becomes
reachable. reachable.
skipping to change at page 26, line 4 skipping to change at page 34, line 37
SCTP_ADDR_UNREACHABL) any relevant error information is available in SCTP_ADDR_UNREACHABL) any relevant error information is available in
this field. this field.
spc_assoc_id: sizeof (sctp_assoc_t) spc_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
5.3.1.3 SCTP_REMOTE_ERROR 5.3.1.3 SCTP_REMOTE_ERROR
A remote peer may send an Operational Error message to its peer. A remote peer may send an Operational Error message to its peer.
This message indicates a variety of error conditions on an This message indicates a variety of error conditions on an
association. The entire error TLV as it appears on the wire is association. The entire ERROR chunk as it appears on the wire is
included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP
specification [SCTP] and any extensions for a list of possible specification RFC2960 [8] and any extensions for a list of possible
error formats. SCTP error TLVs have the format: error formats. SCTP error notifications have the 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[0]; uint8_t sre_data[0];
}; };
skipping to change at page 26, line 46 skipping to change at page 35, line 40
the SCTP specification, in network byte order. the SCTP specification, in network byte order.
sre_assoc_id: sizeof (sctp_assoc_t) sre_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
sre_data: variable sre_data: variable
This contains the payload of the operational error as defined in the This contains the ERROR chunk as defined in the SCTP specification
SCTP specification [SCTP] section 3.3.10. RFC2960 [8] section 3.3.10.
5.3.1.4 SCTP_SEND_FAILED 5.3.1.4 SCTP_SEND_FAILED
If SCTP cannot deliver a message it may return the message as a If SCTP cannot deliver a message it may return the message as a
notification. notification.
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[0]; uint8_t ssf_data[0];
}; };
ssf_type: ssf_type:
It should be SCTP_SEND_FAILED. It should be SCTP_SEND_FAILED.
ssf_flags: 16 bits (unsigned integer)
The flag value will take one of the following values The flag value will take one of the following values
SCTP_DATA_UNSENT - Indicates that the data was never put on SCTP_DATA_UNSENT - Indicates that the data was never put on
the wire. the wire.
SCTP_DATA_SENT - Indicates that the data was put on the wire. SCTP_DATA_SENT - Indicates that the data was put on the wire.
Note that this does not necessarily mean that the Note that this does not necessarily mean that the
data was (or was not) successfully delivered. data was (or was not) successfully delivered.
ssf_length: 32 bits (unsigned integer) ssf_length: 32 bits (unsigned integer)
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header and the payload in ssf_data. the notification header and the payload in ssf_data.
ssf_error: 16 bits (unsigned integer) ssf_error: 16 bits (unsigned integer)
This value represents the reason why the send failed, and if set, This value represents the reason why the send failed, and if set,
will be a SCTP protocol error code as defined in [SCTP] section will be a SCTP protocol error code as defined in RFC2960 [8] section
3.3.10. 3.3.10.
ssf_info: sizeof (struct sctp_sndrcvinfo) ssf_info: sizeof (struct sctp_sndrcvinfo)
The original send information associated with the undelivered The original send information associated with the undelivered
message. message.
ssf_assoc_id: sizeof (sctp_assoc_t) ssf_assoc_id: sizeof (sctp_assoc_t)
The association id field, sf_assoc_id, holds the identifier for the The association id field, sf_assoc_id, holds the identifier for the
association. All notifications for a given association have the association. All notifications for a given association have the same
same association identifier. For TCP style socket, this field is association identifier. For TCP style socket, this field is ignored.
ignored.
ssf_data: variable length ssf_data: variable length
The undelivered message, exactly as delivered by the caller to the The undelivered message, exactly as delivered by the caller to the
original send*() call. original send*() call.
5.3.1.5 SCTP_SHUTDOWN_EVENT 5.3.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.
skipping to change at page 28, line 24 skipping to change at page 37, line 33
It should be SCTP_SHUTDOWN_EVENT It should be SCTP_SHUTDOWN_EVENT
sse_flags: 16 bits (unsigned integer) sse_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sse_length: 32 bits (unsigned integer) sse_length: 32 bits (unsigned integer)
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header. It will generally be the notification header. It will generally be sizeof (struct
sizeof (struct sctp_shutdown_event). sctp_shutdown_event).
sse_flags: 16 bits (unsigned integer) sse_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sse_assoc_id: sizeof (sctp_assoc_t) sse_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
5.3.1.6 SCTP_ADAPTION_INDICATION 5.3.1.6 SCTP_ADAPTION_INDICATION
When a peer sends a Adaption Layer Indication parameter , SCTP When a peer sends a Adaption Layer Indication parameter , SCTP
delivers this notification to inform the application delivers this notification to inform the application that of the
that of the peers requested adaption layer. peers requested adaption layer.
struct sctp_adaption_event { struct sctp_adaption_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_bits; uint32_t sai_adaptation_bits;
sctp_assoc_t sse_assoc_id; sctp_assoc_t sai_assoc_id;
}; };
sai_type sai_type
It should be SCTP_ADAPTION_INDICATION It should be SCTP_ADAPTION_INDICATION
sai_flags: 16 bits (unsigned integer) sai_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sai_length: 32 bits (unsigned integer) sai_length: 32 bits (unsigned integer)
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header. It will generally be the notification header. It will generally be sizeof (struct
sizeof (struct sctp_adaption_event). sctp_adaption_event).
sai_adaption_bits: 32 bits (unsigned integer) sai_adaption_bits: 32 bits (unsigned integer)
This field holds the bit array sent by the peer in the This field holds the bit array sent by the peer in the adaption layer
adaption layer indication parameter. The bits are in indication parameter. The bits are in network byte order.
network byte order.
sai_assoc_id: sizeof (sctp_assoc_t) sai_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
When a receiver is engaged in a partial delivery of a When a receiver is engaged in a partial delivery of a message this
message this notification will be used to indicate notification will be used to indicate various events.
various events.
struct sctp_rcv_pdapi_event { struct sctp_rcv_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;
sctp_assoc_t pdapi_assoc_id; sctp_assoc_t pdapi_assoc_id;
}; };
pdapi_type pdapi_type
It should be SCTP_PARTIAL_DELIVERY_EVENT
It should be SCTP_ADAPTION_INDICATION
pdapi_flags: 16 bits (unsigned integer) pdapi_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
pdapi_length: 32 bits (unsigned integer) pdapi_length: 32 bits (unsigned integer)
This field is the total length of the notification data, including This field is the total length of the notification data, including
the notification header. It will generally be the notification header. It will generally be sizeof (struct
sizeof (struct sctp_rcv_pdapi_event). sctp_rcv_pdapi_event).
pdapi_indication: 32 bits (unsigned integer) pdapi_indication: 32 bits (unsigned integer)
This field holds the indication being sent to the This field holds the indication being sent to the application
application possible values include: possible values include:
SCTP_PARTIAL_DELIVERY_ABORTED SCTP_PARTIAL_DELIVERY_ABORTED
pdapi_assoc_id: sizeof (sctp_assoc_t) pdapi_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association. The association id field, holds the identifier for the association.
All notifications for a given association have the same association All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored. identifier. For TCP style socket, this field is ignored.
5.4 Ancillary Data Considerations and Semantics 5.4 Ancillary Data Considerations and Semantics
Programming with ancillary socket data contains some subtleties and Programming with ancillary socket data contains some subtleties and
pitfalls, which are discussed below. pitfalls, which are discussed below.
skipping to change at page 30, line 26 skipping to change at page 39, line 45
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 or non-SCTP
items, or both. 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 items must always correspond to the data in the msghdr's SCTP_SNDRCV items must always correspond to the data in the msghdr's
msg_iov member. There can be only a single SCTP_SNDRCV info for msg_iov member. There can be only a single SCTP_SNDRCV info for each
each sendmsg() or recvmsg() call. sendmsg() or recvmsg() call.
5.4.2 Accessing and Manipulating Ancillary Data 5.4.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 Implementations may have different padding requirements for ancillary
ancillary data, so portable applications should make use of the data, so portable applications should make use of the macros
macros CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_SPACE, and CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_SPACE, and CMSG_LEN. See
CMSG_LEN. See [RFC2292] and your SCTP implementation's documentation RFC2292 [6] and your SCTP implementation's documentation for more
for more information. Following is an example, from [RFC2292], information. Following is an example, from RFC2292 [6],
demonstrating the use of these macros to access ancillary data: demonstrating the use of these macros to access ancillary data:
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;
skipping to change at page 31, line 20 skipping to change at page 40, line 43
fundamental to the correct and sane operation of the sockets fundamental to the correct and sane operation of the sockets
application. This is particularly true of the UDP semantics, but application. This is particularly true of the UDP semantics, but
also of the TCP semantics. For example, if an application needs to also of the TCP semantics. For example, if an application needs to
send and receive data on different SCTP streams, SCTP_SNDRCV events send and receive data on different SCTP streams, SCTP_SNDRCV events
are indispensable. are 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 the buffer is too small, and crucial data is truncated, it may pose a
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 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 [RFC2292], we would calculate SCTP_SNDRCV_INFO and IPV6_RECVPKTINFO RFC2292 [6], 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 for msg_control on each call to We could then use this buffer for msg_control on each call to
recvmsg() and be assured that we would not lose any ancillary data recvmsg() and be assured that we would not lose any ancillary data to
to truncation. truncation.
6. Common Operations for Both Styles 6. Common Operations for Both Styles
6.1 send(), recv(), sendto(), recvfrom() 6.1 send(), recv(), sendto(), recvfrom()
Applications can use send() and sendto() to transmit data to the Applications can use send() and sendto() to transmit data to the peer
peer of an SCTP endpoint. recv() and recvfrom() can be used to of an SCTP endpoint. recv() and recvfrom() can be used to receive
receive data from the peer. data from the peer.
The syntax is: The syntax is:
ssize_t send(int sd, connst void *msg, size_t len, int flags); ssize_t send(int sd, connst void *msg, size_t len, int flags);
ssize_t sendto(int sd, const void *msg, size_t len, int flags, ssize_t sendto(int sd, const void *msg, size_t len, int flags,
const struct sockaddr *to, int tolen); const struct sockaddr *to, int tolen);
ssize_t recv(int sd, void *buf, size_t len, int flags); ssize_t recv(int sd, void *buf, size_t len, int flags);
ssize_t recvfrom(int sd, void *buf, size_t len, int flags, ssize_t recvfrom(int sd, void *buf, size_t len, int flags,
struct sockaddr *from, int *fromlen); struct sockaddr *from, int *fromlen);
skipping to change at page 32, line 30 skipping to change at page 42, line 44
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 can not distinguish the different
streams. This may result in data seeming to arrive out of streams. This may result in data seeming to arrive out of order.
order. Similarly, if a data chunk is sent unordered, recv() and Similarly, if a data chunk is sent unordered, recv() and recvfrom()
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 which is composed by several buffers, the wants to send a message which 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. recv() and recvfrom() cannot distinguish message combining them. recv() and recvfrom() cannot distinguish message
boundaries. boundaries.
In receiving, if the buffer supplied is not large enough to hold a In 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, when used in the UDP-style model, may Note, the send and recv calls, when used in the UDP-style model, may
only be used with branched off socket descriptors (see Section 8.2). only be used with branched off socket descriptors (see Section 8.2).
Note, if an application calls a send function with no user data Note, if an application calls a send function with no user data and
and no ancillary data the SCTP implementation should reject the no ancillary data the SCTP implementation should reject the request
request with an appropriate error message. An implementation is with an appropriate error message. An implementation is NOT allowed
NOT allowed to send a Data chunk with no user data [RFC2960]. to send a Data chunk with no user data RFC2960 [8].
6.2 setsockopt(), getsockopt() 6.2 setsockopt(), 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 sockets calls. They are described in Section 7. behavior of sockets calls. They are described in Section 7
The syntax is: The syntax is:
ret = getsockopt(int sd, int level, int optname, void *optval, ret = getsockopt(int sd, int level, int optname, void *optval,
size_t *optlen); size_t *optlen);
ret = setsockopt(int sd, int level, int optname, const void *optval, ret = setsockopt(int sd, int level, int optname, const void *optval,
size_t optlen); size_t optlen);
sd - the socket descript. sd - the socket descript.
level - set to IPPROTO_SCTP for all SCTP options. level - set to IPPROTO_SCTP for all SCTP options.
skipping to change at page 33, line 26 skipping to change at page 43, line 45
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).
6.3 read() and write() 6.3 read() and write()
Applications can use read() and write() to send and receive data to Applications can use read() and write() to send and receive data to
and from peer. They have the same semantics as send() and recv() and from peer. They have the same semantics as send() and recv()
except that the flags parameter cannot be used. except that the flags parameter cannot be used.
Note, these calls, when used in the UDP-style model, may only be Note, these calls, when used in the UDP-style model, may only be used
used with branched off socket descriptors (see Section 8.2). with branched off socket descriptors (see Section 8.2).
6.4 getsockname() 6.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 chose a local port. This call is for where the caller let SCTP chose a local port. This call is for where the
endpoint is not multi-homed. It does not work well with multi-homed endpoint is not multi-homed. It does not work well with multi-homed
sockets. See section 8.5 for a multi-homed version of the call. sockets. See Section 8.5 for a multi-homed version of the call.
The syntax is: The syntax is:
int getsockname(int socket, struct sockaddr *address, int getsockname(int socket, struct sockaddr *address,
socklen_t *len); socklen_t *len);
sd - the socket descriptor to be queried. sd - the socket descriptor to be queried.
address - On return, one locally bound address (chosen by address - On return, one locally bound address (chosen by
the SCTP stack) is stored in this buffer. If the the SCTP stack) is stored in this buffer. If the
socket is an IPv4 socket, the address will be IPv4. socket is an IPv4 socket, the address will be IPv4.
If the socket is an IPv6 socket, the address will If the socket is an IPv6 socket, the address will
be either an IPv6 or mapped IPv4 address. be either an IPv6 or IPv4 address.
len - The caller should set the length of address here. len - The caller should set the length of address here.
On return, this is set to the length of the returned On return, this is set to the length of the returned
address. address.
If the actual length of the address is greater than the length of If the actual length of the address is greater than the length of the
the supplied sockaddr structure, the stored address will be supplied sockaddr structure, the stored address will be truncated.
truncated.
If the socket has not been bound to a local name, the value stored If the socket has not been bound to a local name, the value stored in
in the object pointed to by address is unspecified. the object pointed to by address is unspecified.
7. Socket Options 7. Socket Options
The following sub-section describes various SCTP level socket The following sub-section describes various SCTP level socket options
options that are common to both models. SCTP associations can be that are common to both models. SCTP associations can be multi-
multi-homed. Therefore, certain option parameters include a homed. Therefore, certain option parameters include a
sockaddr_storage structure to select which peer address the option sockaddr_storage structure to select which peer address the option
should be applied to. should be applied to.
For the UDP-style sockets, an sctp_assoc_t structure (association For the UDP-style sockets, an sctp_assoc_t structure (association ID)
ID) is used to identify the the association instance that the is used to identify the the association instance that the operation
operation affects. So it must be set when using this model. affects. So it must be set when using this model.
For the TCP-style sockets and branched off UDP-style sockets (see For the TCP-style sockets and branched off UDP-style sockets (see
section 8.2) this association ID parameter is ignored. In the cases Section 8.2) this association ID parameter is ignored. In the cases
noted below where the parameter is ignored, an application can pass noted below where the parameter is ignored, an application can pass
to the system a corresponding option structure similar to those to the system a corresponding option structure similar to those
described below but without the association ID parameter, which described below but without the association ID parameter, which
should be the last field of the option structure. This can make the should be the last field of the option structure. This can make the
option setting/getting operation more efficient. If an application option setting/getting operation more efficient. If an application
does this, it should also specify an appropriate optlen value does this, it should also specify an appropriate optlen value (i.e.
(i.e. sizeof (option parameter) - sizeof (struct sctp_assoc_t)). sizeof (option parameter) - sizeof (struct sctp_assoc_t)).
Note that socket or IP level options is set or retrieved per socket. Note that socket or IP level options is set or retrieved per socket.
This means that for UDP-style sockets, those options will be applied This means that for UDP-style sockets, those options will be applied
to all associations belonging to the socket. And for TCP-style to all associations belonging to the socket. And for TCP-style
model, those options will be applied to all peer addresses of the model, those options will be applied to all peer addresses of the
association controlled by the socket. Applications should be very association controlled by the socket. Applications should be very
careful in setting those options. careful in setting those options.
sctp_opt_info() sctp_opt_info()
For some implementations getsockopt() is read-only, so a new For some implementations getsockopt() is read-only, so a new
interface will be needed when information must be passed both in interface will be needed when information must be passed both in to
to and out of the SCTP stack. The syntax for scpt_opt_info() is, and out of the SCTP stack. The syntax for scpt_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,
size_t *size); size_t *size);
For UDP-style sockets, id specifies the association to query. For For UDP-style sockets, id specifies the association to query. For
TCP-style sockets, id is ignored. TCP-style sockets, id is ignored.
opt specifies which SCTP socket option to get. It can opt specifies which SCTP socket option to get. It can any socket
any socket option currently supported that requests information option currently supported that requests information (either read/
(either read/write options or read only) such as: write options or read only) such as:
SCTP_RTOINFO SCTP_RTOINFO
SCTP_ASSOCINFO SCTP_ASSOCINFO
SCTP_SET_PRIMARY_ADDR SCTP_SET_PRIMARY_ADDR
SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
SCTP_SET_STREAM_TIMEOUTS SCTP_SET_STREAM_TIMEOUTS
SCTP_SET_PEER_ADDR_PARAMS SCTP_SET_PEER_ADDR_PARAMS
SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
arg is an option-specific structure buffer provided by the caller. arg is an option-specific structure buffer provided by the caller.
See 8.5 subsections for more information on these options and See Section 8.5) subsections for more information on these options
option-specific structures. 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.
For those implementations that DO support a read/write For those implementations that DO support a read/write getsocketopt
getsocketopt interface a simple macro wrapper can be interface a simple macro wrapper can be created to support the
created to support the sctp_opt_info() interface such as: sctp_opt_info() interface such as:
#define sctp_opt_info(fd,asoc,opt,arg,sz) \ #define sctp_opt_info(fd,asoc,opt,arg,sz) \
do { \ do { \
if((opt == SCTP_RTOINFO) || \ if((opt == SCTP_RTOINFO) || \
(opt == SCTP_ASSOCINFO) || \ (opt == SCTP_ASSOCINFO) || \
(opt == SCTP_SET_PRIMARY_ADDR) || \ (opt == SCTP_SET_PRIMARY_ADDR) || \
(opt == SCTP_SET_PEER_PRIMARY_ADDR) || \ (opt == SCTP_SET_PEER_PRIMARY_ADDR) || \
(opt == SCTP_SET_STREAM_TIMEOUTS) || \ (opt == SCTP_SET_STREAM_TIMEOUTS) || \
(opt == SCTP_SET_PEER_ADDR_PARAMS) || \ (opt == SCTP_SET_PEER_ADDR_PARAMS) || \
(opt == SCTP_STATUS) || \ (opt == SCTP_STATUS) || \
(opt == SCTP_GET_PEER_ADDR_INFO)){ \ (opt == SCTP_GET_PEER_ADDR_INFO)){ \
*(sctp_assoc_t *)arg = asoc; \ *(sctp_assoc_t *)arg = asoc; \
return(getsockopt(fd,IPPROTO_SCTP,opt,arg,sz)); \ return(getsockopt(fd,IPPROTO_SCTP,opt,arg,sz)); \
}else{ \ }else{ \
return(ENOTSUP); \ return(ENOTSUP); \
} \ } \
}while(0); }while(0);
All options that support specific settings on an association All options that support specific settings on an association by
by filling in either an association id variable or a filling in either an association id variable or a sockaddr_storage
sockaddr_storage SHOULD also support setting of the same SHOULD also support setting of the same value for the entire endpoint
value for the entire endpoint (i.e. future associations). (i.e. future associations). To accomplish this the following logic
To accomplish this the following logic is used when is used when setting one of these options:
setting one of these options:
a) If an address is specified via a sockaddr_storage that a) If an address is specified via a sockaddr_storage that is included
is included in the structure the address is used to in the structure the address is used to lookup the association and
lookup the association and the settings are applied to the settings are applied to the specific address (if appropriate)
the specific address (if appropriate) or to the entire or to the entire association.
association.
b) If an association identification is filled in but not a b) If an association identification is filled in but not a
sockaddr_storage (if present) the association is found sockaddr_storage (if present) the association is found using the
using the association identification and the settings association identification and the settings should be applied to
should be applied to the entire association (since a specific the entire association (since a specific address is specified).
address is specified). Note this also applies to options that Note this also applies to options that hold an association
hold an association identification in their structure but do not identification in their structure but do not have a
have a sockaddr_storage field. sockaddr_storage field.
c) If neither the sockaddr_storage or association identification is set c) If neither the sockaddr_storage or association identification is
i.e. the sockadd_storage is set to all 0's (INADDR_ANY) and the set i.e. the sockadd_storage is set to all 0's (INADDR_ANY) and
association identification is 0, the settings are a default and the association identification is 0, the settings are a default
to be applied to the endpoint (all future associations). and to be applied to the endpoint (all future associations).
7.1 Read / Write Options 7.1 Read / Write Options
7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO) 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
The protocol parameters used to initialize and bound retransmission The protocol parameters used to initialize and bound retransmission
timeout (RTO) are tunable. See [SCTP] for more information on how timeout (RTO) are tunable. See RFC2960 [8] for more information on
these parameters are used in RTO calculation. The peer address how these parameters are used in RTO calculation. The peer address
parameter is ignored for TCP style socket. parameter is ignored for TCP style socket.
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;
skipping to change at page 36, line 28 skipping to change at page 47, line 36
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_initial - This contains the initial RTO value.
srto_max and srto_min - These contain the maximum and minimum bounds srto_max and srto_min - These contain the maximum and minimum bounds
for all RTOs. for all RTOs.
srto_assoc_id - (UDP style socket) This is filled in the application, srto_assoc_id - (UDP style socket) This is filled in the application,
and identifies the association for this query. If and identifies the association for this query. If
this parameter is missing (on a UDP style socket), this parameter is missing (on a UDP style socket),
then the change effects the entire endpoint. then the change effects the entire endpoint.
All parameters are time values, in milliseconds. A value of 0, when All parameters are time values, in milliseconds. A value of 0, when
modifying the parameters, indicates that the current value should modifying the parameters, indicates that the current value should not
not be changed. be 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.
7.1.2 Association Parameters (SCTP_ASSOCINFO) 7.1.2 Association Parameters (SCTP_ASSOCINFO)
This option is used to both examine and set various association This option is used to both examine and set various association and
and endpoint parameters. endpoint parameters.
See [SCTP] for more information on how this parameter is used. The See RFC2960 [8] for more information on how this parameter is used.
peer address parameter is ignored for TCP style socket. The peer address parameter is ignored for TCP style socket.
The following structure is used to access and modify this The following structure is used to access and modify this 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_asocmaxrxt - This contains the maximum retransmission attempts sasoc_asocmaxrxt - This contains the maximum retransmission attempts
to make for the association. to make for the association.
sasoc_number_peer_destinations - This is the number of destination sasoc_number_peer_destinations - This is the number of destination
address that the peer considers address that the peer considers
valid. valid.
sasoc_peer_rwnd - This holds the current value of the peers sasoc_peer_rwnd - This holds the current value of the peers
rwnd (reported in the last SACK) minus any rwnd (reported in the last SACK) minus any
outstanding data (i.e. data inflight). outstanding data (i.e. data inflight).
sasoc_local_rwnd - This holds the last reported rwnd that was sasoc_local_rwnd - This holds the last reported rwnd that was
skipping to change at page 37, line 24 skipping to change at page 48, line 36
sasoc_number_peer_destinations - This is the number of destination sasoc_number_peer_destinations - This is the number of destination
address that the peer considers address that the peer considers
valid. valid.
sasoc_peer_rwnd - This holds the current value of the peers sasoc_peer_rwnd - This holds the current value of the peers
rwnd (reported in the last SACK) minus any rwnd (reported in the last SACK) minus any
outstanding data (i.e. data inflight). outstanding data (i.e. data inflight).
sasoc_local_rwnd - This holds the last reported rwnd that was sasoc_local_rwnd - This holds the last reported rwnd that was
sent to the peer. sent to the peer.
sasoc_cookie_life - This is the associations cookie life value sasoc_cookie_life - This is the associations cookie life value
used when issuing cookies. used when issuing cookies.
sasoc_assoc_id - (UDP style socket) This is filled in the application, sasoc_assoc_id - (UDP style socket) This is filled in the application,
and identifies the association for this query. and identifies the association for this query.
This information may be examined for either the This information may be examined for either the endpoint or a
endpoint or a specific association. To examine a endpoints specific association. To examine a endpoints default parameters the
default parameters the association id (sasoc_assoc_id) should association id (sasoc_assoc_id) should must be set to the value '0'.
must be set to the value '0'. The values of the sasoc_peer_rwnd The values of the sasoc_peer_rwnd is meaningless when examining
is meaningless when examining endpoint information. endpoint information.
The values of the sasoc_asocmaxrxt and sasoc_cookie_life may The values of the sasoc_asocmaxrxt and sasoc_cookie_life may be set
be set on either an endpoint or association basis. The on either an endpoint or association basis. The rwnd and destination
rwnd and destination counts (sasoc_number_peer_destinations, counts (sasoc_number_peer_destinations,
sasoc_peer_rwnd,sasoc_local_rwnd) are NOT settable and any sasoc_peer_rwnd,sasoc_local_rwnd) are NOT settable and any value
value placed in these is ignored. placed in these is 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_ASSOCRTXINFO. SCTP_ASSOCRTXINFO.
The maximum number of retransmissions before an address is The maximum number of retransmissions before an address is considered
considered unreachable is also tunable, but is address-specific, so unreachable is also tunable, but is address-specific, so it is
it is covered in a separate option. If an application attempts to covered in a separate option. If an application attempts to set the
set the value of the association maximum retransmission parameter to value of the association maximum retransmission parameter to more
more than the sum of all maximum retransmission parameters, than the sum of all maximum retransmission parameters, setsockopt()
setsockopt() shall return an error. The reason for this, from shall return an error. The reason for this, from RFC2960 [8] section
[SCTP] section 8.2: 8.2:
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' larger than the having the value of 'Association.Max.Retrans' larger than the
summation of the 'Path.Max.Retrans' of all the destination addresses summation of the 'Path.Max.Retrans' of all the destination addresses
for the remote endpoint. Otherwise, all the destination addresses for the remote endpoint. Otherwise, all the destination addresses
may become inactive while the endpoint still considers the peer may become inactive while the endpoint still considers the peer
endpoint reachable. endpoint reachable.
7.1.3 Initialization Parameters (SCTP_INITMSG) 7.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.2.1. The option name these parameters is defined in Section 5.2.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 Setting initialization parameters is effective only on an unconnected
unconnected socket (for UDP-style sockets only future associations socket (for UDP-style sockets only future associations are effected
are effected by the change). With TCP-style sockets, this option is by the change). With TCP-style sockets, this option is inherited by
inherited by sockets derived from a listener socket. sockets derived from a listener socket.
7.1.4 SO_LINGER 7.1.4 SO_LINGER
An application using the TCP-style socket can use this option to An application using the TCP-style socket can use this option to
perform the SCTP ABORT primitive. The linger option structure is: perform the SCTP ABORT primitive. 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 To enable the option, set l_onoff to 1. If the l_linger value is set
set to 0, calling close() is the same as the ABORT primitive. If to 0, calling close() is the same as the ABORT primitive. If the
the value is set to a negative value, the setsockopt() call will value is set to a negative value, the setsockopt() call will return
return an error. If the value is set to a positive value an error. If the value is set to a positive value linger_time, the
linger_time, the close() can be blocked for at most linger_time ms. close() can be blocked for at most linger_time ms. If the graceful
If the graceful shutdown phase does not finish during this period, shutdown phase does not finish during this period, close() will
close() will return but the graceful shutdown phase continues in the return but the graceful shutdown phase continues in the system.
system.
7.1.5 SCTP_NODELAY 7.1.5 SCTP_NODELAY
Turn off any Nagle-like algorithm. This means that packets are Turn on/off any Nagle-like algorithm. This means that packets are
generally sent as soon as possible and no unnecessary delays are generally sent as soon as possible and no unnecessary delays are
introduced, at the cost of more packets in the network. Expects an introduced, at the cost of more packets in the network. Expects an
integer boolean flag. integer boolean flag.
7.1.6 SO_RCVBUF 7.1.6 SO_RCVBUF
Sets receive buffer size. For SCTP TCP-style sockets, this controls Sets receive buffer size. For SCTP TCP-style sockets, this controls
the receiver window size. For UDP-style sockets, this controls the the receiver window size. For UDP-style sockets, this controls the
receiver window size for all associations bound to the socket receiver window size for all associations bound to the socket
descriptor used in the setsockopt() or getsockopt() call. The option descriptor used in the setsockopt() or getsockopt() call. The option
applies to each association's window size separately. Expects an applies to each association's window size separately. Expects an
integer. integer.
7.1.7 SO_SNDBUF 7.1.7 SO_SNDBUF
Sets send buffer size. For SCTP TCP-style sockets, this controls the Sets send buffer size. For SCTP TCP-style sockets, this controls the
amount of data SCTP may have waiting in internal buffers to be amount of data SCTP may have waiting in internal buffers to be sent.
sent. This option therefore bounds the maximum size of data that can This option therefore bounds the maximum size of data that can be
be sent in a single send call. For UDP-style sockets, the effect is sent in a single send call. For UDP-style sockets, the effect is the
the same, except that it applies to all associations bound to the same, except that it applies to all associations bound to the socket
socket descriptor used in the setsockopt() or getsockopt() call. The descriptor used in the setsockopt() or getsockopt() call. The option
option applies to each association's window size separately. Expects applies to each association's window size separately. Expects an
an integer. integer.
7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE) 7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE)
This socket option is applicable to the UDP-style socket only. When This socket option is applicable to the UDP-style socket only. When
set it will cause associations that are idle for more than the set it will cause associations that are idle for more than the
specified number of seconds to automatically close. An association specified number of seconds to automatically close. An association
being idle is defined an association that has NOT sent or received being idle is defined an association that has NOT sent or received
user data. The special value of '0' indicates that no automatic user data. The special value of '0' indicates that no automatic
close of any associations should be performed. The option expects close of any associations should be performed. The option expects an
an integer defining the number of seconds of idle time before integer defining the number of seconds of idle time before an
an association is closed. association is closed.
7.1.9 Set Primary Address (SCTP_SET_PRIMARY_ADDR) 7.1.9 Set Primary Address (SCTP_SET_PRIMARY_ADDR)
Requests that the peer mark the enclosed address as the association Requests that the peer mark the enclosed address as the association
primary. The enclosed address must be one of the association's primary. The enclosed address must be one of the association's
locally bound addresses. The following structure is used to make a locally bound addresses. The following structure is used to make a
set primary request: set primary request:
struct sctp_setprim { struct sctp_setprim {
sctp_assoc_t ssp_assoc_id; sctp_assoc_t ssp_assoc_id;
skipping to change at page 40, line 8 skipping to change at page 51, line 37
}; };
sspp_addr The address to set as primary sspp_addr The address to set as primary
sspp_assoc_id (UDP style socket) This is filled in by the sspp_assoc_id (UDP style socket) This is filled in by the
application, and identifies the association application, and identifies the association
for this request. for this request.
7.1.11 Set Adaption Layer Indicator (SCTP_SET_ADAPTION_LAYER) 7.1.11 Set Adaption Layer Indicator (SCTP_SET_ADAPTION_LAYER)
Requests that the local endpoint set the specified Adaption Layer Requests that the local endpoint set the specified Adaption Layer
Indication parameter for all future Indication parameter for all future INIT and INIT-ACK exchanges.
INIT and INIT-ACK exchanges.
struct sctp_setadaption { struct sctp_setadaption {
u_int32_t ssb_adaption_ind; u_int32_t ssb_adaption_ind;
}; };
ssb_adaption_ind The adaption layer indicator that will be included ssb_adaption_ind The adaption layer indicator that will be included
in any outgoing Adaption Layer Indication in any outgoing Adaption Layer Indication
parameter. parameter.
7.1.12 Set default message time outs (SCTP_SET_STREAM_TIMEOUTS) 7.1.12 Set default message time outs (SCTP_SET_STREAM_TIMEOUTS)
This option requests that the requested stream apply a This option requests that the requested stream apply a default time-
default time-out for messages in queue. The default value out for messages in queue. The default value is used when the
is used when the application does not specify a timeout application does not specify a timeout in the sendrcvinfo structure
in the sendrcvinfo structure (sinfo_timetolive element (sinfo_timetolive element see Section 5.2.2).
see section 5.2.2).
struct sctp_setstrm_timeout { struct sctp_setstrm_timeout {
sctp_assoc_t ssto_assoc_id; sctp_assoc_t ssto_assoc_id;
u_int32_t ssto_timeout; u_int32_t ssto_timeout;
u_int16_t ssto_streamid_start; u_int16_t ssto_streamid_start;
u_int16_t ssto_streamid_end; u_int16_t ssto_streamid_end;
}; };
ssto_assoc_id (UDP style socket) This is filled in by the ssto_assoc_id (UDP style socket) This is filled in by the
application, and identifies the association application, and identifies the association
skipping to change at page 40, line 50 skipping to change at page 52, line 30
default against. default against.
ssto_streamid_end The ending stream identifier to apply this ssto_streamid_end The ending stream identifier to apply this
default against. default against.
Note that a timeout value of 0 indicates that no inqueue timeout Note that a timeout value of 0 indicates that no inqueue timeout
should be applied against the stream. should be applied against the stream.
7.1.13 Enable/Disable message fragmentation (SCTP_DISABLE_FRAGMENTS) 7.1.13 Enable/Disable message fragmentation (SCTP_DISABLE_FRAGMENTS)
This option is a on/off flag. If enabled no SCTP message This option is a on/off flag. If enabled no SCTP message
fragmentation will be performed. Instead if a message fragmentation will be performed. Instead if a message being sent
being sent exceeds the current PMTU size, the message will exceeds the current PMTU size, the message will NOT be sent and
NOT be sent and instead a error will be indicated to the user. instead a error will be indicated to the user.
7.1.14 Peer Address Parameters (SCTP_SET_PEER_ADDR_PARAMS) 7.1.14 Peer Address Parameters (SCTP_SET_PEER_ADDR_PARAMS)
Applications can enable or disable heartbeats for any peer address Applications can enable or disable heartbeats for any peer address of
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. The following structure is used to access and modify an unreachable. The following structure is used to access and modify an
address's parameters: address's 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;
skipping to change at page 41, line 37 skipping to change at page 53, line 32
interval should remain unchanged. interval should remain unchanged.
spp_pathmaxrxt - This contains the maximum number of spp_pathmaxrxt - This contains the maximum number of
retransmissions before this address shall be retransmissions before this address shall be
considered unreachable. considered unreachable.
To read or modify these parameters, the application should call To read or modify these parameters, the application should call
sctp_opt_info() with the SCTP_SET_PEER_ADDR_PARAMS option. sctp_opt_info() with the SCTP_SET_PEER_ADDR_PARAMS option.
7.1.15 Set default send parameters (SET_DEFAULT_SEND_PARAM) 7.1.15 Set default send parameters (SET_DEFAULT_SEND_PARAM)
Applications that wish to use the sendto() system call may wish Applications that wish to use the sendto() system call may wish to
to specify a default set of parameters that would normally be specify a default set of parameters that would normally be supplied
supplied through the inclusion of ancillary data. This socket through the inclusion of ancillary data. This socket option allows
option allows such an application to set the default such an application to set the default sctp_sndrcvinfo structure.
sctp_sndrcvinfo structure. The application that wishes The application that wishes to use this socket option simply passes
to use this socket option simply passes in to this in to this call the sctp_sndrcvinfo structure defined in Section
call the sctp_sndrcvinfo structure defined in section 5.2.2 5.2.2) The input parameters accepted by this call include
The input parameters accepted by this call include
sinfo_stream, sinfo_flags, sinfo_ppid, sinfo_context, sinfo_stream, sinfo_flags, sinfo_ppid, sinfo_context,
sinfo_timetolive. The user must provide the sinfo_assoc_id sinfo_timetolive. The user must provide the sinfo_assoc_id field in
field in to this call if the caller is using the UDP model. to this call if the caller is using the UDP model.
7.1.16 Set notification and ancillary events (SCTP_SET_EVENTS) 7.1.16 Set notification and ancillary events (SCTP_SET_EVENTS)
This socket option is used to specify various notifications This socket option is used to specify various notifications and
and ancillary data the user wishes to receive. Please see ancillary data the user wishes to receive. Please see Section 7.3)
section 7.3 for a full description of this option and its for a full description of this option and its usage.
usage.
7.2 Read-Only Options 7.2 Read-Only Options
7.2.1 Association Status (SCTP_STATUS) 7.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 unacked data chunks, and number of data chunks pending number of unacked data chunks, and number of data chunks pending
receipt. This information is read-only. The following structure is receipt. This information is read-only. The following structure is
used to access this information: used to access this information:
skipping to change at page 43, line 13 skipping to change at page 55, line 19
will occur. will occur.
To access these status values, the application calls getsockopt() To access these status values, the application calls getsockopt()
with the option name SCTP_STATUS. The sstat_assoc_id parameter is with the option name SCTP_STATUS. The sstat_assoc_id parameter is
ignored for TCP style socket. ignored for TCP style socket.
7.2.2 Peer Address Information (SCTP_GET_PEER_ADDR_INFO) 7.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 window, and retransmission timer values. This information is read-
read-only. The following structure is used to access this only. The following structure is used to access this information:
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;
}; };
skipping to change at page 43, line 47 skipping to change at page 56, line 5
round-trip time calculation in milliseconds. round-trip time calculation in milliseconds.
spinfo_rto - This contains the peer addresses's current spinfo_rto - This contains the peer addresses's current
retransmission timeout value in milliseconds. retransmission timeout value in milliseconds.
spinfo_mtu - The current P-MTU of this address. spinfo_mtu - The current P-MTU of this address.
spinfo_assoc_id - (UDP style socket) This is filled in the application, spinfo_assoc_id - (UDP style socket) This is filled in the application,
and identifies the association for this query. and identifies the association for this query.
To retrieve this information, use sctp_opt_info() with the To retrieve this information, use sctp_opt_info() with the
SCTP_GET_PEER_ADDR_INFO options. SCTP_GET_PEER_ADDR_INFO options.
7.3. Ancillary Data and Notification Interest Options 7.3 Ancillary Data and Notification Interest Options
Applications can receive per-message ancillary information and Applications can receive per-message ancillary information and
notifications of certain SCTP events with recvmsg(). notifications of certain SCTP events with recvmsg().
The following optional information is available to the application: The following optional information is available to the application:
1. SCTP_SNDRCV: Per-message information (i.e. stream number, 1. SCTP_SNDRCV: Per-message information (i.e. stream number, TSN,
TSN, SSN, etc. described in section 5.2.2) SSN, etc. described in Section 5.2.2)
2. SCTP_ASSOC_CHANGE: (described in section 5.3.1.1)
3. SCTP_PEER_ADDR_CHANGE: (described in section 5.3.1.2)
4. SCTP_REMOTE_ERROR: (described in section 5.3.1.3)
5. SCTP_SEND_FAILED: (described in section 5.3.1.4)
6. SCTP_SHUTDOWN_EVENT: (described in section 5.3.1.5)
7. SCTP_ADAPTION_INDICATION: (described in section 5.3.1.6)
8. SCTP_PARTIAL_DELIVERY_EVENT: (described in section 5.3.1.7)
To receive any ancillary data or notifications, first the 2. SCTP_ASSOC_CHANGE: (described in Section 5.3.1.1)
application registers it's interest by calling the SCTP_SET_EVENTS
setsockopt() with the following structure. 3. SCTP_PEER_ADDR_CHANGE: (described in Section 5.3.1.2)
4. SCTP_REMOTE_ERROR: (described in Section 5.3.1.3)
5. SCTP_SEND_FAILED: (described in Section 5.3.1.4)
6. SCTP_SHUTDOWN_EVENT: (described in Section 5.3.1.5)
7. SCTP_ADAPTION_INDICATION: (described in Section 5.3.1.6)
8. SCTP_PARTIAL_DELIVERY_EVENT: (described in Section 5.3.1.7)
To receive any ancillary data or notifications, first the application
registers it's interest by calling the SCTP_SET_EVENTS setsockopt()
with the following structure.
struct sctp_event_subscribe{ struct sctp_event_subscribe{
u_int8_t sctp_data_io_event; u_int8_t sctp_data_io_event;
u_int8_t sctp_association_event; u_int8_t sctp_association_event;
u_int8_t sctp_address_event; u_int8_t sctp_address_event;
u_int8_t sctp_send_failure_event; u_int8_t sctp_send_failure_event;
u_int8_t sctp_peer_error_event; u_int8_t sctp_peer_error_event;
u_int8_t sctp_shutdown_event; u_int8_t sctp_shutdown_event;
u_int8_t sctp_partial_delivery_event; u_int8_t sctp_partial_delivery_event;
u_int8_t sctp_adaption_layer_event; u_int8_t sctp_adaption_layer_event;
}; };
sctp_data_io_event - Setting this flag to 1 will cause the sctp_data_io_event - Setting this flag to 1 will cause the reception
reception of SCTP_SNDRCV information on a per message basis. of SCTP_SNDRCV information on a per message basis. The application
The application will need to use the recvmsg() interface so will need to use the recvmsg() interface so that it can receive the
that it can receive the event information contained in the event information contained in the msg_control field. Please see
msg_control field. Please see section 5.2 for further details. Section 5.2 for further details. Setting the flag to 0 will disable
Setting the flag to 0 will disable reception of the message reception of the message control information.
control information.
sctp_association_event - Setting this flag to 1 will enable sctp_association_event - Setting this flag to 1 will enable the
the reception of association event notifications. Setting reception of association event notifications. Setting the flag to 0
the flag to 0 will disable association event notifications. will disable association event notifications. For more information
For more information on event notifications please see section on event notifications please see Section 5.3.
5.3.
sctp_address_event - Setting this flag to 1 will enable sctp_address_event - Setting this flag to 1 will enable the reception
the reception of address event notifications. Setting of address event notifications. Setting the flag to 0 will disable
the flag to 0 will disable address event notifications. address event notifications. For more information on event
For more information on event notifications please see section notifications please see Section 5.3.
5.3.
sctp_send_failure_event - Setting this flag to 1 will enable sctp_send_failure_event - Setting this flag to 1 will enable the
the reception of send failure event notifications. Setting reception of send failure event notifications. Setting the flag to 0
the flag to 0 will disable send failure event notifications. will disable send failure event notifications. For more information
For more information on event notifications please see section on event notifications please see Section 5.3.
5.3.
sctp_peer_error_event - Setting this flag to 1 will enable sctp_peer_error_event - Setting this flag to 1 will enable the
the reception of peer error event notifications. Setting reception of peer error event notifications. Setting the flag to 0
the flag to 0 will disable peer error event notifications. will disable peer error event notifications. For more information on
For more information on event notifications please see section event notifications please see Section 5.3.
5.3.
sctp_shutdown_event - Setting this flag to 1 will enable sctp_shutdown_event - Setting this flag to 1 will enable the
the reception of shutdown event notifications. Setting reception of shutdown event notifications. Setting the flag to 0
the flag to 0 will disable shutdown event notifications. will disable shutdown event notifications. For more information on
For more information on event notifications please see section event notifications please see Section 5.3.
5.3.
sctp_partial_delivery_event - Setting this flag to 1 will enable sctp_partial_delivery_event - Setting this flag to 1 will enable the
the reception of partial delivery notifications. Setting reception of partial delivery notifications. Setting the flag to 0
the flag to 0 will disable partial delivery event notifications. will disable partial delivery event notifications. For more
For more information on event notifications please see section information on event notifications please see Section 5.3.
5.3.
sctp_adaption_layer_event - Setting this flag to 1 will enable sctp_adaption_layer_event - Setting this flag to 1 will enable the
the reception of adaption layer notifications. Setting reception of adaption layer notifications. Setting the flag to 0
the flag to 0 will disable adaption layer event notifications. will disable adaption layer event notifications. For more
For more information on event notifications please see section information on event notifications please see Section 5.3.
5.3.
An example where an application would like to receive data An example where an application would like to receive data io events
io events and association events but no others would be and association events but no others would be as follows:
as follows:
{ {
struct sctp_event_subscribe event; struct sctp_event_subscribe event;
memset(&event,0,sizeof(event)); memset(&event,0,sizeof(event));
event.sctp_data_io_event = 1; event.sctp_data_io_event = 1;
event.sctp_association_event = 1; event.sctp_association_event = 1;
setsockopt(fd, IPPROTO_SCTP, SCTP_SET_EVENT, &event, sizeof(event)); setsockopt(fd, IPPROTO_SCTP, SCTP_SET_EVENT, &event, sizeof(event));
} }
Note that for UDP-style SCTP sockets, the caller of recvmsg() Note that for UDP-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 TCP-style SCTP sockets, the caller to the file descriptor. For TCP-style SCTP sockets, the caller
receives ancillary data and notifications for only the single receives ancillary data and notifications for only the single
association bound to the file descriptor. association bound to the file descriptor.
By default a TCP-style socket has all options off.
By default a UDP-style socket has sctp_data_io_event and By default a UDP-style socket has sctp_data_io_event and
sctp_association_event on and all other options off. sctp_association_event on and all other options off.
8. New Interfaces 8. New Interfaces
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.
8.1 sctp_bindx() 8.1 sctp_bindx()
skipping to change at page 46, line 4 skipping to change at page 59, line 13
sctp_association_event on and all other options off. sctp_association_event on and all other options off.
8. New Interfaces 8. New Interfaces
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.
8.1 sctp_bindx() 8.1 sctp_bindx()
The syntax of sctp_bindx() is, The syntax of sctp_bindx() is,
int sctp_bindx(int sd, struct sockaddr_storage *addrs, int addrcnt, int sctp_bindx(int sd, struct sockaddr_storage *addrs, int addrcnt,
int flags); int flags);
If sd is an IPv4 socket, the addresses passed must be IPv4 If sd is an IPv4 socket, the addresses passed must be IPv4 addresses.
addresses. If the sd is an IPv6 socket, the addresses passed can If the sd is an IPv6 socket, the addresses passed can either be IPv4
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 or IN6ADDR_ANY, 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. addrs is a pointer to an array of one or more socket addresses. Each
Each address is contained in a struct sockaddr_storage, so each address is contained in a struct sockaddr_storage, so each address is
address is a fixed length. The caller specifies the number of a fixed length. The caller specifies the number of addresses in the
addresses in the array with addrcnt. array with addrcnt.
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:
skipping to change at page 46, line 29 skipping to change at page 59, line 39
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:
SCTP_BINDX_ADD_ADDR SCTP_BINDX_ADD_ADDR
SCTP_BINDX_REM_ADDR 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
association, and SCTP_BINDX_REM_ADDR directs SCTP to remove the association, and SCTP_BINDX_REM_ADDR directs SCTP to remove the given
given addresses from the association. The two flags are mutually addresses from the association. The two flags are mutually
exclusive; if both are given, sctp_bindx() will fail with EINVAL. A exclusive; if both are given, sctp_bindx() will fail with EINVAL. A
caller may not remove all addresses from an association; caller may not remove all addresses from an association; sctp_bindx()
sctp_bindx() will reject such an attempt with EINVAL. 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 use
sctp_bindx(SCTP_BINDX_REM_ADDR) to remove some addresses a listening sctp_bindx(SCTP_BINDX_REM_ADDR) to remove some addresses a listening
socket is associated with so that no new association accepted will socket is associated with so that no new association accepted will be
be associated with those addresses. If the endpoint supports dynamic associated with those addresses. If the endpoint supports dynamic
address a SCTP_BINDX_REM_ADDR or SCTP_BINDX_ADD_ADDR may cause address a SCTP_BINDX_REM_ADDR or SCTP_BINDX_ADD_ADDR may cause a
a endpoint to send the appropriate message to the peer to endpoint to send the appropriate message to the peer to change the
change the peers address lists. peers address lists.
Adding and removing addresses from a connected association is Adding and removing addresses from a connected association is
optional functionality. Implementations that do not support this optional functionality. Implementations that do not support this
functionality should return EOPNOTSUPP. functionality should return EOPNOTSUPP.
8.2 Branched-off Association 8.2 Branched-off Association
After an association is established on a UDP-style socket, the After an association is established on a UDP-style socket, the
application may wish to branch off the association into a separate application may wish to branch off the association into a separate
socket/file descriptor. 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 UDP-style socket but branch off those under the original UDP-style socket but branch off those associations
associations carrying high volume data traffic into their own carrying high volume data traffic into their own separate socket
separate socket descriptors. descriptors.
The application uses sctp_peeloff() call to branch off an The application uses sctp_peeloff() call to branch off an association
association into a separate socket (Note the semantics are somewhat into a separate socket (Note the semantics are somewhat changed from
changed from the traditional TCP-style accept() call). the traditional TCP-style accept() call).
The syntax is: The syntax is:
new_sd = sctp_peeloff(int sd, sctp_assoc_t *assoc_id) new_sd = sctp_peeloff(int sd, sctp_assoc_t *assoc_id);
new_sd - the new socket descriptor representing the branched-off the new socket descriptor representing the branched-off
association. association.
sd - the original UDP-style socket descriptor returned from the the original UDP-style socket descriptor returned from the
socket() system call (see Section 3.1.1). socket() system call (see Section 3.1.1).
assoc_id - the specified identifier of the association that is to be the specified identifier of the association that is to be branched
branched off to a separate file descriptor (Note, in a off to a separate file descriptor (Note, in a traditional TCP-
traditional TCP-style accept() call, this would be an out style accept() call, this would be an out parameter, but for the
parameter, but for the UDP-style call, this is an in UDP-style call, this is an in parameter).
parameter).
8.3 sctp_getpaddrs() 8.3 sctp_getpaddrs()
sctp_getpaddrs() returns all peer addresses in an association. The sctp_getpaddrs() returns all peer addresses in an association. The
syntax is, syntax is,
int sctp_getpaddrs(int sd, sctp_assoc_t id, int sctp_getpaddrs(int sd, sctp_assoc_t id,
struct sockaddr_storage **addrs); struct sockaddr_storage **addrs);
On return, addrs will point to a dynamically allocated array of On return, addrs will point to a dynamically allocated array of
struct sockaddr_storages, one for each peer address. The caller struct sockaddr_storages, one for each peer address. The caller
should use sctp_freepaddrs() to free the memory. addrs must not be should use sctp_freepaddrs() to free the memory. addrs must not be
NULL. 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
skipping to change at page 47, line 54 skipping to change at page 61, line 22
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. mix of IPv4 or IPv6 addresses.
For UDP-style sockets, id specifies the association to query. For For UDP-style sockets, id specifies the association to query. For
TCP-style sockets, id is ignored. TCP-style sockets, id is ignored.
On success, sctp_getpaddrs() returns the number of peer addresses in On success, sctp_getpaddrs() returns the number of peer addresses in
the association. If there is no association on this socket, the association. If there is no association on this socket,
sctp_getpaddrs() returns 0, and the value of *addrs is undefined. If sctp_getpaddrs() returns 0, and the value of *addrs is undefined. If
an error occurs, sctp_getpaddrs() returns -1, and the value of an error occurs, sctp_getpaddrs() returns -1, and the value of *addrs
*addrs is undefined. is undefined.
8.4 sctp_freepaddrs() 8.4 sctp_freepaddrs()
sctp_freepaddrs() frees all resources allocated by sctp_freepaddrs() frees all resources allocated by
sctp_getpaddrs(). Its syntax is, sctp_getpaddrs(). Its syntax is,
void sctp_freepaddrs(struct sockaddr_storage *addrs); void sctp_freepaddrs(struct sockaddr_storage *addrs);
addrs is the array of peer addresses returned by sctp_getpaddrs(). addrs is the array of peer addresses returned by sctp_getpaddrs().
8.5 sctp_getladdrs() 8.5 sctp_getladdrs()
sctp_getladdrs() returns all locally bound address on a socket. The sctp_getladdrs() returns all locally bound address on a socket. The
skipping to change at page 48, line 52 skipping to change at page 63, line 9
sctp_getladdrs(). Its syntax is, sctp_getladdrs(). Its syntax is,
void sctp_freeladdrs(struct sockaddr_storage *addrs); void sctp_freeladdrs(struct sockaddr_storage *addrs);
addrs is the array of peer addresses returned by sctp_getladdrs(). addrs is the array of peer addresses returned by sctp_getladdrs().
9. Security Considerations 9. Security Considerations
Many TCP and UDP implementations reserve port numbers below 1024 for Many TCP and UDP implementations reserve port numbers below 1024 for
privileged users. If the target platform supports privileged users, privileged users. If the target platform supports privileged users,
the SCTP implementation SHOULD restrict the ability to call bind() the SCTP implementation SHOULD restrict the ability to call bind() or
or sctp_bindx() on these port numbers to privileged users. sctp_bindx() on these port numbers to privileged users.
Similarly unprevledged users should not be able to set protocol Similarly unprevledged users should not be able to set protocol
parameters which could result in the congestion control algorithm parameters which could result in the congestion control algorithm
being more aggressive than permitted on the public Internet. These being more aggressive than permitted on the public Internet. These
parameters are: parameters are:
struct sctp_rtoinfo struct sctp_rtoinfo
If an unprivileged user inherits a UDP-style socket with open If an unprivileged user inherits a UDP-style socket with open
associations on a privileged port, it MAY be permitted to accept new associations on a privileged port, it MAY be permitted to accept new
associations, but it SHOULD NOT be permitted to open new associations, but it SHOULD NOT be permitted to open new
associations. This could be relevant for the r* family of associations. This could be relevant for the r* family of protocols.
protocols.
10. Acknowledgments 10. Acknowledgments
The authors wish to thank Kavitha Baratakke, Mike Bartlett, The authors wish to thank Kavitha Baratakke, Mike Bartlett, Jon
Jon Berger, Scott Kimble, Renee Revis, and many others on Berger, Scott Kimble, Renee Revis, and many others on the TSVWG
the TSVWG mailing list for contributing valuable comments. mailing list for contributing valuable comments.
11. Authors' Addresses A special thanks to Phillip Conrad, for his suggested text, quick and
constructive insights, and most of all his persistent fighting to
keep the interface to SCTP usable for the application programmer.
Randall R. Stewart Tel: +1-815-477-2127 References
Cisco Systems, Inc. EMail: rrs@cisco.com
Crystal Lake, IL 60012 [1] Postel, J., "Transmission Control Protocol", STD 7, RFC 793,
September 1981.
[2] Postel, J., "User Datagram Protocol", STD 6, RFC 768, August
1980.
[3] Braden, B., "T/TCP -- TCP Extensions for Transactions Functional
Specification", RFC 1644, July 1994.
[4] Bradner, S., "The Internet Standards Process -- Revision 3", BCP
9, RFC 2026, October 1996.
[5] Bradner, S., "Key words for use in RFCs to Indicate Requirement
Levels", BCP 14, RFC 2119, March 1997.
[6] Stevens, W. and M. Thomas, "Advanced Sockets API for IPv6", RFC
2292, February 1998.
[7] Gilligan, R., Thomson, S., Bound, J. and W. Stevens, "Basic
Socket Interface Extensions for IPv6", RFC 2553, March 1999.
[8] Stewart, R., Xie, Q., Morneault, K., Sharp, C., Schwarzbauer,
H., Taylor, T., Rytina, I., Kalla, M., Zhang, L. and V. Paxson,
"Stream Control Transmission Protocol", RFC 2960, October 2000.
Authors' Addresses
Randall R. Stewart
Cisco Systems, Inc.
8725 West Higgins Road
Suite 300
Chicago, IL 60631
USA USA
Qiaobing Xie Tel: +1-847-632-3028 Phone:
Motorola, Inc. EMail: qxie1@email.mot.com EMail: rrs@cisco.com
1501 W. Shure Drive, Room 2309 Qiaobing Xie
Motorola, Inc.
1501 W. Shure Drive, #2309
Arlington Heights, IL 60004 Arlington Heights, IL 60004
USA USA
La Monte H.P. Yarroll NIC Handle: LY Phone:
Motorola, Inc. EMail: piggy@acm.org EMail: qxie1@email.mot.com
1501 W. Shure Drive, IL27-2315
La Monte H.P. Yarroll
Motorola, Inc.
1501 W. Shure Drive, IL-2315
Arlington Heights, IL 60004 Arlington Heights, IL 60004
USA USA
Phone:
EMail: piggy@acm.org
Jonathan Wood Jonathan Wood
DoCoMo USA Labs Email: jonwood@speakeasy.net DoCoMo USA Labs
181 Metro Drive, Suite 300 181 Metro Drive, Suite 300
San Jose, CA 95110 San Jose, CA 95110
USA USA
Phone:
EMail: jonwood@speakeasy.net
Kacheong Poon Kacheong Poon
Sun Microsystems, Inc. Email: kacheong.poon@sun.com Sun Microsystems, Inc.
901 San Antonio Road 901 San Antonio Road
Palo Alto, CA 94303 Palo Alto, CA 94303
USA USA
Ken Fujita Tel: +1-408-863-6045 Phone:
NEC Corporation Email: fken@cd.jp.nec.com EMail: kcpoon@yahoo.com
Cupertino, CA
12. References
[RFC793] Postel, J., "Transmission Control Protocol", STD 7, RFC 793,
September 1981.
[RFC768] Postel, J. (ed.), "User Datagram Protocol", STD 6, RFC 768,
August 1980.
[RFC1644] Braden, R., "T/TCP -- TCP Extensions for Transactions
Functional Specification," RFC 1644, July 1994.
[RFC2026] Bradner, S., "The Internet Standards Process -- Revision 3",
RFC 2026, October 1996.
[RFC2292] W.R. Stevens, M. Thomas, "Advanced Sockets API for IPv6",
RFC 2292, February 1998.
[RFC2553] R. Gilligan, S. Thomson, J. Bound, W. Stevens. "Basic Socket Ken Fujita
Interface Extensions for IPv6," RFC 2553, March 1999. NEC USA, Inc.
10080 Wolfe Road, Suite SW3-350
Cupertino, CA 95014
USA
[SCTP] R.R. Stewart, Q. Xie, K. Morneault, C. Sharp, H.J. Schwarzbauer, Phone:
T. Taylor, I. Rytina, M. Kalla, L. Zhang, and, V. Paxson, EMail: fken@ccrl.sj.nec.com
"Stream Control Transmission Protocol," RFC2960, October 2000. Michael Tuexen
Siemens AG
ICN WN CC SE 7
D-81359 Munich
Germany
[STEVENS] W.R. Stevens, M. Thomas, E. Nordmark, "Advanced Sockets API for Phone:
IPv6," <draft-ietf-ipngwg-rfc2292bis-03.txt>, November 2001 EMail: Michael.Tuexen@siemens.com
(Work in progress)
Appendix A: TCP-style Code Example Appendix A. TCP-style Code Example
The following code is a simple implementation of an echo server over The following code is a simple implementation of an echo server over
SCTP. The example shows how to use some features of TCP-style IPv4 SCTP. The example shows how to use some features of TCP-style IPv4
SCTP sockets, including: SCTP sockets, including:
o Opening, binding, and listening for new associations on a socket; o Opening, binding, and listening for new associations on a socket;
o Enabling ancillary data o Enabling ancillary data
o Enabling notifications o Enabling notifications
o Using ancillary data with sendmsg() and recvmsg() o Using ancillary data with sendmsg() and recvmsg()
o Using MSG_EOR to determine if an entire message has been read o Using MSG_EOR to determine if an entire message has been read
o Handling notifications o Handling notifications
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/sctp.h>
#include <sys/uio.h>
#define BUFLEN 100
static void static void
handle_event(void *buf) handle_event(void *buf)
{ {
struct sctp_assoc_change *sac; struct sctp_assoc_change *sac;
struct sctp_send_failed *ssf; struct sctp_send_failed *ssf;
struct sctp_paddr_change *spc; struct sctp_paddr_change *spc;
struct sctp_remote_error *sre; struct sctp_remote_error *sre;
union sctp_notification *snp; union sctp_notification *snp;
char addrbuf[INET6_ADDRSTRLEN]; char addrbuf[INET6_ADDRSTRLEN];
const char *ap; const char *ap;
skipping to change at page 52, line 7 skipping to change at page 70, line 8
{ {
ssize_t nr = 0; ssize_t nr = 0;
struct iovec iov[1]; struct iovec iov[1];
*nrp = 0; *nrp = 0;
iov->iov_base = buf; iov->iov_base = buf;
msg->msg_iov = iov; msg->msg_iov = iov;
msg->msg_iovlen = 1; msg->msg_iovlen = 1;
for (;;) { for (;;) {
#ifndef MSG_XPG4_2
#define MSG_XPG4_2 0
#endif
msg->msg_flags = MSG_XPG4_2; msg->msg_flags = MSG_XPG4_2;
msg->msg_iov->iov_len = *buflen; msg->msg_iov->iov_len = *buflen;
msg->msg_controllen = cmsglen; msg->msg_controllen = cmsglen;
nr += recvmsg(fd, msg, 0); nr += recvmsg(fd, msg, 0);
if (nr <= 0) { if (nr <= 0) {
/* EOF or error */ /* EOF or error */
*nrp = nr; *nrp = nr;
return (NULL); return (NULL);
} }
skipping to change at page 54, line 19 skipping to change at page 72, line 35
exit(1); exit(1);
} }
if (listen(lfd, 1) == -1) { if (listen(lfd, 1) == -1) {
perror("listen"); perror("listen");
exit(1); exit(1);
} }
/* Wait for new associations */ /* Wait for new associations */
for (;;) { for (;;) {
struct sctp_event_subscribe event;
if ((cfd = accept(lfd, NULL, 0)) == -1) { if ((cfd = accept(lfd, NULL, 0)) == -1) {
perror("accept"); perror("accept");
exit(1); exit(1);
} }
/* Enable ancillary data */ /* Enable all events */
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT, event.sctp_data_io_event = 1;
&onoff, 4) < 0) { event.sctp_association_event = 1;
perror("setsockopt RECVDATAIOEVNT"); event.sctp_address_event = 1;
exit(1); event.sctp_send_failure_event = 1;
} event.sctp_peer_error_event = 1;
/* Enable notifications */ event.sctp_shutdown_event = 1;
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVASSOCEVNT, event.sctp_partial_delivery_event = 1;
&onoff, 4) < 0) { event.sctp_adaption_layer_event = 1;
perror("setsockopt SCTP_RECVASSOCEVNT"); if (setsockopt(r->fd, IPPROTO_SCTP,
exit(1); SCTP_SET_EVENTS, &event,
} sizeof(event)) != 0) {
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, perror("setevent failed");
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVASSOCEVNT");
exit(1);
}
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPADDREVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPADDREVNT");
exit(1);
}
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPEERERR,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPEERERR");
exit(1);
}
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVSHUTDOWNEVNT");
exit(1); exit(1);
} }
/* Echo back any and all data */ /* Echo back any and all data */
echo(cfd,0); echo(cfd,0);
} }
} }
Appendix B: UDP-style Code Example Appendix B. UDP-style Code Example
The following code is a simple implementation of an echo server over The following code is a simple implementation of an echo server over
SCTP. The example shows how to use some features of UDP-style IPv4 SCTP. The example shows how to use some features of UDP-style IPv4
SCTP sockets, including: SCTP sockets, including:
o Opening and binding of a socket; o Opening and binding of a socket;
o Enabling ancillary data o Enabling ancillary data
o Enabling notifications o Enabling notifications
o Using ancillary data with sendmsg() and recvmsg() o Using ancillary data with sendmsg() and recvmsg()
o Using MSG_EOR to determine if an entire message has been read o Using MSG_EOR to determine if an entire message has been read
o Handling notifications o Handling notifications
Note most functions defined in Appendix A are reused in Note most functions defined in Appendix A are reused in this example.
this example.
int main() int main()
{ {
int fd; int fd;
int onoff = 1; int onoff = 1;
int idleTime = 2; int idleTime = 2;
struct sockaddr_in sin[1]; struct sockaddr_in sin[1];
if ((fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) == -1) { if ((fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) == -1) {
perror("socket"); perror("socket");
skipping to change at page 55, line 44 skipping to change at page 74, line 45
} }
sin->sin_family = AF_INET; sin->sin_family = AF_INET;
sin->sin_port = htons(7); sin->sin_port = htons(7);
sin->sin_addr.s_addr = INADDR_ANY; sin->sin_addr.s_addr = INADDR_ANY;
if (bind(fd, (struct sockaddr *)sin, sizeof (*sin)) == -1) { if (bind(fd, (struct sockaddr *)sin, sizeof (*sin)) == -1) {
perror("bind"); perror("bind");
exit(1); exit(1);
} }
/* Enable notifications */ /* Enable all notifications and events */
event.sctp_data_io_event = 1;
/* SCTP_RECVASSOCEVNT and SCTP_RECVDATAIOEVNT are on by default */ event.sctp_association_event = 1;
event.sctp_address_event = 1;
/* if a send fails we want to know it */ event.sctp_send_failure_event = 1;
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, event.sctp_peer_error_event = 1;
&onoff, 4) < 0) { event.sctp_shutdown_event = 1;
perror("setsockopt SCTP_RECVASSOCEVNT"); event.sctp_partial_delivery_event = 1;
exit(1); event.sctp_adaption_layer_event = 1;
} if (setsockopt(r->fd, IPPROTO_SCTP,
/* if a network address change or event transpires SCTP_SET_EVENTS, &event,
* we wish to know it sizeof(event)) != 0) {
*/ perror("setevent failed");
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPADDREVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPADDREVNT");
exit(1);
}
/* We would like all error TLV's from the peer */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPEERERR,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPEERERR");
exit(1);
}
/* And of course we would like to know about shutdown's */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVSHUTDOWNEVNT");
exit(1); exit(1);
} }
/* Set associations to auto-close in 2 seconds of /* Set associations to auto-close in 2 seconds of
* inactivity * inactivity
*/ */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_AUTOCLOSE, if (setsockopt(fd, IPPROTO_SCTP, SCTP_AUTOCLOSE,
&idleTime, 4) < 0) { &idleTime, 4) < 0) {
perror("setsockopt SCTP_AUTOCLOSE"); perror("setsockopt SCTP_AUTOCLOSE");
exit(1); exit(1);
} }
skipping to change at line 2986 skipping to change at page 76, line 4
perror("listen"); perror("listen");
exit(1); exit(1);
} }
/* Wait for new associations */ /* Wait for new associations */
while(1){ while(1){
/* Echo back any and all data */ /* Echo back any and all data */
echo(fd,1); echo(fd,1);
} }
} }
Full Copyright Statement
Copyright (C) The Internet Society (2002). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement
Funding for the RFC Editor function is currently provided by the
Internet Society.
 End of changes. 

This html diff was produced by rfcdiff 1.23, available from http://www.levkowetz.com/ietf/tools/rfcdiff/