2
0

SSL_get_stream_read_state.pod 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. =pod
  2. =head1 NAME
  3. SSL_get_stream_read_state, SSL_get_stream_write_state,
  4. SSL_get_stream_read_error_code, SSL_get_stream_write_error_code,
  5. SSL_STREAM_STATE_NONE, SSL_STREAM_STATE_OK, SSL_STREAM_STATE_WRONG_DIR,
  6. SSL_STREAM_STATE_FINISHED, SSL_STREAM_STATE_RESET_LOCAL,
  7. SSL_STREAM_STATE_RESET_REMOTE, SSL_STREAM_STATE_CONN_CLOSED - get QUIC stream
  8. state
  9. =head1 SYNOPSIS
  10. #include <openssl/ssl.h>
  11. #define SSL_STREAM_STATE_NONE
  12. #define SSL_STREAM_STATE_OK
  13. #define SSL_STREAM_STATE_WRONG_DIR
  14. #define SSL_STREAM_STATE_FINISHED
  15. #define SSL_STREAM_STATE_RESET_LOCAL
  16. #define SSL_STREAM_STATE_RESET_REMOTE
  17. #define SSL_STREAM_STATE_CONN_CLOSED
  18. int SSL_get_stream_read_state(SSL *ssl);
  19. int SSL_get_stream_write_state(SSL *ssl);
  20. int SSL_get_stream_read_error_code(SSL *ssl, uint64_t *app_error_code);
  21. int SSL_get_stream_write_error_code(SSL *ssl, uint64_t *app_error_code);
  22. =head1 DESCRIPTION
  23. SSL_get_stream_read_state() and SSL_get_stream_write_state() retrieve the
  24. overall state of the receiving and sending parts of a QUIC stream, respectively.
  25. They both return one of the following values:
  26. =over 4
  27. =item B<SSL_STREAM_STATE_NONE>
  28. This value is returned if called on a non-QUIC SSL object, or on a QUIC
  29. connection SSL object without a default stream attached.
  30. =item B<SSL_STREAM_STATE_OK>
  31. This value is returned on a stream which has not been concluded and remains
  32. healthy.
  33. =item B<SSL_STREAM_STATE_WRONG_DIR>
  34. This value is returned if SSL_get_stream_read_state() is called on a
  35. locally-initiated (and thus send-only) unidirectional stream, or, conversely, if
  36. SSL_get_stream_write_state() is called on a remotely-initiated (and thus
  37. receive-only) unidirectional stream.
  38. =item B<SSL_STREAM_STATE_FINISHED>
  39. For SSL_get_stream_read_state(), this value is returned when the remote peer has
  40. signalled the end of the receiving part of the stream. Note that there may still
  41. be residual data available to read via L<SSL_read(3)> when this state is
  42. returned.
  43. For SSL_get_stream_write_state(), this value is returned when the local
  44. application has concluded the stream using L<SSL_stream_conclude(3)>. Future
  45. L<SSL_write(3)> calls will not succeed.
  46. =item B<SSL_STREAM_STATE_RESET_LOCAL>
  47. This value is returned when the applicable stream part was reset by the local
  48. application.
  49. For SSL_get_stream_read_state(), this means that the receiving part of the
  50. stream was aborted using a locally transmitted QUIC B<STOP_SENDING> frame. It
  51. may or may not still be possible to obtain any residual data which remains to be
  52. read by calling L<SSL_read(3)>.
  53. For SSL_get_stream_write_state(), this means that the sending part of the stream
  54. was aborted, for example because the application called L<SSL_stream_reset(3)>,
  55. or because a QUIC stream SSL object with an un-concluded sending part was freed
  56. using L<SSL_free(3)>. Calls to L<SSL_write(3)> will fail.
  57. When this value is returned, the application error code which was signalled can
  58. be obtained by calling SSL_get_stream_read_error_code() or
  59. SSL_get_stream_write_error_code() as appropriate.
  60. =item B<SSL_STREAM_STATE_RESET_REMOTE>
  61. This value is returned when the applicable stream part was reset by the remote
  62. peer.
  63. For SSL_get_stream_read_state(), this means that the peer sent a QUIC
  64. B<RESET_STREAM> frame for the receiving part of the stream; the receiving part
  65. of the stream was logically aborted by the peer.
  66. For SSL_get_stream_write_state(), this means that the peer sent a QUIC
  67. B<STOP_SENDING> frame for the sending part of the stream; the peer has indicated
  68. that it does not wish to receive further data on the sending part of the stream.
  69. Calls to L<SSL_write(3)> will fail.
  70. When this value is returned, the application error code which was signalled can
  71. be obtained by calling SSL_get_stream_read_error_code() or
  72. SSL_get_stream_write_error_code() as appropriate.
  73. =item B<SSL_STREAM_STATE_CONN_CLOSED>
  74. The QUIC connection to which the stream belongs was closed. You can obtain
  75. information about the circumstances of this closure using
  76. L<SSL_get_conn_close_info(3)>. There may still be residual data available to
  77. read via L<SSL_read(3)> when this state is returned. Calls to L<SSL_write(3)>
  78. will fail. SSL_get_stream_read_state() will return this state if and only if
  79. SSL_get_stream_write_state() will also return this state.
  80. =back
  81. SSL_get_stream_read_error_code() and SSL_get_stream_write_error_code() provide
  82. the application error code which was signalled during non-normal termination of
  83. the receiving or sending parts of a stream, respectively. On success, the
  84. application error code is written to I<*app_error_code>.
  85. =head1 NOTES
  86. If a QUIC connection is closed, the stream state for all streams transitions to
  87. B<SSL_STREAM_STATE_CONN_CLOSED>, but no application error code can be retrieved
  88. using SSL_get_stream_read_error_code() or SSL_get_stream_write_error_code(), as
  89. the QUIC connection closure process does not cause an application error code to
  90. be associated with each individual stream still existing at the time of
  91. connection closure. However, you can obtain the overall error code associated
  92. with the connection closure using L<SSL_get_conn_close_info(3)>.
  93. =head1 RETURN VALUES
  94. SSL_get_stream_read_state() and SSL_get_stream_write_state() return one of the
  95. B<SSL_STREAM_STATE> values. If called on a non-QUIC SSL object, or a QUIC
  96. connection SSL object without a default stream, B<SSL_STREAM_STATE_NONE> is
  97. returned.
  98. SSL_get_stream_read_error_code() and SSL_get_stream_write_error_code() return 1
  99. on success and 0 if the stream was terminated normally. They return -1 on error,
  100. for example if the stream is still healthy, was still healthy at the time of
  101. connection closure, if called on a stream for which the respective stream part
  102. does not exist (e.g. on a unidirectional stream), or if called on a non-QUIC
  103. object or a QUIC connection SSL object without a default stream attached.
  104. =head1 SEE ALSO
  105. L<SSL_stream_conclude(3)>, L<SSL_stream_reset(3)>, L<SSL_new_stream(3)>,
  106. L<SSL_accept_stream(3)>, L<SSL_get_conn_close_info(3)>
  107. =head1 HISTORY
  108. These functions were added in OpenSSL 3.2.
  109. =head1 COPYRIGHT
  110. Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
  111. Licensed under the Apache License 2.0 (the "License"). You may not use
  112. this file except in compliance with the License. You can obtain a copy
  113. in the file LICENSE in the source distribution or at
  114. L<https://www.openssl.org/source/license.html>.
  115. =cut