2007-02-22 14:32:39 +00:00
|
|
|
.\" Copyright (c) 1983, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2013-05-28 20:37:48 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
2007-02-22 14:32:39 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
|
|
|
.Dd December 15, 2006
|
|
|
|
.Dt SCTP_SENDMSG 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2007-06-18 10:20:32 +00:00
|
|
|
.Nm sctp_sendmsg ,
|
2007-02-22 14:32:39 +00:00
|
|
|
.Nm sctp_sendmsgx
|
|
|
|
.Nd send a message from an SCTP socket
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In sys/types.h
|
|
|
|
.In sys/socket.h
|
2007-02-26 12:23:32 +00:00
|
|
|
.In netinet/sctp.h
|
2007-02-22 14:32:39 +00:00
|
|
|
.Ft ssize_t
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fo sctp_sendmsg
|
|
|
|
.Fa "int s" "const void *msg" "size_t len" "const struct sockaddr *to"
|
|
|
|
.Fa "socklen_t tolen" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no"
|
|
|
|
.Fa "uint32_t timetolive" "uint32_t context"
|
|
|
|
.Fc
|
2007-02-22 14:32:39 +00:00
|
|
|
.Ft ssize_t
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fo sctp_sendmsgx
|
|
|
|
.Fa "int s" "const void *msg" "size_t len" "const struct sockaddr *to"
|
|
|
|
.Fa "int addrcnt" "uint32_t ppid" "uint32_t flags" "uint16_t stream_no"
|
|
|
|
.Fa "uint32_t timetolive" "uint32_t context"
|
|
|
|
.Fc
|
2007-02-22 14:32:39 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn sctp_sendmsg
|
2007-06-18 10:20:32 +00:00
|
|
|
system call
|
2007-02-22 14:32:39 +00:00
|
|
|
is used to transmit a message to another SCTP endpoint.
|
|
|
|
The
|
|
|
|
.Fn sctp_sendmsg
|
2007-06-18 10:20:32 +00:00
|
|
|
may be used at any time.
|
|
|
|
If the socket is a one-to-many type (SOCK_SEQPACKET)
|
2007-02-22 14:32:39 +00:00
|
|
|
socket then an attempt to send to an address that no association exists to will
|
2007-06-18 10:20:32 +00:00
|
|
|
implicitly create a new association.
|
|
|
|
Data sent in such an instance will result in
|
|
|
|
the data being sent on the third leg of the SCTP four-way handshake.
|
|
|
|
Note that if
|
2007-02-22 14:32:39 +00:00
|
|
|
the socket is a one-to-one type (SOCK_STREAM) socket then an association must
|
2012-03-29 05:02:12 +00:00
|
|
|
be in existence (by use of the
|
2007-06-18 10:20:32 +00:00
|
|
|
.Xr connect 2
|
|
|
|
system call).
|
2012-03-29 05:02:12 +00:00
|
|
|
Calling
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fn sctp_sendmsg
|
|
|
|
or
|
|
|
|
.Fn sctp_sendmsgx
|
2007-06-18 10:20:32 +00:00
|
|
|
on a non-connected one-to-one socket will result in
|
|
|
|
.Va errno
|
|
|
|
being set to
|
|
|
|
.Er ENOTCONN ,
|
|
|
|
-1 being returned, and the message not being transmitted.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
|
|
|
The address of the target is given by
|
|
|
|
.Fa to
|
|
|
|
with
|
|
|
|
.Fa tolen
|
|
|
|
specifying its size.
|
2012-03-29 05:02:12 +00:00
|
|
|
The length of the message
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa msg
|
|
|
|
is given by
|
|
|
|
.Fa len .
|
|
|
|
If the message is too long to pass atomically through the
|
2007-06-18 10:20:32 +00:00
|
|
|
underlying protocol,
|
|
|
|
.Va errno
|
2012-03-29 05:02:12 +00:00
|
|
|
is set to
|
2007-06-18 10:20:32 +00:00
|
|
|
.Er EMSGSIZE ,
|
|
|
|
-1 is returned, and
|
2007-02-22 14:32:39 +00:00
|
|
|
the message is not transmitted.
|
|
|
|
.Pp
|
|
|
|
No indication of failure to deliver is implicit in a
|
2009-11-28 11:27:37 +00:00
|
|
|
.Xr sctp_sendmsg 3
|
2007-06-18 10:20:32 +00:00
|
|
|
call.
|
2007-02-22 14:32:39 +00:00
|
|
|
Locally detected errors are indicated by a return value of -1.
|
|
|
|
.Pp
|
2007-06-18 10:20:32 +00:00
|
|
|
If no space is available at the socket to hold
|
2007-02-22 14:32:39 +00:00
|
|
|
the message to be transmitted, then
|
2009-11-28 11:27:37 +00:00
|
|
|
.Xr sctp_sendmsg 3
|
2007-02-22 14:32:39 +00:00
|
|
|
normally blocks, unless the socket has been placed in
|
|
|
|
non-blocking I/O mode.
|
|
|
|
The
|
2007-06-18 10:20:32 +00:00
|
|
|
.Xr select 2
|
2007-02-22 14:32:39 +00:00
|
|
|
system call may be used to determine when it is possible to
|
|
|
|
send more data on one-to-one type (SOCK_STREAM) sockets.
|
|
|
|
.Pp
|
2012-03-29 05:02:12 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa ppid
|
|
|
|
argument is an opaque 32 bit value that is passed transparently
|
2007-06-18 10:20:32 +00:00
|
|
|
through the stack to the peer endpoint.
|
|
|
|
It will be available on
|
2007-02-22 14:32:39 +00:00
|
|
|
reception of a message (see
|
2009-11-28 11:27:37 +00:00
|
|
|
.Xr sctp_recvmsg 3 ) .
|
2007-06-18 10:20:32 +00:00
|
|
|
Note that the stack passes this value without regard to byte
|
2007-02-22 14:32:39 +00:00
|
|
|
order.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa flags
|
|
|
|
argument may include one or more of the following:
|
|
|
|
.Bd -literal
|
|
|
|
#define SCTP_EOF 0x0100 /* Start a shutdown procedures */
|
|
|
|
#define SCTP_ABORT 0x0200 /* Send an ABORT to peer */
|
|
|
|
#define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
|
|
|
|
#define SCTP_ADDR_OVER 0x0800 /* Override the primary-address */
|
|
|
|
#define SCTP_SENDALL 0x1000 /* Send this on all associations */
|
|
|
|
/* for the endpoint */
|
|
|
|
/* The lower byte is an enumeration of PR-SCTP policies */
|
|
|
|
#define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
|
|
|
|
#define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
|
|
|
|
#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2012-03-29 05:02:12 +00:00
|
|
|
The flag
|
2007-02-22 14:32:39 +00:00
|
|
|
.Dv SCTP_EOF
|
|
|
|
is used to instruct the SCTP stack to queue this message
|
2007-06-18 10:20:32 +00:00
|
|
|
and then start a graceful shutdown of the association.
|
|
|
|
All
|
2007-02-22 14:32:39 +00:00
|
|
|
remaining data in queue will be sent after which the association
|
2007-06-18 10:20:32 +00:00
|
|
|
will be shut down.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
|
|
|
.Dv SCTP_ABORT
|
2007-06-18 10:20:32 +00:00
|
|
|
is used to immediately terminate an association.
|
|
|
|
An abort
|
2007-02-22 14:32:39 +00:00
|
|
|
is sent to the peer and the local TCB is destroyed.
|
|
|
|
.Pp
|
|
|
|
.Dv SCTP_UNORDERED
|
|
|
|
is used to specify that the message being sent has no
|
|
|
|
specific order and should be delivered to the peer application
|
2007-06-18 10:20:32 +00:00
|
|
|
as soon as possible.
|
|
|
|
When this flag is absent messages
|
2007-02-22 14:32:39 +00:00
|
|
|
are delivered in order within the stream they are sent, but without
|
|
|
|
respect to order to peer streams.
|
|
|
|
.Pp
|
|
|
|
The flag
|
|
|
|
.Dv SCTP_ADDR_OVER
|
2007-06-18 10:20:32 +00:00
|
|
|
is used to specify that an specific address should be used.
|
|
|
|
Normally
|
|
|
|
SCTP will use only one of a multi-homed peers addresses as the primary
|
|
|
|
address to send to.
|
2012-03-29 05:02:12 +00:00
|
|
|
By default, no matter what the
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa to
|
2007-06-18 10:20:32 +00:00
|
|
|
argument is, this primary address is used to send data.
|
|
|
|
By specifying
|
2007-02-22 14:32:39 +00:00
|
|
|
this flag, the user is asking the stack to ignore the primary address
|
2007-06-18 10:20:32 +00:00
|
|
|
and instead use the specified address not only as a lookup mechanism
|
|
|
|
to find the association but also as the actual address to send to.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
|
|
|
For a one-to-many type (SOCK_SEQPACKET) socket the flag
|
|
|
|
.Dv SCTP_SENDALL
|
2010-08-16 15:18:30 +00:00
|
|
|
can be used as a convenient way to make one send call and have
|
2007-02-22 14:32:39 +00:00
|
|
|
all associations that are under the socket get a copy of the message.
|
2010-08-02 16:01:45 +00:00
|
|
|
Note that this mechanism is quite efficient and makes only one actual
|
2007-02-22 14:32:39 +00:00
|
|
|
copy of the data which is shared by all the associations for sending.
|
|
|
|
.Pp
|
2007-09-25 16:48:08 +00:00
|
|
|
The remaining flags are used for the partial reliability extension (RFC3758)
|
2007-02-22 14:32:39 +00:00
|
|
|
and will only be effective if the peer endpoint supports this extension.
|
2007-09-25 16:48:08 +00:00
|
|
|
This option specifies what local policy the local endpoint should use
|
2007-06-18 10:20:32 +00:00
|
|
|
in skipping data.
|
|
|
|
If none of these options are set, then data is
|
2007-02-22 14:32:39 +00:00
|
|
|
never skipped over.
|
|
|
|
.Pp
|
|
|
|
.Dv SCTP_PR_SCTP_TTL
|
2007-09-25 16:48:08 +00:00
|
|
|
is used to indicate that a time based lifetime is being applied
|
2007-06-18 10:20:32 +00:00
|
|
|
to the data.
|
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa timetolive
|
|
|
|
argument is then a number of milliseconds for which the data is
|
2007-06-18 10:20:32 +00:00
|
|
|
attempted to be transmitted.
|
2010-08-16 15:18:30 +00:00
|
|
|
If that many milliseconds elapse
|
2007-06-18 10:20:32 +00:00
|
|
|
and the peer has not acknowledged the data, the data will be
|
|
|
|
skipped and no longer transmitted.
|
|
|
|
Note that this policy does
|
2010-09-11 10:49:56 +00:00
|
|
|
not even assure that the data will ever be sent.
|
2007-06-18 10:20:32 +00:00
|
|
|
In times of a congestion
|
2012-03-29 05:02:12 +00:00
|
|
|
with large amounts of data being queued, the
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa timetolive
|
|
|
|
may expire before the first transmission is ever made.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv SCTP_PR_SCTP_BUF
|
|
|
|
based policy transforms the
|
2012-03-29 05:02:12 +00:00
|
|
|
.Fa timetolive
|
2007-02-22 14:32:39 +00:00
|
|
|
field into a total number of bytes allowed on the outbound
|
2007-06-18 10:20:32 +00:00
|
|
|
send queue.
|
|
|
|
If that number or more bytes are in queue, then
|
2007-02-22 14:32:39 +00:00
|
|
|
other buffer based sends are looked to be removed and
|
2007-06-18 10:20:32 +00:00
|
|
|
skipped.
|
|
|
|
Note that this policy may also result in the data
|
2007-02-22 14:32:39 +00:00
|
|
|
never being sent if no buffer based sends are in queue and
|
2012-03-29 05:02:12 +00:00
|
|
|
the maximum specified by
|
|
|
|
.Fa timetolive
|
2007-02-22 14:32:39 +00:00
|
|
|
bytes is in queue.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv SCTP_PR_SCTP_RTX
|
|
|
|
policy transforms the
|
2012-03-29 05:02:12 +00:00
|
|
|
.Fa timetolive
|
2007-06-18 10:20:32 +00:00
|
|
|
into a number of retransmissions to allow.
|
|
|
|
This policy
|
2010-09-11 10:49:56 +00:00
|
|
|
always assures that at a minimum one send attempt is
|
2007-06-18 10:20:32 +00:00
|
|
|
made of the data.
|
2012-03-29 05:02:12 +00:00
|
|
|
After which no more than
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa timetolive
|
|
|
|
retransmissions will be made before the data is skipped.
|
|
|
|
.Pp
|
|
|
|
.Fa stream_no
|
|
|
|
is the SCTP stream that you wish to send the
|
2007-06-18 10:20:32 +00:00
|
|
|
message on.
|
|
|
|
Streams in SCTP are reliable (or partially reliable) flows of ordered
|
|
|
|
messages.
|
2012-03-29 05:02:12 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa context
|
2007-06-18 10:20:32 +00:00
|
|
|
field is used only in the event the message cannot be sent.
|
|
|
|
This is an opaque
|
2007-02-22 14:32:39 +00:00
|
|
|
value that the stack retains and will give to the user when a failed send
|
|
|
|
is given if that notification is enabled (see
|
2007-09-25 16:48:08 +00:00
|
|
|
.Xr sctp 4 ) .
|
2007-06-18 10:20:32 +00:00
|
|
|
Normally a user process can use this value to index some application
|
2007-02-22 14:32:39 +00:00
|
|
|
specific data structure when a send cannot be fulfilled.
|
|
|
|
.Fn sctp_sendmsgx
|
2012-03-29 05:02:12 +00:00
|
|
|
is identical to
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fn sctp_sendmsg
|
2007-09-25 16:48:08 +00:00
|
|
|
with the exception that it takes an array of sockaddr structures in the
|
2007-02-22 14:32:39 +00:00
|
|
|
argument
|
|
|
|
.Fa to
|
|
|
|
and adds the additional argument
|
|
|
|
.Fa addrcnt
|
2007-06-18 10:20:32 +00:00
|
|
|
which specifies how many addresses are in the array.
|
|
|
|
This allows a
|
2007-09-25 16:48:08 +00:00
|
|
|
caller to implicitly set up an association passing multiple addresses
|
|
|
|
as if
|
2012-03-29 05:02:12 +00:00
|
|
|
.Fn sctp_connectx
|
2007-09-25 16:48:08 +00:00
|
|
|
had been called to set up the association.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The call returns the number of characters sent, or -1
|
|
|
|
if an error occurred.
|
|
|
|
.Sh ERRORS
|
|
|
|
The
|
2007-09-25 16:48:08 +00:00
|
|
|
.Fn sctp_sendmsg
|
2007-02-22 14:32:39 +00:00
|
|
|
system call
|
2010-01-12 21:45:03 +00:00
|
|
|
fails if:
|
2007-02-22 14:32:39 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EBADF
|
|
|
|
An invalid descriptor was specified.
|
|
|
|
.It Bq Er ENOTSOCK
|
|
|
|
The argument
|
|
|
|
.Fa s
|
|
|
|
is not a socket.
|
|
|
|
.It Bq Er EFAULT
|
|
|
|
An invalid user space address was specified for an argument.
|
|
|
|
.It Bq Er EMSGSIZE
|
|
|
|
The socket requires that message be sent atomically,
|
|
|
|
and the size of the message to be sent made this impossible.
|
|
|
|
.It Bq Er EAGAIN
|
|
|
|
The socket is marked non-blocking and the requested operation
|
|
|
|
would block.
|
|
|
|
.It Bq Er ENOBUFS
|
|
|
|
The system was unable to allocate an internal buffer.
|
|
|
|
The operation may succeed when buffers become available.
|
|
|
|
.It Bq Er ENOBUFS
|
|
|
|
The output queue for a network interface was full.
|
|
|
|
This generally indicates that the interface has stopped sending,
|
|
|
|
but may be caused by transient congestion.
|
|
|
|
.It Bq Er EHOSTUNREACH
|
|
|
|
The remote host was unreachable.
|
2010-01-31 21:45:14 +00:00
|
|
|
.It Bq Er ENOTCONN
|
2007-06-18 10:20:32 +00:00
|
|
|
On a one-to-one style socket no association exists.
|
2007-02-22 14:32:39 +00:00
|
|
|
.It Bq Er ECONNRESET
|
|
|
|
An abort was received by the stack while the user was
|
|
|
|
attempting to send data to the peer.
|
|
|
|
.It Bq Er ENOENT
|
2007-06-18 10:20:32 +00:00
|
|
|
On a one-to-many style socket no address is specified
|
2007-02-22 14:32:39 +00:00
|
|
|
so that the association cannot be located or the
|
2007-06-18 10:20:32 +00:00
|
|
|
.Dv SCTP_ABORT
|
|
|
|
flag was specified on a non-existing association.
|
2007-02-22 14:32:39 +00:00
|
|
|
.It Bq Er EPIPE
|
|
|
|
The socket is unable to send anymore data
|
|
|
|
.Dv ( SBS_CANTSENDMORE
|
|
|
|
has been set on the socket).
|
|
|
|
This typically means that the socket
|
|
|
|
is not connected and is a one-to-one style socket.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr connect 2 ,
|
|
|
|
.Xr getsockopt 2 ,
|
|
|
|
.Xr recv 2 ,
|
|
|
|
.Xr select 2 ,
|
2016-02-29 17:19:15 +00:00
|
|
|
.Xr sendmsg 2 ,
|
2007-02-22 14:32:39 +00:00
|
|
|
.Xr socket 2 ,
|
2007-06-18 10:20:32 +00:00
|
|
|
.Xr write 2 ,
|
|
|
|
.Xr sctp_connectx 3 ,
|
|
|
|
.Xr sctp 4
|
2007-02-22 14:32:39 +00:00
|
|
|
.Sh BUGS
|
2010-01-12 21:45:03 +00:00
|
|
|
Because in the one-to-many style socket
|
2012-03-29 05:02:12 +00:00
|
|
|
.Fn sctp_sendmsg
|
2007-02-22 14:32:39 +00:00
|
|
|
or
|
|
|
|
.Fn sctp_sendmsgx
|
|
|
|
may have multiple associations under one endpoint, a
|
|
|
|
select on write will only work for a one-to-one style
|
|
|
|
socket.
|