comparison src/event/ngx_event_quic_transport.c @ 7911:78e362f0b081 quic

Introduced macros for building length-value transport parameters.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 29 May 2020 13:05:57 +0300
parents 125cbfa77013
children 6633f17044eb
comparison
equal deleted inserted replaced
7910:125cbfa77013 7911:78e362f0b081
1611 ngx_quic_build_int(&p, id); \ 1611 ngx_quic_build_int(&p, id); \
1612 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \ 1612 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \
1613 ngx_quic_build_int(&p, value); \ 1613 ngx_quic_build_int(&p, value); \
1614 } while (0) 1614 } while (0)
1615 1615
1616 #define ngx_quic_tp_strlen(id, value) \
1617 ngx_quic_varint_len(id) \
1618 + ngx_quic_varint_len(value.len) \
1619 + value.len
1620
1621 #define ngx_quic_tp_str(id, value) \
1622 do { \
1623 ngx_quic_build_int(&p, id); \
1624 ngx_quic_build_int(&p, value.len); \
1625 p = ngx_cpymem(p, value.data, value.len); \
1626 } while (0)
1627
1616 p = pos; 1628 p = pos;
1617 1629
1618 len = ngx_quic_tp_len(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, 1630 len = ngx_quic_tp_len(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT,
1619 tp->active_connection_id_limit); 1631 tp->active_connection_id_limit);
1620 1632
1637 1649
1638 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, 1650 len += ngx_quic_tp_len(NGX_QUIC_TP_MAX_IDLE_TIMEOUT,
1639 tp->max_idle_timeout); 1651 tp->max_idle_timeout);
1640 1652
1641 if (tp->retry) { 1653 if (tp->retry) {
1642 len += ngx_quic_varint_len(NGX_QUIC_TP_ORIGINAL_CONNECTION_ID); 1654 len += ngx_quic_tp_strlen(NGX_QUIC_TP_ORIGINAL_CONNECTION_ID,
1643 len += ngx_quic_varint_len(tp->original_connection_id.len); 1655 tp->original_connection_id);
1644 len += tp->original_connection_id.len;
1645 } 1656 }
1646 1657
1647 if (pos == NULL) { 1658 if (pos == NULL) {
1648 return len; 1659 return len;
1649 } 1660 }
1671 1682
1672 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, 1683 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT,
1673 tp->max_idle_timeout); 1684 tp->max_idle_timeout);
1674 1685
1675 if (tp->retry) { 1686 if (tp->retry) {
1676 ngx_quic_build_int(&p, NGX_QUIC_TP_ORIGINAL_CONNECTION_ID); 1687 ngx_quic_tp_str(NGX_QUIC_TP_ORIGINAL_CONNECTION_ID,
1677 ngx_quic_build_int(&p, tp->original_connection_id.len); 1688 tp->original_connection_id);
1678 p = ngx_cpymem(p, tp->original_connection_id.data,
1679 tp->original_connection_id.len);
1680 } 1689 }
1681 1690
1682 return p - pos; 1691 return p - pos;
1683 } 1692 }
1684 1693