BIO_get_rpoll_descriptor.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. =pod
  2. =head1 NAME
  3. BIO_get_rpoll_descriptor, BIO_get_wpoll_descriptor - obtain a structure which
  4. can be used to determine when a BIO object can next be read or written
  5. =head1 SYNOPSIS
  6. #include <openssl/bio.h>
  7. typedef struct bio_poll_descriptor_st {
  8. uint32_t type;
  9. union {
  10. int fd;
  11. void *custom;
  12. uintptr_t custom_ui;
  13. } value;
  14. } BIO_POLL_DESCRIPTOR;
  15. int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
  16. int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
  17. =head1 DESCRIPTION
  18. BIO_get_rpoll_descriptor() and BIO_get_wpoll_descriptor(), on success, fill
  19. I<*desc> with a poll descriptor. A poll descriptor is a tagged union structure
  20. which represents some kind of OS or non-OS resource which can be used to
  21. synchronise on I/O availability events.
  22. BIO_get_rpoll_descriptor() outputs a descriptor which can be used to determine
  23. when the BIO can (potentially) next be read, and BIO_get_wpoll_descriptor()
  24. outputs a descriptor which can be used to determine when the BIO can
  25. (potentially) next be written.
  26. It is permissible for BIO_get_rpoll_descriptor() and BIO_get_wpoll_descriptor()
  27. to output the same descriptor.
  28. Poll descriptors can represent different kinds of information. A typical kind of
  29. resource which might be represented by a poll descriptor is an OS file
  30. descriptor which can be used with APIs such as select().
  31. The kinds of poll descriptor defined by OpenSSL are:
  32. =over 4
  33. =item BIO_POLL_DESCRIPTOR_TYPE_NONE
  34. Represents the absence of a valid poll descriptor. It may be used by
  35. BIO_get_rpoll_descriptor() or BIO_get_wpoll_descriptor() to indicate that the
  36. BIO is not pollable for readability or writeability respectively.
  37. For this type, no field within the I<value> field of the B<BIO_POLL_DESCRIPTOR>
  38. is valid.
  39. =item BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD
  40. The poll descriptor represents an OS socket resource. The field I<value.fd>
  41. in the B<BIO_POLL_DESCRIPTOR> is valid if it is not set to -1.
  42. The resource is whatever kind of handle is used by a given OS to represent
  43. sockets, which may vary by OS. For example, on Windows, the value is a B<SOCKET>
  44. for use with the Winsock API. On POSIX-like platforms, it is a file descriptor.
  45. Where a poll descriptor of this type is output by BIO_get_rpoll_descriptor(), it
  46. should be polled for readability to determine when the BIO might next be able to
  47. successfully complete a BIO_read() operation; likewise, where a poll descriptor
  48. of this type is output by BIO_get_wpoll_descriptor(), it should be polled for
  49. writeability to determine when the BIO might next be able to successfully
  50. complete a BIO_write() operation.
  51. =item BIO_POLL_DESCRIPTOR_CUSTOM_START
  52. Type values beginning with this value (inclusive) are reserved for application
  53. allocation for custom poll descriptor types. Any of the definitions in the union
  54. field I<value> can be used by the application arbitrarily as opaque values.
  55. =back
  56. Because poll descriptors are a tagged union structure, they can represent
  57. different kinds of information. New types of poll descriptor may be defined,
  58. including by applications, according to their needs.
  59. =head1 RETURN VALUES
  60. The functions BIO_get_rpoll_descriptor() and BIO_get_wpoll_descriptor() return 1
  61. on success and 0 on failure.
  62. These functions are permitted to succeed and initialise I<*desc> with a poll
  63. descriptor of type B<BIO_POLL_DESCRIPTOR_TYPE_NONE> to indicate that the BIO is
  64. not pollable for readability or writeability respectively.
  65. =head1 SEE ALSO
  66. L<SSL_handle_events(3)>, L<SSL_get_event_timeout(3)>, L<SSL_get_rpoll_descriptor(3)>,
  67. L<SSL_get_wpoll_descriptor(3)>, L<bio(7)>
  68. =head1 HISTORY
  69. The SSL_get_rpoll_descriptor() and SSL_get_wpoll_descriptor() functions were
  70. added in OpenSSL 3.2.
  71. =head1 COPYRIGHT
  72. Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
  73. Licensed under the Apache License 2.0 (the "License"). You may not use
  74. this file except in compliance with the License. You can obtain a copy
  75. in the file LICENSE in the source distribution or at
  76. L<https://www.openssl.org/source/license.html>.
  77. =cut