Compile with the latest ngtcp2 and nghttp3

This commit is contained in:
Tatsuhiro Tsujikawa 2020-12-07 22:31:58 +09:00
parent 863434fa01
commit 132cd21c12
2 changed files with 10 additions and 24 deletions

View File

@ -289,7 +289,7 @@ int Http3Session::init_conn() {
return -1; return -1;
} }
nghttp3_conn_callbacks callbacks{ nghttp3_callbacks callbacks{
nullptr, // acked_stream_data nullptr, // acked_stream_data
h2load::stream_close, h2load::stream_close,
h2load::recv_data, h2load::recv_data,
@ -310,8 +310,8 @@ int Http3Session::init_conn() {
auto config = client_->worker->config; auto config = client_->worker->config;
nghttp3_conn_settings settings; nghttp3_settings settings;
nghttp3_conn_settings_default(&settings); nghttp3_settings_default(&settings);
settings.qpack_max_table_capacity = config->header_table_size; settings.qpack_max_table_capacity = config->header_table_size;
settings.qpack_blocked_streams = 100; settings.qpack_blocked_streams = 100;

View File

@ -26,6 +26,8 @@
#include <iostream> #include <iostream>
#include <ngtcp2/ngtcp2_crypto_openssl.h>
#include <openssl/err.h> #include <openssl/err.h>
#include "h2load_http3_session.h" #include "h2load_http3_session.h"
@ -233,31 +235,14 @@ ngtcp2_tstamp timestamp(struct ev_loop *loop) {
} }
} // namespace } // namespace
namespace {
ngtcp2_crypto_level from_ossl_level(OSSL_ENCRYPTION_LEVEL ossl_level) {
switch (ossl_level) {
case ssl_encryption_initial:
return NGTCP2_CRYPTO_LEVEL_INITIAL;
case ssl_encryption_early_data:
return NGTCP2_CRYPTO_LEVEL_EARLY;
case ssl_encryption_handshake:
return NGTCP2_CRYPTO_LEVEL_HANDSHAKE;
case ssl_encryption_application:
return NGTCP2_CRYPTO_LEVEL_APPLICATION;
default:
assert(0);
}
}
} // namespace
namespace { namespace {
int set_encryption_secrets(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level, int set_encryption_secrets(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level,
const uint8_t *rx_secret, const uint8_t *tx_secret, const uint8_t *rx_secret, const uint8_t *tx_secret,
size_t secret_len) { size_t secret_len) {
auto c = static_cast<Client *>(SSL_get_app_data(ssl)); auto c = static_cast<Client *>(SSL_get_app_data(ssl));
if (c->quic_on_key(from_ossl_level(ossl_level), rx_secret, tx_secret, if (c->quic_on_key(ngtcp2_crypto_from_ossl_encryption_level(ossl_level),
secret_len) != 0) { rx_secret, tx_secret, secret_len) != 0) {
return 0; return 0;
} }
@ -269,7 +254,8 @@ namespace {
int add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level, int add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level,
const uint8_t *data, size_t len) { const uint8_t *data, size_t len) {
auto c = static_cast<Client *>(SSL_get_app_data(ssl)); auto c = static_cast<Client *>(SSL_get_app_data(ssl));
c->quic_write_client_handshake(from_ossl_level(ossl_level), data, len); c->quic_write_client_handshake(
ngtcp2_crypto_from_ossl_encryption_level(ossl_level), data, len);
return 1; return 1;
} }
} // namespace } // namespace
@ -318,7 +304,7 @@ int Client::quic_init(const sockaddr *local_addr, socklen_t local_addrlen,
return -1; return -1;
} }
auto callbacks = ngtcp2_conn_callbacks{ auto callbacks = ngtcp2_callbacks{
ngtcp2_crypto_client_initial_cb, ngtcp2_crypto_client_initial_cb,
nullptr, // recv_client_initial nullptr, // recv_client_initial
h2load::recv_crypto_data, h2load::recv_crypto_data,