struct ngx_quic_connection_s {
+ ngx_udp_connection_t udp;
+
uint32_t version;
ngx_str_t scid; /* initial client ID */
ngx_str_t dcid; /* server (our own) ID */
p = buf;
last = p + sizeof(buf);
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
p = ngx_slprintf(p, last, "state:");
enum ssl_encryption_level_t level, const SSL_CIPHER *cipher,
const uint8_t *rsecret, size_t secret_len)
{
- ngx_connection_t *c;
+ ngx_connection_t *c;
+ ngx_quic_connection_t *qc;
c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
+ qc = ngx_quic_get_connection(c);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_set_read_secret() level:%d", level);
ngx_quic_hexdump(c->log, "quic read secret", rsecret, secret_len);
#endif
- return ngx_quic_keys_set_encryption_secret(c->pool, 0, c->quic->keys, level,
+ return ngx_quic_keys_set_encryption_secret(c->pool, 0, qc->keys, level,
cipher, rsecret, secret_len);
}
enum ssl_encryption_level_t level, const SSL_CIPHER *cipher,
const uint8_t *wsecret, size_t secret_len)
{
- ngx_connection_t *c;
+ ngx_connection_t *c;
+ ngx_quic_connection_t *qc;
c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
+ qc = ngx_quic_get_connection(c);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_set_write_secret() level:%d", level);
ngx_quic_hexdump(c->log, "quic write secret", wsecret, secret_len);
#endif
- return ngx_quic_keys_set_encryption_secret(c->pool, 1, c->quic->keys, level,
+ return ngx_quic_keys_set_encryption_secret(c->pool, 1, qc->keys, level,
cipher, wsecret, secret_len);
}
enum ssl_encryption_level_t level, const uint8_t *rsecret,
const uint8_t *wsecret, size_t secret_len)
{
- ngx_connection_t *c;
- const SSL_CIPHER *cipher;
+ ngx_connection_t *c;
+ const SSL_CIPHER *cipher;
+ ngx_quic_connection_t *qc;
c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
+ qc = ngx_quic_get_connection(c);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_set_encryption_secrets() level:%d", level);
cipher = SSL_get_current_cipher(ssl_conn);
- if (ngx_quic_keys_set_encryption_secret(c->pool, 0, c->quic->keys, level,
+ if (ngx_quic_keys_set_encryption_secret(c->pool, 0, qc->keys, level,
cipher, rsecret, secret_len)
!= 1)
{
ngx_quic_hexdump(c->log, "quic write secret", wsecret, secret_len);
#endif
- return ngx_quic_keys_set_encryption_secret(c->pool, 1, c->quic->keys, level,
+ return ngx_quic_keys_set_encryption_secret(c->pool, 1, qc->keys, level,
cipher, wsecret, secret_len);
}
ngx_quic_frames_stream_t *fs;
c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_add_handshake_data");
"quic ngx_quic_send_alert() lvl:%d alert:%d",
(int) level, (int) alert);
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (qc == NULL) {
return 1;
}
void
ngx_quic_run(ngx_connection_t *c, ngx_quic_conf_t *conf)
{
- ngx_int_t rc;
+ ngx_int_t rc;
+ ngx_quic_connection_t *qc;
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic run");
return;
}
- ngx_add_timer(c->read, c->quic->in_retry ? NGX_QUIC_RETRY_TIMEOUT
- : c->quic->tp.max_idle_timeout);
+ qc = ngx_quic_get_connection(c);
+
+ ngx_add_timer(c->read, qc->in_retry ? NGX_QUIC_RETRY_TIMEOUT
+ : qc->tp.max_idle_timeout);
c->read->handler = ngx_quic_input_handler;
ngx_quic_client_id_t *cid;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
/* A stateless reset uses an entire UDP datagram */
if (pkt->raw->start != pkt->data) {
static ngx_int_t
ngx_quic_send_retry(ngx_connection_t *c)
{
- ssize_t len;
- ngx_str_t res, token;
- ngx_quic_header_t pkt;
- u_char buf[NGX_QUIC_RETRY_BUFFER_SIZE];
+ ssize_t len;
+ ngx_str_t res, token;
+ ngx_quic_header_t pkt;
+ ngx_quic_connection_t *qc;
+ u_char buf[NGX_QUIC_RETRY_BUFFER_SIZE];
+
+ qc = ngx_quic_get_connection(c);
if (ngx_quic_new_token(c, &token) != NGX_OK) {
return NGX_ERROR;
ngx_memzero(&pkt, sizeof(ngx_quic_header_t));
pkt.flags = NGX_QUIC_PKT_FIXED_BIT | NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_RETRY;
- pkt.version = c->quic->version;
+ pkt.version = qc->version;
pkt.log = c->log;
- pkt.odcid = c->quic->odcid;
- pkt.dcid = c->quic->scid;
- pkt.scid = c->quic->dcid;
+ pkt.odcid = qc->odcid;
+ pkt.dcid = qc->scid;
+ pkt.scid = qc->dcid;
pkt.token = token;
res.data = buf;
return NGX_ERROR;
}
- c->quic->token = token;
+ qc->token = token;
#if (NGX_QUIC_DRAFT_VERSION < 28)
- c->quic->tp.original_dcid = c->quic->odcid;
+ qc->tp.original_dcid = qc->odcid;
#endif
- c->quic->tp.retry_scid = c->quic->dcid;
- c->quic->in_retry = 1;
+ qc->tp.retry_scid = qc->dcid;
+ qc->in_retry = 1;
- if (ngx_quic_insert_server_id(c, &c->quic->dcid) == NULL) {
+ if (ngx_quic_insert_server_id(c, &qc->dcid) == NULL) {
return NGX_ERROR;
}
static ngx_int_t
ngx_quic_new_token(ngx_connection_t *c, ngx_str_t *token)
{
- int len, iv_len;
- u_char *data, *p, *key, *iv;
- ngx_msec_t now;
- EVP_CIPHER_CTX *ctx;
- const EVP_CIPHER *cipher;
- struct sockaddr_in *sin;
+ int len, iv_len;
+ u_char *data, *p, *key, *iv;
+ ngx_msec_t now;
+ EVP_CIPHER_CTX *ctx;
+ const EVP_CIPHER *cipher;
+ struct sockaddr_in *sin;
#if (NGX_HAVE_INET6)
- struct sockaddr_in6 *sin6;
+ struct sockaddr_in6 *sin6;
#endif
- u_char in[NGX_QUIC_MAX_TOKEN_SIZE];
+ ngx_quic_connection_t *qc;
+ u_char in[NGX_QUIC_MAX_TOKEN_SIZE];
switch (c->sockaddr->sa_family) {
return NGX_ERROR;
}
- key = c->quic->conf->token_key;
+ qc = ngx_quic_get_connection(c);
+ key = qc->conf->token_key;
iv = token->data;
if (RAND_bytes(iv, iv_len) <= 0
ngx_quic_connection_t *qc;
u_char tdec[NGX_QUIC_MAX_TOKEN_SIZE];
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
/* Retry token */
/* NEW_TOKEN in a previous connection */
cipher = EVP_aes_256_cbc();
- key = c->quic->conf->token_key;
+ key = qc->conf->token_key;
iv = pkt->token.data;
iv_len = EVP_CIPHER_iv_length(cipher);
ngx_ssl_conn_t *ssl_conn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (ngx_ssl_create_connection(qc->conf->ssl, c, NGX_SSL_BUFFER) != NGX_OK) {
return NGX_ERROR;
b.memory = 1;
c = rev->data;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
c->log->action = "handling quic input";
static void
ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc)
{
- ngx_pool_t *pool;
+ ngx_pool_t *pool;
+ ngx_quic_connection_t *qc;
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_close_connection rc:%i", rc);
- if (!c->quic) {
+ qc = ngx_quic_get_connection(c);
+
+ if (qc == NULL) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic close connection early error");
ngx_quic_server_id_t *sid;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (!qc->closing) {
"quic part of connection is terminated");
/* may be tested from SSL callback during SSL shutdown */
- c->quic = NULL;
+ c->udp = NULL;
return NGX_OK;
}
{
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
qc->error = err;
qc->error_reason = reason;
qc->error_app = 1;
static ngx_int_t
ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf)
{
- u_char *p;
- ngx_int_t rc;
- ngx_uint_t good;
- ngx_quic_header_t pkt;
+ u_char *p;
+ ngx_int_t rc;
+ ngx_uint_t good;
+ ngx_quic_header_t pkt;
+ ngx_quic_connection_t *qc;
good = 0;
pkt.flags = p[0];
pkt.raw->pos++;
- if (c->quic) {
- c->quic->error = 0;
- c->quic->error_reason = 0;
+ qc = ngx_quic_get_connection(c);
+ if (qc) {
+ qc->error = 0;
+ qc->error_reason = 0;
}
rc = ngx_quic_process_packet(c, conf, &pkt);
c->log->action = "processing quic packet";
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
#if (NGX_DEBUG)
ngx_quic_hexdump(c->log, "quic packet rx dcid",
return NGX_ERROR;
}
- c->quic = qc;
+ c->udp = &qc->udp;
if (ngx_terminate || ngx_exiting) {
qc->error = NGX_QUIC_ERR_CONNECTION_REFUSED;
if (qc->validated == 0) {
qc->validated = 1;
- ngx_post_event(&c->quic->push, &ngx_posted_events);
+ ngx_post_event(&qc->push, &ngx_posted_events);
}
}
{
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (ngx_quic_keys_set_initial_secret(c->pool, qc->keys, &qc->odcid)
!= NGX_OK)
ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (!ngx_quic_keys_available(qc->keys, level)) {
return;
ngx_quic_frame_t frame;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (qc->closing) {
/*
static ngx_int_t
ngx_quic_ack_packet(ngx_connection_t *c, ngx_quic_header_t *pkt)
{
- uint64_t base, largest, smallest, gs, ge, gap, range, pn;
- uint64_t prev_pending;
- ngx_uint_t i, nr;
- ngx_quic_send_ctx_t *ctx;
- ngx_quic_ack_range_t *r;
+ uint64_t base, largest, smallest, gs, ge, gap, range, pn;
+ uint64_t prev_pending;
+ ngx_uint_t i, nr;
+ ngx_quic_send_ctx_t *ctx;
+ ngx_quic_ack_range_t *r;
+ ngx_quic_connection_t *qc;
c->log->action = "preparing ack";
- ctx = ngx_quic_get_send_ctx(c->quic, pkt->level);
+ qc = ngx_quic_get_connection(c);
+
+ ctx = ngx_quic_get_send_ctx(qc, pkt->level);
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic ngx_quic_ack_packet pn:%uL largest %L fr:%uL"
if (pkt->need_ack) {
- ngx_post_event(&c->quic->push, &ngx_posted_events);
+ ngx_post_event(&qc->push, &ngx_posted_events);
if (ctx->send_ack == 0) {
ctx->ack_delay_start = ngx_current_msec;
static ngx_int_t
ngx_quic_send_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
{
- u_char *p;
- size_t ranges_len;
- uint64_t ack_delay;
- ngx_uint_t i;
- ngx_quic_frame_t *frame;
+ u_char *p;
+ size_t ranges_len;
+ uint64_t ack_delay;
+ ngx_uint_t i;
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
if (ctx->level == ssl_encryption_application) {
ack_delay = ngx_current_msec - ctx->largest_received;
ack_delay *= 1000;
- ack_delay >>= c->quic->ctp.ack_delay_exponent;
+ ack_delay >>= qc->ctp.ack_delay_exponent;
} else {
ack_delay = 0;
frame->u.ack.ranges_start = frame->data;
frame->u.ack.ranges_end = frame->data + ranges_len;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
return NGX_OK;
}
ngx_quic_frame_t *frame;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (qc->draining) {
return NGX_OK;
frame->u.close.reason.data = (u_char *) qc->error_reason;
}
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
qc->last_cc = ngx_current_msec;
static ngx_int_t
ngx_quic_send_new_token(ngx_connection_t *c)
{
- ngx_str_t token;
- ngx_quic_frame_t *frame;
+ ngx_str_t token;
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
- if (!c->quic->conf->retry) {
+ if (!qc->conf->retry) {
return NGX_OK;
}
frame->u.token.length = token.len;
frame->u.token.data = token.data;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
return NGX_OK;
}
ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
ctx = ngx_quic_get_send_ctx(qc, pkt->level);
ngx_quic_frame_t *f;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
*send_time = NGX_TIMER_INFINITE;
found = 0;
ngx_msec_t latest_rtt, ack_delay, adjusted_rtt, rttvar_sample;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
latest_rtt = ngx_current_msec - send_time;
qc->latest_rtt = latest_rtt;
ngx_msec_t duration;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
/* PTO calculation: quic-recovery, Appendix 8 */
duration = qc->avg_rtt;
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
sn = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id);
if (sn == NULL) {
ngx_quic_crypto_frame_t *f;
ngx_quic_frames_stream_t *fs;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
fs = &qc->crypto[pkt->level];
f = &frame->u.crypto;
last = f->offset + f->length;
if (last > fs->received && last - fs->received > NGX_QUIC_MAX_BUFFERED) {
- c->quic->error = NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED;
+ qc->error = NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED;
return NGX_ERROR;
}
{
int n, sslerr;
ngx_ssl_conn_t *ssl_conn;
+ ngx_quic_connection_t *qc;
ngx_quic_crypto_frame_t *f;
+ qc = ngx_quic_get_connection(c);
+
f = &frame->u.crypto;
ssl_conn = c->ssl->connection;
/* 12.4 Frames and frame types, figure 8 */
frame->level = ssl_encryption_application;
frame->type = NGX_QUIC_FT_HANDSHAKE_DONE;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
if (ngx_quic_send_new_token(c) != NGX_OK) {
return NGX_ERROR;
* See quic-tls 9.4 Header Protection Timing Side-Channels.
*/
- if (ngx_quic_keys_update(c, c->quic->keys) != NGX_OK) {
+ if (ngx_quic_keys_update(c, qc->keys) != NGX_OK) {
return NGX_ERROR;
}
ngx_quic_stream_frame_t *f;
ngx_quic_frames_stream_t *fs;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
f = &frame->u.stream;
if ((f->stream_id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
window = b->end - b->last;
if (last > window) {
- c->quic->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR;
+ qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR;
goto cleanup;
}
window = (b->pos - b->start) + (b->end - b->last);
if (last > fs->received && last - fs->received > window) {
- c->quic->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR;
+ qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR;
return NGX_ERROR;
}
ngx_quic_connection_t *qc;
ngx_quic_stream_frame_t *f;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
sn = data;
f = &frame->u.stream;
ngx_quic_stream_t *qs;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
tree = &qc->streams.tree;
if (f->max_data <= qc->streams.send_max_data) {
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
&& (f->id & NGX_QUIC_STREAM_SERVER_INITIATED))
frame->u.max_stream_data.id = f->id;
frame->u.max_stream_data.limit = n;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
return NGX_OK;
}
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
&& (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0)
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
&& (f->id & NGX_QUIC_STREAM_SERVER_INITIATED))
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL)
&& (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0)
{
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (f->bidi) {
if (qc->streams.server_max_streams_bidi < f->limit) {
ngx_quic_handle_path_challenge_frame(ngx_connection_t *c,
ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f)
{
- ngx_quic_frame_t *frame;
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
frame = ngx_quic_alloc_frame(c, 0);
if (frame == NULL) {
frame->type = NGX_QUIC_FT_PATH_RESPONSE;
frame->u.path_response = *f;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
return NGX_OK;
}
ngx_quic_client_id_t *cid, *item;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (f->seqnum < qc->max_retired_seqnum) {
/*
ngx_quic_retire_connection_id(ngx_connection_t *c,
enum ssl_encryption_level_t level, uint64_t seqnum)
{
- ngx_quic_frame_t *frame;
+ ngx_quic_frame_t *frame;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
frame = ngx_quic_alloc_frame(c, 0);
if (frame == NULL) {
frame->type = NGX_QUIC_FT_RETIRE_CONNECTION_ID;
frame->u.retire_cid.sequence_number = seqnum;
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
return NGX_OK;
}
ngx_quic_server_id_t *sid;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
for (q = ngx_queue_head(&qc->server_ids);
q != ngx_queue_sentinel(&qc->server_ids);
if (sid->seqnum == f->sequence_number) {
ngx_queue_remove(q);
+ ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue);
ngx_rbtree_delete(&c->listening->rbtree, &sid->udp.node);
qc->nserver_ids--;
-
- if (c->udp != &sid->udp) {
- ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue);
- }
-
break;
}
}
ngx_quic_connection_t *qc;
u_char id[NGX_QUIC_SERVER_CID_LEN];
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
n = ngx_min(NGX_QUIC_MAX_SERVER_IDS, qc->ctp.active_connection_id_limit);
return NGX_ERROR;
}
- ngx_quic_queue_frame(c->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
}
return NGX_OK;
ngx_quic_server_id_t *sid;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic clear temp server ids");
}
ngx_queue_remove(q);
+ ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue);
ngx_rbtree_delete(&c->listening->rbtree, &sid->udp.node);
qc->nserver_ids--;
-
- if (c->udp != &sid->udp) {
- ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue);
- }
}
}
ngx_quic_server_id_t *sid;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
sid = ngx_quic_alloc_server_id(c, qc);
if (sid == NULL) {
ngx_insert_udp_connection(c, &sid->udp, &dcid);
- if (c->udp == NULL) {
- c->udp = &sid->udp;
- }
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic insert server id seqnum:%uL", sid->seqnum);
c->log->action = "sending frames";
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
ngx_quic_congestion_t *cg;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
if (ngx_queue_empty(&ctx->frames)) {
out.len = p - out.data;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
pkt.keys = qc->keys;
pkt.flags |= NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_HANDSHAKE;
} else {
- if (c->quic->key_phase) {
+ if (qc->key_phase) {
pkt.flags |= NGX_QUIC_PKT_KPHASE;
}
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer");
c = ev->data;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
qc->pto_count++;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic pto pnum:%uL pto_count:%ui level:%d",
- start->pnum, c->quic->pto_count, start->level);
+ start->pnum, qc->pto_count, start->level);
ngx_quic_resend_frames(c, ctx);
}
ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
now = ngx_current_msec;
min_wait = 0;
ngx_quic_stream_t *sn;
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
q = ngx_queue_head(&ctx->sent);
start = ngx_queue_data(q, ngx_quic_frame_t, queue);
ngx_quic_connection_t *qc;
qs = c->qs;
- qc = qs->parent->quic;
+ qc = ngx_quic_get_connection(qs->parent);
if (bidi) {
if (qc->streams.server_streams_bidi
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic stream id:0x%xL is new", id);
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) {
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic stream id:0x%xL create", id);
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, c->log);
if (pool == NULL) {
cln->handler = ngx_quic_stream_cleanup_handler;
cln->data = sn->c;
- ngx_rbtree_insert(&c->quic->streams.tree, &sn->node);
+ ngx_rbtree_insert(&qc->streams.tree, &sn->node);
return sn;
}
qs = c->qs;
b = qs->b;
pc = qs->parent;
- qc = pc->quic;
+ qc = ngx_quic_get_connection(pc);
rev = c->read;
if (rev->error) {
frame->u.max_stream_data.limit = qs->fs.received + (b->pos - b->start)
+ (b->end - b->last);
- ngx_quic_queue_frame(pc->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
}
if ((qc->streams.recv_max_data / 2) < qc->streams.received) {
frame->type = NGX_QUIC_FT_MAX_DATA;
frame->u.max_data.max_data = qc->streams.recv_max_data;
- ngx_quic_queue_frame(pc->quic, frame);
+ ngx_quic_queue_frame(qc, frame);
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic stream id:0x%xL recv: increased max_data:%uL",
qs = c->qs;
pc = qs->parent;
- qc = pc->quic;
+ qc = ngx_quic_get_connection(pc);
wev = c->write;
if (wev->error) {
ngx_quic_connection_t *qc;
qs = c->qs;
- qc = qs->parent->quic;
+ qc = ngx_quic_get_connection(qs->parent);
size = NGX_QUIC_STREAM_BUFSIZE;
sent = c->sent;
qs = c->qs;
pc = qs->parent;
- qc = pc->quic;
+ qc = ngx_quic_get_connection(pc);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic stream id:0x%xL cleanup", qs->id);
p = NULL;
}
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (!ngx_queue_empty(&qc->free_frames)) {
return;
}
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
cg->in_flight -= f->plen;
return;
}
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
cg->in_flight -= f->plen;
{
ngx_quic_connection_t *qc;
- qc = c->quic;
+ qc = ngx_quic_get_connection(c);
if (frame->data) {
ngx_free(frame->data);
uint32_t
ngx_quic_version(ngx_connection_t *c)
{
- uint32_t version;
+ uint32_t version;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
- version = c->quic->version;
+ version = qc->version;
return (version & 0xff000000) == 0xff000000 ? version & 0xff : version;
}