Bladeren bron

Use just one style for the shim.

It's currently a mix of GoogleCPlusPlusStyle and unix_hacker_style. Since it's
now been thoroughly C++-ified, let's go with the former. This also matches the
tool, our other bit of C++ code.

Change-Id: Ie90a166006aae3b8f41628dbb35fcd64e99205df
Reviewed-on: https://boringssl-review.googlesource.com/3348
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin 9 jaren geleden
committed by Adam Langley
bovenliggende
commit
c273d2c537
5 gewijzigde bestanden met toevoegingen van 128 en 136 verwijderingen
  1. +30
    -30
      ssl/test/async_bio.cc
  2. +8
    -8
      ssl/test/async_bio.h
  3. +72
    -80
      ssl/test/bssl_shim.cc
  4. +16
    -16
      ssl/test/packeted_bio.cc
  5. +2
    -2
      ssl/test/packeted_bio.h

+ 30
- 30
ssl/test/async_bio.cc Bestand weergeven

@@ -22,23 +22,23 @@

namespace {

extern const BIO_METHOD async_bio_method;
extern const BIO_METHOD g_async_bio_method;

struct async_bio {
struct AsyncBio {
bool datagram;
size_t read_quota;
size_t write_quota;
};

async_bio *get_data(BIO *bio) {
if (bio->method != &async_bio_method) {
AsyncBio *GetData(BIO *bio) {
if (bio->method != &g_async_bio_method) {
return NULL;
}
return (async_bio *)bio->ptr;
return (AsyncBio *)bio->ptr;
}

static int async_write(BIO *bio, const char *in, int inl) {
async_bio *a = get_data(bio);
static int AsyncWrite(BIO *bio, const char *in, int inl) {
AsyncBio *a = GetData(bio);
if (a == NULL || bio->next_bio == NULL) {
return 0;
}
@@ -69,8 +69,8 @@ static int async_write(BIO *bio, const char *in, int inl) {
return ret;
}

static int async_read(BIO *bio, char *out, int outl) {
async_bio *a = get_data(bio);
static int AsyncRead(BIO *bio, char *out, int outl) {
AsyncBio *a = GetData(bio);
if (a == NULL || bio->next_bio == NULL) {
return 0;
}
@@ -95,7 +95,7 @@ static int async_read(BIO *bio, char *out, int outl) {
return ret;
}

static long async_ctrl(BIO *bio, int cmd, long num, void *ptr) {
static long AsyncCtrl(BIO *bio, int cmd, long num, void *ptr) {
if (bio->next_bio == NULL) {
return 0;
}
@@ -105,8 +105,8 @@ static long async_ctrl(BIO *bio, int cmd, long num, void *ptr) {
return ret;
}

static int async_new(BIO *bio) {
async_bio *a = (async_bio *)OPENSSL_malloc(sizeof(*a));
static int AsyncNew(BIO *bio) {
AsyncBio *a = (AsyncBio *)OPENSSL_malloc(sizeof(*a));
if (a == NULL) {
return 0;
}
@@ -116,7 +116,7 @@ static int async_new(BIO *bio) {
return 1;
}

static int async_free(BIO *bio) {
static int AsyncFree(BIO *bio) {
if (bio == NULL) {
return 0;
}
@@ -128,51 +128,51 @@ static int async_free(BIO *bio) {
return 1;
}

static long async_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
static long AsyncCallbackCtrl(BIO *bio, int cmd, bio_info_cb fp) {
if (bio->next_bio == NULL) {
return 0;
}
return BIO_callback_ctrl(bio->next_bio, cmd, fp);
}

const BIO_METHOD async_bio_method = {
const BIO_METHOD g_async_bio_method = {
BIO_TYPE_FILTER,
"async bio",
async_write,
async_read,
AsyncWrite,
AsyncRead,
NULL /* puts */,
NULL /* gets */,
async_ctrl,
async_new,
async_free,
async_callback_ctrl,
AsyncCtrl,
AsyncNew,
AsyncFree,
AsyncCallbackCtrl,
};

} // namespace

ScopedBIO async_bio_create() {
return ScopedBIO(BIO_new(&async_bio_method));
ScopedBIO AsyncBioCreate() {
return ScopedBIO(BIO_new(&g_async_bio_method));
}

ScopedBIO async_bio_create_datagram() {
ScopedBIO ret(BIO_new(&async_bio_method));
ScopedBIO AsyncBioCreateDatagram() {
ScopedBIO ret(BIO_new(&g_async_bio_method));
if (!ret) {
return nullptr;
}
get_data(ret.get())->datagram = true;
GetData(ret.get())->datagram = true;
return ret;
}

void async_bio_allow_read(BIO *bio, size_t count) {
async_bio *a = get_data(bio);
void AsyncBioAllowRead(BIO *bio, size_t count) {
AsyncBio *a = GetData(bio);
if (a == NULL) {
return;
}
a->read_quota += count;
}

void async_bio_allow_write(BIO *bio, size_t count) {
async_bio *a = get_data(bio);
void AsyncBioAllowWrite(BIO *bio, size_t count) {
AsyncBio *a = GetData(bio);
if (a == NULL) {
return;
}


+ 8
- 8
ssl/test/async_bio.h Bestand weergeven

@@ -20,23 +20,23 @@
#include "scoped_types.h"


// async_bio_create creates a filter BIO for testing asynchronous state
// AsyncBioCreate creates a filter BIO for testing asynchronous state
// machines which consume a stream socket. Reads and writes will fail
// and return EAGAIN unless explicitly allowed. Each async BIO has a
// read quota and a write quota. Initially both are zero. As each is
// incremented, bytes are allowed to flow through the BIO.
ScopedBIO async_bio_create();
ScopedBIO AsyncBioCreate();

// async_bio_create_datagram creates a filter BIO for testing for
// AsyncBioCreateDatagram creates a filter BIO for testing for
// asynchronous state machines which consume datagram sockets. The read
// and write quota count in packets rather than bytes.
ScopedBIO async_bio_create_datagram();
ScopedBIO AsyncBioCreateDatagram();

// async_bio_allow_read increments |bio|'s read quota by |count|.
void async_bio_allow_read(BIO *bio, size_t count);
// AsyncBioAllowRead increments |bio|'s read quota by |count|.
void AsyncBioAllowRead(BIO *bio, size_t count);

// async_bio_allow_write increments |bio|'s write quota by |count|.
void async_bio_allow_write(BIO *bio, size_t count);
// AsyncBioAllowWrite increments |bio|'s write quota by |count|.
void AsyncBioAllowWrite(BIO *bio, size_t count);


#endif // HEADER_ASYNC_BIO

+ 72
- 80
ssl/test/bssl_shim.cc Bestand weergeven

@@ -35,7 +35,7 @@
#include "scoped_types.h"
#include "test_config.h"

static int usage(const char *program) {
static int Usage(const char *program) {
fprintf(stderr, "Usage: %s [flags...]\n", program);
return 1;
}
@@ -110,10 +110,10 @@ static bool InstallCertificate(SSL *ssl) {
return true;
}

static int early_callback_called = 0;
static int g_early_callback_called = 0;

static int select_certificate_callback(const struct ssl_early_callback_ctx *ctx) {
early_callback_called = 1;
static int SelectCertificateCallback(const struct ssl_early_callback_ctx *ctx) {
g_early_callback_called = 1;

const TestConfig *config = GetConfigPtr(ctx->ssl);

@@ -153,47 +153,40 @@ static int select_certificate_callback(const struct ssl_early_callback_ctx *ctx)
return 1;
}

static int skip_verify(int preverify_ok, X509_STORE_CTX *store_ctx) {
static int SkipVerify(int preverify_ok, X509_STORE_CTX *store_ctx) {
return 1;
}

static int next_protos_advertised_callback(SSL *ssl,
const uint8_t **out,
unsigned int *out_len,
void *arg) {
static int NextProtosAdvertisedCallback(SSL *ssl, const uint8_t **out,
unsigned int *out_len, void *arg) {
const TestConfig *config = GetConfigPtr(ssl);
if (config->advertise_npn.empty())
if (config->advertise_npn.empty()) {
return SSL_TLSEXT_ERR_NOACK;
}

*out = (const uint8_t*)config->advertise_npn.data();
*out_len = config->advertise_npn.size();
return SSL_TLSEXT_ERR_OK;
}

static int next_proto_select_callback(SSL* ssl,
uint8_t** out,
uint8_t* outlen,
const uint8_t* in,
unsigned inlen,
void* arg) {
static int NextProtoSelectCallback(SSL* ssl, uint8_t** out, uint8_t* outlen,
const uint8_t* in, unsigned inlen, void* arg) {
const TestConfig *config = GetConfigPtr(ssl);
if (config->select_next_proto.empty())
if (config->select_next_proto.empty()) {
return SSL_TLSEXT_ERR_NOACK;
}

*out = (uint8_t*)config->select_next_proto.data();
*outlen = config->select_next_proto.size();
return SSL_TLSEXT_ERR_OK;
}

static int alpn_select_callback(SSL* ssl,
const uint8_t** out,
uint8_t* outlen,
const uint8_t* in,
unsigned inlen,
void* arg) {
static int AlpnSelectCallback(SSL* ssl, const uint8_t** out, uint8_t* outlen,
const uint8_t* in, unsigned inlen, void* arg) {
const TestConfig *config = GetConfigPtr(ssl);
if (config->select_alpn.empty())
if (config->select_alpn.empty()) {
return SSL_TLSEXT_ERR_NOACK;
}

if (!config->expected_advertised_alpn.empty() &&
(config->expected_advertised_alpn.size() != inlen ||
@@ -208,7 +201,8 @@ static int alpn_select_callback(SSL* ssl,
return SSL_TLSEXT_ERR_OK;
}

static int cookie_generate_callback(SSL *ssl, uint8_t *cookie, size_t *cookie_len) {
static int CookieGenerateCallback(SSL *ssl, uint8_t *cookie,
size_t *cookie_len) {
if (*cookie_len < 32) {
fprintf(stderr, "Insufficient space for cookie\n");
return 0;
@@ -218,7 +212,8 @@ static int cookie_generate_callback(SSL *ssl, uint8_t *cookie, size_t *cookie_le
return 1;
}

static int cookie_verify_callback(SSL *ssl, const uint8_t *cookie, size_t cookie_len) {
static int CookieVerifyCallback(SSL *ssl, const uint8_t *cookie,
size_t cookie_len) {
if (cookie_len != 32) {
fprintf(stderr, "Cookie length mismatch.\n");
return 0;
@@ -232,10 +227,10 @@ static int cookie_verify_callback(SSL *ssl, const uint8_t *cookie, size_t cookie
return 1;
}

static unsigned psk_client_callback(SSL *ssl, const char *hint,
char *out_identity,
unsigned max_identity_len,
uint8_t *out_psk, unsigned max_psk_len) {
static unsigned PskClientCallback(SSL *ssl, const char *hint,
char *out_identity,
unsigned max_identity_len,
uint8_t *out_psk, unsigned max_psk_len) {
const TestConfig *config = GetConfigPtr(ssl);

if (strcmp(hint ? hint : "", config->psk_identity.c_str()) != 0) {
@@ -256,8 +251,8 @@ static unsigned psk_client_callback(SSL *ssl, const char *hint,
return config->psk.size();
}

static unsigned psk_server_callback(SSL *ssl, const char *identity,
uint8_t *out_psk, unsigned max_psk_len) {
static unsigned PskServerCallback(SSL *ssl, const char *identity,
uint8_t *out_psk, unsigned max_psk_len) {
const TestConfig *config = GetConfigPtr(ssl);

if (strcmp(identity, config->psk_identity.c_str()) != 0) {
@@ -274,15 +269,15 @@ static unsigned psk_server_callback(SSL *ssl, const char *identity,
return config->psk.size();
}

static void current_time_cb(SSL *ssl, OPENSSL_timeval *out_clock) {
static void CurrentTimeCallback(SSL *ssl, OPENSSL_timeval *out_clock) {
*out_clock = *GetClockPtr(ssl);
}

static void channel_id_callback(SSL *ssl, EVP_PKEY **out_pkey) {
static void ChannelIdCallback(SSL *ssl, EVP_PKEY **out_pkey) {
*out_pkey = GetAsyncState(ssl)->channel_id.release();
}

static int cert_callback(SSL *ssl, void *arg) {
static int CertCallback(SSL *ssl, void *arg) {
if (!GetAsyncState(ssl)->cert_ready) {
return -1;
}
@@ -292,8 +287,8 @@ static int cert_callback(SSL *ssl, void *arg) {
return 1;
}

static SSL_SESSION *get_session_callback(SSL *ssl, uint8_t *data, int len,
int *copy) {
static SSL_SESSION *GetSessionCallback(SSL *ssl, uint8_t *data, int len,
int *copy) {
AsyncState *async_state = GetAsyncState(ssl);
if (async_state->session) {
*copy = 0;
@@ -305,7 +300,7 @@ static SSL_SESSION *get_session_callback(SSL *ssl, uint8_t *data, int len,
}
}

static ScopedSSL_CTX setup_ctx(const TestConfig *config) {
static ScopedSSL_CTX SetupCtx(const TestConfig *config) {
ScopedSSL_CTX ssl_ctx(SSL_CTX_new(
config->is_dtls ? DTLS_method() : TLS_method()));
if (!ssl_ctx) {
@@ -338,37 +333,37 @@ static ScopedSSL_CTX setup_ctx(const TestConfig *config) {
// we use an external session cache.
SSL_CTX_set_session_cache_mode(
ssl_ctx.get(), SSL_SESS_CACHE_BOTH | SSL_SESS_CACHE_NO_INTERNAL);
SSL_CTX_sess_set_get_cb(ssl_ctx.get(), get_session_callback);
SSL_CTX_sess_set_get_cb(ssl_ctx.get(), GetSessionCallback);
} else {
SSL_CTX_set_session_cache_mode(ssl_ctx.get(), SSL_SESS_CACHE_BOTH);
}

ssl_ctx->select_certificate_cb = select_certificate_callback;
ssl_ctx->select_certificate_cb = SelectCertificateCallback;

SSL_CTX_set_next_protos_advertised_cb(
ssl_ctx.get(), next_protos_advertised_callback, NULL);
ssl_ctx.get(), NextProtosAdvertisedCallback, NULL);
if (!config->select_next_proto.empty()) {
SSL_CTX_set_next_proto_select_cb(ssl_ctx.get(), next_proto_select_callback,
SSL_CTX_set_next_proto_select_cb(ssl_ctx.get(), NextProtoSelectCallback,
NULL);
}

if (!config->select_alpn.empty()) {
SSL_CTX_set_alpn_select_cb(ssl_ctx.get(), alpn_select_callback, NULL);
SSL_CTX_set_alpn_select_cb(ssl_ctx.get(), AlpnSelectCallback, NULL);
}

SSL_CTX_set_cookie_generate_cb(ssl_ctx.get(), cookie_generate_callback);
SSL_CTX_set_cookie_verify_cb(ssl_ctx.get(), cookie_verify_callback);
SSL_CTX_set_cookie_generate_cb(ssl_ctx.get(), CookieGenerateCallback);
SSL_CTX_set_cookie_verify_cb(ssl_ctx.get(), CookieVerifyCallback);

ssl_ctx->tlsext_channel_id_enabled_new = 1;
SSL_CTX_set_channel_id_cb(ssl_ctx.get(), channel_id_callback);
SSL_CTX_set_channel_id_cb(ssl_ctx.get(), ChannelIdCallback);

ssl_ctx->current_time_cb = current_time_cb;
ssl_ctx->current_time_cb = CurrentTimeCallback;

return ssl_ctx;
}

static int retry_async(SSL *ssl, int ret, BIO *async,
OPENSSL_timeval *clock_delta) {
static int RetryAsync(SSL *ssl, int ret, BIO *async,
OPENSSL_timeval *clock_delta) {
// No error; don't retry.
if (ret >= 0) {
return 0;
@@ -394,10 +389,10 @@ static int retry_async(SSL *ssl, int ret, BIO *async,
// the appropriate end to maximally stress the state machine.
switch (SSL_get_error(ssl, ret)) {
case SSL_ERROR_WANT_READ:
async_bio_allow_read(async, 1);
AsyncBioAllowRead(async, 1);
return 1;
case SSL_ERROR_WANT_WRITE:
async_bio_allow_write(async, 1);
AsyncBioAllowWrite(async, 1);
return 1;
case SSL_ERROR_WANT_CHANNEL_ID_LOOKUP:
GetAsyncState(ssl)->channel_id =
@@ -415,13 +410,10 @@ static int retry_async(SSL *ssl, int ret, BIO *async,
}
}

static int do_exchange(ScopedSSL_SESSION *out_session,
SSL_CTX *ssl_ctx,
const TestConfig *config,
bool is_resume,
int fd,
SSL_SESSION *session) {
early_callback_called = 0;
static int DoExchange(ScopedSSL_SESSION *out_session, SSL_CTX *ssl_ctx,
const TestConfig *config, bool is_resume,
int fd, SSL_SESSION *session) {
g_early_callback_called = 0;

OPENSSL_timeval clock = {0}, clock_delta = {0};
ScopedSSL ssl(SSL_new(ssl_ctx));
@@ -446,14 +438,14 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
if (config->async) {
// TODO(davidben): Also test |s->ctx->client_cert_cb| on the client and
// |s->ctx->select_certificate_cb| on the server.
SSL_set_cert_cb(ssl.get(), cert_callback, NULL);
SSL_set_cert_cb(ssl.get(), CertCallback, NULL);
} else if (!InstallCertificate(ssl.get())) {
BIO_print_errors_fp(stdout);
return 1;
}
if (config->require_any_client_certificate) {
SSL_set_verify(ssl.get(), SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
skip_verify);
SkipVerify);
}
if (config->false_start) {
SSL_set_mode(ssl.get(), SSL_MODE_HANDSHAKE_CUTTHROUGH);
@@ -491,7 +483,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
if (!config->send_channel_id.empty()) {
SSL_enable_tls_channel_id(ssl.get());
if (!config->async) {
// The async case will be supplied by |channel_id_callback|.
// The async case will be supplied by |ChannelIdCallback|.
ScopedEVP_PKEY pkey = LoadPrivateKey(config->send_channel_id);
if (!pkey || !SSL_set1_tls_channel_id(ssl.get(), pkey.get())) {
BIO_print_errors_fp(stdout);
@@ -507,8 +499,8 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
config->advertise_alpn.size());
}
if (!config->psk.empty()) {
SSL_set_psk_client_callback(ssl.get(), psk_client_callback);
SSL_set_psk_server_callback(ssl.get(), psk_server_callback);
SSL_set_psk_client_callback(ssl.get(), PskClientCallback);
SSL_set_psk_server_callback(ssl.get(), PskServerCallback);
}
if (!config->psk_identity.empty() &&
!SSL_use_psk_identity_hint(ssl.get(), config->psk_identity.c_str())) {
@@ -548,14 +540,14 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
return 1;
}
if (config->is_dtls) {
ScopedBIO packeted = packeted_bio_create(&clock_delta);
ScopedBIO packeted = PacketedBioCreate(&clock_delta);
BIO_push(packeted.get(), bio.release());
bio = std::move(packeted);
}
BIO *async = NULL;
if (config->async) {
ScopedBIO async_scoped =
config->is_dtls ? async_bio_create_datagram() : async_bio_create();
config->is_dtls ? AsyncBioCreateDatagram() : AsyncBioCreate();
BIO_push(async_scoped.get(), bio.release());
async = async_scoped.get();
bio = std::move(async_scoped);
@@ -591,7 +583,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
} else {
ret = SSL_connect(ssl.get());
}
} while (config->async && retry_async(ssl.get(), ret, async, &clock_delta));
} while (config->async && RetryAsync(ssl.get(), ret, async, &clock_delta));
if (ret != 1) {
BIO_print_errors_fp(stdout);
return 2;
@@ -613,7 +605,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
return 2;
}

if (!early_callback_called) {
if (!g_early_callback_called) {
fprintf(stderr, "early callback not called\n");
return 2;
}
@@ -755,7 +747,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
if (w > 0) {
off += (size_t) w;
}
} while ((config->async && retry_async(ssl.get(), w, async, &clock_delta)) ||
} while ((config->async && RetryAsync(ssl.get(), w, async, &clock_delta)) ||
(w > 0 && off < len));

if (w < 0 || off != len) {
@@ -768,14 +760,14 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
int w;
do {
w = SSL_write(ssl.get(), "hello", 5);
} while (config->async && retry_async(ssl.get(), w, async, &clock_delta));
} while (config->async && RetryAsync(ssl.get(), w, async, &clock_delta));
}
for (;;) {
uint8_t buf[512];
int n;
do {
n = SSL_read(ssl.get(), buf, sizeof(buf));
} while (config->async && retry_async(ssl.get(), n, async, &clock_delta));
} while (config->async && RetryAsync(ssl.get(), n, async, &clock_delta));
int err = SSL_get_error(ssl.get(), n);
if (err == SSL_ERROR_ZERO_RETURN ||
(n == 0 && err == SSL_ERROR_SYSCALL)) {
@@ -783,8 +775,8 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
fprintf(stderr, "Invalid SSL_get_error output\n");
return 3;
}
/* Accept shutdowns with or without close_notify.
* TODO(davidben): Write tests which distinguish these two cases. */
// Accept shutdowns with or without close_notify.
// TODO(davidben): Write tests which distinguish these two cases.
break;
} else if (err != SSL_ERROR_NONE) {
if (n > 0) {
@@ -794,7 +786,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
BIO_print_errors_fp(stdout);
return 3;
}
/* Successfully read data. */
// Successfully read data.
if (n <= 0) {
fprintf(stderr, "Invalid SSL_get_error output\n");
return 3;
@@ -805,7 +797,7 @@ static int do_exchange(ScopedSSL_SESSION *out_session,
int w;
do {
w = SSL_write(ssl.get(), buf, n);
} while (config->async && retry_async(ssl.get(), w, async, &clock_delta));
} while (config->async && RetryAsync(ssl.get(), w, async, &clock_delta));
if (w != n) {
BIO_print_errors_fp(stdout);
return 4;
@@ -838,25 +830,25 @@ int main(int argc, char **argv) {

TestConfig config;
if (!ParseConfig(argc - 1, argv + 1, &config)) {
return usage(argv[0]);
return Usage(argv[0]);
}

ScopedSSL_CTX ssl_ctx = setup_ctx(&config);
ScopedSSL_CTX ssl_ctx = SetupCtx(&config);
if (!ssl_ctx) {
BIO_print_errors_fp(stdout);
return 1;
}

ScopedSSL_SESSION session;
int ret = do_exchange(&session, ssl_ctx.get(), &config, false /* is_resume */,
3 /* fd */, NULL /* session */);
int ret = DoExchange(&session, ssl_ctx.get(), &config, false /* is_resume */,
3 /* fd */, NULL /* session */);
if (ret != 0) {
return ret;
}

if (config.resume) {
ret = do_exchange(NULL, ssl_ctx.get(), &config, true /* is_resume */,
4 /* fd */, session.get());
ret = DoExchange(NULL, ssl_ctx.get(), &config, true /* is_resume */,
4 /* fd */, session.get());
if (ret != 0) {
return ret;
}


+ 16
- 16
ssl/test/packeted_bio.cc Bestand weergeven

@@ -23,13 +23,13 @@

namespace {

extern const BIO_METHOD packeted_bio_method;
extern const BIO_METHOD g_packeted_bio_method;

const uint8_t kOpcodePacket = 'P';
const uint8_t kOpcodeTimeout = 'T';
const uint8_t kOpcodeTimeoutAck = 't';

static int packeted_write(BIO *bio, const char *in, int inl) {
static int PacketedWrite(BIO *bio, const char *in, int inl) {
if (bio->next_bio == NULL) {
return 0;
}
@@ -55,7 +55,7 @@ static int packeted_write(BIO *bio, const char *in, int inl) {
return ret;
}

static int packeted_read(BIO *bio, char *out, int outl) {
static int PacketedRead(BIO *bio, char *out, int outl) {
if (bio->next_bio == NULL) {
return 0;
}
@@ -138,7 +138,7 @@ static int packeted_read(BIO *bio, char *out, int outl) {
return outl;
}

static long packeted_ctrl(BIO *bio, int cmd, long num, void *ptr) {
static long PacketedCtrl(BIO *bio, int cmd, long num, void *ptr) {
if (bio->next_bio == NULL) {
return 0;
}
@@ -148,12 +148,12 @@ static long packeted_ctrl(BIO *bio, int cmd, long num, void *ptr) {
return ret;
}

static int packeted_new(BIO *bio) {
static int PacketedNew(BIO *bio) {
bio->init = 1;
return 1;
}

static int packeted_free(BIO *bio) {
static int PacketedFree(BIO *bio) {
if (bio == NULL) {
return 0;
}
@@ -162,30 +162,30 @@ static int packeted_free(BIO *bio) {
return 1;
}

static long packeted_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
static long PacketedCallbackCtrl(BIO *bio, int cmd, bio_info_cb fp) {
if (bio->next_bio == NULL) {
return 0;
}
return BIO_callback_ctrl(bio->next_bio, cmd, fp);
}

const BIO_METHOD packeted_bio_method = {
const BIO_METHOD g_packeted_bio_method = {
BIO_TYPE_FILTER,
"packeted bio",
packeted_write,
packeted_read,
PacketedWrite,
PacketedRead,
NULL /* puts */,
NULL /* gets */,
packeted_ctrl,
packeted_new,
packeted_free,
packeted_callback_ctrl,
PacketedCtrl,
PacketedNew,
PacketedFree,
PacketedCallbackCtrl,
};

} // namespace

ScopedBIO packeted_bio_create(OPENSSL_timeval *out_timeout) {
ScopedBIO bio(BIO_new(&packeted_bio_method));
ScopedBIO PacketedBioCreate(OPENSSL_timeval *out_timeout) {
ScopedBIO bio(BIO_new(&g_packeted_bio_method));
bio->ptr = out_timeout;
return bio;
}

+ 2
- 2
ssl/test/packeted_bio.h Bestand weergeven

@@ -21,7 +21,7 @@
#include "scoped_types.h"


// packeted_bio_create creates a filter BIO which implements a reliable in-order
// PacketedBioCreate creates a filter BIO which implements a reliable in-order
// blocking datagram socket. The resulting BIO, on |BIO_read|, may simulate a
// timeout which sets |*out_timeout| to the timeout and fails the read.
// |*out_timeout| must be zero on entry to |BIO_read|; it is an error to not
@@ -30,7 +30,7 @@
// Note: The read timeout simulation is intended to be used with the async BIO
// wrapper. It doesn't simulate BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, used in DTLS's
// blocking mode.
ScopedBIO packeted_bio_create(OPENSSL_timeval *out_timeout);
ScopedBIO PacketedBioCreate(OPENSSL_timeval *out_timeout);


#endif // HEADER_PACKETED_BIO

Laden…
Annuleren
Opslaan