packeted_bio.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Copyright (c) 2014, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #ifndef HEADER_PACKETED_BIO
  15. #define HEADER_PACKETED_BIO
  16. #include <openssl/base.h>
  17. #include <openssl/bio.h>
  18. #if defined(OPENSSL_WINDOWS)
  19. OPENSSL_MSVC_PRAGMA(warning(push, 3))
  20. #include <winsock2.h>
  21. OPENSSL_MSVC_PRAGMA(warning(pop))
  22. #else
  23. #include <sys/time.h>
  24. #endif
  25. // PacketedBioCreate creates a filter BIO which implements a reliable in-order
  26. // blocking datagram socket. It uses the value of |*clock| as the clock.
  27. //
  28. // During a |BIO_read|, the peer may signal the filter BIO to simulate a
  29. // timeout. The operation will fail immediately. The caller must then call
  30. // |PacketedBioAdvanceClock| before retrying |BIO_read|.
  31. bssl::UniquePtr<BIO> PacketedBioCreate(timeval *clock);
  32. // PacketedBioAdvanceClock advances |bio|'s clock and returns true if there is a
  33. // pending timeout. Otherwise, it returns false.
  34. bool PacketedBioAdvanceClock(BIO *bio);
  35. #endif // HEADER_PACKETED_BIO