packeted_bio.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef HEADER_PACKETED_BIO
  10. #define HEADER_PACKETED_BIO
  11. #include <openssl/base.h>
  12. #include <openssl/bio.h>
  13. #if defined(OPENSSL_SYS_WINDOWS)
  14. OPENSSL_MSVC_PRAGMA(warning(push, 3))
  15. #include <winsock2.h>
  16. OPENSSL_MSVC_PRAGMA(warning(pop))
  17. #else
  18. #include <sys/time.h>
  19. #endif
  20. // PacketedBioCreate creates a filter BIO which implements a reliable in-order
  21. // blocking datagram socket. It internally maintains a clock and honors
  22. // |BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT| based on it.
  23. //
  24. // During a |BIO_read|, the peer may signal the filter BIO to simulate a
  25. // timeout. If |advance_clock| is true, it automatically advances the clock and
  26. // continues reading, subject to the read deadline. Otherwise, it fails
  27. // immediately. The caller must then call |PacketedBioAdvanceClock| before
  28. // retrying |BIO_read|.
  29. bssl::UniquePtr<BIO> PacketedBioCreate(bool advance_clock);
  30. // PacketedBioGetClock returns the current time for |bio|.
  31. timeval PacketedBioGetClock(const BIO *bio);
  32. // PacketedBioAdvanceClock advances |bio|'s internal clock and returns true if
  33. // there is a pending timeout. Otherwise, it returns false.
  34. bool PacketedBioAdvanceClock(BIO *bio);
  35. #endif // HEADER_PACKETED_BIO