protocol-quic 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/ext/ngtcp2/AUTHORS +44 -0
- data/ext/ngtcp2/CMakeLists.txt +431 -0
- data/ext/ngtcp2/CMakeOptions.txt +17 -0
- data/ext/ngtcp2/COPYING +22 -0
- data/ext/ngtcp2/ChangeLog +0 -0
- data/ext/ngtcp2/Makefile.am +60 -0
- data/ext/ngtcp2/NEWS +0 -0
- data/ext/ngtcp2/README +1 -0
- data/ext/ngtcp2/README.rst +258 -0
- data/ext/ngtcp2/ci/build_boringssl.sh +10 -0
- data/ext/ngtcp2/ci/build_nghttp3.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl1.sh +8 -0
- data/ext/ngtcp2/ci/build_openssl1_cross.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl3.sh +8 -0
- data/ext/ngtcp2/ci/build_picotls.sh +26 -0
- data/ext/ngtcp2/ci/build_wolfssl.sh +9 -0
- data/ext/ngtcp2/ci/gen-certificate.sh +8 -0
- data/ext/ngtcp2/cmake/ExtractValidFlags.cmake +31 -0
- data/ext/ngtcp2/cmake/FindCUnit.cmake +40 -0
- data/ext/ngtcp2/cmake/FindJemalloc.cmake +40 -0
- data/ext/ngtcp2/cmake/FindLibev.cmake +38 -0
- data/ext/ngtcp2/cmake/FindLibnghttp3.cmake +41 -0
- data/ext/ngtcp2/cmake/Findwolfssl.cmake +41 -0
- data/ext/ngtcp2/cmake/Version.cmake +11 -0
- data/ext/ngtcp2/cmakeconfig.h.in +36 -0
- data/ext/ngtcp2/configure.ac +755 -0
- data/ext/ngtcp2/crypto/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/Makefile.am +49 -0
- data/ext/ngtcp2/crypto/boringssl/CMakeLists.txt +64 -0
- data/ext/ngtcp2/crypto/boringssl/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/boringssl/boringssl.c +630 -0
- data/ext/ngtcp2/crypto/boringssl/libngtcp2_crypto_boringssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/gnutls/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/gnutls/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/gnutls/gnutls.c +644 -0
- data/ext/ngtcp2/crypto/gnutls/libngtcp2_crypto_gnutls.pc.in +33 -0
- data/ext/ngtcp2/crypto/includes/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/includes/Makefile.am +45 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto.h +893 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_boringssl.h +104 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_gnutls.h +107 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_openssl.h +132 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_picotls.h +246 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
- data/ext/ngtcp2/crypto/openssl/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/openssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/openssl/libngtcp2_crypto_openssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/openssl/openssl.c +807 -0
- data/ext/ngtcp2/crypto/picotls/CMakeLists.txt +65 -0
- data/ext/ngtcp2/crypto/picotls/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/picotls/libngtcp2_crypto_picotls.pc.in +33 -0
- data/ext/ngtcp2/crypto/picotls/picotls.c +707 -0
- data/ext/ngtcp2/crypto/shared.c +1431 -0
- data/ext/ngtcp2/crypto/shared.h +350 -0
- data/ext/ngtcp2/crypto/wolfssl/CMakeLists.txt +84 -0
- data/ext/ngtcp2/crypto/wolfssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/wolfssl/libngtcp2_crypto_wolfssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/wolfssl/wolfssl.c +534 -0
- data/ext/ngtcp2/doc/Makefile.am +65 -0
- data/ext/ngtcp2/doc/make.bat +35 -0
- data/ext/ngtcp2/doc/mkapiref.py +356 -0
- data/ext/ngtcp2/doc/source/conf.py.in +94 -0
- data/ext/ngtcp2/doc/source/index.rst +22 -0
- data/ext/ngtcp2/doc/source/programmers-guide.rst +476 -0
- data/ext/ngtcp2/docker/Dockerfile +39 -0
- data/ext/ngtcp2/examples/CMakeLists.txt +361 -0
- data/ext/ngtcp2/examples/Makefile.am +228 -0
- data/ext/ngtcp2/examples/client.cc +3049 -0
- data/ext/ngtcp2/examples/client.h +192 -0
- data/ext/ngtcp2/examples/client_base.cc +202 -0
- data/ext/ngtcp2/examples/client_base.h +213 -0
- data/ext/ngtcp2/examples/debug.cc +298 -0
- data/ext/ngtcp2/examples/debug.h +124 -0
- data/ext/ngtcp2/examples/examplestest.cc +84 -0
- data/ext/ngtcp2/examples/gtlssimpleclient.c +720 -0
- data/ext/ngtcp2/examples/h09client.cc +2601 -0
- data/ext/ngtcp2/examples/h09client.h +196 -0
- data/ext/ngtcp2/examples/h09server.cc +3024 -0
- data/ext/ngtcp2/examples/h09server.h +237 -0
- data/ext/ngtcp2/examples/http.cc +138 -0
- data/ext/ngtcp2/examples/http.h +44 -0
- data/ext/ngtcp2/examples/network.h +80 -0
- data/ext/ngtcp2/examples/server.cc +3731 -0
- data/ext/ngtcp2/examples/server.h +256 -0
- data/ext/ngtcp2/examples/server_base.cc +58 -0
- data/ext/ngtcp2/examples/server_base.h +195 -0
- data/ext/ngtcp2/examples/shared.cc +385 -0
- data/ext/ngtcp2/examples/shared.h +96 -0
- data/ext/ngtcp2/examples/simpleclient.c +683 -0
- data/ext/ngtcp2/examples/template.h +71 -0
- data/ext/ngtcp2/examples/tests/README.rst +60 -0
- data/ext/ngtcp2/examples/tests/__init__.py +0 -0
- data/ext/ngtcp2/examples/tests/config.ini.in +32 -0
- data/ext/ngtcp2/examples/tests/conftest.py +28 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/__init__.py +6 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/certs.py +476 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/client.py +187 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/env.py +191 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/log.py +101 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/server.py +137 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/tls.py +983 -0
- data/ext/ngtcp2/examples/tests/test_01_handshake.py +30 -0
- data/ext/ngtcp2/examples/tests/test_02_resume.py +46 -0
- data/ext/ngtcp2/examples/tests/test_03_earlydata.py +56 -0
- data/ext/ngtcp2/examples/tests/test_04_clientcert.py +57 -0
- data/ext/ngtcp2/examples/tests/test_05_ciphers.py +46 -0
- data/ext/ngtcp2/examples/tls_client_context.h +52 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.cc +126 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.cc +74 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.h +50 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.cc +137 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.cc +158 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.h +53 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.cc +177 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.h +51 -0
- data/ext/ngtcp2/examples/tls_client_session.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.cc +110 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.cc +190 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.cc +113 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.cc +147 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.cc +160 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.cc +257 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.cc +99 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.h +59 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.cc +338 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.cc +321 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.h +58 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.cc +284 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.h +55 -0
- data/ext/ngtcp2/examples/tls_server_session.h +52 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.cc +84 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.cc +155 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.h +46 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.cc +70 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.cc +55 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.h +47 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.cc +87 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.h +51 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.cc +56 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.h +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.h +54 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.cc +59 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.h +36 -0
- data/ext/ngtcp2/examples/util.cc +646 -0
- data/ext/ngtcp2/examples/util.h +361 -0
- data/ext/ngtcp2/examples/util_gnutls.cc +136 -0
- data/ext/ngtcp2/examples/util_openssl.cc +131 -0
- data/ext/ngtcp2/examples/util_test.cc +237 -0
- data/ext/ngtcp2/examples/util_test.h +45 -0
- data/ext/ngtcp2/examples/util_wolfssl.cc +130 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack_ecn +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/connection_close +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/crypto +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/data_blocked +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram_len +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_data +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_stream_data +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_streams +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_token +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_challenge +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_response +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/reset_stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/retire_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stop_sending +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_data_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_len +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/streams_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/ksl/random +0 -0
- data/ext/ngtcp2/fuzz/decode_frame.cc +25 -0
- data/ext/ngtcp2/fuzz/ksl.cc +77 -0
- data/ext/ngtcp2/interop/Dockerfile +39 -0
- data/ext/ngtcp2/interop/run_endpoint.sh +93 -0
- data/ext/ngtcp2/lib/CMakeLists.txt +110 -0
- data/ext/ngtcp2/lib/Makefile.am +122 -0
- data/ext/ngtcp2/lib/includes/CMakeLists.txt +4 -0
- data/ext/ngtcp2/lib/includes/Makefile.am +25 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/ngtcp2.h +5843 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/version.h.in +51 -0
- data/ext/ngtcp2/lib/libngtcp2.pc.in +33 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.c +335 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.h +221 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.c +117 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.h +69 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.c +90 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.h +91 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.c +693 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.h +157 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.c +1490 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.h +149 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.c +56 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.h +108 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.c +616 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.h +422 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.c +147 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.h +175 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.c +13731 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.h +1119 -0
- data/ext/ngtcp2/lib/ngtcp2_conn_stat.h +131 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.c +291 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.h +208 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.c +895 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.h +148 -0
- data/ext/ngtcp2/lib/ngtcp2_err.c +154 -0
- data/ext/ngtcp2/lib/ngtcp2_err.h +34 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.c +167 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.h +98 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.c +79 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.h +89 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.c +819 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.h +345 -0
- data/ext/ngtcp2/lib/ngtcp2_log.c +822 -0
- data/ext/ngtcp2/lib/ngtcp2_log.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_macro.h +58 -0
- data/ext/ngtcp2/lib/ngtcp2_map.c +336 -0
- data/ext/ngtcp2/lib/ngtcp2_map.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.c +113 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.h +72 -0
- data/ext/ngtcp2/lib/ngtcp2_net.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.c +40 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.h +140 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.c +46 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.h +65 -0
- data/ext/ngtcp2/lib/ngtcp2_path.c +77 -0
- data/ext/ngtcp2/lib/ngtcp2_path.h +49 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.c +2527 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.h +1235 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.c +160 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.c +230 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.h +153 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.c +164 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.h +126 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.c +172 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.h +194 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.c +1219 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.h +161 -0
- data/ext/ngtcp2/lib/ngtcp2_range.c +61 -0
- data/ext/ngtcp2/lib/ngtcp2_range.h +80 -0
- data/ext/ngtcp2/lib/ngtcp2_rcvry.h +40 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.c +121 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.h +132 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.c +319 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.h +197 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.c +138 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.h +86 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.c +1676 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.h +468 -0
- data/ext/ngtcp2/lib/ngtcp2_str.c +233 -0
- data/ext/ngtcp2/lib/ngtcp2_str.h +94 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.c +698 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.h +310 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.c +71 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.h +46 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.c +243 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.h +120 -0
- data/ext/ngtcp2/lib/ngtcp2_version.c +39 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.c +99 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.h +65 -0
- data/ext/ngtcp2/m4/ax_check_compile_flag.m4 +74 -0
- data/ext/ngtcp2/m4/ax_cxx_compile_stdcxx.m4 +1009 -0
- data/ext/ngtcp2/tests/CMakeLists.txt +68 -0
- data/ext/ngtcp2/tests/Makefile.am +94 -0
- data/ext/ngtcp2/tests/main.c +358 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.c +367 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.c +9821 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.h +104 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.c +430 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.h +46 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.c +667 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.c +127 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.c +79 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.c +502 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.h +39 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.c +206 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.c +1645 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.h +68 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.c +153 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.c +129 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.c +105 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.c +91 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.c +552 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.c +470 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.c +96 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.c +575 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.c +404 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.h +191 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.c +426 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.h +36 -0
- data/ext/ngtcp2/third-party/CMakeLists.txt +34 -0
- data/ext/ngtcp2/third-party/Makefile.am +31 -0
- data/ext/ngtcp2/third-party/http-parser/AUTHORS +68 -0
- data/ext/ngtcp2/third-party/http-parser/LICENSE-MIT +23 -0
- data/ext/ngtcp2/third-party/http-parser/Makefile +157 -0
- data/ext/ngtcp2/third-party/http-parser/README.md +246 -0
- data/ext/ngtcp2/third-party/http-parser/bench.c +111 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/parsertrace.c +160 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/url_parser.c +47 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.c +2419 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.gyp +111 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.h +431 -0
- data/ext/ngtcp2/third-party/http-parser/test.c +4411 -0
- data/lib/protocol/quic/version.rb +10 -0
- data/lib/protocol/quic.rb +9 -0
- data/license.md +21 -0
- data.tar.gz.sig +1 -0
- metadata +424 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,895 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2017 ngtcp2 contributors
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
#include "ngtcp2_crypto.h"
|
26
|
+
|
27
|
+
#include <string.h>
|
28
|
+
#include <assert.h>
|
29
|
+
|
30
|
+
#include "ngtcp2_str.h"
|
31
|
+
#include "ngtcp2_conv.h"
|
32
|
+
#include "ngtcp2_conn.h"
|
33
|
+
#include "ngtcp2_net.h"
|
34
|
+
|
35
|
+
int ngtcp2_crypto_km_new(ngtcp2_crypto_km **pckm, const uint8_t *secret,
|
36
|
+
size_t secretlen,
|
37
|
+
const ngtcp2_crypto_aead_ctx *aead_ctx,
|
38
|
+
const uint8_t *iv, size_t ivlen,
|
39
|
+
const ngtcp2_mem *mem) {
|
40
|
+
int rv = ngtcp2_crypto_km_nocopy_new(pckm, secretlen, ivlen, mem);
|
41
|
+
if (rv != 0) {
|
42
|
+
return rv;
|
43
|
+
}
|
44
|
+
|
45
|
+
if (secretlen) {
|
46
|
+
memcpy((*pckm)->secret.base, secret, secretlen);
|
47
|
+
}
|
48
|
+
if (aead_ctx) {
|
49
|
+
(*pckm)->aead_ctx = *aead_ctx;
|
50
|
+
}
|
51
|
+
memcpy((*pckm)->iv.base, iv, ivlen);
|
52
|
+
|
53
|
+
return 0;
|
54
|
+
}
|
55
|
+
|
56
|
+
int ngtcp2_crypto_km_nocopy_new(ngtcp2_crypto_km **pckm, size_t secretlen,
|
57
|
+
size_t ivlen, const ngtcp2_mem *mem) {
|
58
|
+
size_t len;
|
59
|
+
uint8_t *p;
|
60
|
+
|
61
|
+
len = sizeof(ngtcp2_crypto_km) + secretlen + ivlen;
|
62
|
+
|
63
|
+
*pckm = ngtcp2_mem_malloc(mem, len);
|
64
|
+
if (*pckm == NULL) {
|
65
|
+
return NGTCP2_ERR_NOMEM;
|
66
|
+
}
|
67
|
+
|
68
|
+
p = (uint8_t *)(*pckm) + sizeof(ngtcp2_crypto_km);
|
69
|
+
(*pckm)->secret.base = p;
|
70
|
+
(*pckm)->secret.len = secretlen;
|
71
|
+
p += secretlen;
|
72
|
+
(*pckm)->iv.base = p;
|
73
|
+
(*pckm)->iv.len = ivlen;
|
74
|
+
(*pckm)->aead_ctx.native_handle = NULL;
|
75
|
+
(*pckm)->pkt_num = -1;
|
76
|
+
(*pckm)->use_count = 0;
|
77
|
+
(*pckm)->flags = NGTCP2_CRYPTO_KM_FLAG_NONE;
|
78
|
+
|
79
|
+
return 0;
|
80
|
+
}
|
81
|
+
|
82
|
+
void ngtcp2_crypto_km_del(ngtcp2_crypto_km *ckm, const ngtcp2_mem *mem) {
|
83
|
+
if (ckm == NULL) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
ngtcp2_mem_free(mem, ckm);
|
88
|
+
}
|
89
|
+
|
90
|
+
void ngtcp2_crypto_create_nonce(uint8_t *dest, const uint8_t *iv, size_t ivlen,
|
91
|
+
int64_t pkt_num) {
|
92
|
+
size_t i;
|
93
|
+
uint64_t n;
|
94
|
+
|
95
|
+
assert(ivlen >= 8);
|
96
|
+
|
97
|
+
memcpy(dest, iv, ivlen);
|
98
|
+
n = ngtcp2_htonl64((uint64_t)pkt_num);
|
99
|
+
|
100
|
+
for (i = 0; i < 8; ++i) {
|
101
|
+
dest[ivlen - 8 + i] ^= ((uint8_t *)&n)[i];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
/*
|
106
|
+
* varint_paramlen returns the length of a single transport parameter
|
107
|
+
* which has variable integer in its parameter.
|
108
|
+
*/
|
109
|
+
static size_t varint_paramlen(ngtcp2_transport_param_id id, uint64_t param) {
|
110
|
+
size_t valuelen = ngtcp2_put_uvarintlen(param);
|
111
|
+
return ngtcp2_put_uvarintlen(id) + ngtcp2_put_uvarintlen(valuelen) + valuelen;
|
112
|
+
}
|
113
|
+
|
114
|
+
/*
|
115
|
+
* write_varint_param writes parameter |id| of the given |value| in
|
116
|
+
* varint encoding. It returns p + the number of bytes written.
|
117
|
+
*/
|
118
|
+
static uint8_t *write_varint_param(uint8_t *p, ngtcp2_transport_param_id id,
|
119
|
+
uint64_t value) {
|
120
|
+
p = ngtcp2_put_uvarint(p, id);
|
121
|
+
p = ngtcp2_put_uvarint(p, ngtcp2_put_uvarintlen(value));
|
122
|
+
return ngtcp2_put_uvarint(p, value);
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* cid_paramlen returns the length of a single transport parameter
|
127
|
+
* which has |cid| as value.
|
128
|
+
*/
|
129
|
+
static size_t cid_paramlen(ngtcp2_transport_param_id id,
|
130
|
+
const ngtcp2_cid *cid) {
|
131
|
+
return ngtcp2_put_uvarintlen(id) + ngtcp2_put_uvarintlen(cid->datalen) +
|
132
|
+
cid->datalen;
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* write_cid_param writes parameter |id| of the given |cid|. It
|
137
|
+
* returns p + the number of bytes written.
|
138
|
+
*/
|
139
|
+
static uint8_t *write_cid_param(uint8_t *p, ngtcp2_transport_param_id id,
|
140
|
+
const ngtcp2_cid *cid) {
|
141
|
+
assert(cid->datalen == 0 || cid->datalen >= NGTCP2_MIN_CIDLEN);
|
142
|
+
assert(cid->datalen <= NGTCP2_MAX_CIDLEN);
|
143
|
+
|
144
|
+
p = ngtcp2_put_uvarint(p, id);
|
145
|
+
p = ngtcp2_put_uvarint(p, cid->datalen);
|
146
|
+
if (cid->datalen) {
|
147
|
+
p = ngtcp2_cpymem(p, cid->data, cid->datalen);
|
148
|
+
}
|
149
|
+
return p;
|
150
|
+
}
|
151
|
+
|
152
|
+
static const uint8_t empty_address[16];
|
153
|
+
|
154
|
+
ngtcp2_ssize ngtcp2_encode_transport_params_versioned(
|
155
|
+
uint8_t *dest, size_t destlen, ngtcp2_transport_params_type exttype,
|
156
|
+
int transport_params_version, const ngtcp2_transport_params *params) {
|
157
|
+
uint8_t *p;
|
158
|
+
size_t len = 0;
|
159
|
+
/* For some reason, gcc 7.3.0 requires this initialization. */
|
160
|
+
size_t preferred_addrlen = 0;
|
161
|
+
size_t version_infolen = 0;
|
162
|
+
const ngtcp2_sockaddr_in *sa_in;
|
163
|
+
const ngtcp2_sockaddr_in6 *sa_in6;
|
164
|
+
(void)transport_params_version;
|
165
|
+
|
166
|
+
switch (exttype) {
|
167
|
+
case NGTCP2_TRANSPORT_PARAMS_TYPE_CLIENT_HELLO:
|
168
|
+
break;
|
169
|
+
case NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS:
|
170
|
+
len +=
|
171
|
+
cid_paramlen(NGTCP2_TRANSPORT_PARAM_ORIGINAL_DESTINATION_CONNECTION_ID,
|
172
|
+
¶ms->original_dcid);
|
173
|
+
|
174
|
+
if (params->stateless_reset_token_present) {
|
175
|
+
len +=
|
176
|
+
ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_STATELESS_RESET_TOKEN) +
|
177
|
+
ngtcp2_put_uvarintlen(NGTCP2_STATELESS_RESET_TOKENLEN) +
|
178
|
+
NGTCP2_STATELESS_RESET_TOKENLEN;
|
179
|
+
}
|
180
|
+
if (params->preferred_address_present) {
|
181
|
+
assert(params->preferred_address.cid.datalen >= NGTCP2_MIN_CIDLEN);
|
182
|
+
assert(params->preferred_address.cid.datalen <= NGTCP2_MAX_CIDLEN);
|
183
|
+
preferred_addrlen = 4 /* ipv4Address */ + 2 /* ipv4Port */ +
|
184
|
+
16 /* ipv6Address */ + 2 /* ipv6Port */
|
185
|
+
+ 1 +
|
186
|
+
params->preferred_address.cid.datalen /* CID */ +
|
187
|
+
NGTCP2_STATELESS_RESET_TOKENLEN;
|
188
|
+
len += ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_PREFERRED_ADDRESS) +
|
189
|
+
ngtcp2_put_uvarintlen(preferred_addrlen) + preferred_addrlen;
|
190
|
+
}
|
191
|
+
if (params->retry_scid_present) {
|
192
|
+
len += cid_paramlen(NGTCP2_TRANSPORT_PARAM_RETRY_SOURCE_CONNECTION_ID,
|
193
|
+
¶ms->retry_scid);
|
194
|
+
}
|
195
|
+
break;
|
196
|
+
default:
|
197
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
198
|
+
}
|
199
|
+
|
200
|
+
len += cid_paramlen(NGTCP2_TRANSPORT_PARAM_INITIAL_SOURCE_CONNECTION_ID,
|
201
|
+
¶ms->initial_scid);
|
202
|
+
|
203
|
+
if (params->initial_max_stream_data_bidi_local) {
|
204
|
+
len += varint_paramlen(
|
205
|
+
NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL,
|
206
|
+
params->initial_max_stream_data_bidi_local);
|
207
|
+
}
|
208
|
+
if (params->initial_max_stream_data_bidi_remote) {
|
209
|
+
len += varint_paramlen(
|
210
|
+
NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE,
|
211
|
+
params->initial_max_stream_data_bidi_remote);
|
212
|
+
}
|
213
|
+
if (params->initial_max_stream_data_uni) {
|
214
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_UNI,
|
215
|
+
params->initial_max_stream_data_uni);
|
216
|
+
}
|
217
|
+
if (params->initial_max_data) {
|
218
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_DATA,
|
219
|
+
params->initial_max_data);
|
220
|
+
}
|
221
|
+
if (params->initial_max_streams_bidi) {
|
222
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_BIDI,
|
223
|
+
params->initial_max_streams_bidi);
|
224
|
+
}
|
225
|
+
if (params->initial_max_streams_uni) {
|
226
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_UNI,
|
227
|
+
params->initial_max_streams_uni);
|
228
|
+
}
|
229
|
+
if (params->max_udp_payload_size !=
|
230
|
+
NGTCP2_DEFAULT_MAX_RECV_UDP_PAYLOAD_SIZE) {
|
231
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_MAX_UDP_PAYLOAD_SIZE,
|
232
|
+
params->max_udp_payload_size);
|
233
|
+
}
|
234
|
+
if (params->ack_delay_exponent != NGTCP2_DEFAULT_ACK_DELAY_EXPONENT) {
|
235
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_ACK_DELAY_EXPONENT,
|
236
|
+
params->ack_delay_exponent);
|
237
|
+
}
|
238
|
+
if (params->disable_active_migration) {
|
239
|
+
len +=
|
240
|
+
ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION) +
|
241
|
+
ngtcp2_put_uvarintlen(0);
|
242
|
+
}
|
243
|
+
if (params->max_ack_delay != NGTCP2_DEFAULT_MAX_ACK_DELAY) {
|
244
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_MAX_ACK_DELAY,
|
245
|
+
params->max_ack_delay / NGTCP2_MILLISECONDS);
|
246
|
+
}
|
247
|
+
if (params->max_idle_timeout) {
|
248
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_MAX_IDLE_TIMEOUT,
|
249
|
+
params->max_idle_timeout / NGTCP2_MILLISECONDS);
|
250
|
+
}
|
251
|
+
if (params->active_connection_id_limit &&
|
252
|
+
params->active_connection_id_limit !=
|
253
|
+
NGTCP2_DEFAULT_ACTIVE_CONNECTION_ID_LIMIT) {
|
254
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_ACTIVE_CONNECTION_ID_LIMIT,
|
255
|
+
params->active_connection_id_limit);
|
256
|
+
}
|
257
|
+
if (params->max_datagram_frame_size) {
|
258
|
+
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_MAX_DATAGRAM_FRAME_SIZE,
|
259
|
+
params->max_datagram_frame_size);
|
260
|
+
}
|
261
|
+
if (params->grease_quic_bit) {
|
262
|
+
len += ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT) +
|
263
|
+
ngtcp2_put_uvarintlen(0);
|
264
|
+
}
|
265
|
+
if (params->version_info_present) {
|
266
|
+
version_infolen =
|
267
|
+
sizeof(uint32_t) + params->version_info.available_versionslen;
|
268
|
+
len += ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_VERSION_INFORMATION) +
|
269
|
+
ngtcp2_put_uvarintlen(version_infolen) + version_infolen;
|
270
|
+
}
|
271
|
+
|
272
|
+
if (dest == NULL && destlen == 0) {
|
273
|
+
return (ngtcp2_ssize)len;
|
274
|
+
}
|
275
|
+
|
276
|
+
if (destlen < len) {
|
277
|
+
return NGTCP2_ERR_NOBUF;
|
278
|
+
}
|
279
|
+
|
280
|
+
p = dest;
|
281
|
+
|
282
|
+
if (exttype == NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
|
283
|
+
p = write_cid_param(
|
284
|
+
p, NGTCP2_TRANSPORT_PARAM_ORIGINAL_DESTINATION_CONNECTION_ID,
|
285
|
+
¶ms->original_dcid);
|
286
|
+
|
287
|
+
if (params->stateless_reset_token_present) {
|
288
|
+
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_STATELESS_RESET_TOKEN);
|
289
|
+
p = ngtcp2_put_uvarint(p, sizeof(params->stateless_reset_token));
|
290
|
+
p = ngtcp2_cpymem(p, params->stateless_reset_token,
|
291
|
+
sizeof(params->stateless_reset_token));
|
292
|
+
}
|
293
|
+
if (params->preferred_address_present) {
|
294
|
+
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_PREFERRED_ADDRESS);
|
295
|
+
p = ngtcp2_put_uvarint(p, preferred_addrlen);
|
296
|
+
|
297
|
+
if (params->preferred_address.ipv4_present) {
|
298
|
+
sa_in = ¶ms->preferred_address.ipv4;
|
299
|
+
p = ngtcp2_cpymem(p, &sa_in->sin_addr, sizeof(sa_in->sin_addr));
|
300
|
+
p = ngtcp2_put_uint16(p, sa_in->sin_port);
|
301
|
+
} else {
|
302
|
+
p = ngtcp2_cpymem(p, empty_address, sizeof(sa_in->sin_addr));
|
303
|
+
p = ngtcp2_put_uint16(p, 0);
|
304
|
+
}
|
305
|
+
|
306
|
+
if (params->preferred_address.ipv6_present) {
|
307
|
+
sa_in6 = ¶ms->preferred_address.ipv6;
|
308
|
+
p = ngtcp2_cpymem(p, &sa_in6->sin6_addr, sizeof(sa_in6->sin6_addr));
|
309
|
+
p = ngtcp2_put_uint16(p, sa_in6->sin6_port);
|
310
|
+
} else {
|
311
|
+
p = ngtcp2_cpymem(p, empty_address, sizeof(sa_in6->sin6_addr));
|
312
|
+
p = ngtcp2_put_uint16(p, 0);
|
313
|
+
}
|
314
|
+
|
315
|
+
*p++ = (uint8_t)params->preferred_address.cid.datalen;
|
316
|
+
if (params->preferred_address.cid.datalen) {
|
317
|
+
p = ngtcp2_cpymem(p, params->preferred_address.cid.data,
|
318
|
+
params->preferred_address.cid.datalen);
|
319
|
+
}
|
320
|
+
p = ngtcp2_cpymem(
|
321
|
+
p, params->preferred_address.stateless_reset_token,
|
322
|
+
sizeof(params->preferred_address.stateless_reset_token));
|
323
|
+
}
|
324
|
+
if (params->retry_scid_present) {
|
325
|
+
p = write_cid_param(p, NGTCP2_TRANSPORT_PARAM_RETRY_SOURCE_CONNECTION_ID,
|
326
|
+
¶ms->retry_scid);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
p = write_cid_param(p, NGTCP2_TRANSPORT_PARAM_INITIAL_SOURCE_CONNECTION_ID,
|
331
|
+
¶ms->initial_scid);
|
332
|
+
|
333
|
+
if (params->initial_max_stream_data_bidi_local) {
|
334
|
+
p = write_varint_param(
|
335
|
+
p, NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL,
|
336
|
+
params->initial_max_stream_data_bidi_local);
|
337
|
+
}
|
338
|
+
|
339
|
+
if (params->initial_max_stream_data_bidi_remote) {
|
340
|
+
p = write_varint_param(
|
341
|
+
p, NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE,
|
342
|
+
params->initial_max_stream_data_bidi_remote);
|
343
|
+
}
|
344
|
+
|
345
|
+
if (params->initial_max_stream_data_uni) {
|
346
|
+
p = write_varint_param(p,
|
347
|
+
NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_UNI,
|
348
|
+
params->initial_max_stream_data_uni);
|
349
|
+
}
|
350
|
+
|
351
|
+
if (params->initial_max_data) {
|
352
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_DATA,
|
353
|
+
params->initial_max_data);
|
354
|
+
}
|
355
|
+
|
356
|
+
if (params->initial_max_streams_bidi) {
|
357
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_BIDI,
|
358
|
+
params->initial_max_streams_bidi);
|
359
|
+
}
|
360
|
+
|
361
|
+
if (params->initial_max_streams_uni) {
|
362
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_UNI,
|
363
|
+
params->initial_max_streams_uni);
|
364
|
+
}
|
365
|
+
|
366
|
+
if (params->max_udp_payload_size !=
|
367
|
+
NGTCP2_DEFAULT_MAX_RECV_UDP_PAYLOAD_SIZE) {
|
368
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_MAX_UDP_PAYLOAD_SIZE,
|
369
|
+
params->max_udp_payload_size);
|
370
|
+
}
|
371
|
+
|
372
|
+
if (params->ack_delay_exponent != NGTCP2_DEFAULT_ACK_DELAY_EXPONENT) {
|
373
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_ACK_DELAY_EXPONENT,
|
374
|
+
params->ack_delay_exponent);
|
375
|
+
}
|
376
|
+
|
377
|
+
if (params->disable_active_migration) {
|
378
|
+
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION);
|
379
|
+
p = ngtcp2_put_uvarint(p, 0);
|
380
|
+
}
|
381
|
+
|
382
|
+
if (params->max_ack_delay != NGTCP2_DEFAULT_MAX_ACK_DELAY) {
|
383
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_MAX_ACK_DELAY,
|
384
|
+
params->max_ack_delay / NGTCP2_MILLISECONDS);
|
385
|
+
}
|
386
|
+
|
387
|
+
if (params->max_idle_timeout) {
|
388
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_MAX_IDLE_TIMEOUT,
|
389
|
+
params->max_idle_timeout / NGTCP2_MILLISECONDS);
|
390
|
+
}
|
391
|
+
|
392
|
+
if (params->active_connection_id_limit &&
|
393
|
+
params->active_connection_id_limit !=
|
394
|
+
NGTCP2_DEFAULT_ACTIVE_CONNECTION_ID_LIMIT) {
|
395
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_ACTIVE_CONNECTION_ID_LIMIT,
|
396
|
+
params->active_connection_id_limit);
|
397
|
+
}
|
398
|
+
|
399
|
+
if (params->max_datagram_frame_size) {
|
400
|
+
p = write_varint_param(p, NGTCP2_TRANSPORT_PARAM_MAX_DATAGRAM_FRAME_SIZE,
|
401
|
+
params->max_datagram_frame_size);
|
402
|
+
}
|
403
|
+
|
404
|
+
if (params->grease_quic_bit) {
|
405
|
+
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT);
|
406
|
+
p = ngtcp2_put_uvarint(p, 0);
|
407
|
+
}
|
408
|
+
|
409
|
+
if (params->version_info_present) {
|
410
|
+
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_VERSION_INFORMATION);
|
411
|
+
p = ngtcp2_put_uvarint(p, version_infolen);
|
412
|
+
p = ngtcp2_put_uint32be(p, params->version_info.chosen_version);
|
413
|
+
if (params->version_info.available_versionslen) {
|
414
|
+
p = ngtcp2_cpymem(p, params->version_info.available_versions,
|
415
|
+
params->version_info.available_versionslen);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
|
419
|
+
assert((size_t)(p - dest) == len);
|
420
|
+
|
421
|
+
return (ngtcp2_ssize)len;
|
422
|
+
}
|
423
|
+
|
424
|
+
/*
|
425
|
+
* decode_varint decodes a single varint from the buffer pointed by
|
426
|
+
* |*pp| of length |end - *pp|. If it decodes an integer
|
427
|
+
* successfully, it stores the integer in |*pdest|, increment |*pp| by
|
428
|
+
* the number of bytes read from |*pp|, and returns 0. Otherwise it
|
429
|
+
* returns -1.
|
430
|
+
*/
|
431
|
+
static int decode_varint(uint64_t *pdest, const uint8_t **pp,
|
432
|
+
const uint8_t *end) {
|
433
|
+
const uint8_t *p = *pp;
|
434
|
+
size_t len;
|
435
|
+
|
436
|
+
if (p == end) {
|
437
|
+
return -1;
|
438
|
+
}
|
439
|
+
|
440
|
+
len = ngtcp2_get_uvarintlen(p);
|
441
|
+
if ((uint64_t)(end - p) < len) {
|
442
|
+
return -1;
|
443
|
+
}
|
444
|
+
|
445
|
+
*pp = ngtcp2_get_uvarint(pdest, p);
|
446
|
+
|
447
|
+
return 0;
|
448
|
+
}
|
449
|
+
|
450
|
+
/*
|
451
|
+
* decode_varint_param decodes length prefixed value from the buffer
|
452
|
+
* pointed by |*pp| of length |end - *pp|. The length and value are
|
453
|
+
* encoded in varint form. If it decodes a value successfully, it
|
454
|
+
* stores the value in |*pdest|, increment |*pp| by the number of
|
455
|
+
* bytes read from |*pp|, and returns 0. Otherwise it returns -1.
|
456
|
+
*/
|
457
|
+
static int decode_varint_param(uint64_t *pdest, const uint8_t **pp,
|
458
|
+
const uint8_t *end) {
|
459
|
+
const uint8_t *p = *pp;
|
460
|
+
uint64_t valuelen;
|
461
|
+
|
462
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
463
|
+
return -1;
|
464
|
+
}
|
465
|
+
|
466
|
+
if (p == end) {
|
467
|
+
return -1;
|
468
|
+
}
|
469
|
+
|
470
|
+
if ((uint64_t)(end - p) < valuelen) {
|
471
|
+
return -1;
|
472
|
+
}
|
473
|
+
|
474
|
+
if (ngtcp2_get_uvarintlen(p) != valuelen) {
|
475
|
+
return -1;
|
476
|
+
}
|
477
|
+
|
478
|
+
*pp = ngtcp2_get_uvarint(pdest, p);
|
479
|
+
|
480
|
+
return 0;
|
481
|
+
}
|
482
|
+
|
483
|
+
/*
|
484
|
+
* decode_cid_param decodes length prefixed ngtcp2_cid from the buffer
|
485
|
+
* pointed by |*pp| of length |end - *pp|. The length is encoded in
|
486
|
+
* varint form. If it decodes a value successfully, it stores the
|
487
|
+
* value in |*pdest|, increment |*pp| by the number of read from
|
488
|
+
* |*pp|, and returns the number of bytes read. Otherwise it returns
|
489
|
+
* the one of the negative error code:
|
490
|
+
*
|
491
|
+
* NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM
|
492
|
+
* Could not decode Connection ID.
|
493
|
+
*/
|
494
|
+
static int decode_cid_param(ngtcp2_cid *pdest, const uint8_t **pp,
|
495
|
+
const uint8_t *end) {
|
496
|
+
const uint8_t *p = *pp;
|
497
|
+
uint64_t valuelen;
|
498
|
+
|
499
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
500
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
501
|
+
}
|
502
|
+
|
503
|
+
if ((valuelen != 0 && valuelen < NGTCP2_MIN_CIDLEN) ||
|
504
|
+
valuelen > NGTCP2_MAX_CIDLEN || (size_t)(end - p) < valuelen) {
|
505
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
506
|
+
}
|
507
|
+
|
508
|
+
ngtcp2_cid_init(pdest, p, (size_t)valuelen);
|
509
|
+
|
510
|
+
p += valuelen;
|
511
|
+
|
512
|
+
*pp = p;
|
513
|
+
|
514
|
+
return 0;
|
515
|
+
}
|
516
|
+
|
517
|
+
int ngtcp2_decode_transport_params_versioned(
|
518
|
+
int transport_params_version, ngtcp2_transport_params *params,
|
519
|
+
ngtcp2_transport_params_type exttype, const uint8_t *data, size_t datalen) {
|
520
|
+
const uint8_t *p, *end, *lend;
|
521
|
+
size_t len;
|
522
|
+
uint64_t param_type;
|
523
|
+
uint64_t valuelen;
|
524
|
+
int rv;
|
525
|
+
int initial_scid_present = 0;
|
526
|
+
int original_dcid_present = 0;
|
527
|
+
ngtcp2_sockaddr_in *sa_in;
|
528
|
+
ngtcp2_sockaddr_in6 *sa_in6;
|
529
|
+
uint32_t version;
|
530
|
+
|
531
|
+
(void)transport_params_version;
|
532
|
+
|
533
|
+
if (datalen == 0) {
|
534
|
+
return NGTCP2_ERR_REQUIRED_TRANSPORT_PARAM;
|
535
|
+
}
|
536
|
+
|
537
|
+
/* Set default values */
|
538
|
+
memset(params, 0, sizeof(*params));
|
539
|
+
params->initial_max_streams_bidi = 0;
|
540
|
+
params->initial_max_streams_uni = 0;
|
541
|
+
params->initial_max_stream_data_bidi_local = 0;
|
542
|
+
params->initial_max_stream_data_bidi_remote = 0;
|
543
|
+
params->initial_max_stream_data_uni = 0;
|
544
|
+
params->max_udp_payload_size = NGTCP2_DEFAULT_MAX_RECV_UDP_PAYLOAD_SIZE;
|
545
|
+
params->ack_delay_exponent = NGTCP2_DEFAULT_ACK_DELAY_EXPONENT;
|
546
|
+
params->stateless_reset_token_present = 0;
|
547
|
+
params->preferred_address_present = 0;
|
548
|
+
params->disable_active_migration = 0;
|
549
|
+
params->max_ack_delay = NGTCP2_DEFAULT_MAX_ACK_DELAY;
|
550
|
+
params->max_idle_timeout = 0;
|
551
|
+
params->active_connection_id_limit =
|
552
|
+
NGTCP2_DEFAULT_ACTIVE_CONNECTION_ID_LIMIT;
|
553
|
+
params->retry_scid_present = 0;
|
554
|
+
params->max_datagram_frame_size = 0;
|
555
|
+
memset(¶ms->retry_scid, 0, sizeof(params->retry_scid));
|
556
|
+
memset(¶ms->initial_scid, 0, sizeof(params->initial_scid));
|
557
|
+
memset(¶ms->original_dcid, 0, sizeof(params->original_dcid));
|
558
|
+
params->version_info_present = 0;
|
559
|
+
|
560
|
+
p = data;
|
561
|
+
end = data + datalen;
|
562
|
+
|
563
|
+
for (; (size_t)(end - p) >= 2;) {
|
564
|
+
if (decode_varint(¶m_type, &p, end) != 0) {
|
565
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
566
|
+
}
|
567
|
+
|
568
|
+
switch (param_type) {
|
569
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL:
|
570
|
+
if (decode_varint_param(¶ms->initial_max_stream_data_bidi_local, &p,
|
571
|
+
end) != 0) {
|
572
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
573
|
+
}
|
574
|
+
break;
|
575
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE:
|
576
|
+
if (decode_varint_param(¶ms->initial_max_stream_data_bidi_remote, &p,
|
577
|
+
end) != 0) {
|
578
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
579
|
+
}
|
580
|
+
break;
|
581
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAM_DATA_UNI:
|
582
|
+
if (decode_varint_param(¶ms->initial_max_stream_data_uni, &p, end) !=
|
583
|
+
0) {
|
584
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
585
|
+
}
|
586
|
+
break;
|
587
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_DATA:
|
588
|
+
if (decode_varint_param(¶ms->initial_max_data, &p, end) != 0) {
|
589
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
590
|
+
}
|
591
|
+
break;
|
592
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_BIDI:
|
593
|
+
if (decode_varint_param(¶ms->initial_max_streams_bidi, &p, end) !=
|
594
|
+
0) {
|
595
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
596
|
+
}
|
597
|
+
if (params->initial_max_streams_bidi > NGTCP2_MAX_STREAMS) {
|
598
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
599
|
+
}
|
600
|
+
break;
|
601
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_MAX_STREAMS_UNI:
|
602
|
+
if (decode_varint_param(¶ms->initial_max_streams_uni, &p, end) != 0) {
|
603
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
604
|
+
}
|
605
|
+
if (params->initial_max_streams_uni > NGTCP2_MAX_STREAMS) {
|
606
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
607
|
+
}
|
608
|
+
break;
|
609
|
+
case NGTCP2_TRANSPORT_PARAM_MAX_IDLE_TIMEOUT:
|
610
|
+
if (decode_varint_param(¶ms->max_idle_timeout, &p, end) != 0) {
|
611
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
612
|
+
}
|
613
|
+
params->max_idle_timeout *= NGTCP2_MILLISECONDS;
|
614
|
+
break;
|
615
|
+
case NGTCP2_TRANSPORT_PARAM_MAX_UDP_PAYLOAD_SIZE:
|
616
|
+
if (decode_varint_param(¶ms->max_udp_payload_size, &p, end) != 0) {
|
617
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
618
|
+
}
|
619
|
+
break;
|
620
|
+
case NGTCP2_TRANSPORT_PARAM_STATELESS_RESET_TOKEN:
|
621
|
+
if (exttype != NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
|
622
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
623
|
+
}
|
624
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
625
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
626
|
+
}
|
627
|
+
if ((size_t)valuelen != sizeof(params->stateless_reset_token)) {
|
628
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
629
|
+
}
|
630
|
+
if ((size_t)(end - p) < sizeof(params->stateless_reset_token)) {
|
631
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
632
|
+
}
|
633
|
+
|
634
|
+
p = ngtcp2_get_bytes(params->stateless_reset_token, p,
|
635
|
+
sizeof(params->stateless_reset_token));
|
636
|
+
params->stateless_reset_token_present = 1;
|
637
|
+
|
638
|
+
break;
|
639
|
+
case NGTCP2_TRANSPORT_PARAM_ACK_DELAY_EXPONENT:
|
640
|
+
if (decode_varint_param(¶ms->ack_delay_exponent, &p, end) != 0) {
|
641
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
642
|
+
}
|
643
|
+
if (params->ack_delay_exponent > 20) {
|
644
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
645
|
+
}
|
646
|
+
break;
|
647
|
+
case NGTCP2_TRANSPORT_PARAM_PREFERRED_ADDRESS:
|
648
|
+
if (exttype != NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
|
649
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
650
|
+
}
|
651
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
652
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
653
|
+
}
|
654
|
+
if ((size_t)(end - p) < valuelen) {
|
655
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
656
|
+
}
|
657
|
+
len = 4 /* ipv4Address */ + 2 /* ipv4Port */ + 16 /* ipv6Address */ +
|
658
|
+
2 /* ipv6Port */
|
659
|
+
+ 1 /* cid length */ + NGTCP2_STATELESS_RESET_TOKENLEN;
|
660
|
+
if (valuelen < len) {
|
661
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
662
|
+
}
|
663
|
+
|
664
|
+
sa_in = ¶ms->preferred_address.ipv4;
|
665
|
+
|
666
|
+
p = ngtcp2_get_bytes(&sa_in->sin_addr, p, sizeof(sa_in->sin_addr));
|
667
|
+
p = ngtcp2_get_uint16be(&sa_in->sin_port, p);
|
668
|
+
|
669
|
+
if (sa_in->sin_port || memcmp(empty_address, &sa_in->sin_addr,
|
670
|
+
sizeof(sa_in->sin_addr)) != 0) {
|
671
|
+
sa_in->sin_family = AF_INET;
|
672
|
+
params->preferred_address.ipv4_present = 1;
|
673
|
+
}
|
674
|
+
|
675
|
+
sa_in6 = ¶ms->preferred_address.ipv6;
|
676
|
+
|
677
|
+
p = ngtcp2_get_bytes(&sa_in6->sin6_addr, p, sizeof(sa_in6->sin6_addr));
|
678
|
+
p = ngtcp2_get_uint16be(&sa_in6->sin6_port, p);
|
679
|
+
|
680
|
+
if (sa_in6->sin6_port || memcmp(empty_address, &sa_in6->sin6_addr,
|
681
|
+
sizeof(sa_in6->sin6_addr)) != 0) {
|
682
|
+
sa_in6->sin6_family = AF_INET6;
|
683
|
+
params->preferred_address.ipv6_present = 1;
|
684
|
+
}
|
685
|
+
|
686
|
+
/* cid */
|
687
|
+
params->preferred_address.cid.datalen = *p++;
|
688
|
+
len += params->preferred_address.cid.datalen;
|
689
|
+
if (valuelen != len ||
|
690
|
+
params->preferred_address.cid.datalen > NGTCP2_MAX_CIDLEN ||
|
691
|
+
params->preferred_address.cid.datalen < NGTCP2_MIN_CIDLEN) {
|
692
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
693
|
+
}
|
694
|
+
if (params->preferred_address.cid.datalen) {
|
695
|
+
p = ngtcp2_get_bytes(params->preferred_address.cid.data, p,
|
696
|
+
params->preferred_address.cid.datalen);
|
697
|
+
}
|
698
|
+
|
699
|
+
/* stateless reset token */
|
700
|
+
p = ngtcp2_get_bytes(
|
701
|
+
params->preferred_address.stateless_reset_token, p,
|
702
|
+
sizeof(params->preferred_address.stateless_reset_token));
|
703
|
+
params->preferred_address_present = 1;
|
704
|
+
break;
|
705
|
+
case NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION:
|
706
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
707
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
708
|
+
}
|
709
|
+
if (valuelen != 0) {
|
710
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
711
|
+
}
|
712
|
+
params->disable_active_migration = 1;
|
713
|
+
break;
|
714
|
+
case NGTCP2_TRANSPORT_PARAM_ORIGINAL_DESTINATION_CONNECTION_ID:
|
715
|
+
if (exttype != NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
|
716
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
717
|
+
}
|
718
|
+
rv = decode_cid_param(¶ms->original_dcid, &p, end);
|
719
|
+
if (rv != 0) {
|
720
|
+
return rv;
|
721
|
+
}
|
722
|
+
original_dcid_present = 1;
|
723
|
+
break;
|
724
|
+
case NGTCP2_TRANSPORT_PARAM_RETRY_SOURCE_CONNECTION_ID:
|
725
|
+
if (exttype != NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
|
726
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
727
|
+
}
|
728
|
+
rv = decode_cid_param(¶ms->retry_scid, &p, end);
|
729
|
+
if (rv != 0) {
|
730
|
+
return rv;
|
731
|
+
}
|
732
|
+
params->retry_scid_present = 1;
|
733
|
+
break;
|
734
|
+
case NGTCP2_TRANSPORT_PARAM_INITIAL_SOURCE_CONNECTION_ID:
|
735
|
+
rv = decode_cid_param(¶ms->initial_scid, &p, end);
|
736
|
+
if (rv != 0) {
|
737
|
+
return rv;
|
738
|
+
}
|
739
|
+
initial_scid_present = 1;
|
740
|
+
break;
|
741
|
+
case NGTCP2_TRANSPORT_PARAM_MAX_ACK_DELAY:
|
742
|
+
if (decode_varint_param(¶ms->max_ack_delay, &p, end) != 0) {
|
743
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
744
|
+
}
|
745
|
+
if (params->max_ack_delay >= 16384) {
|
746
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
747
|
+
}
|
748
|
+
params->max_ack_delay *= NGTCP2_MILLISECONDS;
|
749
|
+
break;
|
750
|
+
case NGTCP2_TRANSPORT_PARAM_ACTIVE_CONNECTION_ID_LIMIT:
|
751
|
+
if (decode_varint_param(¶ms->active_connection_id_limit, &p, end) !=
|
752
|
+
0) {
|
753
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
754
|
+
}
|
755
|
+
break;
|
756
|
+
case NGTCP2_TRANSPORT_PARAM_MAX_DATAGRAM_FRAME_SIZE:
|
757
|
+
if (decode_varint_param(¶ms->max_datagram_frame_size, &p, end) != 0) {
|
758
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
759
|
+
}
|
760
|
+
break;
|
761
|
+
case NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT:
|
762
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
763
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
764
|
+
}
|
765
|
+
if (valuelen != 0) {
|
766
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
767
|
+
}
|
768
|
+
params->grease_quic_bit = 1;
|
769
|
+
break;
|
770
|
+
case NGTCP2_TRANSPORT_PARAM_VERSION_INFORMATION:
|
771
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
772
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
773
|
+
}
|
774
|
+
if ((size_t)(end - p) < valuelen) {
|
775
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
776
|
+
}
|
777
|
+
if (valuelen < sizeof(uint32_t) || (valuelen & 0x3)) {
|
778
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
779
|
+
}
|
780
|
+
p = ngtcp2_get_uint32(¶ms->version_info.chosen_version, p);
|
781
|
+
if (params->version_info.chosen_version == 0) {
|
782
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
783
|
+
}
|
784
|
+
if (valuelen > sizeof(uint32_t)) {
|
785
|
+
params->version_info.available_versions = (uint8_t *)p;
|
786
|
+
params->version_info.available_versionslen =
|
787
|
+
(size_t)valuelen - sizeof(uint32_t);
|
788
|
+
|
789
|
+
for (lend = p + (valuelen - sizeof(uint32_t)); p != lend;) {
|
790
|
+
p = ngtcp2_get_uint32(&version, p);
|
791
|
+
if (version == 0) {
|
792
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
793
|
+
}
|
794
|
+
}
|
795
|
+
}
|
796
|
+
params->version_info_present = 1;
|
797
|
+
break;
|
798
|
+
default:
|
799
|
+
/* Ignore unknown parameter */
|
800
|
+
if (decode_varint(&valuelen, &p, end) != 0) {
|
801
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
802
|
+
}
|
803
|
+
if ((size_t)(end - p) < valuelen) {
|
804
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
805
|
+
}
|
806
|
+
p += valuelen;
|
807
|
+
break;
|
808
|
+
}
|
809
|
+
}
|
810
|
+
|
811
|
+
if (end - p != 0) {
|
812
|
+
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
|
813
|
+
}
|
814
|
+
|
815
|
+
if (!initial_scid_present ||
|
816
|
+
(exttype == NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS &&
|
817
|
+
!original_dcid_present)) {
|
818
|
+
return NGTCP2_ERR_REQUIRED_TRANSPORT_PARAM;
|
819
|
+
}
|
820
|
+
|
821
|
+
return 0;
|
822
|
+
}
|
823
|
+
|
824
|
+
static int transport_params_copy_new(ngtcp2_transport_params **pdest,
|
825
|
+
const ngtcp2_transport_params *src,
|
826
|
+
const ngtcp2_mem *mem) {
|
827
|
+
size_t len = sizeof(**pdest);
|
828
|
+
ngtcp2_transport_params *dest;
|
829
|
+
uint8_t *p;
|
830
|
+
|
831
|
+
if (src->version_info_present) {
|
832
|
+
len += src->version_info.available_versionslen;
|
833
|
+
}
|
834
|
+
|
835
|
+
dest = ngtcp2_mem_malloc(mem, len);
|
836
|
+
if (dest == NULL) {
|
837
|
+
return NGTCP2_ERR_NOMEM;
|
838
|
+
}
|
839
|
+
|
840
|
+
*dest = *src;
|
841
|
+
|
842
|
+
if (src->version_info_present && src->version_info.available_versionslen) {
|
843
|
+
p = (uint8_t *)dest + sizeof(*dest);
|
844
|
+
memcpy(p, src->version_info.available_versions,
|
845
|
+
src->version_info.available_versionslen);
|
846
|
+
dest->version_info.available_versions = p;
|
847
|
+
}
|
848
|
+
|
849
|
+
*pdest = dest;
|
850
|
+
|
851
|
+
return 0;
|
852
|
+
}
|
853
|
+
|
854
|
+
int ngtcp2_decode_transport_params_new(ngtcp2_transport_params **pparams,
|
855
|
+
ngtcp2_transport_params_type exttype,
|
856
|
+
const uint8_t *data, size_t datalen,
|
857
|
+
const ngtcp2_mem *mem) {
|
858
|
+
int rv;
|
859
|
+
ngtcp2_transport_params params;
|
860
|
+
|
861
|
+
rv = ngtcp2_decode_transport_params(¶ms, exttype, data, datalen);
|
862
|
+
if (rv < 0) {
|
863
|
+
return rv;
|
864
|
+
}
|
865
|
+
|
866
|
+
if (mem == NULL) {
|
867
|
+
mem = ngtcp2_mem_default();
|
868
|
+
}
|
869
|
+
|
870
|
+
return transport_params_copy_new(pparams, ¶ms, mem);
|
871
|
+
}
|
872
|
+
|
873
|
+
void ngtcp2_transport_params_del(ngtcp2_transport_params *params,
|
874
|
+
const ngtcp2_mem *mem) {
|
875
|
+
if (params == NULL) {
|
876
|
+
return;
|
877
|
+
}
|
878
|
+
|
879
|
+
if (mem == NULL) {
|
880
|
+
mem = ngtcp2_mem_default();
|
881
|
+
}
|
882
|
+
|
883
|
+
ngtcp2_mem_free(mem, params);
|
884
|
+
}
|
885
|
+
|
886
|
+
int ngtcp2_transport_params_copy_new(ngtcp2_transport_params **pdest,
|
887
|
+
const ngtcp2_transport_params *src,
|
888
|
+
const ngtcp2_mem *mem) {
|
889
|
+
if (src == NULL) {
|
890
|
+
*pdest = NULL;
|
891
|
+
return 0;
|
892
|
+
}
|
893
|
+
|
894
|
+
return transport_params_copy_new(pdest, src, mem);
|
895
|
+
}
|