Mercurial > hg > nginx
comparison src/event/ngx_event_quic_transport.c @ 8269:c9c3a73df6e8 quic
Support for HTTP/3 ALPN.
This is required by Chrome.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 23 Mar 2020 19:26:24 +0300 |
parents | 159eb325ec82 |
children | cb75f194f1f0 |
comparison
equal
deleted
inserted
replaced
8268:159eb325ec82 | 8269:c9c3a73df6e8 |
---|---|
54 static u_char *ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out); | 54 static u_char *ngx_quic_parse_int(u_char *pos, u_char *end, uint64_t *out); |
55 static u_char *ngx_quic_parse_int_multi(u_char *pos, u_char *end, ...); | 55 static u_char *ngx_quic_parse_int_multi(u_char *pos, u_char *end, ...); |
56 static void ngx_quic_build_int(u_char **pos, uint64_t value); | 56 static void ngx_quic_build_int(u_char **pos, uint64_t value); |
57 | 57 |
58 static u_char *ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value); | 58 static u_char *ngx_quic_read_uint8(u_char *pos, u_char *end, uint8_t *value); |
59 /*static*/ u_char *ngx_quic_read_uint16(u_char *pos, u_char *end, uint16_t *value); // usage depends on quic_version | 59 /*static*/ u_char *ngx_quic_read_uint16(u_char *pos, u_char *end, uint16_t *value); // usage depends on NGX_QUIC_VERSION |
60 static u_char *ngx_quic_read_uint32(u_char *pos, u_char *end, uint32_t *value); | 60 static u_char *ngx_quic_read_uint32(u_char *pos, u_char *end, uint32_t *value); |
61 static u_char *ngx_quic_read_bytes(u_char *pos, u_char *end, size_t len, | 61 static u_char *ngx_quic_read_bytes(u_char *pos, u_char *end, size_t len, |
62 u_char **out); | 62 u_char **out); |
63 static u_char *ngx_quic_copy_bytes(u_char *pos, u_char *end, size_t len, | 63 static u_char *ngx_quic_copy_bytes(u_char *pos, u_char *end, size_t len, |
64 u_char *dst); | 64 u_char *dst); |
293 } | 293 } |
294 | 294 |
295 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 295 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
296 "quic flags:%xi version:%xD", pkt->flags, pkt->version); | 296 "quic flags:%xi version:%xD", pkt->flags, pkt->version); |
297 | 297 |
298 if (pkt->version != quic_version) { | 298 if (pkt->version != NGX_QUIC_VERSION) { |
299 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, | 299 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, |
300 "unsupported quic version: 0x%xi", pkt->version); | 300 "unsupported quic version: 0x%xi", pkt->version); |
301 return NGX_ERROR; | 301 return NGX_ERROR; |
302 } | 302 } |
303 | 303 |
347 | 347 |
348 p = start = out->data; | 348 p = start = out->data; |
349 | 349 |
350 *p++ = pkt->flags; | 350 *p++ = pkt->flags; |
351 | 351 |
352 p = ngx_quic_write_uint32(p, quic_version); | 352 p = ngx_quic_write_uint32(p, NGX_QUIC_VERSION); |
353 | 353 |
354 *p++ = pkt->scid.len; | 354 *p++ = pkt->scid.len; |
355 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); | 355 p = ngx_cpymem(p, pkt->scid.data, pkt->scid.len); |
356 | 356 |
357 *p++ = pkt->dcid.len; | 357 *p++ = pkt->dcid.len; |
1325 ngx_quic_parse_transport_params(u_char *p, u_char *end, ngx_quic_tp_t *tp, | 1325 ngx_quic_parse_transport_params(u_char *p, u_char *end, ngx_quic_tp_t *tp, |
1326 ngx_log_t *log) | 1326 ngx_log_t *log) |
1327 { | 1327 { |
1328 ngx_int_t rc; | 1328 ngx_int_t rc; |
1329 | 1329 |
1330 #if (quic_version < 0xff00001b) | 1330 #if (NGX_QUIC_DRAFT_VERSION < 27) |
1331 | 1331 |
1332 uint16_t id, len, tp_len; | 1332 uint16_t id, len, tp_len; |
1333 | 1333 |
1334 p = ngx_quic_read_uint16(p, end, &tp_len); | 1334 p = ngx_quic_read_uint16(p, end, &tp_len); |
1335 if (p == NULL) { | 1335 if (p == NULL) { |
1491 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) | 1491 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) |
1492 { | 1492 { |
1493 u_char *p; | 1493 u_char *p; |
1494 size_t len; | 1494 size_t len; |
1495 | 1495 |
1496 #if (quic_version < 0xff00001b) | 1496 #if (NGX_QUIC_DRAFT_VERSION < 27) |
1497 | 1497 |
1498 /* older drafts with static transport parameters encoding */ | 1498 /* older drafts with static transport parameters encoding */ |
1499 | 1499 |
1500 #define ngx_quic_tp_len(id, value) \ | 1500 #define ngx_quic_tp_len(id, value) \ |
1501 4 + ngx_quic_varint_len(value) | 1501 4 + ngx_quic_varint_len(value) |
1546 | 1546 |
1547 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, | 1547 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, |
1548 tp->initial_max_stream_data_uni); | 1548 tp->initial_max_stream_data_uni); |
1549 | 1549 |
1550 if (pos == NULL) { | 1550 if (pos == NULL) { |
1551 #if (quic_version < 0xff00001b) | 1551 #if (NGX_QUIC_DRAFT_VERSION < 27) |
1552 len += 2; | 1552 len += 2; |
1553 #endif | 1553 #endif |
1554 return len; | 1554 return len; |
1555 } | 1555 } |
1556 | 1556 |
1557 #if (quic_version < 0xff00001b) | 1557 #if (NGX_QUIC_DRAFT_VERSION < 27) |
1558 /* TLS extension length */ | 1558 /* TLS extension length */ |
1559 p = ngx_quic_write_uint16(p, len); | 1559 p = ngx_quic_write_uint16(p, len); |
1560 #endif | 1560 #endif |
1561 | 1561 |
1562 ngx_quic_tp_vint(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, | 1562 ngx_quic_tp_vint(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, |