changeset 8594:ee06a813756c quic

QUIC: teach how to compute only the length of created QUIC headers. It will be used for precise expansion of UDP datagram payload.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 21 Oct 2020 12:03:23 +0100
parents d8a0bb1e85bf
children 96798101c3aa
files src/event/ngx_event_quic_transport.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic_transport.c
+++ b/src/event/ngx_event_quic_transport.c
@@ -420,6 +420,12 @@ ngx_quic_create_long_header(ngx_quic_hea
 {
     u_char  *p, *start;
 
+    if (out == NULL) {
+        return 5 + 2 + pkt->dcid.len + pkt->scid.len
+               + ngx_quic_varint_len(pkt_len + pkt->num_len) + pkt->num_len
+               + (pkt->level == ssl_encryption_initial ? 1 : 0);
+    }
+
     p = start = out;
 
     *p++ = pkt->flags;
@@ -465,6 +471,10 @@ ngx_quic_create_short_header(ngx_quic_he
 {
     u_char  *p, *start;
 
+    if (out == NULL) {
+        return 1 + pkt->dcid.len + pkt->num_len;
+    }
+
     p = start = out;
 
     *p++ = pkt->flags;