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,123 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2018 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_LOG_H
|
26
|
+
#define NGTCP2_LOG_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_pkt.h"
|
35
|
+
|
36
|
+
typedef struct ngtcp2_log {
|
37
|
+
/* log_printf is a sink to write log. NULL means no logging
|
38
|
+
output. */
|
39
|
+
ngtcp2_printf log_printf;
|
40
|
+
/* ts is the time point used to write time delta in the log. */
|
41
|
+
ngtcp2_tstamp ts;
|
42
|
+
/* last_ts is the most recent time point that this object is
|
43
|
+
told. */
|
44
|
+
ngtcp2_tstamp last_ts;
|
45
|
+
/* user_data is user-defined opaque data which is passed to
|
46
|
+
log_pritnf. */
|
47
|
+
void *user_data;
|
48
|
+
/* scid is SCID encoded as NULL-terminated hex string. */
|
49
|
+
uint8_t scid[NGTCP2_MAX_CIDLEN * 2 + 1];
|
50
|
+
} ngtcp2_log;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @enum
|
54
|
+
*
|
55
|
+
* :type:`ngtcp2_log_event` defines an event of ngtcp2 library
|
56
|
+
* internal logger.
|
57
|
+
*/
|
58
|
+
typedef enum ngtcp2_log_event {
|
59
|
+
/**
|
60
|
+
* :enum:`NGTCP2_LOG_EVENT_NONE` represents no event.
|
61
|
+
*/
|
62
|
+
NGTCP2_LOG_EVENT_NONE,
|
63
|
+
/**
|
64
|
+
* :enum:`NGTCP2_LOG_EVENT_CON` is a connection (catch-all) event
|
65
|
+
*/
|
66
|
+
NGTCP2_LOG_EVENT_CON,
|
67
|
+
/**
|
68
|
+
* :enum:`NGTCP2_LOG_EVENT_PKT` is a packet event.
|
69
|
+
*/
|
70
|
+
NGTCP2_LOG_EVENT_PKT,
|
71
|
+
/**
|
72
|
+
* :enum:`NGTCP2_LOG_EVENT_FRM` is a QUIC frame event.
|
73
|
+
*/
|
74
|
+
NGTCP2_LOG_EVENT_FRM,
|
75
|
+
/**
|
76
|
+
* :enum:`NGTCP2_LOG_EVENT_RCV` is a congestion and recovery event.
|
77
|
+
*/
|
78
|
+
NGTCP2_LOG_EVENT_RCV,
|
79
|
+
/**
|
80
|
+
* :enum:`NGTCP2_LOG_EVENT_CRY` is a crypto event.
|
81
|
+
*/
|
82
|
+
NGTCP2_LOG_EVENT_CRY,
|
83
|
+
/**
|
84
|
+
* :enum:`NGTCP2_LOG_EVENT_PTV` is a path validation event.
|
85
|
+
*/
|
86
|
+
NGTCP2_LOG_EVENT_PTV,
|
87
|
+
} ngtcp2_log_event;
|
88
|
+
|
89
|
+
void ngtcp2_log_init(ngtcp2_log *log, const ngtcp2_cid *scid,
|
90
|
+
ngtcp2_printf log_printf, ngtcp2_tstamp ts,
|
91
|
+
void *user_data);
|
92
|
+
|
93
|
+
void ngtcp2_log_rx_fr(ngtcp2_log *log, const ngtcp2_pkt_hd *hd,
|
94
|
+
const ngtcp2_frame *fr);
|
95
|
+
void ngtcp2_log_tx_fr(ngtcp2_log *log, const ngtcp2_pkt_hd *hd,
|
96
|
+
const ngtcp2_frame *fr);
|
97
|
+
|
98
|
+
void ngtcp2_log_rx_vn(ngtcp2_log *log, const ngtcp2_pkt_hd *hd,
|
99
|
+
const uint32_t *sv, size_t nsv);
|
100
|
+
|
101
|
+
void ngtcp2_log_rx_sr(ngtcp2_log *log, const ngtcp2_pkt_stateless_reset *sr);
|
102
|
+
|
103
|
+
void ngtcp2_log_remote_tp(ngtcp2_log *log, uint8_t exttype,
|
104
|
+
const ngtcp2_transport_params *params);
|
105
|
+
|
106
|
+
void ngtcp2_log_pkt_lost(ngtcp2_log *log, int64_t pkt_num, uint8_t type,
|
107
|
+
uint8_t flags, ngtcp2_tstamp sent_ts);
|
108
|
+
|
109
|
+
void ngtcp2_log_rx_pkt_hd(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
|
110
|
+
|
111
|
+
void ngtcp2_log_tx_pkt_hd(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
|
112
|
+
|
113
|
+
void ngtcp2_log_tx_cancel(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @function
|
117
|
+
*
|
118
|
+
* `ngtcp2_log_info` writes info level log.
|
119
|
+
*/
|
120
|
+
void ngtcp2_log_info(ngtcp2_log *log, ngtcp2_log_event ev, const char *fmt,
|
121
|
+
...);
|
122
|
+
|
123
|
+
#endif /* NGTCP2_LOG_H */
|
@@ -0,0 +1,58 @@
|
|
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
|
+
#ifndef NGTCP2_MACRO_H
|
26
|
+
#define NGTCP2_MACRO_H
|
27
|
+
|
28
|
+
#ifdef HAVE_CONFIG_H
|
29
|
+
# include <config.h>
|
30
|
+
#endif /* HAVE_CONFIG_H */
|
31
|
+
|
32
|
+
#include <stddef.h>
|
33
|
+
|
34
|
+
#include <ngtcp2/ngtcp2.h>
|
35
|
+
|
36
|
+
#define ngtcp2_min(A, B) ((A) < (B) ? (A) : (B))
|
37
|
+
#define ngtcp2_max(A, B) ((A) > (B) ? (A) : (B))
|
38
|
+
|
39
|
+
#define ngtcp2_struct_of(ptr, type, member) \
|
40
|
+
((type *)(void *)((char *)(ptr)-offsetof(type, member)))
|
41
|
+
|
42
|
+
/* ngtcp2_list_insert inserts |T| before |*PD|. The contract is that
|
43
|
+
this is singly linked list, and the next element is pointed by next
|
44
|
+
field of the previous element. |PD| must be a pointer to the
|
45
|
+
pointer to the next field of the previous element of |*PD|: if C is
|
46
|
+
the previous element of |PD|, PD = &C->next. */
|
47
|
+
#define ngtcp2_list_insert(T, PD) \
|
48
|
+
do { \
|
49
|
+
(T)->next = *(PD); \
|
50
|
+
*(PD) = (T); \
|
51
|
+
} while (0)
|
52
|
+
|
53
|
+
/*
|
54
|
+
* ngtcp2_arraylen returns the number of elements in array |A|.
|
55
|
+
*/
|
56
|
+
#define ngtcp2_arraylen(A) (sizeof(A) / sizeof(A[0]))
|
57
|
+
|
58
|
+
#endif /* NGTCP2_MACRO_H */
|
@@ -0,0 +1,336 @@
|
|
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_map.h"
|
27
|
+
|
28
|
+
#include <string.h>
|
29
|
+
#include <assert.h>
|
30
|
+
#include <stdio.h>
|
31
|
+
|
32
|
+
#include "ngtcp2_conv.h"
|
33
|
+
|
34
|
+
#define NGTCP2_INITIAL_TABLE_LENBITS 4
|
35
|
+
|
36
|
+
void ngtcp2_map_init(ngtcp2_map *map, const ngtcp2_mem *mem) {
|
37
|
+
map->mem = mem;
|
38
|
+
map->tablelen = 0;
|
39
|
+
map->tablelenbits = 0;
|
40
|
+
map->table = NULL;
|
41
|
+
map->size = 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
void ngtcp2_map_free(ngtcp2_map *map) {
|
45
|
+
if (!map) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
ngtcp2_mem_free(map->mem, map->table);
|
50
|
+
}
|
51
|
+
|
52
|
+
void ngtcp2_map_each_free(ngtcp2_map *map, int (*func)(void *data, void *ptr),
|
53
|
+
void *ptr) {
|
54
|
+
uint32_t i;
|
55
|
+
ngtcp2_map_bucket *bkt;
|
56
|
+
|
57
|
+
for (i = 0; i < map->tablelen; ++i) {
|
58
|
+
bkt = &map->table[i];
|
59
|
+
|
60
|
+
if (bkt->data == NULL) {
|
61
|
+
continue;
|
62
|
+
}
|
63
|
+
|
64
|
+
func(bkt->data, ptr);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
int ngtcp2_map_each(ngtcp2_map *map, int (*func)(void *data, void *ptr),
|
69
|
+
void *ptr) {
|
70
|
+
int rv;
|
71
|
+
uint32_t i;
|
72
|
+
ngtcp2_map_bucket *bkt;
|
73
|
+
|
74
|
+
if (map->size == 0) {
|
75
|
+
return 0;
|
76
|
+
}
|
77
|
+
|
78
|
+
for (i = 0; i < map->tablelen; ++i) {
|
79
|
+
bkt = &map->table[i];
|
80
|
+
|
81
|
+
if (bkt->data == NULL) {
|
82
|
+
continue;
|
83
|
+
}
|
84
|
+
|
85
|
+
rv = func(bkt->data, ptr);
|
86
|
+
if (rv != 0) {
|
87
|
+
return rv;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
return 0;
|
92
|
+
}
|
93
|
+
|
94
|
+
static uint32_t hash(ngtcp2_map_key_type key) {
|
95
|
+
return (uint32_t)((key * 11400714819323198485llu) >> 32);
|
96
|
+
}
|
97
|
+
|
98
|
+
static size_t h2idx(uint32_t hash, uint32_t bits) {
|
99
|
+
return hash >> (32 - bits);
|
100
|
+
}
|
101
|
+
|
102
|
+
static size_t distance(uint32_t tablelen, uint32_t tablelenbits,
|
103
|
+
ngtcp2_map_bucket *bkt, size_t idx) {
|
104
|
+
return (idx - h2idx(bkt->hash, tablelenbits)) & (tablelen - 1);
|
105
|
+
}
|
106
|
+
|
107
|
+
static void map_bucket_swap(ngtcp2_map_bucket *bkt, uint32_t *phash,
|
108
|
+
ngtcp2_map_key_type *pkey, void **pdata) {
|
109
|
+
uint32_t h = bkt->hash;
|
110
|
+
ngtcp2_map_key_type key = bkt->key;
|
111
|
+
void *data = bkt->data;
|
112
|
+
|
113
|
+
bkt->hash = *phash;
|
114
|
+
bkt->key = *pkey;
|
115
|
+
bkt->data = *pdata;
|
116
|
+
|
117
|
+
*phash = h;
|
118
|
+
*pkey = key;
|
119
|
+
*pdata = data;
|
120
|
+
}
|
121
|
+
|
122
|
+
static void map_bucket_set_data(ngtcp2_map_bucket *bkt, uint32_t hash,
|
123
|
+
ngtcp2_map_key_type key, void *data) {
|
124
|
+
bkt->hash = hash;
|
125
|
+
bkt->key = key;
|
126
|
+
bkt->data = data;
|
127
|
+
}
|
128
|
+
|
129
|
+
void ngtcp2_map_print_distance(ngtcp2_map *map) {
|
130
|
+
uint32_t i;
|
131
|
+
size_t idx;
|
132
|
+
ngtcp2_map_bucket *bkt;
|
133
|
+
|
134
|
+
for (i = 0; i < map->tablelen; ++i) {
|
135
|
+
bkt = &map->table[i];
|
136
|
+
|
137
|
+
if (bkt->data == NULL) {
|
138
|
+
fprintf(stderr, "@%u <EMPTY>\n", i);
|
139
|
+
continue;
|
140
|
+
}
|
141
|
+
|
142
|
+
idx = h2idx(bkt->hash, map->tablelenbits);
|
143
|
+
fprintf(stderr, "@%u hash=%08x key=%" PRIu64 " base=%zu distance=%zu\n", i,
|
144
|
+
bkt->hash, bkt->key, idx,
|
145
|
+
distance(map->tablelen, map->tablelenbits, bkt, idx));
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
static int insert(ngtcp2_map_bucket *table, uint32_t tablelen,
|
150
|
+
uint32_t tablelenbits, uint32_t hash, ngtcp2_map_key_type key,
|
151
|
+
void *data) {
|
152
|
+
size_t idx = h2idx(hash, tablelenbits);
|
153
|
+
size_t d = 0, dd;
|
154
|
+
ngtcp2_map_bucket *bkt;
|
155
|
+
|
156
|
+
for (;;) {
|
157
|
+
bkt = &table[idx];
|
158
|
+
|
159
|
+
if (bkt->data == NULL) {
|
160
|
+
map_bucket_set_data(bkt, hash, key, data);
|
161
|
+
return 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
dd = distance(tablelen, tablelenbits, bkt, idx);
|
165
|
+
if (d > dd) {
|
166
|
+
map_bucket_swap(bkt, &hash, &key, &data);
|
167
|
+
d = dd;
|
168
|
+
} else if (bkt->key == key) {
|
169
|
+
/* TODO This check is just a waste after first swap or if this
|
170
|
+
function is called from map_resize. That said, there is no
|
171
|
+
difference with or without this conditional in performance
|
172
|
+
wise. */
|
173
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
174
|
+
}
|
175
|
+
|
176
|
+
++d;
|
177
|
+
idx = (idx + 1) & (tablelen - 1);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
/* new_tablelen must be power of 2 and new_tablelen == (1 <<
|
182
|
+
new_tablelenbits) must hold. */
|
183
|
+
static int map_resize(ngtcp2_map *map, uint32_t new_tablelen,
|
184
|
+
uint32_t new_tablelenbits) {
|
185
|
+
uint32_t i;
|
186
|
+
ngtcp2_map_bucket *new_table;
|
187
|
+
ngtcp2_map_bucket *bkt;
|
188
|
+
int rv;
|
189
|
+
(void)rv;
|
190
|
+
|
191
|
+
new_table =
|
192
|
+
ngtcp2_mem_calloc(map->mem, new_tablelen, sizeof(ngtcp2_map_bucket));
|
193
|
+
if (new_table == NULL) {
|
194
|
+
return NGTCP2_ERR_NOMEM;
|
195
|
+
}
|
196
|
+
|
197
|
+
for (i = 0; i < map->tablelen; ++i) {
|
198
|
+
bkt = &map->table[i];
|
199
|
+
if (bkt->data == NULL) {
|
200
|
+
continue;
|
201
|
+
}
|
202
|
+
rv = insert(new_table, new_tablelen, new_tablelenbits, bkt->hash, bkt->key,
|
203
|
+
bkt->data);
|
204
|
+
|
205
|
+
assert(0 == rv);
|
206
|
+
}
|
207
|
+
|
208
|
+
ngtcp2_mem_free(map->mem, map->table);
|
209
|
+
map->tablelen = new_tablelen;
|
210
|
+
map->tablelenbits = new_tablelenbits;
|
211
|
+
map->table = new_table;
|
212
|
+
|
213
|
+
return 0;
|
214
|
+
}
|
215
|
+
|
216
|
+
int ngtcp2_map_insert(ngtcp2_map *map, ngtcp2_map_key_type key, void *data) {
|
217
|
+
int rv;
|
218
|
+
|
219
|
+
assert(data);
|
220
|
+
|
221
|
+
/* Load factor is 0.75 */
|
222
|
+
if ((map->size + 1) * 4 > map->tablelen * 3) {
|
223
|
+
if (map->tablelen) {
|
224
|
+
rv = map_resize(map, map->tablelen * 2, map->tablelenbits + 1);
|
225
|
+
if (rv != 0) {
|
226
|
+
return rv;
|
227
|
+
}
|
228
|
+
} else {
|
229
|
+
rv = map_resize(map, 1 << NGTCP2_INITIAL_TABLE_LENBITS,
|
230
|
+
NGTCP2_INITIAL_TABLE_LENBITS);
|
231
|
+
if (rv != 0) {
|
232
|
+
return rv;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
rv = insert(map->table, map->tablelen, map->tablelenbits, hash(key), key,
|
238
|
+
data);
|
239
|
+
if (rv != 0) {
|
240
|
+
return rv;
|
241
|
+
}
|
242
|
+
++map->size;
|
243
|
+
return 0;
|
244
|
+
}
|
245
|
+
|
246
|
+
void *ngtcp2_map_find(ngtcp2_map *map, ngtcp2_map_key_type key) {
|
247
|
+
uint32_t h;
|
248
|
+
size_t idx;
|
249
|
+
ngtcp2_map_bucket *bkt;
|
250
|
+
size_t d = 0;
|
251
|
+
|
252
|
+
if (map->size == 0) {
|
253
|
+
return NULL;
|
254
|
+
}
|
255
|
+
|
256
|
+
h = hash(key);
|
257
|
+
idx = h2idx(h, map->tablelenbits);
|
258
|
+
|
259
|
+
for (;;) {
|
260
|
+
bkt = &map->table[idx];
|
261
|
+
|
262
|
+
if (bkt->data == NULL ||
|
263
|
+
d > distance(map->tablelen, map->tablelenbits, bkt, idx)) {
|
264
|
+
return NULL;
|
265
|
+
}
|
266
|
+
|
267
|
+
if (bkt->key == key) {
|
268
|
+
return bkt->data;
|
269
|
+
}
|
270
|
+
|
271
|
+
++d;
|
272
|
+
idx = (idx + 1) & (map->tablelen - 1);
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
int ngtcp2_map_remove(ngtcp2_map *map, ngtcp2_map_key_type key) {
|
277
|
+
uint32_t h;
|
278
|
+
size_t idx, didx;
|
279
|
+
ngtcp2_map_bucket *bkt;
|
280
|
+
size_t d = 0;
|
281
|
+
|
282
|
+
if (map->size == 0) {
|
283
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
284
|
+
}
|
285
|
+
|
286
|
+
h = hash(key);
|
287
|
+
idx = h2idx(h, map->tablelenbits);
|
288
|
+
|
289
|
+
for (;;) {
|
290
|
+
bkt = &map->table[idx];
|
291
|
+
|
292
|
+
if (bkt->data == NULL ||
|
293
|
+
d > distance(map->tablelen, map->tablelenbits, bkt, idx)) {
|
294
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
295
|
+
}
|
296
|
+
|
297
|
+
if (bkt->key == key) {
|
298
|
+
map_bucket_set_data(bkt, 0, 0, NULL);
|
299
|
+
|
300
|
+
didx = idx;
|
301
|
+
idx = (idx + 1) & (map->tablelen - 1);
|
302
|
+
|
303
|
+
for (;;) {
|
304
|
+
bkt = &map->table[idx];
|
305
|
+
if (bkt->data == NULL ||
|
306
|
+
distance(map->tablelen, map->tablelenbits, bkt, idx) == 0) {
|
307
|
+
break;
|
308
|
+
}
|
309
|
+
|
310
|
+
map->table[didx] = *bkt;
|
311
|
+
map_bucket_set_data(bkt, 0, 0, NULL);
|
312
|
+
didx = idx;
|
313
|
+
|
314
|
+
idx = (idx + 1) & (map->tablelen - 1);
|
315
|
+
}
|
316
|
+
|
317
|
+
--map->size;
|
318
|
+
|
319
|
+
return 0;
|
320
|
+
}
|
321
|
+
|
322
|
+
++d;
|
323
|
+
idx = (idx + 1) & (map->tablelen - 1);
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
void ngtcp2_map_clear(ngtcp2_map *map) {
|
328
|
+
if (map->tablelen == 0) {
|
329
|
+
return;
|
330
|
+
}
|
331
|
+
|
332
|
+
memset(map->table, 0, sizeof(*map->table) * map->tablelen);
|
333
|
+
map->size = 0;
|
334
|
+
}
|
335
|
+
|
336
|
+
size_t ngtcp2_map_size(ngtcp2_map *map) { return map->size; }
|
@@ -0,0 +1,136 @@
|
|
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_MAP_H
|
27
|
+
#define NGTCP2_MAP_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 unordered map */
|
38
|
+
|
39
|
+
typedef uint64_t ngtcp2_map_key_type;
|
40
|
+
|
41
|
+
typedef struct ngtcp2_map_bucket {
|
42
|
+
uint32_t hash;
|
43
|
+
ngtcp2_map_key_type key;
|
44
|
+
void *data;
|
45
|
+
} ngtcp2_map_bucket;
|
46
|
+
|
47
|
+
typedef struct ngtcp2_map {
|
48
|
+
ngtcp2_map_bucket *table;
|
49
|
+
const ngtcp2_mem *mem;
|
50
|
+
size_t size;
|
51
|
+
uint32_t tablelen;
|
52
|
+
uint32_t tablelenbits;
|
53
|
+
} ngtcp2_map;
|
54
|
+
|
55
|
+
/*
|
56
|
+
* Initializes the map |map|.
|
57
|
+
*/
|
58
|
+
void ngtcp2_map_init(ngtcp2_map *map, const ngtcp2_mem *mem);
|
59
|
+
|
60
|
+
/*
|
61
|
+
* Deallocates any resources allocated for |map|. The stored entries
|
62
|
+
* are not freed by this function. Use ngtcp2_map_each_free() to free
|
63
|
+
* each entries.
|
64
|
+
*/
|
65
|
+
void ngtcp2_map_free(ngtcp2_map *map);
|
66
|
+
|
67
|
+
/*
|
68
|
+
* Deallocates each entries using |func| function and any resources
|
69
|
+
* allocated for |map|. The |func| function is responsible for freeing
|
70
|
+
* given the |data| object. The |ptr| will be passed to the |func| as
|
71
|
+
* send argument. The return value of the |func| will be ignored.
|
72
|
+
*/
|
73
|
+
void ngtcp2_map_each_free(ngtcp2_map *map, int (*func)(void *data, void *ptr),
|
74
|
+
void *ptr);
|
75
|
+
|
76
|
+
/*
|
77
|
+
* Inserts the new |data| with the |key| to the map |map|.
|
78
|
+
*
|
79
|
+
* This function returns 0 if it succeeds, or one of the following
|
80
|
+
* negative error codes:
|
81
|
+
*
|
82
|
+
* NGTCP2_ERR_INVALID_ARGUMENT
|
83
|
+
* The item associated by |key| already exists.
|
84
|
+
* NGTCP2_ERR_NOMEM
|
85
|
+
* Out of memory
|
86
|
+
*/
|
87
|
+
int ngtcp2_map_insert(ngtcp2_map *map, ngtcp2_map_key_type key, void *data);
|
88
|
+
|
89
|
+
/*
|
90
|
+
* Returns the data associated by the key |key|. If there is no such
|
91
|
+
* data, this function returns NULL.
|
92
|
+
*/
|
93
|
+
void *ngtcp2_map_find(ngtcp2_map *map, ngtcp2_map_key_type key);
|
94
|
+
|
95
|
+
/*
|
96
|
+
* Removes the data associated by the key |key| from the |map|. The
|
97
|
+
* removed data is not freed by this function.
|
98
|
+
*
|
99
|
+
* This function returns 0 if it succeeds, or one of the following
|
100
|
+
* negative error codes:
|
101
|
+
*
|
102
|
+
* NGTCP2_ERR_INVALID_ARGUMENT
|
103
|
+
* The data associated by |key| does not exist.
|
104
|
+
*/
|
105
|
+
int ngtcp2_map_remove(ngtcp2_map *map, ngtcp2_map_key_type key);
|
106
|
+
|
107
|
+
/*
|
108
|
+
* Removes all entries from |map|.
|
109
|
+
*/
|
110
|
+
void ngtcp2_map_clear(ngtcp2_map *map);
|
111
|
+
|
112
|
+
/*
|
113
|
+
* Returns the number of items stored in the map |map|.
|
114
|
+
*/
|
115
|
+
size_t ngtcp2_map_size(ngtcp2_map *map);
|
116
|
+
|
117
|
+
/*
|
118
|
+
* Applies the function |func| to each data in the |map| with the
|
119
|
+
* optional user supplied pointer |ptr|.
|
120
|
+
*
|
121
|
+
* If the |func| returns 0, this function calls the |func| with the
|
122
|
+
* next data. If the |func| returns nonzero, it will not call the
|
123
|
+
* |func| for further entries and return the return value of the
|
124
|
+
* |func| immediately. Thus, this function returns 0 if all the
|
125
|
+
* invocations of the |func| return 0, or nonzero value which the last
|
126
|
+
* invocation of |func| returns.
|
127
|
+
*
|
128
|
+
* Don't use this function to free each data. Use
|
129
|
+
* ngtcp2_map_each_free() instead.
|
130
|
+
*/
|
131
|
+
int ngtcp2_map_each(ngtcp2_map *map, int (*func)(void *data, void *ptr),
|
132
|
+
void *ptr);
|
133
|
+
|
134
|
+
void ngtcp2_map_print_distance(ngtcp2_map *map);
|
135
|
+
|
136
|
+
#endif /* NGTCP2_MAP_H */
|