draft-ietf-tsvwg-sctpsocket-00.txt   draft-ietf-tsvwg-sctpsocket-01.txt 
skipping to change at page 1, line 14 skipping to change at page 1, line 14
INTERNET-DRAFT Cisco INTERNET-DRAFT Cisco
Q. Xie Q. Xie
L Yarroll L Yarroll
Motorola Motorola
J. Wood J. Wood
K. Poon K. Poon
Sun Microsystems Sun Microsystems
K. Fujita K. Fujita
NEC NEC
expires in six months June 1, 2001 expires in six months July 19, 2001
SCTP Sockets Mapping Sockets API Extensions for SCTP
<draft-ietf-tsvwg-sctpsocket-00.txt> <draft-ietf-tsvwg-sctpsocket-01.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]. Internet-Drafts are
working documents of the Internet Engineering Task Force (IETF), its working documents of the Internet Engineering Task Force (IETF), its
areas, and its working groups. Note that other groups may also areas, and its working groups. Note that other groups may also
distribute working documents as Internet-Drafts. distribute working documents as Internet-Drafts.
The list of current Internet-Drafts can be accessed at The list of current Internet-Drafts can be accessed at
skipping to change at page 1, line 49 skipping to change at page 1, line 49
Table of Contents Table of Contents
1. Introduction............................................ 3 1. Introduction............................................ 3
2. Conventions............................................. 4 2. Conventions............................................. 4
2.1 Data Types............................................ 4 2.1 Data Types............................................ 4
3. UDP-style Interface..................................... 4 3. UDP-style Interface..................................... 4
3.1 Basic Operation....................................... 4 3.1 Basic Operation....................................... 4
3.1.1 socket() - UDP Style Syntax...................... 5 3.1.1 socket() - UDP Style Syntax...................... 5
3.1.2 bind() - UDP Style Syntax........................ 5 3.1.2 bind() - UDP Style Syntax........................ 5
3.1.3 sendmsg() and recvmsg() - UDP Style Syntax....... 6 3.1.3 listen() - UDP Style Syntax...................... 6
3.1.4 close() - UDP Style Syntax....................... 7 3.1.4 sendmsg() and recvmsg() - UDP Style Syntax....... 7
3.1.5 close() - UDP Style Syntax....................... 8
3.2 Implicit Association Setup............................ 8 3.2 Implicit Association Setup............................ 8
3.3 Non-blocking mode..................................... 8 3.3 Non-blocking mode..................................... 9
4. TCP-style Interface..................................... 9 4. TCP-style Interface.....................................10
4.1 Basic Operation....................................... 9 4.1 Basic Operation.......................................10
4.1.1 socket() - TCP Style Syntax........................10 4.1.1 socket() - TCP Style Syntax........................11
4.1.2 bind() - TCP Style Syntax..........................10 4.1.2 bind() - TCP Style Syntax..........................11
4.1.3 listen() - TCP Style Syntax........................11 4.1.3 listen() - TCP Style Syntax........................12
4.1.4 accept() - TCP Style Syntax........................11 4.1.4 accept() - TCP Style Syntax........................12
4.1.5 connect() - TCP Style Syntax.......................12 4.1.5 connect() - TCP Style Syntax.......................12
4.1.6 close() - TCP Style Syntax.........................12 4.1.6 close() - TCP Style Syntax.........................13
4.1.7 shutdown() - TCP Style Syntax......................12 4.1.7 shutdown() - TCP Style Syntax......................13
4.1.8 sendmsg() and recvmsg() - TCP Style Syntax.........13 4.1.8 sendmsg() and recvmsg() - TCP Style Syntax.........14
5. Data Structures..........................................13 4.1.9 getsockname() .....................................15
5.1 The msghdr and cmsghdr Structures......................13 4.1.10 getpeername() ....................................15
5.2 SCTP msg_control Structures............................14 5. Data Structures..........................................16
5.2.1 SCTP Initiation Structure (SCTP_INIT)...............15 5.1 The msghdr and cmsghdr Structures......................16
5.2.2 SCTP Header Information Structure (SCTP_SNDRCV).....16 5.2 SCTP msg_control Structures............................17
5.3 SCTP Events and Notifications..........................18 5.2.1 SCTP Initiation Structure (SCTP_INIT)...............18
5.3.1 SCTP Notification Structure.........................18 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV).....19
5.3.1.1 SCTP_ASSOC_CHANGE................................19 5.3 SCTP Events and Notifications..........................20
5.3.1.2 SCTP_PEER_ADDR_CHANGE............................21 5.3.1 SCTP Notification Structure.........................21
5.3.1.3 SCTP_REMOTE_ERROR................................22 5.3.1.1 SCTP_ASSOC_CHANGE................................22
5.3.1.4 SCTP_SEND_FAILE..................................23 5.3.1.2 SCTP_PEER_ADDR_CHANGE............................23
5.3.1.5 SCTP_SHUTDOWN_EVENT..............................24 5.3.1.3 SCTP_REMOTE_ERROR................................25
5.4 Ancillary Data Considerations and Semantics...........25 5.3.1.4 SCTP_SEND_FAILE..................................26
5.4.1 Multiple Items and Ordering........................25 5.3.1.5 SCTP_SHUTDOWN_EVENT..............................27
5.4.2 Accessing and Manipulating Ancillary Data..........25 5.4 Ancillary Data Considerations and Semantics...........27
5.4.3 Control Message Buffer Sizing......................26 5.4.1 Multiple Items and Ordering........................27
6. Common Operations for Both Styles.......................27 5.4.2 Accessing and Manipulating Ancillary Data..........28
6.1 send(), recv(), sendto(), recvfrom()..................27 5.4.3 Control Message Buffer Sizing......................28
6.2 setsockopt(), getsockopt()............................28 6. Common Operations for Both Styles.......................29
6.3 read() and write()....................................28 6.1 send(), recv(), sendto(), recvfrom()..................29
7. Socket Options..........................................28 6.2 setsockopt(), getsockopt()............................30
7.1 Read / Write Options..................................29 6.3 read() and write()....................................30
7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)...29 7. Socket Options..........................................30
7.1 Read / Write Options..................................31
7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)...31
7.1.2 Association Retransmission Parameter 7.1.2 Association Retransmission Parameter
(SCTP_ASSOCRTXINFO)................................29 (SCTP_ASSOCRTXINFO)................................32
7.1.3 Initialization Parameters (SCTP_INITMSG)...........30 7.1.3 Initialization Parameters (SCTP_INITMSG)...........32
7.1.4 SO_LINGER..........................................30 7.1.4 SO_LINGER..........................................33
7.1.5 SO_NODELAY.........................................31 7.1.5 SO_NODELAY.........................................33
7.1.6 SO_RCVBUF..........................................31 7.1.6 SO_RCVBUF..........................................33
7.1.7 SO_SNDBUF..........................................31 7.1.7 SO_SNDBUF..........................................33
7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE)...31 7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE)...33
7.2 Read-Only Options.....................................31 7.1.9 SCTP_SET_PRIMARY_ADDR..............................34
7.2.1 Association Status (SCTP_STATUS)...................31 7.1.10 SCTP_SET_PEER_PRIMARY_ADDR........................34
7.3. Ancillary Data Interest Options.....................32 7.2 Read-Only Options.....................................34
8. New Interface...........................................33 7.2.1 Association Status (SCTP_STATUS)...................34
8.1 sctp_bindx()..........................................33 7.3. Ancillary Data and Notification Interest Options.....35
8.2 Branched-off Association, sctp_peeloff()..............34 8. New Interfaces..........................................36
8.3 sctp_getpaddrs()......................................35 8.1 sctp_bindx()..........................................36
8.4 sctp_freepaddrs().....................................35 8.2 Branched-off Association, sctp_peeloff()..............37
8.5 sctp_opt_info().......................................35 8.3 sctp_getpaddrs()......................................38
8.5.1 Peer Address Parameters............................36 8.4 sctp_freepaddrs().....................................38
8.5.2 Peer Address Information...........................37 8.5 sctp_getladdrs()......................................38
9. Security Considerations.................................37 8.6 sctp_freeladdrs().....................................39
10. Authors' Addresses....................................38 8.7 sctp_opt_info().......................................39
11. References............................................38 8.7.1 Peer Address Parameters............................39
Appendix A: TCP-style Code Example.........................39 8.7.2 Peer Address Information...........................40
Appendix B: UDP-style Code Example.........................43 9. Security Considerations.................................41
10. Acknowledgements......................................41
11. Authors' Addresses....................................41
12. References............................................42
Appendix A: TCP-style Code Example.........................42
Appendix B: UDP-style Code Example.........................47
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 [TCP] and UDP Protocol suite to many operating systems. Both TCP [RFC793] and UDP
[UDP] have benefited from this standard representation and access [RFC768] have benefited from this standard representation and access
method across many diverse platforms. SCTP is a new protocol that method across many diverse platforms. SCTP is a new protocol that
provides many of the characteristics of TCP but also incorporates provides many of the characteristics of TCP but also incorporates
semantics more akin to UDP. This document defines a method to map semantics more akin to UDP. This document defines a method to map
the existing sockets API for use with SCTP, providing both a base the existing sockets API for use with SCTP, providing both a base
for access to new features and compatibility so that most existing for access to new features and compatibility so that most existing
TCP applications can be migrated to SCTP with few (if any) changes. 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:
skipping to change at page 4, line 25 skipping to change at page 4, line 34
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).
C) New inbound associations are accepted automatically.
3.1 Basic Operation 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. setsocketopt() 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()
skipping to change at page 5, line 35 skipping to change at page 5, line 42
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, while, the second form creates an endpoint which can use addresses, while, the second form creates an endpoint which can use
both IPv6 and IPv4 mapped addresses. both IPv6 and IPv4 mapped 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 as the primary address. 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 8.1 to help applications
do the job of associating multiple addresses. 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 initialization process, see [SCTP]. association initialization process, see [SCTP].
After calling bind() or sctp_bindx(), if the endpoint wishes to After calling bind() or sctp_bindx(), if the endpoint wishes to
accept new assocations on the socket, it must enable the accept new associations on the socket, it must call listen() (see
SCTP_ASSOC_CHANGE socket option (see section 5.3.1.1). Then the section 3.1.3).
SCTP endpoint will accept all SCTP INIT requests passing the
COMMUNICATION_UP notification to the endpoint upon reception of a
valid associaition (i.e. the receipt of a valid COOKIE ECHO).
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, int addrlen);
sd - the socket descriptor returned by socket(). sd - the socket descriptor returned by socket().
addr - the address structure (struct sockaddr_in or struct addr - the address structure (struct sockaddr_in or struct
sockaddr_in6 [RFC 2553]), sockaddr_in6 [RFC 2553]),
addrlen - the size of the address structure. addrlen - the size of the address structure.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv4 socket, the address passed must be an IPv4 address.
If 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 or an IPv6 address. 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 an endpoint. After the first call to bind(), all addresses to an endpoint. After the first call to bind(), all
skipping to change at page 6, line 15 skipping to change at page 6, line 17
addr - the address structure (struct sockaddr_in or struct addr - the address structure (struct sockaddr_in or struct
sockaddr_in6 [RFC 2553]), sockaddr_in6 [RFC 2553]),
addrlen - the size of the address structure. addrlen - the size of the address structure.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv4 socket, the address passed must be an IPv4 address.
If 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 or an IPv6 address. 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 an endpoint. After the first call to bind(), all addresses to an endpoint. After the first call to bind(), all
subsequent call will return an error. subsequent calls will return an error.
If addr is specified as INADDR_ANY for an IPv4 or IPv6 socket, or as If addr is specified as a wildcard (INADDR_ANY for an IPv4 address,
IN6ADDR_ANY for an IPv6 socket (normally used by server or as IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address), the
applications), the operating system will associates the endpoint operating system will associate the endpoint with an optimal address
with the optimal subset of available local interfaces. set of the available interfaces.
If a bind() or sctp_bindx() is not called prior to the connect() If a bind() or sctp_bindx() is not called prior to a sendmsg() call
call, the system picks an ephemeral port and will choose an address that initiates a new association, the system picks an ephemeral port
set equivalant to binding with INADDR_ANY and IN6ADDR_ANY for IPv4 and will choose an address set equivalent to binding with a wildcard
and IPv6 socket respectively. One of those addresses will be the address. One of those addresses will be the primary address for the
primary address for the association. This automatically enables the association. This automatically enables the multihoming capability
multihoming capability of SCTP. of SCTP.
3.1.3 sendmsg() and recvmsg() - UDP Style Syntax 3.1.3 listen() - UDP Style Syntax
By default, new associations are not accepted for UDP style sockets.
An application uses listen() to mark a socket as being able to
accept new associations. The syntax is,
int listen(int socket, int backlog);
socket - the socket descriptor of the endpoint.
backlog - ignored for UDP-style sockets.
Note that UDP-style socket consumers do not need to call accept to
retrieve new associations. Calling accept() on a UDP-style socket
should return EOPNOTSUPP. Rather, new associations are accepted
automatically, and notifications of the new associations are
delivered via recvmsg() with the SCTP_ASSOC_CHANGE event (if these
notifications are enabled). Clients will typically not call listen,
so that they can be assured that the only associations on the socket
will be ones they actively initiated. Server or peer-to-peer
sockets, on the other hand, will always accept new associations, so
a well-written application using server UDP-style sockets must be
prepared to handle new associations from unwanted peers.
Also note that the SCTP_ASSOC_CHANGE event provides the association
ID for a new association, so if applications wish to use the
association ID as input to other socket calls, they should ensure
that the SCTP_ASSOC_CHANGE event is enabled (it is enabled by
default).
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);
skipping to change at page 7, line 23 skipping to change at page 7, line 55
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. message belongs. Note that if SCTP_ASSOC_CHANGE events are disabled,
applications must use the peer transport address provided in the
msg_name field by recvmsg() to perform correlation to an
association, 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). 5.1).
If the application does not provide enough buffer space to If the application does not provide enough buffer space to
completely receive a data message, MSG_EOR will not be set in completely receive a data message, MSG_EOR will not be set in
msg_flags. Successive reads will consume more of the same message msg_flags. Successive reads will consume more of the same message
until the entire message has been delievered, and MSG_EOR will be until the 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 a message. In this case, MSG_EOR will not be set, and more deliver a message. In this case, MSG_EOR will not be set, and more
calls to recvmsg() will be necessary to completely consume the calls to recvmsg() will be necessary to completely consume the
message. Only one message at a time can be partially delivered. message. Only 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 association (see Section 3.1), the msg_name field is not used one association (see Section 3.1), the msg_name field is not used
when sending data (i.e., ignored by the SCTP stack). when sending data (i.e., ignored by the SCTP stack).
3.1.4 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 [SCTP]) 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-style socket, an application should use the sendmsg() call, UDP-style socket, an application should use the sendmsg() call,
passing no user data, but including the appropriate flag in the passing no user data, but including the MSG_EOF flag in the
ancillary data (see Section 5.2.2). ancillary data (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.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()/recvmsg() or sendto()/recvfrom() calls, without going sendmsg()/recvmsg() or sendto()/recvfrom() calls, without going
skipping to change at page 8, line 50 skipping to change at page 9, line 32
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 user might want to avoid blocking when they call Some SCTP users might want to avoid blocking when they call
socket interface function. 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 the socket status is writable or readable. If the socket check the socket status is writable or readable. If the socket
status isn't writeable or readable, the user should not call status isn't writeable or readable, the user should not call
sendmsg()/sendto() and recvmsg()/recvfrom(). sendmsg()/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, and the success or fault of the data message (and immediately, and the success or failure of the data message (and
possible SCTP_INITMSG parameters) will be notified by possible SCTP_INITMSG parameters) will be signalled by the
SCTP_ASSOC_CHANGE with COMMUNICATION_UP or CANT_START_ASSOC. If user SCTP_ASSOC_CHANGE event with COMMUNICATION_UP or
data was sent and failed (due to a CANT_START_ASOC), the sender will CANT_START_ASSOC. If user data could not be sent (due to a
also recieve a SCTP_SEND_FAILED event. Those event(s) can be CANT_START_ASSOC), the sender will also receive a SCTP_SEND_FAILED
received by the user calling of recvmsg(). The server side user is event. Those event(s) can be received by the user calling of
also notified of an association up event by the reception of a recvmsg(). A server (having called listen()) is also notified of an
SCTP_ASSOC_CHANGE with COMMUNICATION_UP via the calling of association up event by the reception of a SCTP_ASSOC_CHANGE with
recvmsg() and possibly the reception of the first data message. COMMUNICATION_UP via the calling of recvmsg() and possibly the
reception of the first data message.
When the user want to graceful shutdown the association, the user In order to shutdown the association gracefully, the user must call
must call sendmsg() and send SHUTDOWN. The function returns sendmsg() with no data and with the MSG_EOF flag set. The function
immediately, and the success of the SHUTDOWN is notified by returns immediately, and completion of the graceful shutdown is
SCTP_ASSOC_CHANGE with SHUTDOWN_COMPLETE calling recvmsg(). indicated by an SCTP_ASSOC_CHANGE notification of type
SHUTDOWN_COMPLETE (see section 5.3.1.1).
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 with very little effort. SCTP 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
skipping to change at page 9, line 45 skipping to change at page 10, line 29
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 assocation 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()
to terminate the association. to terminate the association.
skipping to change at page 10, line 24 skipping to change at page 11, line 8
to terminate this association when done. to terminate this association when done.
4.1.1 socket() - TCP Style Syntax 4.1.1 socket() - TCP Style Syntax
Applications calls socket() to create a socket descriptor to Applications calls socket() to create a socket descriptor to
represent an SCTP endpoint. represent an SCTP endpoint.
The syntax is: The syntax is:
sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); int socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
or, or,
sd = 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, while the second form creates an endpoint which can use addresses, while the second form creates an endpoint which can use
both IPv6 and mapped IPv4 addresses. both IPv6 and mapped IPv4 addresses.
4.1.2 bind() - TCP Style Syntax 4.1.2 bind() - TCP Style Syntax
Applications use bind() to pass the primary address assoicated with Applications use bind() to pass an address to be associated with an
an SCTP endpoint to the system. An SCTP endpoint can be associated SCTP endpoint to the system. bind() allows only either a single
with multiple addresses. To do this, sctp_bindx() is introduced in address or a IPv4 or IPv6 wildcard address to be bound. An SCTP
section 8.1 to help applications do the job of associating multiple endpoint can be associated with multiple addresses. To do this,
addresses. sctp_bindx() is introduced in section 8.1 to help 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 initialization process, see [SCTP]. association initialization process, see [SCTP].
The syntax is: The syntax is:
ret = bind(int sd, struct sockaddr *addr, int addrlen); int bind(int sd, struct sockaddr *addr, int 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 addr - the address structure (either struct sockaddr_in or struct
sockaddr_in6 defined in [RFC 2553]). sockaddr_in6 defined in [RFC 2553]).
addrlen - the size of the address structure. addrlen - the size of the address structure.
If sd is an IPv4 socket, the address passed must be an IPv4 address. If sd is an IPv4 socket, the address passed must be an IPv4 address.
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 INADDR_ANY for an IPv4 or IPv6 socket, or as If addr is specified as a wildcard (INADDR_ANY for an IPv4 address,
IN6ADDR_ANY for an IPv6 socket (normally used by server or as IN6ADDR_ANY_INIT or in6addr_any for an IPv6 address), the
applications), the operating system will associate the endpoint with operating system will associate the endpoint with an optimal address
an optimal address set of the available interfaces. set of the available interfaces.
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
set equivalant to binding with a wildcard address. One of those
addresses will be the primary address for the association. This
automatically enables the multihoming capability of SCTP.
The completion of this bind() process does not ready the SCTP The completion of this bind() process does not ready the SCTP
endpoint to accept inbound SCTP association requests. Until a endpoint to accept inbound SCTP association requests. Until a
listen() system call, described below, is performed on the socket, listen() system call, described below, is performed on the socket,
the SCTP endpoint will promptly reject an inbound SCTP INIT request the SCTP endpoint will promptly reject an inbound SCTP INIT request
with an SCTP ABORT. with an SCTP ABORT.
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:
ret = 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 backlog - this specifies the max number of outstanding associations
allowed in the socket's accept queue. These are the allowed in the socket's accept queue. These are the
associations that have finished the four-way initiation associations that have finished the four-way initiation
handshake (see Section 5 of [SCTP]) and are in the handshake (see Section 5 of [SCTP]) and are in the
ESTABLISHED state. ESTABLISHED state.
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
assocation 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. sd - the listening socket descriptor.
addr - on return, will contain the primary address of the peer 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
ret = connect(int sd, const struct sockaddr *addr, int addrlen); int connect(int sd, const struct sockaddr *addr, int addrlen);
sd - the socket descriptor of the endpoint. sd - the socket descriptor of the endpoint.
addr - the peer's address. addr - the peer's address.
addrlen - the size of the 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 [SCTP].
By default, the new association created has only one outbound By default, the new association created has only one outbound
stream. The SCTP_INITMSG option described in Section 7.1.4 should be stream. The SCTP_INITMSG option described in Section 7.1.3 should be
used before connecting to change the number of outbound streams. used 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 equivalant 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
multihoming capability of SCTP. multihoming 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],
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 assocation. 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 setsockopt(). the 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. MSG_EOF is not an acceptable flag with SCTP socket. connection. 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:
ret = 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 socket operations will suceed on that descriptor. further socket operations will suceed on that descriptor.
4.1.7 shutdown() - TCP Style Syntax 4.1.7 shutdown() - TCP Style Syntax
The socket call shutdown() does not have any meaning with an SCTP SCTP differs from TCP in that it does not have half closed
socket because SCTP does not have a half closed semantics. Calling semantics. Hence the shutdown() call for SCTP is an approximation
shutdown() on an SCTP socket will return an error. of the TCP shutdown() call, and solves some different problems.
Full TCP-compatibility is not provided, so developers porting TCP
applications to SCTP may need to recode sections that use
shutdown(). (Note that it is possible to achieve the same results
as half close in SCTP using SCTP streams.)
The syntax is:
int shutdown(int socket, int how);
sd - the socket descriptor of the association to be closed.
how - Specifies the type of shutdown. The values are
as follows:
SHUT_RD
Disables further receive operations. No SCTP
protocol action is taken.
SHUT_WR
Disables further send operations, and initiates
the SCTP shutdown sequence.
SHUT_RDWR
Disables further send and receive operations
and initiates the SCTP shutdown sequence.
The major difference between SCTP and TCP shutdown() is that SCTP
SHUT_WR initiates immediate and full protocol shutdown, whereas TCP
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 SCTP association while still leaving the socket descriptor open,
so that the caller can receive back any data SCTP was unable to
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 [SCTP] section 10.1, an
application can use the socket option SO_LINGER. It is described in application can use the socket option SO_LINGER. It is described in
section 7.1.6. 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: 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
skipping to change at page 13, line 32 skipping to change at page 14, line 57
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
assocication, or use SO_LINGER option with close() to abort an association, or use SO_LINGER option with close() to abort an
asssociation. 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 so. do so.
4.1.9 getsockname()
Applications use getsockname() to retrieve the locally-bound socket
address of the specified socket. The is especially useful if the
caller let SCTP chose a local port. This call is for TCP
compatibility, and is not multihomed. It does not work with
UDP-style sockets. See section 8.5 for a multihomed/UDP-sockets
version of the call.
The syntax is:
int getsockname(int socket, struct sockaddr *address,
socklen_t *len);
sd - the socket descriptor to be queried.
address - On return, one locally bound address (chosen by
the SCTP stack) is stored in this buffer. If the
socket is an IPv4 socket, the address will be IPv4.
If the socket is an IPv6 socket, the address will
be either an IPv6 or mapped IPv4 address.
len - The caller should set the length of address here.
On return, this is set to the length of the returned
address.
If the actual length of the address is greater than the length of
the supplied sockaddr structure, the stored address will be
truncated.
If the socket has not been bound to a local name, the value stored
in the object pointed to by address is unspecified.
4.1.10 getpeername()
Applications use getpeername() to retrieve the primary socket
address of the peer. This call is for TCP compatibility, and is not
multihomed.It does not work with UDP-style sockets. See section 8.3
for a multihomed/UDP-sockets version of the call.
The syntax is:
int getpeername(int socket, struct sockaddr *address,
socklen_t *len);
sd - the socket descriptor to be queried.
address - On return, the peer primary address is stored in
this buffer. If the socket is an IPv4 socket, the
address will be IPv4. If the socket is an IPv6 socket,
the address will be either an IPv6 or mapped IPv4
address.
len - The caller should set the length of address here.
On return, this is set to the length of the returned
address.
If the actual length of the address is greater than the length of
the supplied sockaddr structure, the stored address will be
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.
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]. Here we will cite their
skipping to change at page 14, line 51 skipping to change at page 17, line 28
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 preceeded by a struct cmsghdr (see Each ancillary data item is preceeded 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: initialization data, and, There are two kinds of ancillary data used by SCTP: initialization
header information (SNDRCV). Initialization data (UDP-style only) data, and, header information (SNDRCV). Initialization data
sets protocol parameters for new associations. Section 5.2.1 (UDP-style only) sets protocol parameters for new associations.
provides more details. Header information can set or report Section 5.2.1 provides more details. Header information can set or
parameters on individual messages in a stream. See section 5.2.2 report parameters on individual messages in a stream. See section
for how to use SNDRCV ancillary data. 5.2.2 for 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 information. on a UDP-style socket, SCTP will only pass SCTP_SNDRCV and
Specific ancillary data items can be enabled with socket options SCTP_ASSOC_CHANGE information. Specific ancillary data items can be
defined for SCTP; see section 7.3. Note in particular that for enabled with socket options defined for SCTP; see section 7.3.
UDP-style sockets, new associations will not be accepted by
default. See section 5.2.1 for more information.
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]) 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] and [RFC2553]) define a number of ancillary
skipping to change at page 16, line 52 skipping to change at page 19, line 26
IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
Here is the defintion of sctp_sndrcvinfo: Here is the defintion 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;
uint8_t sinfo_dscp;
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.
skipping to change at page 17, line 31 skipping to change at page 20, line 5
the same information that was passed by the upper layer in the peer the 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
unsent message (Note: if a endpoint has done multple sends, all of undelivered message (Note: if a endpoint has done multple sends, all
which fail, multiple different sinfo_context values will be of which fail, multiple different sinfo_context values will be
returned. One with each user data message). returned. One with each user data message).
sinfo_flags: 16 bits (unsigned integer) sinfo_flags: 16 bits (unsigned integer)
This field may contain any of the following flags and is composed of This field may contain any of the following flags and is composed of
a bitwise OR of these values. a bitwise OR of these values.
recvmsg() flags: recvmsg() flags:
MSG_UNORDERED - This flag is present when the message was sent MSG_UNORDERED - This flag is present when the message was sent
skipping to change at page 18, line 7 skipping to change at page 20, line 35
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).
MSG_EOF - Setting this flag invokes the SCTP graceful shutdown MSG_EOF - Setting this flag invokes the SCTP graceful shutdown
procedures which assure that all data enqueued by procedures on the specified association. Graceful
both endpoints are successfully transmitted before shutdown assures that all data enqueued by both
closing the association (UDP-style only). endpoints is successfully transmitted before closing
the association (UDP-style only).
sinfo_dscp: 8 bits (unsigned integer)
This field is available to change the DSCP value in the outbound IP
packet (hence it is used only from sendmsg()). The default value of
this field is 0. Note only 6 bits of this byte are used, the upper 2
bits are not part of the DS field. Any setting within these upper 2
bits is ignored.
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 COMMUNICATION_UP notification. for the association announced in the COMMUNICATION_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.
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.
skipping to change at page 19, line 57 skipping to change at page 22, line 26
message i.e. this structure message i.e. this structure
uses the sctp_sndrecvinfo per uses the sctp_sndrecvinfo per
section 5.3.1.4. 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 should be sent on this socket. data should be sent on this socket.
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 the new association has either begun or ended. The identifier for a new association is
resides in the sctp_notification structure in the cmsg_data provided by this notificaion. The notification information has the
ancillary data. The notification information has the following following format:
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;
sctp_assoc_t sac_assoc_id;
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;
}; };
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: sizeof (uint32_t) sac_length: sizeof (uint32_t)
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_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association.
All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored.
sac_state: 32 bits (signed integer) sac_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 that happened to the association. They include: event that happened to the association. They include:
Event Name Description Event Name Description
---------------- --------------- ---------------- ---------------
COMMUNICATION_UP A new association is now ready COMMUNICATION_UP A new association is now ready
and data may be exchanged with this and data may be exchanged with this
peer. peer.
skipping to change at page 21, line 21 skipping to change at page 23, line 37
sac_error: 32 bits (signed integer) sac_error: 32 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.
COMMUNICATION_LOST) any relevant error information is available in COMMUNICATION_LOST) any relevant error information is available in
this field. This corresponds to the protocol error codes defined in this field. This corresponds to the protocol error codes defined in
[SCTP]. [SCTP].
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 directtion are The maximum number of streams allowed in each direction are
available in sac_outbound_streams and sac_inbound streams. available in sac_outbound_streams and sac_inbound streams.
An application must enable this notification with setsockopt (see sac_assoc_id: sizeof (sctp_assoc_t)
section 7.3) before any new associations will be accepted on a
UDP-style socket. This is the mechanism by which a server (or peer The association id field, holds the identifier for the association.
application that wishes to accept new associations) instructs the All notifications for a given association have the same association
SCTP stack to accept new associations on a socket. Clients (i.e. identifier. For TCP style socket, this field is ignored.
applications on which only active opens are made) can leave this
ancillary data item off; they will then be assured that the only
associations on the socket will be ones they actively initiated.
Server or peer to peer sockets, on the other hand, will always
accept new associations, so a well-written application using server
UDP-style sockets must be prepared to handle new associations from
unwanted peers.
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;
sctp_assoc_t spc_assoc_id;
struct sockaddr_storage spc_aaddr; struct sockaddr_storage spc_aaddr;
int spc_state; int spc_state;
int spc_error; int spc_error;
sctp_assoc_t spc_assoc_id;
} }
spc_type: spc_type:
It should be SCTP_PEER_ADDR_CHANGE. It should be SCTP_PEER_ADDR_CHANGE.
spc_flags: 16 bits (unsigned integer) spc_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
spc_length: sizeof (uint32_t) spc_length: sizeof (uint32_t)
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_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association.
All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored.
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 that happened to the address. They include: event that happened to the address. They include:
skipping to change at page 22, line 52 skipping to change at page 24, line 55
ADDRESS_MADE_PRIM This address has now been made ADDRESS_MADE_PRIM This address has now been made
to be the primary destination address. to be the primary destination address.
spc_error: 32 bits (signed integer) spc_error: 32 bits (signed integer)
If the state was reached due to any error condition (e.g. If the state was reached due to any error condition (e.g.
ADDRESS_UNREACHABLE) any relevant error information is available in ADDRESS_UNREACHABLE) any relevant error information is available in
this field. this field.
spc_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association.
All notifications for a given association have the same association
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 TLV 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 [SCTP] and any extensions for a list of possible
error formats. SCTP error TLVs have the format: error formats. SCTP error TLVs 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;
sctp_assoc_t sre_assoc_id;
uint16_t sre_error; uint16_t sre_error;
uint16_t sre_len; uint16_t sre_len;
sctp_assoc_t sre_assoc_id;
uint8_t sre_data[0]; uint8_t sre_data[0];
}; };
sre_type: sre_type:
It should be SCTP_REMOTE_ERROR. It should be SCTP_REMOTE_ERROR.
sre_flags: 16 bits (unsigned integer) sre_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sre_length: sizeof (uint32_t) sre_length: sizeof (uint32_t)
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.
sre_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association.
All notifications for a given association have the same association
identifier. For TCP style socket, this field is ignored.
sre_error: 16 bits (unsigned integer) sre_error: 16 bits (unsigned integer)
This value represents one of the Operational Error causes defined in This value represents one of the Operational Error causes defined in
the SCTP specification, in network byte order. the SCTP specification, in network byte order.
sre_len: 16 bits (unsigned integer) sre_len: 16 bits (unsigned integer)
This value represents the length of the operational error payload in This value represents the length of the operational error payload in
plus the size of sre_error and sre_len in network byte order. plus the size of sre_error and sre_len in network byte order.
sre_assoc_id: sizeof (sctp_assoc_t)
The association id field, holds the identifier for the association.
All notifications for a given association have the same association
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 payload of the operational error as defined in the
SCTP specification [SCTP] section 3.3.10. SCTP specification [SCTP] 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;
sctp_assoc_t ssf_assoc_id;
uint32_t ssf_error; uint32_t ssf_error;
struct sctp_sndrcvinfo ssf_info; struct sctp_sndrcvinfo ssf_info;
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) 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_INQUEUE - When this flag is indicated the SCTP_DATA_UNSENT - Indicates that the data was never put on
data was never attempted to be the wire.
sent. I.e. it was never assigned
a TSN and sent onto the wire.
SCTP_DATA_INTMIT - When this flag is indicated the SCTP_DATA_SENT - Indicates that the data was put on the wire.
data WAS assigned a TSN and sent Note that this does not necessarily mean that the
at least once but never acknowleded. data was (or was not) successfully delivered.
ssf_length: sizeof (uint32_t) ssf_length: sizeof (uint32_t)
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.
ssf_error: 16 bits (unsigned integer)
This value represents the reason why the send failed, and if set,
will be a SCTP protocol error code as defined in [SCTP] section
3.3.10.
ssf_info: sizeof (struct sctp_sndrcvinfo)
The original send information associated with the undelivered
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 association identifier. For TCP style socket, this field is same association identifier. For TCP style socket, this field is
ignored. ignored.
ssf_error: 16 bits (unsigned integer) ssf_data: variable length
This value represents the reason why the send fails.
ssf_info: sizeof (struct sctp_sndrcvinfo)
The original send information associated with the unsent message.
ssf_data: variable
The unsent message. The undelivered message, exactly as delivered by the caller to the
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.
struct sctp_shutdown_event { struct sctp_shutdown_event {
uint16_t sse_type; uint16_t sse_type;
uint16_t sse_flags; uint16_t sse_flags;
uint32_t sse_length; uint32_t sse_length;
sctp_assoc_t sse_assoc_id; sctp_assoc_t sse_assoc_id;
}; };
sse_type sse_type
It should be SCTP_SEND_FAILED. It should be SCTP_SHUTDOWN_EVENT
sse_flags: 16 bits (unsigned integer) sse_flags: 16 bits (unsigned integer)
Currently unused. Currently unused.
sse_length: sizeof (uint32_t) sse_length: sizeof (uint32_t)
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.
skipping to change at page 28, line 5 skipping to change at page 30, line 16
streams. This may result in data seeming to arrive out of streams. This may result in data seeming to arrive out of
order. Similarly, if a data chunk is sent unordered, recv() and order. Similarly, if a data chunk is sent unordered, recv() and
recvfrom() provide no indication. recvfrom() 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
boundries. 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 messaage, 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 "peeled off" or high bandwidth socket descriptors only be used with branched off socket descriptors (see Section 8.2).
(see Section 8.2).
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,
skipping to change at page 28, line 42 skipping to change at page 30, line 52
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 with high bandwidth socket descriptors (see Section 8.2). used with branched off socket descriptors (see Section 8.2).
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 that are common to both models. SCTP associations can be options that are common to both models. SCTP associations can be
multihomed. Therefore, certain option parameters include a multihomed. 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 datagram model, an sctp_assoc_t structure (association ID) For the UDP-style sockets, an sctp_assoc_t structure (association
is used to identify the the association instance that the operation ID) is used to identify the the association instance that the
affects. So it must be set when using this model. operation affects. So it must be set when using this model.
For the connnection oriented model and high bandwidth datagram
sockets (see section 8.2) this association ID parameter is ignored.
In the cases noted below where the parameter is ignored, an For the TCP-style sockets and branched off UDP-style sockets (see
application can pass to the system a corresponding option structure section 8.2) this association ID parameter is ignored. In the cases
similar to those described below but without the association ID noted below where the parameter is ignored, an application can pass
parameter, which should be the last field of the option structure. to the system a corresponding option structure similar to those
This can make the option setting/getting operation more efficient. described below but without the association ID parameter, which
If an application does this, it should also specify an appropriate should be the last field of the option structure. This can make the
optlen value (i.e. sizeof (option parameter) - sizeof (struct option setting/getting operation more efficient. If an application
sctp_assoc_t)). does this, it should also specify an appropriate optlen value
(i.e. 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 datagram model, those options will be applied to This means that for UDP-style sockets, those options will be applied
all associations belonging to the socket. And for TCP-style model, to all associations belonging to the socket. And for TCP-style
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.
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 [SCTP] for more information on how
these parameters are used in RTO calculation. The peer address these parameters are used in RTO calculation. The peer address
skipping to change at page 30, line 20 skipping to change at page 32, line 30
uint16_t sasoc_asocmaxrxt; uint16_t sasoc_asocmaxrxt;
sctp_assoc_t sasoc_assoc_id; sctp_assoc_t sasoc_assoc_id;
}; };
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_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.
To access or modify these parameters, the application should call To access or modify these parameters, the application should call
gesockopt 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 unreachable is also tunable, but is address-specific, so considered unreachable is also tunable, but is address-specific, so
it is covered in a seperate option. If an application attempts to it is covered in a seperate option. If an application attempts to
set the value of the association maximum retransmission parameter to set the value of the association maximum retransmission parameter to
more than the sum of all maximum retransmission parameters, more than the sum of all maximum retransmission parameters,
setsockopt() shall return an error. The reason for this, from setsockopt() shall return an error. The reason for this, from
[SCTP] section 8.2: [SCTP] section 8.2:
skipping to change at page 30, line 46 skipping to change at page 32, line 56
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 intialization. The structure used to access and modify association intialization. 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 socket (for the datagram model only future associations unconnected socket (for UDP-style sockets only future associations
are effected by the change). This option is inherited by sockets are effected by the change). With TCP-style sockets, this option is
derived from a listener socket. inherited by 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 */
}; };
skipping to change at page 31, line 29 skipping to change at page 33, line 38
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 seperately. Expects an applies to each association's window size seperately. Expects an
integer boolean flag. 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. This option therefore bounds the maximum size of data that can sent. This option therefore bounds the maximum size of data that can
be sent in a single send call. For UDP-style sockets, the effect is be sent in a single send call. For UDP-style sockets, the effect is
the same, except that it applies to all associations bound to the the same, except that it applies to all associations bound to the
socket descriptor used in the setsockopt() or getsockopt() call. The socket descriptor used in the setsockopt() or getsockopt() call. The
option applies to each association's window size seperately. Expects option applies to each association's window size seperately. Expects
an integer boolean flag. an 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 recieved 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 integer defining the number of seconds of idle time before an integer defining the number of seconds of idle time before
an associatin is closed. an association is closed.
7.1.9 Set Primary Address (SCTP_SET_PRIMARY_ADDR)
Requests that the peer mark the enclosed address as the association
primary. The enclosed address must be one of the association's
locally bound addresses. The following structure is used to make a
set primary request:
struct sctp_setprim {
struct sockaddr_storage ssp_addr;
sctp_assoc_t ssp_assoc_id;
};
ssp_addr The address to set as primary
ssp_assoc_id (UDP style socket) This is filled in by the
application, and identifies the association
for this request.
This functionality is optional. Implementations that do not support
this functionality should return EOPNOTSUPP.
7.1.10 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
Requests that the local SCTP stack use the enclosed peer address as
the association primary. The enclosed address must be one of the
association peer's addresses. The following structure is used to
make a set peer primary request:
struct sctp_setpeerprim {
struct sockaddr_storage sspp_addr;
sctp_assoc_t sspp_assoc_id;
};
sspp_addr The address to set as primary
sspp_assoc_id (UDP style socket) This is filled in by the
application, and identifies the association
for this request.
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 32, line 46 skipping to change at page 35, line 38
sstat_primary - This is information on the current primary peer sstat_primary - This is information on the current primary peer
address. address.
sstat_assoc_id - (UDP style socket) This holds the an identifier for the sstat_assoc_id - (UDP style socket) This holds the an identifier for the
association. All notifications for a given association association. All notifications for a given association
have the same association identifier. have the same association identifier.
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.3. Ancillary Data Interest Options 7.3. Ancillary Data and Notification Interest Options
Applications can receive notifications of certain SCTP events and Applications can receive per-message ancillary information and
per-message information as ancillary data 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_RECVDATAIOEVNT: Per-message information (i.e. stream number, 1. SCTP_RECVDATAIOEVNT: Per-message information (i.e. stream number,
TSN, SSN, etc. described in section 5.2.2) TSN, SSN, etc. described in section 5.2.2)
2. SCTP_RECVASSOCEVNT: (described in section 5.3.1.1) 2. SCTP_RECVASSOCEVNT: (described in section 5.3.1.1)
3. SCTP_RECVPADDREVNT: (described in section 5.3.1.2) 3. SCTP_RECVPADDREVNT: (described in section 5.3.1.2)
4. SCTP_RECVPEERERR: (described in section 5.3.1.3) 4. SCTP_RECVPEERERR: (described in section 5.3.1.3)
5. SCTP_RECVSENDFAILEVNT: (described in section 5.3.1.4) 5. SCTP_RECVSENDFAILEVNT: (described in section 5.3.1.4)
6. SCTP_RECVSHUTDOWNEVNT: (described in section 5.3.1.5); 6. SCTP_RECVSHUTDOWNEVNT: (described in section 5.3.1.5);
To receive any ancillary data, first the application registers it's To receive any ancillary data or notifications, first the
interest by calling setsockopt() to turn on the corresponding flag: application registers it's interest by calling setsockopt() to turn
on the corresponding flag:
int on = 1; int on = 1;
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT, &on, sizeof(on)); setsockopt(fd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT, &on, sizeof(on));
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVASSOCEVNT, &on, sizeof(on));
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPADDREVNT, &on, sizeof(on)); setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPADDREVNT, &on, sizeof(on));
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, &on, sizeof(on)); setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, &on, sizeof(on));
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPEERERR, &on, sizeof(on)); setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPEERERR, &on, sizeof(on));
setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT, &on, sizeof(on)); setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT, &on, sizeof(on));
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 for ALL associations bound to the file receives ancillary data and notifications for ALL associations bound
descriptor. For TCP-style SCTP sockets, the caller receives to the file descriptor. For TCP-style SCTP sockets, the caller
ancillary data for only the single association bound to the file receives ancillary data and notifications for only the single
descriptor. association bound to the file descriptor.
By default a TCP-style socket has all options off. By default a TCP-style socket has all options off.
By default a UDP-style socket has SCTP_REVCVDATAIOEVENT on and all By default a UDP-style socket has SCTP_RECVDATAIOEVNT and
other options off. SCTP_RECVASSOCEVNT on and all other options off.
The format of the data structures for each ancillary data item is
given in section 5.2.
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 funtion. as a system call or library funtion.
8.1 sctp_bindx() 8.1 sctp_bindx()
The syntax of sctp_bindx() is, The syntax of sctp_bindx() is,
skipping to change at page 34, line 15 skipping to change at page 37, line 6
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_BIND_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_BIND_REM_ADDR directs SCTP to remove the given association, and SCTP_BINDX_REM_ADDR directs SCTP to remove the
addresses from the association. The two flags are mutually given 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() will reject such an attempt with EINVAL. sctp_bindx() will reject such an attempt with EINVAL.
An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate
additional addresses with an endpoint after calling bind(). Or use additional addresses with an endpoint after calling bind(). Or 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 associated with those addresses. be associated with those addresses.
skipping to change at page 35, line 49 skipping to change at page 38, line 39
an error occurs, sctp_getpaddrs() returns -1, and the value of an error occurs, sctp_getpaddrs() returns -1, and the value of
*addrs is undefined. *addrs 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_opt_info() 8.5 sctp_getladdrs()
sctp_getladdrs() returns all locally bound address on a socket. The
syntax is,
int sctp_getladdrs(int sock, sctp_assoc_t id,
struct sockaddr_storage **ss);
On return, addrs will point to a dynamically allocated array of
struct sockaddr_storages, one for each local address. The caller
should use sctp_freeladdrs() to free the memory. addrs must not be
NULL.
If sd is an IPv4 socket, the addresses returned will be all IPv4
addresses. If sd is an IPv6 socket, the addresses returned can be a
mix of IPv4 or IPv6 addresses.
For UDP-style sockets, id specifies the association to query. For
TCP-style sockets, id is ignored.
On success, sctp_getladdrs() returns the number of local addresses
bound to the socket. If the socket is unbound, sctp_getladdrs()
returns 0, and the value of *addrs is undefined. If an error occurs,
sctp_getladdrs() returns -1, and the value of *addrs is undefined.
8.6 sctp_freeladdrs()
sctp_freeladdrs() frees all resources allocated by
sctp_getladdrs(). Its syntax is,
void sctp_freeladdrs(struct sockaddr_storage *addrs);
addrs is the array of peer addresses returned by sctp_getladdrs().
8.7 sctp_opt_info()
getsockopt() is read-only, so a new interface is required when getsockopt() is read-only, so a new interface is required when
information must be passed both in to and out of the SCTP stack. The information must be passed both in to and out of the SCTP stack. The
syntax for scpt_opt_info() is, syntax for scpt_opt_info() is,
int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg); int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg);
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 option to get or set. It can be one of the opt specifies which SCTP option to get or set. It can be one of the
following: following:
SCTP_SET_PRIMARY_ADDRS
SCTP_SET_PEER_PRIMARY_ADDRS
SCTP_SET_PEER_ADDR_PARAMS SCTP_SET_PEER_ADDR_PARAMS
SCTP_GET_PEER_ADDR_PARAMS SCTP_GET_PEER_ADDR_PARAMS
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 8.5 subsections for more information on these options and
option-specific structures. option-specific structures.
sctp_opt_info() returns 0 on success, or on failure returns -1 and sctp_opt_info() returns 0 on success, or on failure returns -1 and
sets errno to the appropriate error code. sets errno to the appropriate error code.
8.5.1 Peer Address Parameters 8.7.1 Peer Address Parameters
Applications can enable or disable heartbeats for any peer address Applications can enable or disable heartbeats for any peer address
of an association, modify an address's heartbeat interval, force a of 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. An application may also set what it deems as the unreachable. The following structure is used to access and modify an
primary address as well as communicate to the remote peer what address's parameters:
address the local application would like the remote peer to use
as its primary address (when sending to the local endpoint).
The following structure is used to access and modify an address's
parameters:
struct sctp_paddrparams { struct sctp_paddrparams {
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;
sctp_assoc_t spp_assoc_id; sctp_assoc_t spp_assoc_id;
}; };
spp_address - This specifies which address is of interest. spp_address - This specifies which address is of interest.
spp_hbinterval - This contains the value of the heartbeat interval, spp_hbinterval - This contains the value of the heartbeat interval,
skipping to change at page 37, line 10 skipping to change at page 40, line 29
retransmissions before this address shall be retransmissions before this address shall be
considered unreachable. considered unreachable.
spp_assoc_id - (UDP style socket) This is filled in the application, spp_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 modify these parameters, the application should call To modify these parameters, the application should call
sctp_opt_info() with the SCTP_SET_PEER_ADDR_PARAMS option. To get sctp_opt_info() with the SCTP_SET_PEER_ADDR_PARAMS option. To get
these parameters, the application should use these parameters, the application should use
SCTP_GET_PEER_ADDR_PARAMS. SCTP_GET_PEER_ADDR_PARAMS.
8.5.2 Peer Address Information 8.7.2 Peer Address Information
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-only. The following structure is used to access this read-only. The following structure is used to access this
information: information:
struct sctp_paddrinfo { struct sctp_paddrinfo {
struct sockaddr_storage spinfo_address; struct sockaddr_storage spinfo_address;
int32_t spinfo_state; int32_t spinfo_state;
skipping to change at page 38, line 7 skipping to change at page 41, line 25
the SCTP implementation SHOULD restrict the ability to call bind() the SCTP implementation SHOULD restrict the ability to call bind()
or sctp_bindx() on these port numbers to privileged users. or sctp_bindx() on these port numbers to privileged users.
Similarly unprivelged users should not be able to set protocol Similarly unprivelged 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 agressive than permitted on the public Internet. These being more agressive than permitted on the public Internet. These
paramaters are: paramaters are:
struct sctp_rtoinfo struct sctp_rtoinfo
If an unprivileged user inherits a datagram model 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. Authors' Addresses 10. Acknowledgements
The authors wish to thank Mike Bartlett, Jon Berger, Renee Ravis,
and many others on the TSVWG mailing list for contributing valuable
comments.
11. Authors' Addresses
Randall R. Stewart Tel: +1-815-477-2127 Randall R. Stewart Tel: +1-815-477-2127
Cisco Systems, Inc. EMail: rrs@cisco.com Cisco Systems, Inc. EMail: rrs@cisco.com
Crystal Lake, IL 60012 Crystal Lake, IL 60012
USA USA
Qiaobing Xie Tel: +1-847-632-3028 Qiaobing Xie Tel: +1-847-632-3028
Motorola, Inc. EMail: qxie1@email.mot.com Motorola, Inc. EMail: qxie1@email.mot.com
1501 W. Shure Drive, Room 2309 1501 W. Shure Drive, Room 2309
Arlington Heights, IL 60004 Arlington Heights, IL 60004
skipping to change at page 38, line 50 skipping to change at page 42, line 21
901 San Antonio Road 901 San Antonio Road
Palo Alto, CA 94303 Palo Alto, CA 94303
USA USA
Ken Fujita Tel: +81-471-82-1131 Ken Fujita Tel: +81-471-82-1131
NEC Corporation Email: fken@cd.jp.nec.com NEC Corporation Email: fken@cd.jp.nec.com
1131, Hinode, Abiko 1131, Hinode, Abiko
Chiba, 270-1198 Chiba, 270-1198
Japan Japan
11. References 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 [RFC1644] Braden, R., "T/TCP -- TCP Extensions for Transactions
Functional Specification," RFC 1644, July 1994. Functional Specification," RFC 1644, July 1994.
[RFC2026] Bradner, S., "The Internet Standards Process -- Revision 3", [RFC2026] Bradner, S., "The Internet Standards Process -- Revision 3",
RFC 2026, October 1996. RFC 2026, October 1996.
[RFC2292] W.R. Stevens, M. Thomas, "Advanced Sockets API for IPv6", [RFC2292] W.R. Stevens, M. Thomas, "Advanced Sockets API for IPv6",
RFC 2292, February 1998. RFC 2292, February 1998.
skipping to change at page 43, line 32 skipping to change at page 47, line 10
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVASSOCEVNT"); perror("setsockopt SCTP_RECVASSOCEVNT");
exit(1); exit(1);
} }
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPADDREVNT, if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPADDREVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPADDREVNT"); perror("setsockopt SCTP_RECVPADDREVNT");
exit(1); exit(1);
} }
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVDATAIOEVNT");
exit(1);
}
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPEERERR, if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVPEERERR,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPEERERR"); perror("setsockopt SCTP_RECVPEERERR");
exit(1); exit(1);
} }
if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT, if (setsockopt(cfd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVSHUTDOWNEVNT"); perror("setsockopt SCTP_RECVSHUTDOWNEVNT");
exit(1); exit(1);
} }
skipping to change at page 44, line 35 skipping to change at page 48, line 10
} }
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);
} }
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT,
&onoff, 4) < 0) {
perror("setsockopt RECVDATAIOEVNT");
exit(1);
}
/* Enable notifications */ /* Enable notifications */
/* This will get us new associations as well */ /* SCTP_RECVASSOCEVNT and SCTP_RECVDATAIOEVNT are on by default */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVASSOCEVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVASSOCEVNT");
exit(1);
}
/* if a send fails we want to know it */ /* if a send fails we want to know it */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT, if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSENDFAILEVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVASSOCEVNT"); perror("setsockopt SCTP_RECVASSOCEVNT");
exit(1); exit(1);
} }
/* if a network address change or event transpires /* if a network address change or event transpires
* we wish to know it * we wish to know it
*/ */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPADDREVNT, if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPADDREVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPADDREVNT"); perror("setsockopt SCTP_RECVPADDREVNT");
exit(1); exit(1);
} }
/* We would like all io events */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVDATAIOEVNT,
&onoff, 4) < 0) {
perror("setsockopt SCTP_RECVDATAIOEVNT");
exit(1);
}
/* We would like all error TLV's from the peer */ /* We would like all error TLV's from the peer */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPEERERR, if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVPEERERR,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVPEERERR"); perror("setsockopt SCTP_RECVPEERERR");
exit(1); exit(1);
} }
/* And of course we would like to know about shutdown's */ /* And of course we would like to know about shutdown's */
if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT, if (setsockopt(fd, IPPROTO_SCTP, SCTP_RECVSHUTDOWNEVNT,
&onoff, 4) < 0) { &onoff, 4) < 0) {
perror("setsockopt SCTP_RECVSHUTDOWNEVNT"); 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);
} }
/* Allow new associations to be accepted */
if (listen(fd, 0) < 0) {
perror("listen");
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);
} }
} }
 End of changes. 

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