| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
- .\"
- .\" Standard preamble:
- .\" ========================================================================
- .de Sp \" Vertical space (when we can't use .PP)
- .if t .sp .5v
- .if n .sp
- ..
- .de Vb \" Begin verbatim text
- .ft CW
- .nf
- .ne \\$1
- ..
- .de Ve \" End verbatim text
- .ft R
- .fi
- ..
- .\" Set up some character translations and predefined strings. \*(-- will
- .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
- .\" double quote, and \*(R" will give a right double quote. \*(C+ will
- .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
- .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
- .\" nothing in troff, for use with C<>.
- .tr \(*W-
- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
- .ie n \{\
- . ds -- \(*W-
- . ds PI pi
- . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
- . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
- . ds L" ""
- . ds R" ""
- . ds C` ""
- . ds C' ""
- 'br\}
- .el\{\
- . ds -- \|\(em\|
- . ds PI \(*p
- . ds L" ``
- . ds R" ''
- . ds C`
- . ds C'
- 'br\}
- .\"
- .\" Escape single quotes in literal strings from groff's Unicode transform.
- .ie \n(.g .ds Aq \(aq
- .el .ds Aq '
- .\"
- .\" If the F register is >0, we'll generate index entries on stderr for
- .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
- .\" entries marked with X<> in POD. Of course, you'll have to process the
- .\" output yourself in some meaningful fashion.
- .\"
- .\" Avoid warning from groff about undefined register 'F'.
- .de IX
- ..
- .nr rF 0
- .if \n(.g .if rF .nr rF 1
- .if (\n(rF:(\n(.g==0)) \{\
- . if \nF \{\
- . de IX
- . tm Index:\\$1\t\\n%\t"\\$2"
- ..
- . if !\nF==2 \{\
- . nr % 0
- . nr F 2
- . \}
- . \}
- .\}
- .rr rF
- .\"
- .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
- .\" Fear. Run. Save yourself. No user-serviceable parts.
- . \" fudge factors for nroff and troff
- .if n \{\
- . ds #H 0
- . ds #V .8m
- . ds #F .3m
- . ds #[ \f1
- . ds #] \fP
- .\}
- .if t \{\
- . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
- . ds #V .6m
- . ds #F 0
- . ds #[ \&
- . ds #] \&
- .\}
- . \" simple accents for nroff and troff
- .if n \{\
- . ds ' \&
- . ds ` \&
- . ds ^ \&
- . ds , \&
- . ds ~ ~
- . ds /
- .\}
- .if t \{\
- . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
- . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
- . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
- . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
- . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
- . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
- .\}
- . \" troff and (daisy-wheel) nroff accents
- .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
- .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
- .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
- .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
- .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
- .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
- .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
- .ds ae a\h'-(\w'a'u*4/10)'e
- .ds Ae A\h'-(\w'A'u*4/10)'E
- . \" corrections for vroff
- .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
- .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
- . \" for low resolution devices (crt and lpr)
- .if \n(.H>23 .if \n(.V>19 \
- \{\
- . ds : e
- . ds 8 ss
- . ds o a
- . ds d- d\h'-1'\(ga
- . ds D- D\h'-1'\(hy
- . ds th \o'bp'
- . ds Th \o'LP'
- . ds ae ae
- . ds Ae AE
- .\}
- .rm #[ #] #H #V #F C
- .\" ========================================================================
- .\"
- .IX Title "BIO_SENDMMSG 3ossl"
- .TH BIO_SENDMMSG 3ossl "2024-09-03" "3.3.2" "OpenSSL"
- .\" For nroff, turn off justification. Always turn off hyphenation; it makes
- .\" way too many mistakes in technical documents.
- .if n .ad l
- .nh
- .SH "NAME"
- BIO_sendmmsg, BIO_recvmmsg, BIO_dgram_set_local_addr_enable,
- BIO_dgram_get_local_addr_enable, BIO_dgram_get_local_addr_cap,
- BIO_err_is_non_fatal \- send and receive multiple datagrams in a single call
- .SH "SYNOPSIS"
- .IX Header "SYNOPSIS"
- .Vb 1
- \& #include <openssl/bio.h>
- \&
- \& typedef struct bio_msg_st {
- \& void *data;
- \& size_t data_len;
- \& BIO_ADDR *peer, *local;
- \& uint64_t flags;
- \& } BIO_MSG;
- \&
- \& int BIO_sendmmsg(BIO *b, BIO_MSG *msg,
- \& size_t stride, size_t num_msg, uint64_t flags,
- \& size_t *msgs_processed);
- \& int BIO_recvmmsg(BIO *b, BIO_MSG *msg,
- \& size_t stride, size_t num_msg, uint64_t flags,
- \& size_t *msgs_processed);
- \&
- \& int BIO_dgram_set_local_addr_enable(BIO *b, int enable);
- \& int BIO_dgram_get_local_addr_enable(BIO *b, int *enable);
- \& int BIO_dgram_get_local_addr_cap(BIO *b);
- \& int BIO_err_is_non_fatal(unsigned int errcode);
- .Ve
- .SH "DESCRIPTION"
- .IX Header "DESCRIPTION"
- \&\fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR functions can be used to send and receive
- multiple messages in a single call to a \s-1BIO.\s0 They are analogous to \fBsendmmsg\fR\|(2)
- and \fBrecvmmsg\fR\|(2) on operating systems which provide those functions.
- .PP
- The \fB\s-1BIO_MSG\s0\fR structure provides a subset of the functionality of the \fBstruct
- msghdr\fR structure defined by \s-1POSIX.\s0 These functions accept an array of
- \&\fB\s-1BIO_MSG\s0\fR structures. On any particular invocation, these functions may process
- all of the passed structures, some of them, or none of them. This is indicated
- by the value stored in \fI*msgs_processed\fR, which expresses the number of
- messages processed.
- .PP
- The caller should set the \fIdata\fR member of a \fB\s-1BIO_MSG\s0\fR to a buffer containing
- the data to send, or to be filled with a received message. \fIdata_len\fR should be
- set to the size of the buffer in bytes. If the given \fB\s-1BIO_MSG\s0\fR is processed (in
- other words, if the integer returned by the function is greater than or equal to
- that \fB\s-1BIO_MSG\s0\fR's array index), \fIdata_len\fR will be modified to specify the
- actual amount of data sent or received.
- .PP
- The \fIflags\fR field of a \fB\s-1BIO_MSG\s0\fR provides input per-message flags to the
- invocation. If the invocation processes that \fB\s-1BIO_MSG\s0\fR, the \fIflags\fR field is
- written with output per-message flags, or zero if no such flags are applicable.
- .PP
- Currently, no input or output per-message flags are defined and this field
- should be set to zero before calling \fBBIO_sendmmsg()\fR or \fBBIO_recvmmsg()\fR.
- .PP
- The \fIflags\fR argument to \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR provides global
- flags which affect the entire invocation. No global flags are currently
- defined and this argument should be set to zero.
- .PP
- When these functions are used to send and receive datagrams, the \fIpeer\fR field
- of a \fB\s-1BIO_MSG\s0\fR allows the destination address of sent datagrams to be specified
- on a per-datagram basis, and the source address of received datagrams to be
- determined. The \fIpeer\fR field should be set to point to a \fB\s-1BIO_ADDR\s0\fR, which
- will be read by \fBBIO_sendmmsg()\fR and used as the destination address for sent
- datagrams, and written by \fBBIO_recvmmsg()\fR with the source address of received
- datagrams.
- .PP
- Similarly, the \fIlocal\fR field of a \fB\s-1BIO_MSG\s0\fR allows the source address of sent
- datagrams to be specified on a per-datagram basis, and the destination address
- of received datagrams to be determined. Unlike \fIpeer\fR, support for \fIlocal\fR
- must be explicitly enabled on a \fB\s-1BIO\s0\fR before it can be used; see
- \&\fBBIO_dgram_set_local_addr_enable()\fR. If \fIlocal\fR is non-NULL in a \fB\s-1BIO_MSG\s0\fR and
- support for \fIlocal\fR has not been enabled, processing of that \fB\s-1BIO_MSG\s0\fR fails.
- .PP
- \&\fIpeer\fR and \fIlocal\fR should be set to \s-1NULL\s0 if they are not required. Support for
- \&\fIlocal\fR may not be available on all platforms; on these platforms, these
- functions always fail if \fIlocal\fR is non-NULL.
- .PP
- If \fIlocal\fR is specified and local address support is enabled, but the operating
- system does not report a local address for a specific received message, the
- \&\fB\s-1BIO_ADDR\s0\fR it points to will be cleared (address family set to \f(CW\*(C`AF_UNSPEC\*(C'\fR).
- This is known to happen on Windows when a packet is received which was sent by
- the local system, regardless of whether the packet's destination address was the
- loopback address or the \s-1IP\s0 address of a local non-loopback interface. This is
- also known to happen on macOS in some circumstances, such as for packets sent
- before local address support was enabled for a receiving socket. These are
- OS-specific limitations. As such, users of this \s-1API\s0 using local address support
- should expect to sometimes receive a cleared local \fB\s-1BIO_ADDR\s0\fR instead of the
- correct value.
- .PP
- The \fIstride\fR argument must be set to \f(CW\*(C`sizeof(BIO_MSG)\*(C'\fR. This argument
- facilitates backwards compatibility if fields are added to \fB\s-1BIO_MSG\s0\fR. Callers
- must zero-initialize \fB\s-1BIO_MSG\s0\fR.
- .PP
- \&\fInum_msg\fR should be sent to the maximum number of messages to send or receive,
- which is also the length of the array pointed to by \fImsg\fR.
- .PP
- \&\fImsgs_processed\fR must be non-NULL and points to an integer written with the
- number of messages successfully processed; see the \s-1RETURN VALUES\s0 section for
- further discussion.
- .PP
- Unlike most \s-1BIO\s0 functions, these functions explicitly support multi-threaded
- use. Multiple concurrent writers and multiple concurrent readers of the same \s-1BIO\s0
- are permitted in any combination. As such, these functions do not clear, set, or
- otherwise modify \s-1BIO\s0 retry flags. The return value must be used to determine
- whether an operation should be retried; see below.
- .PP
- The support for concurrent use extends to \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR
- only, and no other function may be called on a given \s-1BIO\s0 while any call to
- \&\fBBIO_sendmmsg()\fR or \fBBIO_recvmmsg()\fR is in progress, or vice versa.
- .PP
- \&\fBBIO_dgram_set_local_addr_enable()\fR and \fBBIO_dgram_get_local_addr_enable()\fR control
- whether local address support is enabled. To enable local address support, call
- \&\fBBIO_dgram_set_local_addr_enable()\fR with an argument of 1. The call will fail if
- local address support is not available for the platform.
- \&\fBBIO_dgram_get_local_addr_enable()\fR retrieves the value set by
- \&\fBBIO_dgram_set_local_addr_enable()\fR.
- .PP
- \&\fBBIO_dgram_get_local_addr_cap()\fR determines if the \fB\s-1BIO\s0\fR is capable of supporting
- local addresses.
- .PP
- \&\fBBIO_err_is_non_fatal()\fR determines if a packed error code represents an error
- which is transient in nature.
- .SH "NOTES"
- .IX Header "NOTES"
- Some implementations of the \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR \s-1BIO\s0 methods might
- always process at most one message at a time, for example when OS-level
- functionality to transmit or receive multiple messages at a time is not
- available.
- .SH "RETURN VALUES"
- .IX Header "RETURN VALUES"
- On success, the functions \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR return 1 and write
- the number of messages successfully processed (which need not be nonzero) to
- \&\fImsgs_processed\fR. Where a positive value n is written to \fImsgs_processed\fR, all
- entries in the \fB\s-1BIO_MSG\s0\fR array from 0 through n\-1 inclusive have their
- \&\fIdata_len\fR and \fIflags\fR fields updated with the results of the operation on
- that message. If the call was to \fBBIO_recvmmsg()\fR and the \fIpeer\fR or \fIlocal\fR
- fields of that message are non-NULL, the \fB\s-1BIO_ADDR\s0\fR structures they point to
- are written with the relevant address.
- .PP
- On failure, the functions \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR return 0 and write
- zero to \fImsgs_processed\fR. Thus \fImsgs_processed\fR is always written regardless
- of the outcome of the function call.
- .PP
- If \fBBIO_sendmmsg()\fR and \fBBIO_recvmmsg()\fR fail, they always raise an \fB\s-1ERR_LIB_BIO\s0\fR
- error using \fBERR_raise\fR\|(3). Any error may be raised, but the following in
- particular may be noted:
- .IP "\fB\s-1BIO_R_LOCAL_ADDR_NOT_AVAILABLE\s0\fR" 2
- .IX Item "BIO_R_LOCAL_ADDR_NOT_AVAILABLE"
- The \fIlocal\fR field was set to a non-NULL value, but local address support is not
- available or not enabled on the \s-1BIO.\s0
- .IP "\fB\s-1BIO_R_PEER_ADDR_NOT_AVAILABLE\s0\fR" 2
- .IX Item "BIO_R_PEER_ADDR_NOT_AVAILABLE"
- The \fIpeer\fR field was set to a non-NULL value, but peer address support is not
- available on the \s-1BIO.\s0
- .IP "\fB\s-1BIO_R_UNSUPPORTED_METHOD\s0\fR" 2
- .IX Item "BIO_R_UNSUPPORTED_METHOD"
- The \fBBIO_sendmmsg()\fR or \fBBIO_recvmmsg()\fR method is not supported on the \s-1BIO.\s0
- .IP "\fB\s-1BIO_R_NON_FATAL\s0\fR" 2
- .IX Item "BIO_R_NON_FATAL"
- The call failed due to a transient, non-fatal error (for example, because the
- \&\s-1BIO\s0 is in nonblocking mode and the call would otherwise have blocked).
- .Sp
- Implementations of this interface which do not make system calls and thereby
- pass through system error codes using \fB\s-1ERR_LIB_SYS\s0\fR (for example, memory-based
- implementations) should issue this reason code to indicate a transient failure.
- However, users of this interface should not test for this reason code directly,
- as there are multiple possible packed error codes representing a transient
- failure; use \fBBIO_err_is_non_fatal()\fR instead (discussed below).
- .IP "Socket errors" 2
- .IX Item "Socket errors"
- OS-level socket errors are reported using an error with library code
- \&\fB\s-1ERR_LIB_SYS\s0\fR; for a packed error code \fBerrcode\fR where
- \&\f(CW\*(C`ERR_SYSTEM_ERROR(errcode) == 1\*(C'\fR, the OS-level socket error code can be
- retrieved using \f(CW\*(C`ERR_GET_REASON(errcode)\*(C'\fR. The packed error code can be
- retrieved by calling \fBERR_peek_last_error\fR\|(3) after the call to \fBBIO_sendmmsg()\fR
- or \fBBIO_recvmmsg()\fR returns 0.
- .IP "Non-fatal errors" 2
- .IX Item "Non-fatal errors"
- Whether an error is transient can be determined by passing the packed error code
- to \fBBIO_err_is_non_fatal()\fR. Callers should do this instead of testing the reason
- code directly, as there are many possible error codes which can indicate a
- transient error, many of which are system specific.
- .PP
- Third parties implementing custom BIOs supporting the \fBBIO_sendmmsg()\fR or
- \&\fBBIO_recvmmsg()\fR methods should note that it is a required part of the \s-1API\s0
- contract that an error is always raised when either of these functions return 0.
- .PP
- \&\fBBIO_dgram_set_local_addr_enable()\fR returns 1 if local address support was
- successfully enabled or disabled and 0 otherwise.
- .PP
- \&\fBBIO_dgram_get_local_addr_enable()\fR returns 1 if the local address support enable
- flag was successfully retrieved.
- .PP
- \&\fBBIO_dgram_get_local_addr_cap()\fR returns 1 if the \fB\s-1BIO\s0\fR can support local
- addresses.
- .PP
- \&\fBBIO_err_is_non_fatal()\fR returns 1 if the passed packed error code represents an
- error which is transient in nature.
- .SH "HISTORY"
- .IX Header "HISTORY"
- These functions were added in OpenSSL 3.2.
- .SH "COPYRIGHT"
- .IX Header "COPYRIGHT"
- Copyright 2000\-2023 The OpenSSL Project Authors. All Rights Reserved.
- .PP
- Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
- this file except in compliance with the License. You can obtain a copy
- in the file \s-1LICENSE\s0 in the source distribution or at
- <https://www.openssl.org/source/license.html>.
|