comparison src/event/ngx_event_quic.c @ 8191:7bd7c4e24951 quic

Macro for calculating size of varint.
author Vladimir Homutov <vl@nginx.com>
date Wed, 04 Mar 2020 23:24:51 +0300
parents 2bc1f97c1c2d
children fb0879c65650
comparison
equal deleted inserted replaced
8190:2bc1f97c1c2d 8191:7bd7c4e24951
47 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t)) 47 (*(uint16_t *) (p) = htons((uint16_t) (s)), (p) + sizeof(uint16_t))
48 48
49 #define ngx_quic_write_uint32_aligned(p, s) \ 49 #define ngx_quic_write_uint32_aligned(p, s) \
50 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t)) 50 (*(uint32_t *) (p) = htonl((uint32_t) (s)), (p) + sizeof(uint32_t))
51 51
52 #define ngx_quic_varint_len(value) \
53 ((value) <= 63 ? 1 : (value) <= 16383 ? 2 : (value) <= 1073741823 ? 4 : 8)
52 54
53 55
54 #if (NGX_DEBUG) 56 #if (NGX_DEBUG)
55 57
56 #define ngx_quic_hexdump(log, fmt, data, len, ...) \ 58 #define ngx_quic_hexdump(log, fmt, data, len, ...) \
347 ngx_quic_create_crypto(u_char *p, ngx_quic_crypto_frame_t *crypto) 349 ngx_quic_create_crypto(u_char *p, ngx_quic_crypto_frame_t *crypto)
348 { 350 {
349 u_char *start; 351 u_char *start;
350 352
351 if (p == NULL) { 353 if (p == NULL) {
352 if (crypto->len >= 64) { 354 return 3 + ngx_quic_varint_len(crypto->len) + crypto->len;
353 return crypto->len + 4;
354
355 } else {
356 return crypto->len + 3;
357 } // TODO: proper calculation of varint
358 } 355 }
359 356
360 start = p; 357 start = p;
361 358
362 ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO); 359 ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO);