]> git.kaiwu.me - nginx.git/commitdiff
QUIC: teach how to compute only the length of created QUIC headers.
authorSergey Kandaurov <pluknet@nginx.com>
Wed, 21 Oct 2020 11:03:23 +0000 (12:03 +0100)
committerSergey Kandaurov <pluknet@nginx.com>
Wed, 21 Oct 2020 11:03:23 +0000 (12:03 +0100)
It will be used for precise expansion of UDP datagram payload.

src/event/ngx_event_quic_transport.c

index cea69ab7ae87f23efd1d553c205b4de0d92ca3ac..93b3bae782e3aab06b0d8a598a856b8f2a8df7e0 100644 (file)
@@ -420,6 +420,12 @@ ngx_quic_create_long_header(ngx_quic_header_t *pkt, u_char *out,
 {
     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_header_t *pkt, u_char *out,
 {
     u_char  *p, *start;
 
+    if (out == NULL) {
+        return 1 + pkt->dcid.len + pkt->num_len;
+    }
+
     p = start = out;
 
     *p++ = pkt->flags;