xref: /netbsd-src/crypto/external/bsd/openssl/dist/doc/man3/SSL_pending.pod (revision b0d1725196a7921d003d2c66a14f186abda4176b)
113d40330Schristos=pod
213d40330Schristos
313d40330Schristos=head1 NAME
413d40330Schristos
513d40330SchristosSSL_pending, SSL_has_pending - check for readable bytes buffered in an
613d40330SchristosSSL object
713d40330Schristos
813d40330Schristos=head1 SYNOPSIS
913d40330Schristos
1013d40330Schristos #include <openssl/ssl.h>
1113d40330Schristos
1213d40330Schristos int SSL_pending(const SSL *ssl);
1313d40330Schristos int SSL_has_pending(const SSL *s);
1413d40330Schristos
1513d40330Schristos=head1 DESCRIPTION
1613d40330Schristos
1713d40330SchristosData is received in whole blocks known as records from the peer. A whole record
1813d40330Schristosis processed (e.g. decrypted) in one go and is buffered by OpenSSL until it is
1913d40330Schristosread by the application via a call to L<SSL_read_ex(3)> or L<SSL_read(3)>.
2013d40330Schristos
2113d40330SchristosSSL_pending() returns the number of bytes which have been processed, buffered
2213d40330Schristosand are available inside B<ssl> for immediate read.
2313d40330Schristos
2413d40330SchristosIf the B<SSL> object's I<read_ahead> flag is set (see
2513d40330SchristosL<SSL_CTX_set_read_ahead(3)>), additional protocol bytes (beyond the current
2613d40330Schristosrecord) may have been read containing more TLS/SSL records. This also applies to
2713d40330SchristosDTLS and pipelining (see L<SSL_CTX_set_split_send_fragment(3)>). These
2813d40330Schristosadditional bytes will be buffered by OpenSSL but will remain unprocessed until
2913d40330Schristosthey are needed. As these bytes are still in an unprocessed state SSL_pending()
30f30e0929Schristoswill ignore them. Therefore, it is possible for no more bytes to be readable from
3113d40330Schristosthe underlying BIO (because OpenSSL has already read them) and for SSL_pending()
3213d40330Schristosto return 0, even though readable application data bytes are available (because
3313d40330Schristosthe data is in unprocessed buffered records).
3413d40330Schristos
3513d40330SchristosSSL_has_pending() returns 1 if B<s> has buffered data (whether processed or
3613d40330Schristosunprocessed) and 0 otherwise. Note that it is possible for SSL_has_pending() to
3713d40330Schristosreturn 1, and then a subsequent call to SSL_read_ex() or SSL_read() to return no
3813d40330Schristosdata because the unprocessed buffered data when processed yielded no application
3913d40330Schristosdata (for example this can happen during renegotiation). It is also possible in
4013d40330Schristosthis scenario for SSL_has_pending() to continue to return 1 even after an
4113d40330SchristosSSL_read_ex() or SSL_read() call because the buffered and unprocessed data is
4213d40330Schristosnot yet processable (e.g. because OpenSSL has only received a partial record so
4313d40330Schristosfar).
4413d40330Schristos
4513d40330Schristos=head1 RETURN VALUES
4613d40330Schristos
4713d40330SchristosSSL_pending() returns the number of buffered and processed application data
4813d40330Schristosbytes that are pending and are available for immediate read. SSL_has_pending()
4913d40330Schristosreturns 1 if there is buffered record data in the SSL object and 0 otherwise.
5013d40330Schristos
5113d40330Schristos=head1 SEE ALSO
5213d40330Schristos
5313d40330SchristosL<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_CTX_set_read_ahead(3)>,
5413d40330SchristosL<SSL_CTX_set_split_send_fragment(3)>, L<ssl(7)>
5513d40330Schristos
5613d40330Schristos=head1 HISTORY
5713d40330Schristos
5813d40330SchristosThe SSL_has_pending() function was added in OpenSSL 1.1.0.
5913d40330Schristos
6013d40330Schristos=head1 COPYRIGHT
6113d40330Schristos
62f30e0929SchristosCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
6313d40330Schristos
64*b0d17251SchristosLicensed under the Apache License 2.0 (the "License").  You may not use
6513d40330Schristosthis file except in compliance with the License.  You can obtain a copy
6613d40330Schristosin the file LICENSE in the source distribution or at
6713d40330SchristosL<https://www.openssl.org/source/license.html>.
6813d40330Schristos
6913d40330Schristos=cut
70