blob: 9974139d954a30f2a5f30a842f37449ca1a44992 [file] [log] [blame]
David Benjamin43ec06f2014-08-05 02:28:57 -04001/* 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
15#ifndef HEADER_ASYNC_BIO
16#define HEADER_ASYNC_BIO
17
18#include <openssl/bio.h>
19
20
David Benjaminc273d2c2015-02-09 12:59:46 -050021// AsyncBioCreate creates a filter BIO for testing asynchronous state
David Benjamin6fd297b2014-08-11 18:43:38 -040022// machines which consume a stream socket. Reads and writes will fail
23// and return EAGAIN unless explicitly allowed. Each async BIO has a
24// read quota and a write quota. Initially both are zero. As each is
25// incremented, bytes are allowed to flow through the BIO.
Matt Braithwaited17d74d2016-08-17 20:10:28 -070026bssl::UniquePtr<BIO> AsyncBioCreate();
David Benjamin43ec06f2014-08-05 02:28:57 -040027
David Benjaminc273d2c2015-02-09 12:59:46 -050028// AsyncBioCreateDatagram creates a filter BIO for testing for
David Benjamin6fd297b2014-08-11 18:43:38 -040029// asynchronous state machines which consume datagram sockets. The read
30// and write quota count in packets rather than bytes.
Matt Braithwaited17d74d2016-08-17 20:10:28 -070031bssl::UniquePtr<BIO> AsyncBioCreateDatagram();
David Benjamin43ec06f2014-08-05 02:28:57 -040032
David Benjaminc273d2c2015-02-09 12:59:46 -050033// AsyncBioAllowRead increments |bio|'s read quota by |count|.
34void AsyncBioAllowRead(BIO *bio, size_t count);
David Benjamin6fd297b2014-08-11 18:43:38 -040035
David Benjaminc273d2c2015-02-09 12:59:46 -050036// AsyncBioAllowWrite increments |bio|'s write quota by |count|.
37void AsyncBioAllowWrite(BIO *bio, size_t count);
David Benjamin43ec06f2014-08-05 02:28:57 -040038
David Benjamin13e81fc2015-11-02 17:16:13 -050039// AsyncBioEnforceWriteQuota configures where |bio| enforces its write quota.
40void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce);
41
David Benjamin43ec06f2014-08-05 02:28:57 -040042
43#endif // HEADER_ASYNC_BIO