Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions deps/ngtcp2/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ NGTCP2_EXTERN SSL *ngtcp2_crypto_ossl_ctx_get_ssl(ngtcp2_crypto_ossl_ctx *ctx);
*/
NGTCP2_EXTERN int ngtcp2_crypto_ossl_init(void);

/**
* @function
*
* `ngtcp2_crypto_ossl_free` frees the resources allocated by
* `ngtcp2_crypto_ossl_init`. It is safe to call this function even
* if `ngtcp2_crypto_ossl_init` fails or is not called at all. This
* function might be useful to make some leak detection tools happy.
*
* .. version-added:: 1.24.0
*/
NGTCP2_EXTERN void ngtcp2_crypto_ossl_free(void);

/**
* @function
*
Expand Down
54 changes: 54 additions & 0 deletions deps/ngtcp2/ngtcp2/crypto/ossl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,60 @@ int ngtcp2_crypto_ossl_init(void) {
return 0;
}

void ngtcp2_crypto_ossl_free(void) {
if (crypto_hkdf) {
EVP_KDF_free(crypto_hkdf);
crypto_hkdf = NULL;
}

if (crypto_sha384) {
EVP_MD_free(crypto_sha384);
crypto_sha384 = NULL;
}

if (crypto_sha256) {
EVP_MD_free(crypto_sha256);
crypto_sha256 = NULL;
}

#ifndef NGTCP2_NO_CHACHA_POLY1305
if (crypto_chacha20) {
EVP_CIPHER_free(crypto_chacha20);
crypto_chacha20 = NULL;
}

if (crypto_chacha20_poly1305) {
EVP_CIPHER_free(crypto_chacha20_poly1305);
crypto_chacha20_poly1305 = NULL;
}
#endif /* !defined(NGTCP2_NO_CHACHA_POLY1305) */

if (crypto_aes_256_ecb) {
EVP_CIPHER_free(crypto_aes_256_ecb);
crypto_aes_256_ecb = NULL;
}

if (crypto_aes_128_ecb) {
EVP_CIPHER_free(crypto_aes_128_ecb);
crypto_aes_128_ecb = NULL;
}

if (crypto_aes_128_ccm) {
EVP_CIPHER_free(crypto_aes_128_ccm);
crypto_aes_128_ccm = NULL;
}

if (crypto_aes_256_gcm) {
EVP_CIPHER_free(crypto_aes_256_gcm);
crypto_aes_256_gcm = NULL;
}

if (crypto_aes_128_gcm) {
EVP_CIPHER_free(crypto_aes_128_gcm);
crypto_aes_128_gcm = NULL;
}
}

