protocol-quic 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ngtcp2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2017 ngtcp2 contributors
|
|
5
|
+
* Copyright (c) 2012 nghttp2 contributors
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
* a copy of this software and associated documentation files (the
|
|
9
|
+
* "Software"), to deal in the Software without restriction, including
|
|
10
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
* the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be
|
|
16
|
+
* included in all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
#include "ngtcp2_pq.h"
|
|
27
|
+
|
|
28
|
+
#include <assert.h>
|
|
29
|
+
|
|
30
|
+
#include "ngtcp2_macro.h"
|
|
31
|
+
|
|
32
|
+
void ngtcp2_pq_init(ngtcp2_pq *pq, ngtcp2_less less, const ngtcp2_mem *mem) {
|
|
33
|
+
pq->mem = mem;
|
|
34
|
+
pq->capacity = 0;
|
|
35
|
+
pq->q = NULL;
|
|
36
|
+
pq->length = 0;
|
|
37
|
+
pq->less = less;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void ngtcp2_pq_free(ngtcp2_pq *pq) {
|
|
41
|
+
ngtcp2_mem_free(pq->mem, pq->q);
|
|
42
|
+
pq->q = NULL;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static void swap(ngtcp2_pq *pq, size_t i, size_t j) {
|
|
46
|
+
ngtcp2_pq_entry *a = pq->q[i];
|
|
47
|
+
ngtcp2_pq_entry *b = pq->q[j];
|
|
48
|
+
|
|
49
|
+
pq->q[i] = b;
|
|
50
|
+
b->index = i;
|
|
51
|
+
pq->q[j] = a;
|
|
52
|
+
a->index = j;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static void bubble_up(ngtcp2_pq *pq, size_t index) {
|
|
56
|
+
size_t parent;
|
|
57
|
+
while (index != 0) {
|
|
58
|
+
parent = (index - 1) / 2;
|
|
59
|
+
if (!pq->less(pq->q[index], pq->q[parent])) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
swap(pq, parent, index);
|
|
63
|
+
index = parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
int ngtcp2_pq_push(ngtcp2_pq *pq, ngtcp2_pq_entry *item) {
|
|
68
|
+
if (pq->capacity <= pq->length) {
|
|
69
|
+
void *nq;
|
|
70
|
+
size_t ncapacity;
|
|
71
|
+
|
|
72
|
+
ncapacity = ngtcp2_max(4, (pq->capacity * 2));
|
|
73
|
+
|
|
74
|
+
nq = ngtcp2_mem_realloc(pq->mem, pq->q,
|
|
75
|
+
ncapacity * sizeof(ngtcp2_pq_entry *));
|
|
76
|
+
if (nq == NULL) {
|
|
77
|
+
return NGTCP2_ERR_NOMEM;
|
|
78
|
+
}
|
|
79
|
+
pq->capacity = ncapacity;
|
|
80
|
+
pq->q = nq;
|
|
81
|
+
}
|
|
82
|
+
pq->q[pq->length] = item;
|
|
83
|
+
item->index = pq->length;
|
|
84
|
+
++pq->length;
|
|
85
|
+
bubble_up(pq, pq->length - 1);
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ngtcp2_pq_entry *ngtcp2_pq_top(ngtcp2_pq *pq) {
|
|
90
|
+
assert(pq->length);
|
|
91
|
+
return pq->q[0];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static void bubble_down(ngtcp2_pq *pq, size_t index) {
|
|
95
|
+
size_t i, j, minindex;
|
|
96
|
+
for (;;) {
|
|
97
|
+
j = index * 2 + 1;
|
|
98
|
+
minindex = index;
|
|
99
|
+
for (i = 0; i < 2; ++i, ++j) {
|
|
100
|
+
if (j >= pq->length) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (pq->less(pq->q[j], pq->q[minindex])) {
|
|
104
|
+
minindex = j;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (minindex == index) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
swap(pq, index, minindex);
|
|
111
|
+
index = minindex;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void ngtcp2_pq_pop(ngtcp2_pq *pq) {
|
|
116
|
+
if (pq->length > 0) {
|
|
117
|
+
pq->q[0] = pq->q[pq->length - 1];
|
|
118
|
+
pq->q[0]->index = 0;
|
|
119
|
+
--pq->length;
|
|
120
|
+
bubble_down(pq, 0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void ngtcp2_pq_remove(ngtcp2_pq *pq, ngtcp2_pq_entry *item) {
|
|
125
|
+
assert(pq->q[item->index] == item);
|
|
126
|
+
|
|
127
|
+
if (item->index == 0) {
|
|
128
|
+
ngtcp2_pq_pop(pq);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (item->index == pq->length - 1) {
|
|
133
|
+
--pq->length;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
pq->q[item->index] = pq->q[pq->length - 1];
|
|
138
|
+
pq->q[item->index]->index = item->index;
|
|
139
|
+
--pq->length;
|
|
140
|
+
|
|
141
|
+
if (pq->less(item, pq->q[item->index])) {
|
|
142
|
+
bubble_down(pq, item->index);
|
|
143
|
+
} else {
|
|
144
|
+
bubble_up(pq, item->index);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
int ngtcp2_pq_empty(ngtcp2_pq *pq) { return pq->length == 0; }
|
|
149
|
+
|
|
150
|
+
size_t ngtcp2_pq_size(ngtcp2_pq *pq) { return pq->length; }
|
|
151
|
+
|
|
152
|
+
int ngtcp2_pq_each(ngtcp2_pq *pq, ngtcp2_pq_item_cb fun, void *arg) {
|
|
153
|
+
size_t i;
|
|
154
|
+
|
|
155
|
+
if (pq->length == 0) {
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
for (i = 0; i < pq->length; ++i) {
|
|
159
|
+
if ((*fun)(pq->q[i], arg)) {
|
|
160
|
+
return 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ngtcp2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2017 ngtcp2 contributors
|
|
5
|
+
* Copyright (c) 2012 nghttp2 contributors
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
* a copy of this software and associated documentation files (the
|
|
9
|
+
* "Software"), to deal in the Software without restriction, including
|
|
10
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
* the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be
|
|
16
|
+
* included in all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
#ifndef NGTCP2_PQ_H
|
|
27
|
+
#define NGTCP2_PQ_H
|
|
28
|
+
|
|
29
|
+
#ifdef HAVE_CONFIG_H
|
|
30
|
+
# include <config.h>
|
|
31
|
+
#endif /* HAVE_CONFIG_H */
|
|
32
|
+
|
|
33
|
+
#include <ngtcp2/ngtcp2.h>
|
|
34
|
+
|
|
35
|
+
#include "ngtcp2_mem.h"
|
|
36
|
+
|
|
37
|
+
/* Implementation of priority queue */
|
|
38
|
+
|
|
39
|
+
/* NGTCP2_PQ_BAD_INDEX is the priority queue index which indicates
|
|
40
|
+
that an entry is not queued. Assigning this value to
|
|
41
|
+
ngtcp2_pq_entry.index can check that the entry is queued or not. */
|
|
42
|
+
#define NGTCP2_PQ_BAD_INDEX SIZE_MAX
|
|
43
|
+
|
|
44
|
+
typedef struct ngtcp2_pq_entry {
|
|
45
|
+
size_t index;
|
|
46
|
+
} ngtcp2_pq_entry;
|
|
47
|
+
|
|
48
|
+
/* "less" function, return nonzero if |lhs| is less than |rhs|. */
|
|
49
|
+
typedef int (*ngtcp2_less)(const ngtcp2_pq_entry *lhs,
|
|
50
|
+
const ngtcp2_pq_entry *rhs);
|
|
51
|
+
|
|
52
|
+
typedef struct ngtcp2_pq {
|
|
53
|
+
/* The pointer to the pointer to the item stored */
|
|
54
|
+
ngtcp2_pq_entry **q;
|
|
55
|
+
/* Memory allocator */
|
|
56
|
+
const ngtcp2_mem *mem;
|
|
57
|
+
/* The number of items stored */
|
|
58
|
+
size_t length;
|
|
59
|
+
/* The maximum number of items this pq can store. This is
|
|
60
|
+
automatically extended when length is reached to this value. */
|
|
61
|
+
size_t capacity;
|
|
62
|
+
/* The less function between items */
|
|
63
|
+
ngtcp2_less less;
|
|
64
|
+
} ngtcp2_pq;
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Initializes priority queue |pq| with compare function |cmp|.
|
|
68
|
+
*/
|
|
69
|
+
void ngtcp2_pq_init(ngtcp2_pq *pq, ngtcp2_less less, const ngtcp2_mem *mem);
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* Deallocates any resources allocated for |pq|. The stored items are
|
|
73
|
+
* not freed by this function.
|
|
74
|
+
*/
|
|
75
|
+
void ngtcp2_pq_free(ngtcp2_pq *pq);
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Adds |item| to the priority queue |pq|.
|
|
79
|
+
*
|
|
80
|
+
* This function returns 0 if it succeeds, or one of the following
|
|
81
|
+
* negative error codes:
|
|
82
|
+
*
|
|
83
|
+
* NGTCP2_ERR_NOMEM
|
|
84
|
+
* Out of memory.
|
|
85
|
+
*/
|
|
86
|
+
int ngtcp2_pq_push(ngtcp2_pq *pq, ngtcp2_pq_entry *item);
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* Returns item at the top of the queue |pq|. It is undefined if the
|
|
90
|
+
* queue is empty.
|
|
91
|
+
*/
|
|
92
|
+
ngtcp2_pq_entry *ngtcp2_pq_top(ngtcp2_pq *pq);
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* Pops item at the top of the queue |pq|. The popped item is not
|
|
96
|
+
* freed by this function.
|
|
97
|
+
*/
|
|
98
|
+
void ngtcp2_pq_pop(ngtcp2_pq *pq);
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* Returns nonzero if the queue |pq| is empty.
|
|
102
|
+
*/
|
|
103
|
+
int ngtcp2_pq_empty(ngtcp2_pq *pq);
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Returns the number of items in the queue |pq|.
|
|
107
|
+
*/
|
|
108
|
+
size_t ngtcp2_pq_size(ngtcp2_pq *pq);
|
|
109
|
+
|
|
110
|
+
typedef int (*ngtcp2_pq_item_cb)(ngtcp2_pq_entry *item, void *arg);
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* Applys |fun| to each item in |pq|. The |arg| is passed as arg
|
|
114
|
+
* parameter to callback function. This function must not change the
|
|
115
|
+
* ordering key. If the return value from callback is nonzero, this
|
|
116
|
+
* function returns 1 immediately without iterating remaining items.
|
|
117
|
+
* Otherwise this function returns 0.
|
|
118
|
+
*/
|
|
119
|
+
int ngtcp2_pq_each(ngtcp2_pq *pq, ngtcp2_pq_item_cb fun, void *arg);
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* Removes |item| from priority queue.
|
|
123
|
+
*/
|
|
124
|
+
void ngtcp2_pq_remove(ngtcp2_pq *pq, ngtcp2_pq_entry *item);
|
|
125
|
+
|
|
126
|
+
#endif /* NGTCP2_PQ_H */
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ngtcp2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 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_pv.h"
|
|
26
|
+
|
|
27
|
+
#include <string.h>
|
|
28
|
+
#include <assert.h>
|
|
29
|
+
|
|
30
|
+
#include "ngtcp2_mem.h"
|
|
31
|
+
#include "ngtcp2_log.h"
|
|
32
|
+
#include "ngtcp2_macro.h"
|
|
33
|
+
#include "ngtcp2_addr.h"
|
|
34
|
+
|
|
35
|
+
void ngtcp2_pv_entry_init(ngtcp2_pv_entry *pvent, const uint8_t *data,
|
|
36
|
+
ngtcp2_tstamp expiry, uint8_t flags) {
|
|
37
|
+
memcpy(pvent->data, data, sizeof(pvent->data));
|
|
38
|
+
pvent->expiry = expiry;
|
|
39
|
+
pvent->flags = flags;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
int ngtcp2_pv_new(ngtcp2_pv **ppv, const ngtcp2_dcid *dcid,
|
|
43
|
+
ngtcp2_duration timeout, uint8_t flags, ngtcp2_log *log,
|
|
44
|
+
const ngtcp2_mem *mem) {
|
|
45
|
+
(*ppv) = ngtcp2_mem_malloc(mem, sizeof(ngtcp2_pv));
|
|
46
|
+
if (*ppv == NULL) {
|
|
47
|
+
return NGTCP2_ERR_NOMEM;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngtcp2_static_ringbuf_pv_ents_init(&(*ppv)->ents);
|
|
51
|
+
|
|
52
|
+
ngtcp2_dcid_copy(&(*ppv)->dcid, dcid);
|
|
53
|
+
|
|
54
|
+
(*ppv)->mem = mem;
|
|
55
|
+
(*ppv)->log = log;
|
|
56
|
+
(*ppv)->timeout = timeout;
|
|
57
|
+
(*ppv)->fallback_pto = 0;
|
|
58
|
+
(*ppv)->started_ts = UINT64_MAX;
|
|
59
|
+
(*ppv)->probe_pkt_left = NGTCP2_PV_NUM_PROBE_PKT;
|
|
60
|
+
(*ppv)->round = 0;
|
|
61
|
+
(*ppv)->flags = flags;
|
|
62
|
+
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void ngtcp2_pv_del(ngtcp2_pv *pv) {
|
|
67
|
+
if (pv == NULL) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
ngtcp2_mem_free(pv->mem, pv);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void ngtcp2_pv_add_entry(ngtcp2_pv *pv, const uint8_t *data,
|
|
74
|
+
ngtcp2_tstamp expiry, uint8_t flags,
|
|
75
|
+
ngtcp2_tstamp ts) {
|
|
76
|
+
ngtcp2_pv_entry *ent;
|
|
77
|
+
|
|
78
|
+
assert(pv->probe_pkt_left);
|
|
79
|
+
|
|
80
|
+
if (ngtcp2_ringbuf_len(&pv->ents.rb) == 0) {
|
|
81
|
+
pv->started_ts = ts;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ent = ngtcp2_ringbuf_push_back(&pv->ents.rb);
|
|
85
|
+
ngtcp2_pv_entry_init(ent, data, expiry, flags);
|
|
86
|
+
|
|
87
|
+
pv->flags &= (uint8_t)~NGTCP2_PV_FLAG_CANCEL_TIMER;
|
|
88
|
+
--pv->probe_pkt_left;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
int ngtcp2_pv_validate(ngtcp2_pv *pv, uint8_t *pflags, const uint8_t *data) {
|
|
92
|
+
size_t len = ngtcp2_ringbuf_len(&pv->ents.rb);
|
|
93
|
+
size_t i;
|
|
94
|
+
ngtcp2_pv_entry *ent;
|
|
95
|
+
|
|
96
|
+
if (len == 0) {
|
|
97
|
+
return NGTCP2_ERR_INVALID_STATE;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (i = 0; i < len; ++i) {
|
|
101
|
+
ent = ngtcp2_ringbuf_get(&pv->ents.rb, i);
|
|
102
|
+
if (memcmp(ent->data, data, sizeof(ent->data)) == 0) {
|
|
103
|
+
*pflags = ent->flags;
|
|
104
|
+
ngtcp2_log_info(pv->log, NGTCP2_LOG_EVENT_PTV, "path has been validated");
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void ngtcp2_pv_handle_entry_expiry(ngtcp2_pv *pv, ngtcp2_tstamp ts) {
|
|
113
|
+
ngtcp2_pv_entry *ent;
|
|
114
|
+
|
|
115
|
+
if (ngtcp2_ringbuf_len(&pv->ents.rb) == 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ent = ngtcp2_ringbuf_get(&pv->ents.rb, ngtcp2_ringbuf_len(&pv->ents.rb) - 1);
|
|
120
|
+
|
|
121
|
+
if (ent->expiry > ts) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
++pv->round;
|
|
126
|
+
pv->probe_pkt_left = NGTCP2_PV_NUM_PROBE_PKT;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
int ngtcp2_pv_should_send_probe(ngtcp2_pv *pv) {
|
|
130
|
+
return pv->probe_pkt_left > 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
int ngtcp2_pv_validation_timed_out(ngtcp2_pv *pv, ngtcp2_tstamp ts) {
|
|
134
|
+
ngtcp2_tstamp t;
|
|
135
|
+
ngtcp2_pv_entry *ent;
|
|
136
|
+
|
|
137
|
+
if (pv->started_ts == UINT64_MAX) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
assert(ngtcp2_ringbuf_len(&pv->ents.rb));
|
|
142
|
+
|
|
143
|
+
ent = ngtcp2_ringbuf_get(&pv->ents.rb, ngtcp2_ringbuf_len(&pv->ents.rb) - 1);
|
|
144
|
+
|
|
145
|
+
t = pv->started_ts + pv->timeout;
|
|
146
|
+
t = ngtcp2_max(t, ent->expiry);
|
|
147
|
+
|
|
148
|
+
return t <= ts;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ngtcp2_tstamp ngtcp2_pv_next_expiry(ngtcp2_pv *pv) {
|
|
152
|
+
ngtcp2_pv_entry *ent;
|
|
153
|
+
|
|
154
|
+
if ((pv->flags & NGTCP2_PV_FLAG_CANCEL_TIMER) ||
|
|
155
|
+
ngtcp2_ringbuf_len(&pv->ents.rb) == 0) {
|
|
156
|
+
return UINT64_MAX;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ent = ngtcp2_ringbuf_get(&pv->ents.rb, ngtcp2_ringbuf_len(&pv->ents.rb) - 1);
|
|
160
|
+
|
|
161
|
+
return ent->expiry;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void ngtcp2_pv_cancel_expired_timer(ngtcp2_pv *pv, ngtcp2_tstamp ts) {
|
|
165
|
+
ngtcp2_tstamp expiry = ngtcp2_pv_next_expiry(pv);
|
|
166
|
+
|
|
167
|
+
if (expiry > ts) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pv->flags |= NGTCP2_PV_FLAG_CANCEL_TIMER;
|
|
172
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ngtcp2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 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
|
+
#ifndef NGTCP2_PV_H
|
|
26
|
+
#define NGTCP2_PV_H
|
|
27
|
+
|
|
28
|
+
#ifdef HAVE_CONFIG_H
|
|
29
|
+
# include <config.h>
|
|
30
|
+
#endif /* HAVE_CONFIG_H */
|
|
31
|
+
|
|
32
|
+
#include <ngtcp2/ngtcp2.h>
|
|
33
|
+
|
|
34
|
+
#include "ngtcp2_cid.h"
|
|
35
|
+
#include "ngtcp2_ringbuf.h"
|
|
36
|
+
|
|
37
|
+
/* NGTCP2_PV_MAX_ENTRIES is the maximum number of entries that
|
|
38
|
+
ngtcp2_pv can contain. It must be power of 2. */
|
|
39
|
+
#define NGTCP2_PV_MAX_ENTRIES 8
|
|
40
|
+
/* NGTCP2_PV_NUM_PROBE_PKT is the number of probe packets containing
|
|
41
|
+
PATH_CHALLENGE sent at a time. */
|
|
42
|
+
#define NGTCP2_PV_NUM_PROBE_PKT 2
|
|
43
|
+
|
|
44
|
+
typedef struct ngtcp2_log ngtcp2_log;
|
|
45
|
+
|
|
46
|
+
typedef struct ngtcp2_frame_chain ngtcp2_frame_chain;
|
|
47
|
+
|
|
48
|
+
/* NGTCP2_PV_ENTRY_FLAG_NONE indicates that no flag is set. */
|
|
49
|
+
#define NGTCP2_PV_ENTRY_FLAG_NONE 0x00u
|
|
50
|
+
/* NGTCP2_PV_ENTRY_FLAG_UNDERSIZED indicates that UDP datagram which
|
|
51
|
+
contains PATH_CHALLENGE is undersized (< 1200 bytes) */
|
|
52
|
+
#define NGTCP2_PV_ENTRY_FLAG_UNDERSIZED 0x01u
|
|
53
|
+
|
|
54
|
+
typedef struct ngtcp2_pv_entry {
|
|
55
|
+
/* expiry is the timestamp when this PATH_CHALLENGE expires. */
|
|
56
|
+
ngtcp2_tstamp expiry;
|
|
57
|
+
/* flags is zero or more of NGTCP2_PV_ENTRY_FLAG_*. */
|
|
58
|
+
uint8_t flags;
|
|
59
|
+
/* data is a byte string included in PATH_CHALLENGE. */
|
|
60
|
+
uint8_t data[8];
|
|
61
|
+
} ngtcp2_pv_entry;
|
|
62
|
+
|
|
63
|
+
void ngtcp2_pv_entry_init(ngtcp2_pv_entry *pvent, const uint8_t *data,
|
|
64
|
+
ngtcp2_tstamp expiry, uint8_t flags);
|
|
65
|
+
|
|
66
|
+
/* NGTCP2_PV_FLAG_NONE indicates no flag is set. */
|
|
67
|
+
#define NGTCP2_PV_FLAG_NONE 0x00u
|
|
68
|
+
/* NGTCP2_PV_FLAG_DONT_CARE indicates that the outcome of path
|
|
69
|
+
validation should be ignored entirely. */
|
|
70
|
+
#define NGTCP2_PV_FLAG_DONT_CARE 0x01u
|
|
71
|
+
/* NGTCP2_PV_FLAG_CANCEL_TIMER indicates that the expiry timer is
|
|
72
|
+
cancelled. */
|
|
73
|
+
#define NGTCP2_PV_FLAG_CANCEL_TIMER 0x02u
|
|
74
|
+
/* NGTCP2_PV_FLAG_FALLBACK_ON_FAILURE indicates that fallback DCID is
|
|
75
|
+
available in ngtcp2_pv. If path validation fails, fallback to the
|
|
76
|
+
fallback DCID. If path validation succeeds, fallback DCID is
|
|
77
|
+
retired if it does not equal to the current DCID. */
|
|
78
|
+
#define NGTCP2_PV_FLAG_FALLBACK_ON_FAILURE 0x04u
|
|
79
|
+
/* NGTCP2_PV_FLAG_PREFERRED_ADDR indicates that client is migrating to
|
|
80
|
+
server's preferred address. This flag is only used by client. */
|
|
81
|
+
#define NGTCP2_PV_FLAG_PREFERRED_ADDR 0x10u
|
|
82
|
+
|
|
83
|
+
typedef struct ngtcp2_pv ngtcp2_pv;
|
|
84
|
+
|
|
85
|
+
ngtcp2_static_ringbuf_def(pv_ents, NGTCP2_PV_MAX_ENTRIES,
|
|
86
|
+
sizeof(ngtcp2_pv_entry));
|
|
87
|
+
/*
|
|
88
|
+
* ngtcp2_pv is the context of a single path validation.
|
|
89
|
+
*/
|
|
90
|
+
struct ngtcp2_pv {
|
|
91
|
+
const ngtcp2_mem *mem;
|
|
92
|
+
ngtcp2_log *log;
|
|
93
|
+
/* dcid is DCID and path this path validation uses. */
|
|
94
|
+
ngtcp2_dcid dcid;
|
|
95
|
+
/* fallback_dcid is the usually validated DCID and used as a
|
|
96
|
+
fallback if this path validation fails. */
|
|
97
|
+
ngtcp2_dcid fallback_dcid;
|
|
98
|
+
/* ents is the ring buffer of ngtcp2_pv_entry */
|
|
99
|
+
ngtcp2_static_ringbuf_pv_ents ents;
|
|
100
|
+
/* timeout is the duration within which this path validation should
|
|
101
|
+
succeed. */
|
|
102
|
+
ngtcp2_duration timeout;
|
|
103
|
+
/* fallback_pto is PTO of fallback connection. */
|
|
104
|
+
ngtcp2_duration fallback_pto;
|
|
105
|
+
/* started_ts is the timestamp this path validation starts. */
|
|
106
|
+
ngtcp2_tstamp started_ts;
|
|
107
|
+
/* round is the number of times that probe_pkt_left is reset. */
|
|
108
|
+
size_t round;
|
|
109
|
+
/* probe_pkt_left is the number of probe packets containing
|
|
110
|
+
PATH_CHALLENGE which can be send without waiting for an
|
|
111
|
+
expiration of a previous flight. */
|
|
112
|
+
size_t probe_pkt_left;
|
|
113
|
+
/* flags is bitwise-OR of zero or more of NGTCP2_PV_FLAG_*. */
|
|
114
|
+
uint8_t flags;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* ngtcp2_pv_new creates new ngtcp2_pv object and assigns its pointer
|
|
119
|
+
* to |*ppv|. This function makes a copy of |dcid|. |timeout| is a
|
|
120
|
+
* duration within which this path validation must succeed.
|
|
121
|
+
*
|
|
122
|
+
* This function returns 0 if it succeeds, or one of the following
|
|
123
|
+
* negative error codes:
|
|
124
|
+
*
|
|
125
|
+
* NGTCP2_ERR_NOMEM
|
|
126
|
+
* Out of memory
|
|
127
|
+
*/
|
|
128
|
+
int ngtcp2_pv_new(ngtcp2_pv **ppv, const ngtcp2_dcid *dcid,
|
|
129
|
+
ngtcp2_duration timeout, uint8_t flags, ngtcp2_log *log,
|
|
130
|
+
const ngtcp2_mem *mem);
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* ngtcp2_pv_del deallocates |pv|. This function frees memory |pv|
|
|
134
|
+
* points too.
|
|
135
|
+
*/
|
|
136
|
+
void ngtcp2_pv_del(ngtcp2_pv *pv);
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* ngtcp2_pv_add_entry adds new entry with |data|. |expiry| is the
|
|
140
|
+
* expiry time of the entry.
|
|
141
|
+
*/
|
|
142
|
+
void ngtcp2_pv_add_entry(ngtcp2_pv *pv, const uint8_t *data,
|
|
143
|
+
ngtcp2_tstamp expiry, uint8_t flags, ngtcp2_tstamp ts);
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* ngtcp2_pv_full returns nonzero if |pv| is full of ngtcp2_pv_entry.
|
|
147
|
+
*/
|
|
148
|
+
int ngtcp2_pv_full(ngtcp2_pv *pv);
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
* ngtcp2_pv_validate validates that the received |data| matches the
|
|
152
|
+
* one of the existing entry. The flag of ngtcp2_pv_entry that
|
|
153
|
+
* matches |data| is assigned to |*pflags| if this function succeeds.
|
|
154
|
+
*
|
|
155
|
+
* This function returns 0 if it succeeds, or one of the following
|
|
156
|
+
* negative error codes:
|
|
157
|
+
*
|
|
158
|
+
* NGTCP2_ERR_PATH_VALIDATION_FAILED
|
|
159
|
+
* path validation has failed and must be abandoned
|
|
160
|
+
* NGTCP2_ERR_INVALID_STATE
|
|
161
|
+
* |pv| includes no entry
|
|
162
|
+
* NGTCP2_ERR_INVALID_ARGUMENT
|
|
163
|
+
* |pv| does not have an entry which has |data| and |path|
|
|
164
|
+
*/
|
|
165
|
+
int ngtcp2_pv_validate(ngtcp2_pv *pv, uint8_t *pflags, const uint8_t *data);
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* ngtcp2_pv_handle_entry_expiry checks expiry of existing entries.
|
|
169
|
+
*/
|
|
170
|
+
void ngtcp2_pv_handle_entry_expiry(ngtcp2_pv *pv, ngtcp2_tstamp ts);
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* ngtcp2_pv_should_send_probe returns nonzero if new entry can be
|
|
174
|
+
* added by ngtcp2_pv_add_entry.
|
|
175
|
+
*/
|
|
176
|
+
int ngtcp2_pv_should_send_probe(ngtcp2_pv *pv);
|
|
177
|
+
|
|
178
|
+
/*
|
|
179
|
+
* ngtcp2_pv_validation_timed_out returns nonzero if the path
|
|
180
|
+
* validation fails because of timeout.
|
|
181
|
+
*/
|
|
182
|
+
int ngtcp2_pv_validation_timed_out(ngtcp2_pv *pv, ngtcp2_tstamp ts);
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
* ngtcp2_pv_next_expiry returns the earliest expiry.
|
|
186
|
+
*/
|
|
187
|
+
ngtcp2_tstamp ngtcp2_pv_next_expiry(ngtcp2_pv *pv);
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* ngtcp2_pv_cancel_expired_timer cancels the expired timer.
|
|
191
|
+
*/
|
|
192
|
+
void ngtcp2_pv_cancel_expired_timer(ngtcp2_pv *pv, ngtcp2_tstamp ts);
|
|
193
|
+
|
|
194
|
+
#endif /* NGTCP2_PV_H */
|