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.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2015-04-23 13:10:03 +00:00
|
|
|
.Dd April 23, 2015
|
2007-02-22 14:32:39 +00:00
|
|
|
.Dt SCTP_RECVMSG 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm sctp_recvmsg
|
2007-09-20 10:49:10 +00:00
|
|
|
.Nd receive a message from an SCTP socket
|
2007-02-22 14:32:39 +00:00
|
|
|
.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_recvmsg
|
|
|
|
.Fa "int s" "void *msg" "size_t len" "struct sockaddr * restrict from"
|
|
|
|
.Fa "socklen_t * restrict fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags"
|
|
|
|
.Fc
|
2007-02-22 14:32:39 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn sctp_recvmsg
|
2007-06-18 10:20:32 +00:00
|
|
|
system call
|
2007-02-22 14:32:39 +00:00
|
|
|
is used to receive a message from another SCTP endpoint.
|
|
|
|
The
|
|
|
|
.Fn sctp_recvmsg
|
|
|
|
call is used by one-to-one (SOCK_STREAM) type sockets after a
|
2012-03-29 05:02:12 +00:00
|
|
|
successful
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fn connect
|
2012-03-29 05:02:12 +00:00
|
|
|
call or after the application has performed a
|
|
|
|
.Fn listen
|
|
|
|
followed by a successful
|
2007-09-25 16:48:08 +00:00
|
|
|
.Fn accept .
|
2007-06-18 10:20:32 +00:00
|
|
|
For a one-to-many (SOCK_SEQPACKET) type socket, an endpoint may call
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fn sctp_recvmsg
|
|
|
|
after having implicitly started an association via one
|
|
|
|
of the send calls including
|
2012-05-11 20:06:46 +00:00
|
|
|
.Fn sctp_sendmsg ,
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fn sendto
|
2007-02-22 14:32:39 +00:00
|
|
|
and
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fn sendmsg .
|
2007-02-22 14:32:39 +00:00
|
|
|
Or, an application may also receive a message after having
|
|
|
|
called
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fn listen
|
2007-09-25 16:48:08 +00:00
|
|
|
with a positive backlog to enable the reception of new associations.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
|
|
|
The address of the sender is held in the
|
|
|
|
.Fa from
|
2012-03-29 05:02:12 +00:00
|
|
|
argument with
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa fromlen
|
2007-06-18 10:20:32 +00:00
|
|
|
specifying its size.
|
|
|
|
At the completion of a successful
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fn sctp_recvmsg
|
|
|
|
call
|
|
|
|
.Fa from
|
|
|
|
will hold the address of the peer and
|
|
|
|
.Fa fromlen
|
2007-06-18 10:20:32 +00:00
|
|
|
will hold the length of that address.
|
|
|
|
Note that
|
2012-03-29 05:02:12 +00:00
|
|
|
the address is bounded by the initial value of
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa fromlen
|
|
|
|
which is used as an in/out variable.
|
|
|
|
.Pp
|
2012-03-29 05:02:12 +00:00
|
|
|
The length of the message
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa msg
|
|
|
|
to be received is bounded by
|
|
|
|
.Fa len .
|
2007-06-18 10:20:32 +00:00
|
|
|
If the message is too long to fit in the users
|
2012-03-29 05:02:12 +00:00
|
|
|
receive buffer, then the
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa flags
|
2007-09-25 16:48:08 +00:00
|
|
|
argument will
|
|
|
|
.Em not
|
|
|
|
have the
|
2015-04-23 13:10:03 +00:00
|
|
|
.Dv MSG_EOR
|
2007-06-18 10:20:32 +00:00
|
|
|
flag applied.
|
|
|
|
If the message is a complete message then
|
2012-03-29 05:02:12 +00:00
|
|
|
the
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa flags
|
2007-06-18 10:20:32 +00:00
|
|
|
argument will have
|
2015-04-23 13:10:03 +00:00
|
|
|
.Dv MSG_EOR
|
2007-06-18 10:20:32 +00:00
|
|
|
set.
|
2012-03-29 05:02:12 +00:00
|
|
|
Locally detected errors are
|
2007-06-18 10:20:32 +00:00
|
|
|
indicated by a return value of -1 with
|
|
|
|
.Va errno
|
|
|
|
set accordingly.
|
2012-03-29 05:02:12 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa flags
|
2007-06-18 10:20:32 +00:00
|
|
|
argument may also hold the value
|
|
|
|
.Dv MSG_NOTIFICATION .
|
|
|
|
When this
|
2007-09-25 16:48:08 +00:00
|
|
|
occurs it indicates that the message received is
|
|
|
|
.Em not
|
|
|
|
from
|
2007-02-22 14:32:39 +00:00
|
|
|
the peer endpoint, but instead is a notification from the
|
|
|
|
SCTP stack (see
|
2007-06-18 10:20:32 +00:00
|
|
|
.Xr sctp 4
|
|
|
|
for more details).
|
|
|
|
Note that no notifications are ever
|
2007-02-22 14:32:39 +00:00
|
|
|
given unless the user subscribes to such notifications using
|
2007-06-18 10:20:32 +00:00
|
|
|
the
|
|
|
|
.Dv SCTP_EVENTS
|
|
|
|
socket option.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
2007-06-18 10:20:32 +00:00
|
|
|
If no messages are available at the socket then
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fn sctp_recvmsg
|
2007-06-18 10:20:32 +00:00
|
|
|
normally blocks on the reception of a message or NOTIFICATION, unless the
|
|
|
|
socket has been placed in non-blocking I/O mode.
|
2007-02-22 14:32:39 +00:00
|
|
|
The
|
|
|
|
.Xr select 2
|
|
|
|
system call may be used to determine when it is possible to
|
|
|
|
receive a message.
|
|
|
|
.Pp
|
2012-03-29 05:02:12 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa sinfo
|
|
|
|
argument is defined as follows.
|
|
|
|
.Bd -literal
|
|
|
|
struct sctp_sndrcvinfo {
|
2010-07-04 08:09:33 +00:00
|
|
|
uint16_t sinfo_stream; /* Stream arriving on */
|
|
|
|
uint16_t sinfo_ssn; /* Stream Sequence Number */
|
|
|
|
uint16_t sinfo_flags; /* Flags on the incoming message */
|
|
|
|
uint32_t sinfo_ppid; /* The ppid field */
|
|
|
|
uint32_t sinfo_context; /* context field */
|
|
|
|
uint32_t sinfo_timetolive; /* not used by sctp_recvmsg */
|
|
|
|
uint32_t sinfo_tsn; /* The transport sequence number */
|
|
|
|
uint32_t sinfo_cumtsn; /* The cumulative acknowledgment point */
|
2007-02-22 14:32:39 +00:00
|
|
|
sctp_assoc_t sinfo_assoc_id; /* The association id of the peer */
|
|
|
|
};
|
|
|
|
.Ed
|
2007-06-18 10:20:32 +00:00
|
|
|
.Pp
|
2007-02-22 14:32:39 +00:00
|
|
|
The
|
|
|
|
.Fa sinfo->sinfo_ppid
|
2010-01-12 21:45:03 +00:00
|
|
|
field is an opaque 32 bit value that is passed transparently
|
2012-03-29 05:02:12 +00:00
|
|
|
through the stack from the peer endpoint.
|
2007-02-22 14:32:39 +00:00
|
|
|
Note that the stack passes this value without regard to byte
|
|
|
|
order.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa sinfo->sinfo_flags
|
|
|
|
field may include the following:
|
|
|
|
.Bd -literal
|
|
|
|
#define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Dv SCTP_UNORDERED
|
|
|
|
flag is used to specify that the message arrived with no
|
|
|
|
specific order and was delivered to the peer application
|
2007-06-18 10:20:32 +00:00
|
|
|
as soon as possible.
|
|
|
|
When this flag is absent the message
|
2007-02-22 14:32:39 +00:00
|
|
|
was delivered in order within the stream it was received.
|
|
|
|
.Pp
|
2010-01-12 21:45:03 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa sinfo->sinfo_stream
|
2012-03-29 05:02:12 +00:00
|
|
|
field is the SCTP stream that the message was received on.
|
2007-02-22 14:32:39 +00:00
|
|
|
Streams in SCTP are reliable (or partially reliable) flows of ordered
|
|
|
|
messages.
|
|
|
|
.Pp
|
2010-01-12 21:45:03 +00:00
|
|
|
The
|
2007-02-22 14:32:39 +00:00
|
|
|
.Fa sinfo->sinfo_context
|
2007-06-18 10:20:32 +00:00
|
|
|
field is used only if the local application set an association level
|
|
|
|
context with the
|
|
|
|
.Dv SCTP_CONTEXT
|
|
|
|
socket option.
|
2007-02-22 14:32:39 +00:00
|
|
|
Optionally a user process can use this value to index some application
|
|
|
|
specific data structure for all data coming from a specific
|
2012-03-29 05:02:12 +00:00
|
|
|
association.
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa sinfo->sinfo_ssn
|
2010-01-12 21:45:03 +00:00
|
|
|
field will hold the stream sequence number assigned
|
2007-09-25 16:48:08 +00:00
|
|
|
by the peer endpoint if the message is
|
|
|
|
.Em not
|
|
|
|
unordered.
|
2007-02-22 14:32:39 +00:00
|
|
|
For unordered messages this field holds an undefined value.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa sinfo->sinfo_tsn
|
2010-01-12 21:45:03 +00:00
|
|
|
field holds a transport sequence number (TSN) that was assigned
|
2007-06-18 10:20:32 +00:00
|
|
|
to this message by the peer endpoint.
|
|
|
|
For messages that fit in or less
|
2007-02-22 14:32:39 +00:00
|
|
|
than the path MTU this will be the only TSN assigned.
|
2007-09-25 16:48:08 +00:00
|
|
|
Note that for messages that span multiple TSNs this
|
|
|
|
value will be one of the TSNs that was used on the
|
2007-02-22 14:32:39 +00:00
|
|
|
message.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa sinfo->sinfo_cumtsn
|
2010-01-12 21:45:03 +00:00
|
|
|
field holds the current cumulative acknowledgment point of
|
2007-06-18 10:20:32 +00:00
|
|
|
the transport association.
|
|
|
|
Note that this may be larger
|
2007-02-22 14:32:39 +00:00
|
|
|
or smaller than the TSN assigned to the message itself.
|
|
|
|
.Pp
|
2010-01-12 21:45:03 +00:00
|
|
|
The
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fa sinfo->sinfo_assoc_id
|
2007-02-22 14:32:39 +00:00
|
|
|
is the unique association identification that was assigned
|
2007-06-18 10:20:32 +00:00
|
|
|
to the association.
|
|
|
|
For one-to-many (SOCK_SEQPACKET) type
|
2007-02-22 14:32:39 +00:00
|
|
|
sockets this value can be used to send data to the peer without
|
2007-06-18 10:20:32 +00:00
|
|
|
the use of an address field.
|
|
|
|
It is also quite useful in
|
2007-02-22 14:32:39 +00:00
|
|
|
setting various socket options on the specific association
|
2012-03-29 05:02:12 +00:00
|
|
|
(see
|
2007-09-25 16:48:08 +00:00
|
|
|
.Xr sctp 4 ) .
|
2007-02-22 14:32:39 +00:00
|
|
|
.Pp
|
2010-01-12 21:45:03 +00:00
|
|
|
The
|
2007-06-18 10:20:32 +00:00
|
|
|
.Fa sinfo->info_timetolive
|
2012-03-29 05:02:12 +00:00
|
|
|
field is not used by
|
2010-01-12 21:45:03 +00:00
|
|
|
.Fn sctp_recvmsg .
|
2007-02-22 14:32:39 +00:00
|
|
|
.Sh RETURN VALUES
|
2010-06-11 18:43:55 +00:00
|
|
|
The call returns the number of bytes received, or -1
|
2007-02-22 14:32:39 +00:00
|
|
|
if an error occurred.
|
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Fn sctp_recvmsg
|
|
|
|
system call
|
2007-06-18 10:20:32 +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
|
|
|
|
On a one to many style socket no address is specified
|
|
|
|
so that the association cannot be located or the
|
|
|
|
SCTP_ABORT flag was specified on a non-existing association.
|
|
|
|
.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
|
2014-12-21 12:36:36 +00:00
|
|
|
.Xr getsockopt 2 ,
|
2007-02-22 14:32:39 +00:00
|
|
|
.Xr recv 2 ,
|
|
|
|
.Xr select 2 ,
|
2016-02-29 17:19:15 +00:00
|
|
|
.Xr sendmsg 2 ,
|
2014-12-21 12:36:36 +00:00
|
|
|
.Xr setsockopt 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_send 3 ,
|
|
|
|
.Xr sctp_sendmsg 3 ,
|
|
|
|
.Xr sctp 4
|