Mercurial > hg > nginx
comparison src/event/ngx_event_quic_transport.c @ 8417:6633f17044eb quic
QUIC draft-28 transport parameters support.
Draft-27 and draft-28 support can now be enabled interchangeably,
it's based on the compile-time macro NGX_QUIC_DRAFT_VERSION.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 29 May 2020 15:06:33 +0300 |
parents | 78e362f0b081 |
children | c206233d9c29 |
comparison
equal
deleted
inserted
replaced
8416:78e362f0b081 | 8417:6633f17044eb |
---|---|
1352 static ngx_int_t | 1352 static ngx_int_t |
1353 ngx_quic_parse_transport_param(u_char *p, u_char *end, uint16_t id, | 1353 ngx_quic_parse_transport_param(u_char *p, u_char *end, uint16_t id, |
1354 ngx_quic_tp_t *dst) | 1354 ngx_quic_tp_t *dst) |
1355 { | 1355 { |
1356 uint64_t varint; | 1356 uint64_t varint; |
1357 ngx_str_t str; | |
1358 | |
1359 varint = 0; | |
1360 ngx_str_null(&str); | |
1357 | 1361 |
1358 switch (id) { | 1362 switch (id) { |
1359 | 1363 |
1360 case NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION: | 1364 case NGX_QUIC_TP_DISABLE_ACTIVE_MIGRATION: |
1361 /* zero-length option */ | 1365 /* zero-length option */ |
1381 if (p == NULL) { | 1385 if (p == NULL) { |
1382 return NGX_ERROR; | 1386 return NGX_ERROR; |
1383 } | 1387 } |
1384 break; | 1388 break; |
1385 | 1389 |
1390 case NGX_QUIC_TP_INITIAL_SCID: | |
1391 | |
1392 str.len = end - p; | |
1393 p = ngx_quic_read_bytes(p, end, str.len, &str.data); | |
1394 break; | |
1395 | |
1386 default: | 1396 default: |
1387 return NGX_DECLINED; | 1397 return NGX_DECLINED; |
1388 } | 1398 } |
1389 | 1399 |
1390 switch (id) { | 1400 switch (id) { |
1429 dst->max_ack_delay = varint; | 1439 dst->max_ack_delay = varint; |
1430 break; | 1440 break; |
1431 | 1441 |
1432 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: | 1442 case NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT: |
1433 dst->active_connection_id_limit = varint; | 1443 dst->active_connection_id_limit = varint; |
1444 break; | |
1445 | |
1446 case NGX_QUIC_TP_INITIAL_SCID: | |
1447 dst->initial_scid = str; | |
1434 break; | 1448 break; |
1435 | 1449 |
1436 default: | 1450 default: |
1437 return NGX_ERROR; | 1451 return NGX_ERROR; |
1438 } | 1452 } |
1455 "quic failed to parse transport param id"); | 1469 "quic failed to parse transport param id"); |
1456 return NGX_ERROR; | 1470 return NGX_ERROR; |
1457 } | 1471 } |
1458 | 1472 |
1459 switch (id) { | 1473 switch (id) { |
1460 case NGX_QUIC_TP_ORIGINAL_CONNECTION_ID: | 1474 case NGX_QUIC_TP_ORIGINAL_DCID: |
1461 case NGX_QUIC_TP_PREFERRED_ADDRESS: | 1475 case NGX_QUIC_TP_PREFERRED_ADDRESS: |
1476 case NGX_QUIC_TP_RETRY_SCID: | |
1462 case NGX_QUIC_TP_STATELESS_RESET_TOKEN: | 1477 case NGX_QUIC_TP_STATELESS_RESET_TOKEN: |
1463 ngx_log_error(NGX_LOG_INFO, log, 0, | 1478 ngx_log_error(NGX_LOG_INFO, log, 0, |
1464 "quic client sent forbidden transport param" | 1479 "quic client sent forbidden transport param" |
1465 " id 0x%xi", id); | 1480 " id 0x%xi", id); |
1466 return NGX_ERROR; | 1481 return NGX_ERROR; |
1544 tp->max_ack_delay); | 1559 tp->max_ack_delay); |
1545 | 1560 |
1546 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, | 1561 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, |
1547 "quic tp active_connection_id_limit: %ui", | 1562 "quic tp active_connection_id_limit: %ui", |
1548 tp->active_connection_id_limit); | 1563 tp->active_connection_id_limit); |
1564 | |
1565 #if (NGX_QUIC_DRAFT_VERSION >= 28) | |
1566 ngx_quic_hexdump(log, "quic tp initial_source_connection_id:", | |
1567 tp->initial_scid.data, tp->initial_scid.len); | |
1568 #endif | |
1549 | 1569 |
1550 return NGX_OK; | 1570 return NGX_OK; |
1551 } | 1571 } |
1552 | 1572 |
1553 | 1573 |
1648 tp->initial_max_stream_data_uni); | 1668 tp->initial_max_stream_data_uni); |
1649 | 1669 |
1650 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, | 1670 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, |
1651 tp->max_idle_timeout); | 1671 tp->max_idle_timeout); |
1652 | 1672 |
1673 #if (NGX_QUIC_DRAFT_VERSION >= 28) | |
1674 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); | |
1675 len += ngx_quic_tp_strlen(NGX_QUIC_TP_INITIAL_SCID, tp->initial_scid); | |
1676 #endif | |
1677 | |
1653 if (tp->retry) { | 1678 if (tp->retry) { |
1654 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_CONNECTION_ID, | 1679 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
1655 tp->original_connection_id); | 1680 len += ngx_quic_tp_strlen(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
1681 #else | |
1682 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); | |
1683 #endif | |
1656 } | 1684 } |
1657 | 1685 |
1658 if (pos == NULL) { | 1686 if (pos == NULL) { |
1659 return len; | 1687 return len; |
1660 } | 1688 } |
1681 tp->initial_max_stream_data_uni); | 1709 tp->initial_max_stream_data_uni); |
1682 | 1710 |
1683 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, | 1711 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, |
1684 tp->max_idle_timeout); | 1712 tp->max_idle_timeout); |
1685 | 1713 |
1714 #if (NGX_QUIC_DRAFT_VERSION >= 28) | |
1715 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); | |
1716 ngx_quic_tp_str(NGX_QUIC_TP_INITIAL_SCID, tp->initial_scid); | |
1717 #endif | |
1718 | |
1686 if (tp->retry) { | 1719 if (tp->retry) { |
1687 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_CONNECTION_ID, | 1720 #if (NGX_QUIC_DRAFT_VERSION >= 28) |
1688 tp->original_connection_id); | 1721 ngx_quic_tp_str(NGX_QUIC_TP_RETRY_SCID, tp->retry_scid); |
1722 #else | |
1723 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_DCID, tp->original_dcid); | |
1724 #endif | |
1689 } | 1725 } |
1690 | 1726 |
1691 return p - pos; | 1727 return p - pos; |
1692 } | 1728 } |
1693 | 1729 |