xref: /freebsd/crypto/openssl/doc/man3/SSL_pending.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimSSL_pending, SSL_has_pending - check for readable bytes buffered in an
6e71b7053SJung-uk KimSSL object
7e71b7053SJung-uk Kim
8e71b7053SJung-uk Kim=head1 SYNOPSIS
9e71b7053SJung-uk Kim
10e71b7053SJung-uk Kim #include <openssl/ssl.h>
11e71b7053SJung-uk Kim
12e71b7053SJung-uk Kim int SSL_pending(const SSL *ssl);
13e71b7053SJung-uk Kim int SSL_has_pending(const SSL *s);
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim=head1 DESCRIPTION
16e71b7053SJung-uk Kim
17e71b7053SJung-uk KimData is received in whole blocks known as records from the peer. A whole record
18e71b7053SJung-uk Kimis processed (e.g. decrypted) in one go and is buffered by OpenSSL until it is
19e71b7053SJung-uk Kimread by the application via a call to L<SSL_read_ex(3)> or L<SSL_read(3)>.
20e71b7053SJung-uk Kim
21e71b7053SJung-uk KimSSL_pending() returns the number of bytes which have been processed, buffered
22e71b7053SJung-uk Kimand are available inside B<ssl> for immediate read.
23e71b7053SJung-uk Kim
24e71b7053SJung-uk KimIf the B<SSL> object's I<read_ahead> flag is set (see
25e71b7053SJung-uk KimL<SSL_CTX_set_read_ahead(3)>), additional protocol bytes (beyond the current
26e71b7053SJung-uk Kimrecord) may have been read containing more TLS/SSL records. This also applies to
27e71b7053SJung-uk KimDTLS and pipelining (see L<SSL_CTX_set_split_send_fragment(3)>). These
28e71b7053SJung-uk Kimadditional bytes will be buffered by OpenSSL but will remain unprocessed until
29e71b7053SJung-uk Kimthey are needed. As these bytes are still in an unprocessed state SSL_pending()
3058f35182SJung-uk Kimwill ignore them. Therefore, it is possible for no more bytes to be readable from
31e71b7053SJung-uk Kimthe underlying BIO (because OpenSSL has already read them) and for SSL_pending()
32e71b7053SJung-uk Kimto return 0, even though readable application data bytes are available (because
33e71b7053SJung-uk Kimthe data is in unprocessed buffered records).
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimSSL_has_pending() returns 1 if B<s> has buffered data (whether processed or
36e71b7053SJung-uk Kimunprocessed) and 0 otherwise. Note that it is possible for SSL_has_pending() to
37e71b7053SJung-uk Kimreturn 1, and then a subsequent call to SSL_read_ex() or SSL_read() to return no
38e71b7053SJung-uk Kimdata because the unprocessed buffered data when processed yielded no application
39e71b7053SJung-uk Kimdata (for example this can happen during renegotiation). It is also possible in
40e71b7053SJung-uk Kimthis scenario for SSL_has_pending() to continue to return 1 even after an
41e71b7053SJung-uk KimSSL_read_ex() or SSL_read() call because the buffered and unprocessed data is
42e71b7053SJung-uk Kimnot yet processable (e.g. because OpenSSL has only received a partial record so
43e71b7053SJung-uk Kimfar).
44e71b7053SJung-uk Kim
45e71b7053SJung-uk Kim=head1 RETURN VALUES
46e71b7053SJung-uk Kim
47e71b7053SJung-uk KimSSL_pending() returns the number of buffered and processed application data
48e71b7053SJung-uk Kimbytes that are pending and are available for immediate read. SSL_has_pending()
49e71b7053SJung-uk Kimreturns 1 if there is buffered record data in the SSL object and 0 otherwise.
50e71b7053SJung-uk Kim
51e71b7053SJung-uk Kim=head1 SEE ALSO
52e71b7053SJung-uk Kim
53e71b7053SJung-uk KimL<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_CTX_set_read_ahead(3)>,
54e71b7053SJung-uk KimL<SSL_CTX_set_split_send_fragment(3)>, L<ssl(7)>
55e71b7053SJung-uk Kim
56e71b7053SJung-uk Kim=head1 HISTORY
57e71b7053SJung-uk Kim
58e71b7053SJung-uk KimThe SSL_has_pending() function was added in OpenSSL 1.1.0.
59e71b7053SJung-uk Kim
60e71b7053SJung-uk Kim=head1 COPYRIGHT
61e71b7053SJung-uk Kim
6258f35182SJung-uk KimCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
63e71b7053SJung-uk Kim
64*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
65e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
66e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
67e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
68e71b7053SJung-uk Kim
69e71b7053SJung-uk Kim=cut
70