Mercurial > hg > nginx
comparison src/event/ngx_event_quic_transport.c @ 8247:e9891e8ee975 quic
Configurable transport parameters.
- integer parameters can be configured using the following directives:
quic_max_idle_timeout
quic_max_ack_delay
quic_max_packet_size
quic_initial_max_data
quic_initial_max_stream_data_bidi_local
quic_initial_max_stream_data_bidi_remote
quic_initial_max_stream_data_uni
quic_initial_max_streams_bidi
quic_initial_max_streams_uni
quic_ack_delay_exponent
quic_active_migration
quic_active_connection_id_limit
- only following parameters are actually sent:
active_connection_id_limit
initial_max_streams_uni
initial_max_streams_bidi
initial_max_stream_data_bidi_local
initial_max_stream_data_bidi_remote
initial_max_stream_data_uni
(other parameters are to be added into ngx_quic_create_transport_params()
function as needed, should be easy now)
- draft 24 and draft 27 are now supported
(at compile-time using quic_version macro)
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 20 Mar 2020 13:47:44 +0300 |
parents | a14afe21e692 |
children | 3f4b407fa0b8 |
comparison
equal
deleted
inserted
replaced
8246:0d9bc77ae30d | 8247:e9891e8ee975 |
---|---|
85 "CONNECTION_ID_LIMIT_ERROR", | 85 "CONNECTION_ID_LIMIT_ERROR", |
86 "PROTOCOL_VIOLATION", | 86 "PROTOCOL_VIOLATION", |
87 "INVALID_TOKEN", | 87 "INVALID_TOKEN", |
88 "", | 88 "", |
89 "CRYPTO_BUFFER_EXCEEDED", | 89 "CRYPTO_BUFFER_EXCEEDED", |
90 "", | |
90 "CRYPTO_ERROR", | 91 "CRYPTO_ERROR", |
91 }; | 92 }; |
92 | 93 |
93 | 94 |
94 static ngx_inline u_char * | 95 static ngx_inline u_char * |
637 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, | 638 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, |
638 "failed to parse close reason"); | 639 "failed to parse close reason"); |
639 return NGX_ERROR; | 640 return NGX_ERROR; |
640 } | 641 } |
641 | 642 |
642 if (f->u.close.error_code > NGX_QUIC_ERR_LAST) { | 643 if (f->u.close.error_code >= NGX_QUIC_ERR_LAST) { |
643 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, | 644 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, |
644 "unkown error code: %ui, truncated", | 645 "unkown error code: %ui, truncated", |
645 f->u.close.error_code); | 646 f->u.close.error_code); |
646 f->u.close.error_code = NGX_QUIC_ERR_LAST; | 647 f->u.close.error_code = NGX_QUIC_ERR_LAST - 1; |
647 } | 648 } |
648 | 649 |
649 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 650 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
650 "CONN.CLOSE: { %s (0x%xi) type=0x%xi reason='%V'}", | 651 "CONN.CLOSE: { %s (0x%xi) type=0x%xi reason='%V'}", |
651 ngx_quic_error_text(f->u.close.error_code), | 652 ngx_quic_error_text(f->u.close.error_code), |
961 | 962 |
962 return p - start; | 963 return p - start; |
963 } | 964 } |
964 | 965 |
965 | 966 |
967 ssize_t | |
968 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) | |
969 { | |
970 u_char *p; | |
971 size_t len; | |
972 | |
973 #if (quic_version < 0xff00001b) | |
974 | |
975 /* older drafts with static transport parameters encoding */ | |
976 | |
977 #define ngx_quic_tp_len(id, value) \ | |
978 4 + ngx_quic_varint_len(value) | |
979 | |
980 #define ngx_quic_tp_vint(id, value) \ | |
981 do { \ | |
982 p = ngx_quic_write_uint16(p, id); \ | |
983 p = ngx_quic_write_uint16(p, ngx_quic_varint_len(value)); \ | |
984 ngx_quic_build_int(&p, value); \ | |
985 } while (0) | |
986 | |
987 #else | |
988 | |
989 /* recent drafts with variable integer transport parameters encoding */ | |
990 | |
991 #define ngx_quic_tp_len(id, value) \ | |
992 ngx_quic_varint_len(id) \ | |
993 + ngx_quic_varint_len(value) \ | |
994 + ngx_quic_varint_len(ngx_quic_varint_len(value)) | |
995 | |
996 #define ngx_quic_tp_vint(id, value) \ | |
997 do { \ | |
998 ngx_quic_build_int(&p, id); \ | |
999 ngx_quic_build_int(&p, ngx_quic_varint_len(value)); \ | |
1000 ngx_quic_build_int(&p, value); \ | |
1001 } while (0) | |
1002 | |
1003 #endif | |
1004 | |
1005 p = pos; | |
1006 | |
1007 len = ngx_quic_tp_len(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, | |
1008 tp->active_connection_id_limit); | |
1009 | |
1010 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_DATA,tp->initial_max_data); | |
1011 | |
1012 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, | |
1013 tp->initial_max_streams_uni); | |
1014 | |
1015 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, | |
1016 tp->initial_max_streams_bidi); | |
1017 | |
1018 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, | |
1019 tp->initial_max_stream_data_bidi_local); | |
1020 | |
1021 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, | |
1022 tp->initial_max_stream_data_bidi_remote); | |
1023 | |
1024 len += ngx_quic_tp_len(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, | |
1025 tp->initial_max_stream_data_uni); | |
1026 | |
1027 if (pos == NULL) { | |
1028 #if (quic_version < 0xff00001b) | |
1029 len += ngx_quic_varint_len(len); | |
1030 #endif | |
1031 return len; | |
1032 } | |
1033 | |
1034 #if (quic_version < 0xff00001b) | |
1035 /* TLS extension length */ | |
1036 p = ngx_quic_write_uint16(p, len); | |
1037 #endif | |
1038 | |
1039 ngx_quic_tp_vint(NGX_QUIC_TP_ACTIVE_CONNECTION_ID_LIMIT, | |
1040 tp->active_connection_id_limit); | |
1041 | |
1042 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_DATA, | |
1043 tp->initial_max_data); | |
1044 | |
1045 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_UNI, | |
1046 tp->initial_max_streams_uni); | |
1047 | |
1048 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAMS_BIDI, | |
1049 tp->initial_max_streams_bidi); | |
1050 | |
1051 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL, | |
1052 tp->initial_max_stream_data_bidi_local); | |
1053 | |
1054 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE, | |
1055 tp->initial_max_stream_data_bidi_remote); | |
1056 | |
1057 ngx_quic_tp_vint(NGX_QUIC_TP_INITIAL_MAX_STREAM_DATA_UNI, | |
1058 tp->initial_max_stream_data_uni); | |
1059 | |
1060 ngx_quic_hexdump0(ngx_cycle->log, "transport parameters", pos, p - pos); | |
1061 | |
1062 return p - pos; | |
1063 } | |
1064 | |
1065 | |
966 static size_t | 1066 static size_t |
967 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) | 1067 ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) |
968 { | 1068 { |
969 size_t len; | 1069 size_t len; |
970 u_char *start; | 1070 u_char *start; |