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,310 @@
|
|
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_STRM_H
|
26
|
+
#define NGTCP2_STRM_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_rob.h"
|
35
|
+
#include "ngtcp2_map.h"
|
36
|
+
#include "ngtcp2_gaptr.h"
|
37
|
+
#include "ngtcp2_ksl.h"
|
38
|
+
#include "ngtcp2_pq.h"
|
39
|
+
|
40
|
+
typedef struct ngtcp2_frame_chain ngtcp2_frame_chain;
|
41
|
+
|
42
|
+
/* NGTCP2_STRM_FLAG_NONE indicates that no flag is set. */
|
43
|
+
#define NGTCP2_STRM_FLAG_NONE 0x00u
|
44
|
+
/* NGTCP2_STRM_FLAG_SHUT_RD indicates that further reception of stream
|
45
|
+
data is not allowed. */
|
46
|
+
#define NGTCP2_STRM_FLAG_SHUT_RD 0x01u
|
47
|
+
/* NGTCP2_STRM_FLAG_SHUT_WR indicates that further transmission of
|
48
|
+
stream data is not allowed. */
|
49
|
+
#define NGTCP2_STRM_FLAG_SHUT_WR 0x02u
|
50
|
+
#define NGTCP2_STRM_FLAG_SHUT_RDWR \
|
51
|
+
(NGTCP2_STRM_FLAG_SHUT_RD | NGTCP2_STRM_FLAG_SHUT_WR)
|
52
|
+
/* NGTCP2_STRM_FLAG_SENT_RST indicates that RST_STREAM is sent from
|
53
|
+
the local endpoint. In this case, NGTCP2_STRM_FLAG_SHUT_WR is also
|
54
|
+
set. */
|
55
|
+
#define NGTCP2_STRM_FLAG_SENT_RST 0x04u
|
56
|
+
/* NGTCP2_STRM_FLAG_SENT_RST indicates that RST_STREAM is received
|
57
|
+
from the remote endpoint. In this case, NGTCP2_STRM_FLAG_SHUT_RD
|
58
|
+
is also set. */
|
59
|
+
#define NGTCP2_STRM_FLAG_RECV_RST 0x08u
|
60
|
+
/* NGTCP2_STRM_FLAG_STOP_SENDING indicates that STOP_SENDING is sent
|
61
|
+
from the local endpoint. */
|
62
|
+
#define NGTCP2_STRM_FLAG_STOP_SENDING 0x10u
|
63
|
+
/* NGTCP2_STRM_FLAG_RST_ACKED indicates that the outgoing RST_STREAM
|
64
|
+
is acknowledged by peer. */
|
65
|
+
#define NGTCP2_STRM_FLAG_RST_ACKED 0x20u
|
66
|
+
/* NGTCP2_STRM_FLAG_FIN_ACKED indicates that a STREAM with FIN bit set
|
67
|
+
is acknowledged by a remote endpoint. */
|
68
|
+
#define NGTCP2_STRM_FLAG_FIN_ACKED 0x40u
|
69
|
+
/* NGTCP2_STRM_FLAG_ANY_ACKED indicates that any portion of stream
|
70
|
+
data, including 0 length segment, is acknowledged. */
|
71
|
+
#define NGTCP2_STRM_FLAG_ANY_ACKED 0x80u
|
72
|
+
/* NGTCP2_STRM_FLAG_APP_ERROR_CODE_SET indicates that app_error_code
|
73
|
+
field is set. This resolves the ambiguity that the initial
|
74
|
+
app_error_code value 0 might be a proper application error code.
|
75
|
+
In this case, without this flag, we are unable to distinguish
|
76
|
+
assigned value from unassigned one. */
|
77
|
+
#define NGTCP2_STRM_FLAG_APP_ERROR_CODE_SET 0x100u
|
78
|
+
/* NGTCP2_STRM_FLAG_STREAM_STOP_SENDING_CALLED is set when
|
79
|
+
stream_stop_sending callback is called. */
|
80
|
+
#define NGTCP2_STRM_FLAG_STREAM_STOP_SENDING_CALLED 0x200u
|
81
|
+
|
82
|
+
typedef struct ngtcp2_strm ngtcp2_strm;
|
83
|
+
|
84
|
+
struct ngtcp2_strm {
|
85
|
+
union {
|
86
|
+
struct {
|
87
|
+
ngtcp2_pq_entry pe;
|
88
|
+
uint64_t cycle;
|
89
|
+
ngtcp2_objalloc *frc_objalloc;
|
90
|
+
|
91
|
+
struct {
|
92
|
+
/* acked_offset tracks acknowledged outgoing data. */
|
93
|
+
ngtcp2_gaptr *acked_offset;
|
94
|
+
/* cont_acked_offset is the offset that all data up to this offset
|
95
|
+
is acknowledged by a remote endpoint. It is used until the
|
96
|
+
remote endpoint acknowledges data in out-of-order. After that,
|
97
|
+
acked_offset is used instead. */
|
98
|
+
uint64_t cont_acked_offset;
|
99
|
+
/* streamfrq contains STREAM frame for retransmission. The flow
|
100
|
+
control credits have been paid when they are transmitted first
|
101
|
+
time. There are no restriction regarding flow control for
|
102
|
+
retransmission. */
|
103
|
+
ngtcp2_ksl *streamfrq;
|
104
|
+
/* offset is the next offset of outgoing data. In other words, it
|
105
|
+
is the number of bytes sent in this stream without
|
106
|
+
duplication. */
|
107
|
+
uint64_t offset;
|
108
|
+
/* max_tx_offset is the maximum offset that local endpoint can
|
109
|
+
send for this stream. */
|
110
|
+
uint64_t max_offset;
|
111
|
+
/* last_max_stream_data_ts is the timestamp when last
|
112
|
+
MAX_STREAM_DATA frame is sent. */
|
113
|
+
ngtcp2_tstamp last_max_stream_data_ts;
|
114
|
+
/* loss_count is the number of packets that contain STREAM
|
115
|
+
frame for this stream and are declared to be lost. It may
|
116
|
+
include the spurious losses. It does not include a packet
|
117
|
+
whose contents have been reclaimed for PTO and which is
|
118
|
+
later declared to be lost. Those data are not blocked by
|
119
|
+
the flow control and will be sent immediately if no other
|
120
|
+
restrictions are applied. */
|
121
|
+
size_t loss_count;
|
122
|
+
/* last_lost_pkt_num is the packet number of the packet that
|
123
|
+
is counted to loss_count. It is used to avoid to count
|
124
|
+
multiple STREAM frames in one lost packet. */
|
125
|
+
int64_t last_lost_pkt_num;
|
126
|
+
} tx;
|
127
|
+
|
128
|
+
struct {
|
129
|
+
/* rob is the reorder buffer for incoming stream data. The data
|
130
|
+
received in out of order is buffered and sorted by its offset
|
131
|
+
in this object. */
|
132
|
+
ngtcp2_rob *rob;
|
133
|
+
/* cont_offset is the largest offset of consecutive data. It is
|
134
|
+
used until the endpoint receives out-of-order data. After
|
135
|
+
that, rob is used to track the offset and data. */
|
136
|
+
uint64_t cont_offset;
|
137
|
+
/* last_offset is the largest offset of stream data received for
|
138
|
+
this stream. */
|
139
|
+
uint64_t last_offset;
|
140
|
+
/* max_offset is the maximum offset that remote endpoint can send
|
141
|
+
to this stream. */
|
142
|
+
uint64_t max_offset;
|
143
|
+
/* unsent_max_offset is the maximum offset that remote endpoint
|
144
|
+
can send to this stream, and it is not notified to the remote
|
145
|
+
endpoint. unsent_max_offset >= max_offset must be hold. */
|
146
|
+
uint64_t unsent_max_offset;
|
147
|
+
/* window is the stream-level flow control window size. */
|
148
|
+
uint64_t window;
|
149
|
+
} rx;
|
150
|
+
|
151
|
+
const ngtcp2_mem *mem;
|
152
|
+
int64_t stream_id;
|
153
|
+
void *stream_user_data;
|
154
|
+
/* flags is bit-wise OR of zero or more of NGTCP2_STRM_FLAG_*. */
|
155
|
+
uint32_t flags;
|
156
|
+
/* app_error_code is an error code the local endpoint sent in
|
157
|
+
RESET_STREAM or STOP_SENDING, or received from a remote endpoint
|
158
|
+
in RESET_STREAM or STOP_SENDING. First application error code is
|
159
|
+
chosen and when set, NGTCP2_STRM_FLAG_APP_ERROR_CODE_SET flag is
|
160
|
+
set in flags field. */
|
161
|
+
uint64_t app_error_code;
|
162
|
+
};
|
163
|
+
|
164
|
+
ngtcp2_opl_entry oplent;
|
165
|
+
};
|
166
|
+
};
|
167
|
+
|
168
|
+
/*
|
169
|
+
* ngtcp2_strm_init initializes |strm|.
|
170
|
+
*/
|
171
|
+
void ngtcp2_strm_init(ngtcp2_strm *strm, int64_t stream_id, uint32_t flags,
|
172
|
+
uint64_t max_rx_offset, uint64_t max_tx_offset,
|
173
|
+
void *stream_user_data, ngtcp2_objalloc *frc_objalloc,
|
174
|
+
const ngtcp2_mem *mem);
|
175
|
+
|
176
|
+
/*
|
177
|
+
* ngtcp2_strm_free deallocates memory allocated for |strm|. This
|
178
|
+
* function does not free the memory pointed by |strm| itself.
|
179
|
+
*/
|
180
|
+
void ngtcp2_strm_free(ngtcp2_strm *strm);
|
181
|
+
|
182
|
+
/*
|
183
|
+
* ngtcp2_strm_rx_offset returns the minimum offset of stream data
|
184
|
+
* which is not received yet.
|
185
|
+
*/
|
186
|
+
uint64_t ngtcp2_strm_rx_offset(ngtcp2_strm *strm);
|
187
|
+
|
188
|
+
/*
|
189
|
+
* ngtcp2_strm_recv_reordering handles reordered data.
|
190
|
+
*
|
191
|
+
* It returns 0 if it succeeds, or one of the following negative error
|
192
|
+
* codes:
|
193
|
+
*
|
194
|
+
* NGTCP2_ERR_NOMEM
|
195
|
+
* Out of memory
|
196
|
+
*/
|
197
|
+
int ngtcp2_strm_recv_reordering(ngtcp2_strm *strm, const uint8_t *data,
|
198
|
+
size_t datalen, uint64_t offset);
|
199
|
+
|
200
|
+
/*
|
201
|
+
* ngtcp2_strm_update_rx_offset tells that data up to offset bytes are
|
202
|
+
* received in order.
|
203
|
+
*
|
204
|
+
* NGTCP2_ERR_NOMEM
|
205
|
+
* Out of memory
|
206
|
+
*/
|
207
|
+
int ngtcp2_strm_update_rx_offset(ngtcp2_strm *strm, uint64_t offset);
|
208
|
+
|
209
|
+
/*
|
210
|
+
* ngtcp2_strm_shutdown shutdowns |strm|. |flags| should be
|
211
|
+
* NGTCP2_STRM_FLAG_SHUT_RD, and/or NGTCP2_STRM_FLAG_SHUT_WR.
|
212
|
+
*/
|
213
|
+
void ngtcp2_strm_shutdown(ngtcp2_strm *strm, uint32_t flags);
|
214
|
+
|
215
|
+
/*
|
216
|
+
* ngtcp2_strm_streamfrq_push pushes |frc| to streamfrq for
|
217
|
+
* retransmission.
|
218
|
+
*
|
219
|
+
* This function returns 0 if it succeeds, or one of the following
|
220
|
+
* negative error codes:
|
221
|
+
*
|
222
|
+
* NGTCP2_ERR_NOMEM
|
223
|
+
* Out of memory
|
224
|
+
*/
|
225
|
+
int ngtcp2_strm_streamfrq_push(ngtcp2_strm *strm, ngtcp2_frame_chain *frc);
|
226
|
+
|
227
|
+
/*
|
228
|
+
* ngtcp2_strm_streamfrq_pop pops the first ngtcp2_frame_chain and
|
229
|
+
* assigns it to |*pfrc|. This function splits into or merges several
|
230
|
+
* ngtcp2_frame_chain objects so that the returned ngtcp2_frame_chain
|
231
|
+
* has at most |left| data length. If there is no frames to send,
|
232
|
+
* this function returns 0 and |*pfrc| is NULL.
|
233
|
+
*
|
234
|
+
* This function returns 0 if it succeeds, or one of the following
|
235
|
+
* negative error codes:
|
236
|
+
*
|
237
|
+
* NGTCP2_ERR_NOMEM
|
238
|
+
* Out of memory
|
239
|
+
*/
|
240
|
+
int ngtcp2_strm_streamfrq_pop(ngtcp2_strm *strm, ngtcp2_frame_chain **pfrc,
|
241
|
+
size_t left);
|
242
|
+
|
243
|
+
/*
|
244
|
+
* ngtcp2_strm_streamfrq_unacked_offset returns the smallest offset of
|
245
|
+
* unacknowledged stream data held in strm->tx.streamfrq.
|
246
|
+
*/
|
247
|
+
uint64_t ngtcp2_strm_streamfrq_unacked_offset(ngtcp2_strm *strm);
|
248
|
+
|
249
|
+
/*
|
250
|
+
* ngtcp2_strm_streamfrq_top returns the first ngtcp2_frame_chain.
|
251
|
+
* The queue must not be empty.
|
252
|
+
*/
|
253
|
+
ngtcp2_frame_chain *ngtcp2_strm_streamfrq_top(ngtcp2_strm *strm);
|
254
|
+
|
255
|
+
/*
|
256
|
+
* ngtcp2_strm_streamfrq_empty returns nonzero if streamfrq is empty.
|
257
|
+
*/
|
258
|
+
int ngtcp2_strm_streamfrq_empty(ngtcp2_strm *strm);
|
259
|
+
|
260
|
+
/*
|
261
|
+
* ngtcp2_strm_streamfrq_clear removes all frames from streamfrq.
|
262
|
+
*/
|
263
|
+
void ngtcp2_strm_streamfrq_clear(ngtcp2_strm *strm);
|
264
|
+
|
265
|
+
/*
|
266
|
+
* ngtcp2_strm_is_tx_queued returns nonzero if |strm| is queued.
|
267
|
+
*/
|
268
|
+
int ngtcp2_strm_is_tx_queued(ngtcp2_strm *strm);
|
269
|
+
|
270
|
+
/*
|
271
|
+
* ngtcp2_strm_is_all_tx_data_acked returns nonzero if all outgoing
|
272
|
+
* data for |strm| which have sent so far have been acknowledged.
|
273
|
+
*/
|
274
|
+
int ngtcp2_strm_is_all_tx_data_acked(ngtcp2_strm *strm);
|
275
|
+
|
276
|
+
/*
|
277
|
+
* ngtcp2_strm_is_all_tx_data_fin_acked behaves like
|
278
|
+
* ngtcp2_strm_is_all_tx_data_acked, but it also requires that STREAM
|
279
|
+
* frame with fin bit set is acknowledged.
|
280
|
+
*/
|
281
|
+
int ngtcp2_strm_is_all_tx_data_fin_acked(ngtcp2_strm *strm);
|
282
|
+
|
283
|
+
/*
|
284
|
+
* ngtcp2_strm_get_unacked_range_after returns the range that is not
|
285
|
+
* acknowledged yet and intersects or comes after |offset|.
|
286
|
+
*/
|
287
|
+
ngtcp2_range ngtcp2_strm_get_unacked_range_after(ngtcp2_strm *strm,
|
288
|
+
uint64_t offset);
|
289
|
+
|
290
|
+
/*
|
291
|
+
* ngtcp2_strm_get_acked_offset returns offset, that is the data up to
|
292
|
+
* this offset have been acknowledged by a remote endpoint. It
|
293
|
+
* returns 0 if no data is acknowledged.
|
294
|
+
*/
|
295
|
+
uint64_t ngtcp2_strm_get_acked_offset(ngtcp2_strm *strm);
|
296
|
+
|
297
|
+
/*
|
298
|
+
* ngtcp2_strm_ack_data tells |strm| that the data [offset,
|
299
|
+
* offset+len) is acknowledged by a remote endpoint.
|
300
|
+
*/
|
301
|
+
int ngtcp2_strm_ack_data(ngtcp2_strm *strm, uint64_t offset, uint64_t len);
|
302
|
+
|
303
|
+
/*
|
304
|
+
* ngtcp2_strm_set_app_error_code sets |app_error_code| to |strm| and
|
305
|
+
* set NGTCP2_STRM_FLAG_APP_ERROR_CODE_SET flag. If the flag is
|
306
|
+
* already set, this function does nothing.
|
307
|
+
*/
|
308
|
+
void ngtcp2_strm_set_app_error_code(ngtcp2_strm *strm, uint64_t app_error_code);
|
309
|
+
|
310
|
+
#endif /* NGTCP2_STRM_H */
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2022 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_unreachable.h"
|
26
|
+
|
27
|
+
#include <stdio.h>
|
28
|
+
#include <errno.h>
|
29
|
+
#ifdef HAVE_UNISTD_H
|
30
|
+
# include <unistd.h>
|
31
|
+
#endif /* HAVE_UNISTD_H */
|
32
|
+
#include <stdlib.h>
|
33
|
+
#ifdef WIN32
|
34
|
+
# include <io.h>
|
35
|
+
#endif /* WIN32 */
|
36
|
+
|
37
|
+
void ngtcp2_unreachable_fail(const char *file, int line, const char *func) {
|
38
|
+
char *buf;
|
39
|
+
size_t buflen;
|
40
|
+
int rv;
|
41
|
+
|
42
|
+
#define NGTCP2_UNREACHABLE_TEMPLATE "%s:%d %s: Unreachable.\n"
|
43
|
+
|
44
|
+
rv = snprintf(NULL, 0, NGTCP2_UNREACHABLE_TEMPLATE, file, line, func);
|
45
|
+
if (rv < 0) {
|
46
|
+
abort();
|
47
|
+
}
|
48
|
+
|
49
|
+
/* here we explicitly use system malloc */
|
50
|
+
buflen = (size_t)rv + 1;
|
51
|
+
buf = malloc(buflen);
|
52
|
+
if (buf == NULL) {
|
53
|
+
abort();
|
54
|
+
}
|
55
|
+
|
56
|
+
rv = snprintf(buf, buflen, NGTCP2_UNREACHABLE_TEMPLATE, file, line, func);
|
57
|
+
if (rv < 0) {
|
58
|
+
abort();
|
59
|
+
}
|
60
|
+
|
61
|
+
#ifndef WIN32
|
62
|
+
while (write(STDERR_FILENO, buf, (size_t)rv) == -1 && errno == EINTR)
|
63
|
+
;
|
64
|
+
#else /* WIN32 */
|
65
|
+
_write(_fileno(stderr), buf, (unsigned int)rv);
|
66
|
+
#endif /* WIN32 */
|
67
|
+
|
68
|
+
free(buf);
|
69
|
+
|
70
|
+
abort();
|
71
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2022 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_UNREACHABLE_H
|
26
|
+
#define NGTCP2_UNREACHABLE_H
|
27
|
+
|
28
|
+
#ifdef HAVE_CONFIG_H
|
29
|
+
# include <config.h>
|
30
|
+
#endif /* HAVE_CONFIG_H */
|
31
|
+
|
32
|
+
#include <ngtcp2/ngtcp2.h>
|
33
|
+
|
34
|
+
#define ngtcp2_unreachable() \
|
35
|
+
ngtcp2_unreachable_fail(__FILE__, __LINE__, __func__)
|
36
|
+
|
37
|
+
#ifdef _MSC_VER
|
38
|
+
__declspec(noreturn)
|
39
|
+
#endif /* _MSC_VER */
|
40
|
+
void ngtcp2_unreachable_fail(const char *file, int line, const char *func)
|
41
|
+
#ifndef _MSC_VER
|
42
|
+
__attribute__((noreturn))
|
43
|
+
#endif /* !_MSC_VER */
|
44
|
+
;
|
45
|
+
|
46
|
+
#endif /* NGTCP2_UNREACHABLE_H */
|
@@ -0,0 +1,243 @@
|
|
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
|
+
#include "ngtcp2_vec.h"
|
26
|
+
|
27
|
+
#include <string.h>
|
28
|
+
#include <assert.h>
|
29
|
+
|
30
|
+
#include "ngtcp2_str.h"
|
31
|
+
|
32
|
+
ngtcp2_vec *ngtcp2_vec_init(ngtcp2_vec *vec, const uint8_t *base, size_t len) {
|
33
|
+
vec->base = (uint8_t *)base;
|
34
|
+
vec->len = len;
|
35
|
+
return vec;
|
36
|
+
}
|
37
|
+
|
38
|
+
int ngtcp2_vec_new(ngtcp2_vec **pvec, const uint8_t *data, size_t datalen,
|
39
|
+
const ngtcp2_mem *mem) {
|
40
|
+
size_t len;
|
41
|
+
uint8_t *p;
|
42
|
+
|
43
|
+
len = sizeof(ngtcp2_vec) + datalen;
|
44
|
+
|
45
|
+
*pvec = ngtcp2_mem_malloc(mem, len);
|
46
|
+
if (*pvec == NULL) {
|
47
|
+
return NGTCP2_ERR_NOMEM;
|
48
|
+
}
|
49
|
+
|
50
|
+
p = (uint8_t *)(*pvec) + sizeof(ngtcp2_vec);
|
51
|
+
(*pvec)->base = p;
|
52
|
+
(*pvec)->len = datalen;
|
53
|
+
if (datalen) {
|
54
|
+
/* p = */ ngtcp2_cpymem(p, data, datalen);
|
55
|
+
}
|
56
|
+
|
57
|
+
return 0;
|
58
|
+
}
|
59
|
+
|
60
|
+
void ngtcp2_vec_del(ngtcp2_vec *vec, const ngtcp2_mem *mem) {
|
61
|
+
ngtcp2_mem_free(mem, vec);
|
62
|
+
}
|
63
|
+
|
64
|
+
uint64_t ngtcp2_vec_len(const ngtcp2_vec *vec, size_t n) {
|
65
|
+
size_t i;
|
66
|
+
size_t res = 0;
|
67
|
+
|
68
|
+
for (i = 0; i < n; ++i) {
|
69
|
+
res += vec[i].len;
|
70
|
+
}
|
71
|
+
|
72
|
+
return res;
|
73
|
+
}
|
74
|
+
|
75
|
+
int64_t ngtcp2_vec_len_varint(const ngtcp2_vec *vec, size_t n) {
|
76
|
+
uint64_t res = 0;
|
77
|
+
size_t len;
|
78
|
+
size_t i;
|
79
|
+
|
80
|
+
for (i = 0; i < n; ++i) {
|
81
|
+
len = vec[i].len;
|
82
|
+
if (len > NGTCP2_MAX_VARINT - res) {
|
83
|
+
return -1;
|
84
|
+
}
|
85
|
+
|
86
|
+
res += len;
|
87
|
+
}
|
88
|
+
|
89
|
+
return (int64_t)res;
|
90
|
+
}
|
91
|
+
|
92
|
+
ngtcp2_ssize ngtcp2_vec_split(ngtcp2_vec *src, size_t *psrccnt, ngtcp2_vec *dst,
|
93
|
+
size_t *pdstcnt, size_t left, size_t maxcnt) {
|
94
|
+
size_t i;
|
95
|
+
size_t srccnt = *psrccnt;
|
96
|
+
size_t nmove;
|
97
|
+
size_t extra = 0;
|
98
|
+
|
99
|
+
for (i = 0; i < srccnt; ++i) {
|
100
|
+
if (left >= src[i].len) {
|
101
|
+
left -= src[i].len;
|
102
|
+
continue;
|
103
|
+
}
|
104
|
+
|
105
|
+
if (*pdstcnt && src[srccnt - 1].base + src[srccnt - 1].len == dst[0].base) {
|
106
|
+
if (*pdstcnt + srccnt - i - 1 > maxcnt) {
|
107
|
+
return -1;
|
108
|
+
}
|
109
|
+
|
110
|
+
dst[0].len += src[srccnt - 1].len;
|
111
|
+
dst[0].base = src[srccnt - 1].base;
|
112
|
+
extra = src[srccnt - 1].len;
|
113
|
+
--srccnt;
|
114
|
+
} else if (*pdstcnt + srccnt - i > maxcnt) {
|
115
|
+
return -1;
|
116
|
+
}
|
117
|
+
|
118
|
+
if (left == 0) {
|
119
|
+
*psrccnt = i;
|
120
|
+
} else {
|
121
|
+
*psrccnt = i + 1;
|
122
|
+
}
|
123
|
+
|
124
|
+
nmove = srccnt - i;
|
125
|
+
if (nmove) {
|
126
|
+
memmove(dst + nmove, dst, sizeof(ngtcp2_vec) * (*pdstcnt));
|
127
|
+
*pdstcnt += nmove;
|
128
|
+
memcpy(dst, src + i, sizeof(ngtcp2_vec) * nmove);
|
129
|
+
}
|
130
|
+
|
131
|
+
dst[0].len -= left;
|
132
|
+
dst[0].base += left;
|
133
|
+
src[i].len = left;
|
134
|
+
|
135
|
+
if (nmove == 0) {
|
136
|
+
extra -= left;
|
137
|
+
}
|
138
|
+
|
139
|
+
return (ngtcp2_ssize)(ngtcp2_vec_len(dst, nmove) + extra);
|
140
|
+
}
|
141
|
+
|
142
|
+
return 0;
|
143
|
+
}
|
144
|
+
|
145
|
+
size_t ngtcp2_vec_merge(ngtcp2_vec *dst, size_t *pdstcnt, ngtcp2_vec *src,
|
146
|
+
size_t *psrccnt, size_t left, size_t maxcnt) {
|
147
|
+
size_t orig_left = left;
|
148
|
+
size_t i;
|
149
|
+
ngtcp2_vec *a, *b;
|
150
|
+
|
151
|
+
assert(maxcnt);
|
152
|
+
|
153
|
+
if (*pdstcnt == 0) {
|
154
|
+
if (*psrccnt == 0) {
|
155
|
+
return 0;
|
156
|
+
}
|
157
|
+
|
158
|
+
a = &dst[0];
|
159
|
+
b = &src[0];
|
160
|
+
|
161
|
+
if (left >= b->len) {
|
162
|
+
*a = *b;
|
163
|
+
++*pdstcnt;
|
164
|
+
left -= b->len;
|
165
|
+
i = 1;
|
166
|
+
} else {
|
167
|
+
a->len = left;
|
168
|
+
a->base = b->base;
|
169
|
+
|
170
|
+
b->len -= left;
|
171
|
+
b->base += left;
|
172
|
+
|
173
|
+
return left;
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
i = 0;
|
177
|
+
}
|
178
|
+
|
179
|
+
for (; left && i < *psrccnt; ++i) {
|
180
|
+
a = &dst[*pdstcnt - 1];
|
181
|
+
b = &src[i];
|
182
|
+
|
183
|
+
if (left >= b->len) {
|
184
|
+
if (a->base + a->len == b->base) {
|
185
|
+
a->len += b->len;
|
186
|
+
} else if (*pdstcnt == maxcnt) {
|
187
|
+
break;
|
188
|
+
} else {
|
189
|
+
dst[(*pdstcnt)++] = *b;
|
190
|
+
}
|
191
|
+
left -= b->len;
|
192
|
+
continue;
|
193
|
+
}
|
194
|
+
|
195
|
+
if (a->base + a->len == b->base) {
|
196
|
+
a->len += left;
|
197
|
+
} else if (*pdstcnt == maxcnt) {
|
198
|
+
break;
|
199
|
+
} else {
|
200
|
+
dst[*pdstcnt].len = left;
|
201
|
+
dst[*pdstcnt].base = b->base;
|
202
|
+
++*pdstcnt;
|
203
|
+
}
|
204
|
+
|
205
|
+
b->len -= left;
|
206
|
+
b->base += left;
|
207
|
+
left = 0;
|
208
|
+
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
|
212
|
+
memmove(src, src + i, sizeof(ngtcp2_vec) * (*psrccnt - i));
|
213
|
+
*psrccnt -= i;
|
214
|
+
|
215
|
+
return orig_left - left;
|
216
|
+
}
|
217
|
+
|
218
|
+
size_t ngtcp2_vec_copy_at_most(ngtcp2_vec *dst, size_t dstcnt,
|
219
|
+
const ngtcp2_vec *src, size_t srccnt,
|
220
|
+
size_t left) {
|
221
|
+
size_t i, j;
|
222
|
+
|
223
|
+
for (i = 0, j = 0; left > 0 && i < srccnt && j < dstcnt;) {
|
224
|
+
if (src[i].len == 0) {
|
225
|
+
++i;
|
226
|
+
continue;
|
227
|
+
}
|
228
|
+
dst[j] = src[i];
|
229
|
+
if (dst[j].len > left) {
|
230
|
+
dst[j].len = left;
|
231
|
+
return j + 1;
|
232
|
+
}
|
233
|
+
left -= dst[j].len;
|
234
|
+
++i;
|
235
|
+
++j;
|
236
|
+
}
|
237
|
+
|
238
|
+
return j;
|
239
|
+
}
|
240
|
+
|
241
|
+
void ngtcp2_vec_copy(ngtcp2_vec *dst, const ngtcp2_vec *src, size_t cnt) {
|
242
|
+
memcpy(dst, src, sizeof(ngtcp2_vec) * cnt);
|
243
|
+
}
|