async_bio.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright 1995-2016 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 HEADER_ASYNC_BIO
  10. #define HEADER_ASYNC_BIO
  11. #include <openssl/base.h>
  12. #include <openssl/bio.h>
  13. // AsyncBioCreate creates a filter BIO for testing asynchronous state
  14. // machines which consume a stream socket. Reads and writes will fail
  15. // and return EAGAIN unless explicitly allowed. Each async BIO has a
  16. // read quota and a write quota. Initially both are zero. As each is
  17. // incremented, bytes are allowed to flow through the BIO.
  18. bssl::UniquePtr<BIO> AsyncBioCreate();
  19. // AsyncBioCreateDatagram creates a filter BIO for testing for
  20. // asynchronous state machines which consume datagram sockets. The read
  21. // and write quota count in packets rather than bytes.
  22. bssl::UniquePtr<BIO> AsyncBioCreateDatagram();
  23. // AsyncBioAllowRead increments |bio|'s read quota by |count|.
  24. void AsyncBioAllowRead(BIO *bio, size_t count);
  25. // AsyncBioAllowWrite increments |bio|'s write quota by |count|.
  26. void AsyncBioAllowWrite(BIO *bio, size_t count);
  27. // AsyncBioEnforceWriteQuota configures where |bio| enforces its write quota.
  28. void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce);
  29. #endif // HEADER_ASYNC_BIO