2
0

packeted_bio.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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 OSSL_TEST_SHIM_PACKETED_BIO_H
  10. #define OSSL_TEST_SHIM_PACKETED_BIO_H
  11. #include <openssl/base.h>
  12. #include <openssl/bio.h>
  13. // PacketedBioCreate creates a filter BIO which implements a reliable in-order
  14. // blocking datagram socket. It internally maintains a clock and honors
  15. // |BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT| based on it.
  16. //
  17. // During a |BIO_read|, the peer may signal the filter BIO to simulate a
  18. // timeout. If |advance_clock| is true, it automatically advances the clock and
  19. // continues reading, subject to the read deadline. Otherwise, it fails
  20. // immediately. The caller must then call |PacketedBioAdvanceClock| before
  21. // retrying |BIO_read|.
  22. bssl::UniquePtr<BIO> PacketedBioCreate(bool advance_clock);
  23. // PacketedBioGetClock returns the current time for |bio|.
  24. timeval PacketedBioGetClock(const BIO *bio);
  25. // PacketedBioAdvanceClock advances |bio|'s internal clock and returns true if
  26. // there is a pending timeout. Otherwise, it returns false.
  27. bool PacketedBioAdvanceClock(BIO *bio);
  28. #endif // OSSL_TEST_SHIM_PACKETED_BIO_H