| 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 |
|
| 15 |
#ifndef HEADER_ASYNC_BIO |
| 16 |
#define HEADER_ASYNC_BIO |
| 17 |
|
| 18 |
#include <openssl/bio.h> |
| 19 |
|
| 20 |
#include "../../crypto/test/scoped_types.h" |
| 21 |
|
| 22 |
|
| 23 |
// AsyncBioCreate creates a filter BIO for testing asynchronous state |
| 24 |
// machines which consume a stream socket. Reads and writes will fail |
| 25 |
// and return EAGAIN unless explicitly allowed. Each async BIO has a |
| 26 |
// read quota and a write quota. Initially both are zero. As each is |
| 27 |
// incremented, bytes are allowed to flow through the BIO. |
| 28 |
ScopedBIO AsyncBioCreate(); |
| 29 |
|
| 30 |
// AsyncBioCreateDatagram creates a filter BIO for testing for |
| 31 |
// asynchronous state machines which consume datagram sockets. The read |
| 32 |
// and write quota count in packets rather than bytes. |
| 33 |
ScopedBIO AsyncBioCreateDatagram(); |
| 34 |
|
| 35 |
// AsyncBioAllowRead increments |bio|'s read quota by |count|. |
| 36 |
void AsyncBioAllowRead(BIO *bio, size_t count); |
| 37 |
|
| 38 |
// AsyncBioAllowWrite increments |bio|'s write quota by |count|. |
| 39 |
void AsyncBioAllowWrite(BIO *bio, size_t count); |
| 40 |
|
| 41 |
// AsyncBioEnforceWriteQuota configures where |bio| enforces its write quota. |
| 42 |
void AsyncBioEnforceWriteQuota(BIO *bio, bool enforce); |
| 43 |
|
| 44 |
|
| 45 |
#endif // HEADER_ASYNC_BIO |