static const EVP_CIPHER *crypto_aead_aes_128_gcm(void) {
if (crypto_aes_128_gcm) {
return crypto_aes_128_gcm;
Expand Down
4 changes: 2 additions & 2 deletions deps/ngtcp2/ngtcp2/examples/http3_server_proto_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ std::expected<void, Error> ProtoCodec::start_response(Stream *stream) {
nghttp3_pri pri;

if (auto rv =
nghttp3_conn_get_stream_priority(httpconn_, &pri, stream->stream_id);
nghttp3_conn_get_stream_priority2(httpconn_, &pri, stream->stream_id);
rv != 0) {
std::println(stderr, "nghttp3_conn_get_stream_priority: {}",
std::println(stderr, "nghttp3_conn_get_stream_priority2: {}",
nghttp3_strerror(rv));
return std::unexpected{Error::HTTP3};
}
Expand Down
15 changes: 4 additions & 11 deletions deps/ngtcp2/ngtcp2/examples/tls_client_context_ossl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,16 @@
#include "client_base.h"
#include "template.h"

namespace {
auto _ = [] {
if (ngtcp2_crypto_ossl_init() != 0) {
assert(0);
abort();
}

return 0;
}();
} // namespace

extern Config config;

TLSClientContext::TLSClientContext() { ngtcp2_crypto_ossl_init(); }

TLSClientContext::~TLSClientContext() {
if (ssl_ctx_) {
SSL_CTX_free(ssl_ctx_);
}

ngtcp2_crypto_ossl_free();
}

SSL_CTX *TLSClientContext::get_native_handle() const { return ssl_ctx_; }
Expand Down
2 changes: 1 addition & 1 deletion deps/ngtcp2/ngtcp2/examples/tls_client_context_ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace ngtcp2;

class TLSClientContext {
public:
TLSClientContext() = default;
TLSClientContext();
~TLSClientContext();

std::expected<void, Error> init(const char *private_key_file,
Expand Down
15 changes: 4 additions & 11 deletions deps/ngtcp2/ngtcp2/examples/tls_server_context_ossl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,16 @@
#include "server_base.h"
#include "template.h"

namespace {
auto _ = [] {
if (ngtcp2_crypto_ossl_init() != 0) {
assert(0);
abort();
}

return 0;
}();
} // namespace

extern Config config;

TLSServerContext::TLSServerContext() { ngtcp2_crypto_ossl_init(); }

TLSServerContext::~TLSServerContext() {
if (ssl_ctx_) {
SSL_CTX_free(ssl_ctx_);
}

ngtcp2_crypto_ossl_free();
}

SSL_CTX *TLSServerContext::get_native_handle() const { return ssl_ctx_; }
Expand Down
2 changes: 1 addition & 1 deletion deps/ngtcp2/ngtcp2/examples/tls_server_context_ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using namespace ngtcp2;

class TLSServerContext {
public:
TLSServerContext() = default;
TLSServerContext();
~TLSServerContext();

std::expected<void, Error> init(const char *private_key_file,
Expand Down
31 changes: 30 additions & 1 deletion deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/ngtcp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3485,6 +3485,24 @@ typedef int (*ngtcp2_stream_stop_sending)(ngtcp2_conn *conn, int64_t stream_id,
void *user_data,
void *stream_user_data);

/**
* @functypedef
*
* :type:`ngtcp2_recv_stop_sending` is invoked when a STOP_SENDING frame
* is received from a remote endpoint for a stream identified by
* |stream_id|. |app_error_code| is the application error code carried
* by the STOP_SENDING frame. This callback is called at most
* once per stream.
*
* The callback function must return 0 if it succeeds. Returning
* :macro:`NGTCP2_ERR_CALLBACK_FAILURE` makes the library call return
* immediately.
*/
typedef int (*ngtcp2_recv_stop_sending)(ngtcp2_conn *conn, int64_t stream_id,
uint64_t app_error_code,
void *user_data,
void *stream_user_data);

/**
* @functypedef
*
Expand Down Expand Up @@ -3626,7 +3644,8 @@ typedef int (*ngtcp2_get_path_challenge_data2)(ngtcp2_conn *conn,
#define NGTCP2_CALLBACKS_V1 1
#define NGTCP2_CALLBACKS_V2 2
#define NGTCP2_CALLBACKS_V3 3
#define NGTCP2_CALLBACKS_VERSION NGTCP2_CALLBACKS_V3
#define NGTCP2_CALLBACKS_V4 4
#define NGTCP2_CALLBACKS_VERSION NGTCP2_CALLBACKS_V4

/**
* @struct
Expand Down Expand Up @@ -3964,6 +3983,16 @@ typedef struct ngtcp2_callbacks {
* .. version-added:: 1.22.0
*/
ngtcp2_get_path_challenge_data2 get_path_challenge_data2;
/* The following fields have been added since
NGTCP2_CALLBACKS_V3. */
/**
* :member:`recv_stop_sending` is a callback function which is invoked
* when a STOP_SENDING frame is received from a remote endpoint. This
* callback function is optional.
*
* .. version-added:: 1.24.0
*/
ngtcp2_recv_stop_sending recv_stop_sending;
} ngtcp2_callbacks;

/**
Expand Down
4 changes: 2 additions & 2 deletions deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
* Version number of the ngtcp2 library release.
*/
#define NGTCP2_VERSION "1.23.0"
#define NGTCP2_VERSION "1.24.0"

/**
* @macro
Expand All @@ -46,6 +46,6 @@
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
* becomes 0x010203.
*/
#define NGTCP2_VERSION_NUM 0x011700
#define NGTCP2_VERSION_NUM 0x011800

#endif /* !defined(NGTCP2_VERSION_H) */
20 changes: 9 additions & 11 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,8 @@ static void bbr_handle_recovery(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,

static void bbr_on_init(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
ngtcp2_tstamp initial_ts) {
ngtcp2_window_filter_init(&bbr->max_bw_filter, NGTCP2_BBR_MAX_BW_FILTERLEN);
ngtcp2_window_filter_init(&bbr->extra_acked_filter,
NGTCP2_BBR_EXTRA_ACKED_FILTERLEN);
ngtcp2_wf_init(&bbr->max_bw_filter, NGTCP2_BBR_MAX_BW_FILTERLEN);
ngtcp2_wf_init(&bbr->extra_acked_filter, NGTCP2_BBR_EXTRA_ACKED_FILTERLEN);

bbr->min_rtt =
cstat->first_rtt_sample_ts == UINT64_MAX ? UINT64_MAX : cstat->smoothed_rtt;
Expand Down Expand Up @@ -590,10 +589,10 @@ static void bbr_update_max_bw(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat,

if (cstat->delivery_rate_sec && (cstat->delivery_rate_sec >= bbr->max_bw ||
!bbr->rst->rs.is_app_limited)) {
ngtcp2_window_filter_update(&bbr->max_bw_filter, cstat->delivery_rate_sec,
bbr->cycle_count);
ngtcp2_wf_update(&bbr->max_bw_filter, cstat->delivery_rate_sec,
bbr->cycle_count);

bbr->max_bw = ngtcp2_window_filter_get_best(&bbr->max_bw_filter);
bbr->max_bw = ngtcp2_wf_get_best(&bbr->max_bw_filter);
}
}

Expand Down Expand Up @@ -667,15 +666,14 @@ static void bbr_update_ack_aggregation(ngtcp2_cc_bbr *bbr,
}

if (bbr->full_bw_reached) {
bbr->extra_acked_filter.window_length = NGTCP2_BBR_EXTRA_ACKED_FILTERLEN;
bbr->extra_acked_filter.win = NGTCP2_BBR_EXTRA_ACKED_FILTERLEN;
} else {
bbr->extra_acked_filter.window_length = 1;
bbr->extra_acked_filter.win = 1;
}

ngtcp2_window_filter_update(&bbr->extra_acked_filter, extra,
bbr->round_count);
ngtcp2_wf_update(&bbr->extra_acked_filter, extra, bbr->round_count);

bbr->extra_acked = ngtcp2_window_filter_get_best(&bbr->extra_acked_filter);
bbr->extra_acked = ngtcp2_wf_get_best(&bbr->extra_acked_filter);
}

static void bbr_enter_drain(ngtcp2_cc_bbr *bbr) {
Expand Down
6 changes: 3 additions & 3 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_bbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <ngtcp2/ngtcp2.h>

#include "ngtcp2_cc.h"
#include "ngtcp2_window_filter.h"
#include "ngtcp2_wf.h"

typedef struct ngtcp2_rst ngtcp2_rst;
typedef struct ngtcp2_pcg32 ngtcp2_pcg32;
Expand Down Expand Up @@ -67,9 +67,9 @@ typedef struct ngtcp2_cc_bbr {

/* max_bw_filter for tracking the maximum recent delivery rate
samples for estimating max_bw. */
ngtcp2_window_filter max_bw_filter;
ngtcp2_wf max_bw_filter;

ngtcp2_window_filter extra_acked_filter;
ngtcp2_wf extra_acked_filter;

ngtcp2_duration min_rtt;
ngtcp2_tstamp min_rtt_stamp;
Expand Down
3 changes: 3 additions & 0 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ size_t ngtcp2_callbackslen_version(int callbacks_version) {
switch (callbacks_version) {
case NGTCP2_CALLBACKS_VERSION:
return sizeof(callbacks);
case NGTCP2_CALLBACKS_V3:
return offsetof(ngtcp2_callbacks, get_path_challenge_data2) +
sizeof(callbacks.get_path_challenge_data2);
case NGTCP2_CALLBACKS_V2:
return offsetof(ngtcp2_callbacks, begin_path_validation) +
sizeof(callbacks.begin_path_validation);
Expand Down
Loading
Loading