diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-03-28 08:21:25 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2023-05-01 11:03:54 +0100 |
commit | b633cf876435f094e4944f30be4dbbc70115f230 (patch) | |
tree | 748acf8d2c7775b090b3ebee6825ff4e2cec84d6 /test | |
parent | 422368aebd908d6966639597aab786ee12eb62f1 (diff) |
QUIC CC: Move dummy method to test code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20423)
Diffstat (limited to 'test')
-rw-r--r-- | test/build.info | 6 | ||||
-rw-r--r-- | test/cc_dummy.c | 127 |
2 files changed, 130 insertions, 3 deletions
diff --git a/test/build.info b/test/build.info index b3588040c2..4de1c19d4d 100644 --- a/test/build.info +++ b/test/build.info @@ -324,11 +324,11 @@ IF[{- !$disabled{tests} -}] INCLUDE[quic_txpim_test]=../include ../apps/include DEPEND[quic_txpim_test]=../libcrypto.a ../libssl.a libtestutil.a - SOURCE[quic_fifd_test]=quic_fifd_test.c + SOURCE[quic_fifd_test]=quic_fifd_test.c cc_dummy.c INCLUDE[quic_fifd_test]=../include ../apps/include DEPEND[quic_fifd_test]=../libcrypto.a ../libssl.a libtestutil.a - SOURCE[quic_txp_test]=quic_txp_test.c + SOURCE[quic_txp_test]=quic_txp_test.c cc_dummy.c INCLUDE[quic_txp_test]=../include ../apps/include DEPEND[quic_txp_test]=../libcrypto.a ../libssl.a libtestutil.a @@ -1091,7 +1091,7 @@ ENDIF PROGRAMS{noinst}=quic_client_test quic_cc_test ENDIF - SOURCE[quic_ackm_test]=quic_ackm_test.c + SOURCE[quic_ackm_test]=quic_ackm_test.c cc_dummy.c INCLUDE[quic_ackm_test]=../include ../apps/include DEPEND[quic_ackm_test]=../libcrypto.a ../libssl.a libtestutil.a diff --git a/test/cc_dummy.c b/test/cc_dummy.c new file mode 100644 index 0000000000..af0d548379 --- /dev/null +++ b/test/cc_dummy.c @@ -0,0 +1,127 @@ +/* + * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/quic_cc.h" +#include "internal/quic_types.h" + +typedef struct ossl_cc_dummy_st { + size_t max_dgram_len; +} OSSL_CC_DUMMY; + +static OSSL_CC_DATA *dummy_new(OSSL_TIME (*now_cb)(void *arg), + void *now_cb_arg) +{ + OSSL_CC_DUMMY *d = OPENSSL_zalloc(sizeof(*d)); + + if (d == NULL) + return NULL; + + d->max_dgram_len = QUIC_MIN_INITIAL_DGRAM_LEN; + return (OSSL_CC_DATA *)d; +} + +static void dummy_free(OSSL_CC_DATA *cc) +{ + OPENSSL_free(cc); +} + +static void dummy_reset(OSSL_CC_DATA *cc) +{ + +} + +static int dummy_set_option_uint(OSSL_CC_DATA *cc, + uint32_t option_id, + uint64_t value) +{ + OSSL_CC_DUMMY *d = (OSSL_CC_DUMMY *)cc; + + switch (option_id) { + case OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN: + if (value > SIZE_MAX) + return 0; + + d->max_dgram_len = (size_t)value; + return 1; + + default: + return 0; + } +} + +static int dummy_get_option_uint(OSSL_CC_DATA *cc, + uint32_t option_id, + uint64_t *value) +{ + OSSL_CC_DUMMY *d = (OSSL_CC_DUMMY *)cc; + + switch (option_id) { + case OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN: + *value = (uint64_t)d->max_dgram_len; + return 1; + + default: + return 0; + } +} + +static uint64_t dummy_get_tx_allowance(OSSL_CC_DATA *cc) +{ + return SIZE_MAX; +} + +static OSSL_TIME dummy_get_wakeup_deadline(OSSL_CC_DATA *cc) +{ + return ossl_time_infinite(); +} + +static int dummy_on_data_sent(OSSL_CC_DATA *cc, + uint64_t num_bytes) +{ + return 1; +} + +static int dummy_on_data_acked(OSSL_CC_DATA *cc, + const OSSL_CC_ACK_INFO *info) +{ + return 1; +} + +static int dummy_on_data_lost(OSSL_CC_DATA *cc, + const OSSL_CC_LOSS_INFO *info) +{ + return 1; +} + +static int dummy_on_data_lost_finished(OSSL_CC_DATA *cc, + uint32_t flags) +{ + return 1; +} + +static int dummy_on_data_invalidated(OSSL_CC_DATA *cc, + uint64_t num_bytes) +{ + return 1; +} + +const OSSL_CC_METHOD ossl_cc_dummy_method = { + dummy_new, + dummy_free, + dummy_reset, + dummy_set_option_uint, + dummy_get_option_uint, + dummy_get_tx_allowance, + dummy_get_wakeup_deadline, + dummy_on_data_sent, + dummy_on_data_acked, + dummy_on_data_lost, + dummy_on_data_lost_finished, + dummy_on_data_invalidated, +}; |