comparison src/event/ngx_event_quic.c @ 8332:6ad871b63422 quic

Cleaned up magic numbers in ngx_quic_output_frames().
author Vladimir Homutov <vl@nginx.com>
date Mon, 13 Apr 2020 14:57:58 +0300
parents bda817d16cc2
children 167d32476737
comparison
equal deleted inserted replaced
8331:bda817d16cc2 8332:6ad871b63422
159 static void ngx_quic_queue_frame(ngx_quic_connection_t *qc, 159 static void ngx_quic_queue_frame(ngx_quic_connection_t *qc,
160 ngx_quic_frame_t *frame); 160 ngx_quic_frame_t *frame);
161 161
162 static ngx_int_t ngx_quic_output(ngx_connection_t *c); 162 static ngx_int_t ngx_quic_output(ngx_connection_t *c);
163 static ngx_int_t ngx_quic_output_frames(ngx_connection_t *c, 163 static ngx_int_t ngx_quic_output_frames(ngx_connection_t *c,
164 ngx_quic_send_ctx_t *ctx, ngx_uint_t nsi); 164 ngx_quic_send_ctx_t *ctx);
165 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames); 165 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames);
166 static ngx_int_t ngx_quic_send_frames(ngx_connection_t *c, ngx_queue_t *frames); 166 static ngx_int_t ngx_quic_send_frames(ngx_connection_t *c, ngx_queue_t *frames);
167 167
168 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt, 168 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt,
169 ngx_quic_send_ctx_t *ctx); 169 ngx_quic_send_ctx_t *ctx);
1691 c->log->action = "sending frames"; 1691 c->log->action = "sending frames";
1692 1692
1693 qc = c->quic; 1693 qc = c->quic;
1694 1694
1695 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { 1695 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
1696 if (ngx_quic_output_frames(c, &qc->send_ctx[i], i) != NGX_OK) { 1696 if (ngx_quic_output_frames(c, &qc->send_ctx[i]) != NGX_OK) {
1697 return NGX_ERROR; 1697 return NGX_ERROR;
1698 } 1698 }
1699 } 1699 }
1700 1700
1701 if (!qc->send_timer_set && !qc->closing) { 1701 if (!qc->send_timer_set && !qc->closing) {
1710 return NGX_OK; 1710 return NGX_OK;
1711 } 1711 }
1712 1712
1713 1713
1714 static ngx_int_t 1714 static ngx_int_t
1715 ngx_quic_output_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, 1715 ngx_quic_output_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
1716 ngx_uint_t nsi)
1717 { 1716 {
1718 size_t len, hlen, n; 1717 size_t len, hlen, n;
1719 ngx_int_t rc; 1718 ngx_int_t rc;
1720 ngx_queue_t *q, range; 1719 ngx_queue_t *q, range;
1721 ngx_quic_frame_t *f; 1720 ngx_quic_frame_t *f;
1725 1724
1726 if (ngx_queue_empty(&ctx->frames)) { 1725 if (ngx_queue_empty(&ctx->frames)) {
1727 return NGX_OK; 1726 return NGX_OK;
1728 } 1727 }
1729 1728
1730 hlen = (nsi == 2) ? NGX_QUIC_MAX_SHORT_HEADER 1729 q = ngx_queue_head(&ctx->frames);
1731 : NGX_QUIC_MAX_LONG_HEADER; 1730 f = ngx_queue_data(q, ngx_quic_frame_t, queue);
1732 1731
1732 /* all frames in same send_ctx share same level */
1733 hlen = (f->level == ssl_encryption_application) ? NGX_QUIC_MAX_SHORT_HEADER
1734 : NGX_QUIC_MAX_LONG_HEADER;
1733 hlen += EVP_GCM_TLS_TAG_LEN; 1735 hlen += EVP_GCM_TLS_TAG_LEN;
1734
1735 q = ngx_queue_head(&ctx->frames);
1736 1736
1737 do { 1737 do {
1738 len = 0; 1738 len = 0;
1739 ngx_queue_init(&range); 1739 ngx_queue_init(&range);
1740 1740