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,404 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2017 ngtcp2 contributors
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
#include "ngtcp2_test_helper.h"
|
26
|
+
|
27
|
+
#include <string.h>
|
28
|
+
#include <assert.h>
|
29
|
+
|
30
|
+
#include "ngtcp2_conv.h"
|
31
|
+
#include "ngtcp2_pkt.h"
|
32
|
+
#include "ngtcp2_ppe.h"
|
33
|
+
#include "ngtcp2_vec.h"
|
34
|
+
#include "ngtcp2_net.h"
|
35
|
+
|
36
|
+
size_t ngtcp2_t_encode_stream_frame(uint8_t *out, uint8_t flags,
|
37
|
+
uint64_t stream_id, uint64_t offset,
|
38
|
+
uint16_t datalen) {
|
39
|
+
uint8_t *p = out;
|
40
|
+
|
41
|
+
if (offset) {
|
42
|
+
flags |= NGTCP2_STREAM_OFF_BIT;
|
43
|
+
}
|
44
|
+
*p++ = NGTCP2_FRAME_STREAM | flags;
|
45
|
+
|
46
|
+
p = ngtcp2_put_uvarint(p, stream_id);
|
47
|
+
|
48
|
+
if (offset) {
|
49
|
+
p = ngtcp2_put_uvarint(p, offset);
|
50
|
+
}
|
51
|
+
|
52
|
+
if (flags & NGTCP2_STREAM_LEN_BIT) {
|
53
|
+
p = ngtcp2_put_uvarint(p, datalen);
|
54
|
+
}
|
55
|
+
|
56
|
+
memset(p, 0, datalen);
|
57
|
+
p += datalen;
|
58
|
+
|
59
|
+
return (size_t)(p - out);
|
60
|
+
}
|
61
|
+
|
62
|
+
size_t ngtcp2_t_encode_ack_frame(uint8_t *out, uint64_t largest_ack,
|
63
|
+
uint64_t first_ack_blklen, uint64_t gap,
|
64
|
+
uint64_t ack_blklen) {
|
65
|
+
uint8_t *p = out;
|
66
|
+
|
67
|
+
p = out;
|
68
|
+
|
69
|
+
*p++ = NGTCP2_FRAME_ACK;
|
70
|
+
/* Largest Acknowledged */
|
71
|
+
p = ngtcp2_put_uvarint(p, largest_ack);
|
72
|
+
/* ACK Delay */
|
73
|
+
p = ngtcp2_put_uvarint(p, 0);
|
74
|
+
/* ACK Block Count */
|
75
|
+
p = ngtcp2_put_uvarint(p, 1);
|
76
|
+
/* First ACK Block */
|
77
|
+
p = ngtcp2_put_uvarint(p, first_ack_blklen);
|
78
|
+
/* Gap (1) */
|
79
|
+
p = ngtcp2_put_uvarint(p, gap);
|
80
|
+
/* Additional ACK Block (1) */
|
81
|
+
p = ngtcp2_put_uvarint(p, ack_blklen);
|
82
|
+
|
83
|
+
return (size_t)(p - out);
|
84
|
+
}
|
85
|
+
|
86
|
+
static int null_encrypt(uint8_t *dest, const ngtcp2_crypto_aead *aead,
|
87
|
+
const ngtcp2_crypto_aead_ctx *aead_ctx,
|
88
|
+
const uint8_t *plaintext, size_t plaintextlen,
|
89
|
+
const uint8_t *nonce, size_t noncelen,
|
90
|
+
const uint8_t *aad, size_t aadlen) {
|
91
|
+
(void)dest;
|
92
|
+
(void)aead;
|
93
|
+
(void)aead_ctx;
|
94
|
+
(void)plaintext;
|
95
|
+
(void)plaintextlen;
|
96
|
+
(void)nonce;
|
97
|
+
(void)noncelen;
|
98
|
+
(void)aad;
|
99
|
+
(void)aadlen;
|
100
|
+
memset(dest + plaintextlen, 0, NGTCP2_FAKE_AEAD_OVERHEAD);
|
101
|
+
return 0;
|
102
|
+
}
|
103
|
+
|
104
|
+
static int null_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
|
105
|
+
const ngtcp2_crypto_cipher_ctx *hp_ctx,
|
106
|
+
const uint8_t *sample) {
|
107
|
+
(void)hp;
|
108
|
+
(void)hp_ctx;
|
109
|
+
(void)sample;
|
110
|
+
memcpy(dest, NGTCP2_FAKE_HP_MASK, sizeof(NGTCP2_FAKE_HP_MASK) - 1);
|
111
|
+
return 0;
|
112
|
+
}
|
113
|
+
|
114
|
+
size_t write_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
115
|
+
int64_t pkt_num, ngtcp2_frame *fr, size_t frlen,
|
116
|
+
ngtcp2_crypto_km *ckm) {
|
117
|
+
return write_pkt_flags(out, outlen, NGTCP2_PKT_FLAG_NONE, dcid, pkt_num, fr,
|
118
|
+
frlen, ckm);
|
119
|
+
}
|
120
|
+
|
121
|
+
size_t write_pkt_flags(uint8_t *out, size_t outlen, uint8_t flags,
|
122
|
+
const ngtcp2_cid *dcid, int64_t pkt_num,
|
123
|
+
ngtcp2_frame *fr, size_t frlen, ngtcp2_crypto_km *ckm) {
|
124
|
+
ngtcp2_crypto_cc cc;
|
125
|
+
ngtcp2_ppe ppe;
|
126
|
+
ngtcp2_pkt_hd hd;
|
127
|
+
int rv;
|
128
|
+
ngtcp2_ssize n;
|
129
|
+
size_t i;
|
130
|
+
|
131
|
+
memset(&cc, 0, sizeof(cc));
|
132
|
+
cc.encrypt = null_encrypt;
|
133
|
+
cc.hp_mask = null_hp_mask;
|
134
|
+
cc.ckm = ckm;
|
135
|
+
cc.aead.max_overhead = NGTCP2_FAKE_AEAD_OVERHEAD;
|
136
|
+
|
137
|
+
ngtcp2_pkt_hd_init(&hd, flags, NGTCP2_PKT_1RTT, dcid, NULL, pkt_num, 4,
|
138
|
+
NGTCP2_PROTO_VER_V1, 0);
|
139
|
+
|
140
|
+
ngtcp2_ppe_init(&ppe, out, outlen, &cc);
|
141
|
+
rv = ngtcp2_ppe_encode_hd(&ppe, &hd);
|
142
|
+
assert(0 == rv);
|
143
|
+
|
144
|
+
for (i = 0; i < frlen; ++i, ++fr) {
|
145
|
+
rv = ngtcp2_ppe_encode_frame(&ppe, fr);
|
146
|
+
assert(0 == rv);
|
147
|
+
}
|
148
|
+
|
149
|
+
n = ngtcp2_ppe_final(&ppe, NULL);
|
150
|
+
assert(n > 0);
|
151
|
+
|
152
|
+
return (size_t)n;
|
153
|
+
}
|
154
|
+
|
155
|
+
static size_t write_long_header_pkt_generic(
|
156
|
+
uint8_t *out, size_t outlen, uint8_t pkt_type, const ngtcp2_cid *dcid,
|
157
|
+
const ngtcp2_cid *scid, int64_t pkt_num, uint32_t version,
|
158
|
+
const uint8_t *token, size_t tokenlen, ngtcp2_frame *fr, size_t frlen,
|
159
|
+
ngtcp2_crypto_km *ckm) {
|
160
|
+
ngtcp2_crypto_cc cc;
|
161
|
+
ngtcp2_ppe ppe;
|
162
|
+
ngtcp2_pkt_hd hd;
|
163
|
+
int rv;
|
164
|
+
ngtcp2_ssize n;
|
165
|
+
size_t i;
|
166
|
+
|
167
|
+
memset(&cc, 0, sizeof(cc));
|
168
|
+
cc.encrypt = null_encrypt;
|
169
|
+
cc.hp_mask = null_hp_mask;
|
170
|
+
cc.ckm = ckm;
|
171
|
+
switch (pkt_type) {
|
172
|
+
case NGTCP2_PKT_INITIAL:
|
173
|
+
cc.aead.max_overhead = NGTCP2_INITIAL_AEAD_OVERHEAD;
|
174
|
+
break;
|
175
|
+
case NGTCP2_PKT_HANDSHAKE:
|
176
|
+
case NGTCP2_PKT_0RTT:
|
177
|
+
cc.aead.max_overhead = NGTCP2_FAKE_AEAD_OVERHEAD;
|
178
|
+
break;
|
179
|
+
default:
|
180
|
+
assert(0);
|
181
|
+
}
|
182
|
+
|
183
|
+
/* ngtcp2_pkt_encode_hd_long requires known QUIC version. If we
|
184
|
+
need to write unsupported version for testing purpose, just
|
185
|
+
pretend that it is QUIC v1 here and rewrite the version field
|
186
|
+
later. */
|
187
|
+
ngtcp2_pkt_hd_init(
|
188
|
+
&hd, NGTCP2_PKT_FLAG_LONG_FORM, pkt_type, dcid, scid, pkt_num, 4,
|
189
|
+
version != NGTCP2_PROTO_VER_V1 && version != NGTCP2_PROTO_VER_V2
|
190
|
+
? NGTCP2_PROTO_VER_V1
|
191
|
+
: version,
|
192
|
+
0);
|
193
|
+
|
194
|
+
hd.token = token;
|
195
|
+
hd.tokenlen = tokenlen;
|
196
|
+
|
197
|
+
ngtcp2_ppe_init(&ppe, out, outlen, &cc);
|
198
|
+
rv = ngtcp2_ppe_encode_hd(&ppe, &hd);
|
199
|
+
assert(0 == rv);
|
200
|
+
ngtcp2_put_uint32be(&out[1], version);
|
201
|
+
|
202
|
+
for (i = 0; i < frlen; ++i, ++fr) {
|
203
|
+
rv = ngtcp2_ppe_encode_frame(&ppe, fr);
|
204
|
+
assert(0 == rv);
|
205
|
+
}
|
206
|
+
|
207
|
+
n = ngtcp2_ppe_final(&ppe, NULL);
|
208
|
+
assert(n > 0);
|
209
|
+
return (size_t)n;
|
210
|
+
}
|
211
|
+
|
212
|
+
size_t write_initial_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
213
|
+
const ngtcp2_cid *scid, int64_t pkt_num,
|
214
|
+
uint32_t version, const uint8_t *token,
|
215
|
+
size_t tokenlen, ngtcp2_frame *fr, size_t frlen,
|
216
|
+
ngtcp2_crypto_km *ckm) {
|
217
|
+
return write_long_header_pkt_generic(out, outlen, NGTCP2_PKT_INITIAL, dcid,
|
218
|
+
scid, pkt_num, version, token, tokenlen,
|
219
|
+
fr, frlen, ckm);
|
220
|
+
}
|
221
|
+
|
222
|
+
size_t write_handshake_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
223
|
+
const ngtcp2_cid *scid, int64_t pkt_num,
|
224
|
+
uint32_t version, ngtcp2_frame *fr, size_t frlen,
|
225
|
+
ngtcp2_crypto_km *ckm) {
|
226
|
+
return write_long_header_pkt_generic(out, outlen, NGTCP2_PKT_HANDSHAKE, dcid,
|
227
|
+
scid, pkt_num, version, NULL, 0, fr,
|
228
|
+
frlen, ckm);
|
229
|
+
}
|
230
|
+
|
231
|
+
size_t write_0rtt_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
232
|
+
const ngtcp2_cid *scid, int64_t pkt_num, uint32_t version,
|
233
|
+
ngtcp2_frame *fr, size_t frlen, ngtcp2_crypto_km *ckm) {
|
234
|
+
return write_long_header_pkt_generic(out, outlen, NGTCP2_PKT_0RTT, dcid, scid,
|
235
|
+
pkt_num, version, NULL, 0, fr, frlen,
|
236
|
+
ckm);
|
237
|
+
}
|
238
|
+
|
239
|
+
ngtcp2_strm *open_stream(ngtcp2_conn *conn, int64_t stream_id) {
|
240
|
+
ngtcp2_strm *strm;
|
241
|
+
int rv;
|
242
|
+
(void)rv;
|
243
|
+
|
244
|
+
strm = ngtcp2_objalloc_strm_get(&conn->strm_objalloc);
|
245
|
+
assert(strm);
|
246
|
+
|
247
|
+
rv = ngtcp2_conn_init_stream(conn, strm, stream_id, NULL);
|
248
|
+
assert(0 == rv);
|
249
|
+
|
250
|
+
return strm;
|
251
|
+
}
|
252
|
+
|
253
|
+
size_t rtb_entry_length(const ngtcp2_rtb_entry *ent) {
|
254
|
+
size_t len = 0;
|
255
|
+
|
256
|
+
for (; ent; ent = ent->next) {
|
257
|
+
++len;
|
258
|
+
}
|
259
|
+
|
260
|
+
return len;
|
261
|
+
}
|
262
|
+
|
263
|
+
void dcid_init(ngtcp2_cid *cid) {
|
264
|
+
static const uint8_t id[] = "\xff\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
265
|
+
"\xaa\xaa\xaa\xaa\xaa\xff";
|
266
|
+
ngtcp2_cid_init(cid, id, sizeof(id) - 1);
|
267
|
+
}
|
268
|
+
|
269
|
+
void scid_init(ngtcp2_cid *cid) {
|
270
|
+
static const uint8_t id[] = "\xee\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
271
|
+
"\xaa\xaa\xaa\xaa\xaa\xee";
|
272
|
+
ngtcp2_cid_init(cid, id, sizeof(id) - 1);
|
273
|
+
}
|
274
|
+
|
275
|
+
void rcid_init(ngtcp2_cid *cid) {
|
276
|
+
static const uint8_t id[] = "\xdd\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
277
|
+
"\xaa\xaa\xaa\xaa\xaa\xdd";
|
278
|
+
ngtcp2_cid_init(cid, id, sizeof(id) - 1);
|
279
|
+
}
|
280
|
+
|
281
|
+
uint64_t read_pkt_payloadlen(const uint8_t *pkt, const ngtcp2_cid *dcid,
|
282
|
+
const ngtcp2_cid *scid) {
|
283
|
+
uint64_t len;
|
284
|
+
|
285
|
+
ngtcp2_get_uvarint(&len, &pkt[1 + 4 + 1 + dcid->datalen + 1 + scid->datalen]);
|
286
|
+
|
287
|
+
return len;
|
288
|
+
}
|
289
|
+
|
290
|
+
void write_pkt_payloadlen(uint8_t *pkt, const ngtcp2_cid *dcid,
|
291
|
+
const ngtcp2_cid *scid, uint64_t payloadlen) {
|
292
|
+
assert(payloadlen < 1073741824);
|
293
|
+
ngtcp2_put_uvarint30(&pkt[1 + 4 + 1 + dcid->datalen + 1 + scid->datalen],
|
294
|
+
(uint32_t)payloadlen);
|
295
|
+
}
|
296
|
+
|
297
|
+
ngtcp2_ssize pkt_decode_hd_long(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
298
|
+
size_t pktlen) {
|
299
|
+
const uint8_t *p;
|
300
|
+
ngtcp2_ssize nread;
|
301
|
+
|
302
|
+
nread = ngtcp2_pkt_decode_hd_long(dest, pkt, pktlen);
|
303
|
+
if (nread < 0 || (!(dest->flags & NGTCP2_PKT_FLAG_LONG_FORM) &&
|
304
|
+
dest->type == NGTCP2_PKT_VERSION_NEGOTIATION)) {
|
305
|
+
return nread;
|
306
|
+
}
|
307
|
+
|
308
|
+
if ((size_t)nread == pktlen) {
|
309
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
310
|
+
}
|
311
|
+
|
312
|
+
p = pkt + nread;
|
313
|
+
|
314
|
+
dest->pkt_numlen = (size_t)(pkt[0] & NGTCP2_PKT_NUMLEN_MASK) + 1;
|
315
|
+
if (pktlen < (size_t)nread + dest->pkt_numlen) {
|
316
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
317
|
+
}
|
318
|
+
|
319
|
+
dest->pkt_num = ngtcp2_get_pkt_num(p, dest->pkt_numlen);
|
320
|
+
|
321
|
+
return nread + (ngtcp2_ssize)dest->pkt_numlen;
|
322
|
+
}
|
323
|
+
|
324
|
+
ngtcp2_ssize pkt_decode_hd_short(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
325
|
+
size_t pktlen, size_t dcidlen) {
|
326
|
+
const uint8_t *p;
|
327
|
+
ngtcp2_ssize nread;
|
328
|
+
|
329
|
+
nread = ngtcp2_pkt_decode_hd_short(dest, pkt, pktlen, dcidlen);
|
330
|
+
if (nread < 0) {
|
331
|
+
return nread;
|
332
|
+
}
|
333
|
+
|
334
|
+
if ((size_t)nread == pktlen) {
|
335
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
336
|
+
}
|
337
|
+
|
338
|
+
p = pkt + nread;
|
339
|
+
|
340
|
+
dest->pkt_numlen = (size_t)(pkt[0] & NGTCP2_PKT_NUMLEN_MASK) + 1;
|
341
|
+
if (pktlen < (size_t)nread + dest->pkt_numlen) {
|
342
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
343
|
+
}
|
344
|
+
|
345
|
+
dest->pkt_num = ngtcp2_get_pkt_num(p, dest->pkt_numlen);
|
346
|
+
|
347
|
+
return nread + (ngtcp2_ssize)dest->pkt_numlen;
|
348
|
+
}
|
349
|
+
|
350
|
+
ngtcp2_ssize pkt_decode_hd_short_mask(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
351
|
+
size_t pktlen, size_t dcidlen) {
|
352
|
+
static const uint8_t mask[] = NGTCP2_FAKE_HP_MASK;
|
353
|
+
const uint8_t *p;
|
354
|
+
ngtcp2_ssize nread;
|
355
|
+
uint8_t hb;
|
356
|
+
uint8_t pkt_numbuf[4];
|
357
|
+
size_t i;
|
358
|
+
|
359
|
+
nread = ngtcp2_pkt_decode_hd_short(dest, pkt, pktlen, dcidlen);
|
360
|
+
if (nread < 0) {
|
361
|
+
return nread;
|
362
|
+
}
|
363
|
+
|
364
|
+
if ((size_t)nread == pktlen) {
|
365
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
366
|
+
}
|
367
|
+
|
368
|
+
p = pkt + nread;
|
369
|
+
|
370
|
+
hb = (uint8_t)(pkt[0] ^ (mask[0] & 0x1f));
|
371
|
+
|
372
|
+
dest->pkt_numlen = (size_t)(hb & NGTCP2_PKT_NUMLEN_MASK) + 1;
|
373
|
+
if (pktlen < (size_t)nread + dest->pkt_numlen) {
|
374
|
+
return NGTCP2_ERR_INVALID_ARGUMENT;
|
375
|
+
}
|
376
|
+
|
377
|
+
for (i = 0; i < dest->pkt_numlen; ++i) {
|
378
|
+
pkt_numbuf[i] = *(p + i) ^ mask[i + 1];
|
379
|
+
}
|
380
|
+
|
381
|
+
dest->pkt_num = ngtcp2_get_pkt_num(pkt_numbuf, dest->pkt_numlen);
|
382
|
+
|
383
|
+
return nread + (ngtcp2_ssize)dest->pkt_numlen;
|
384
|
+
}
|
385
|
+
|
386
|
+
static void addr_init(ngtcp2_sockaddr_in *dest, uint32_t addr, uint16_t port) {
|
387
|
+
memset(dest, 0, sizeof(*dest));
|
388
|
+
|
389
|
+
dest->sin_family = AF_INET;
|
390
|
+
dest->sin_port = ngtcp2_htons(port);
|
391
|
+
dest->sin_addr.s_addr = ngtcp2_htonl(addr);
|
392
|
+
}
|
393
|
+
|
394
|
+
void path_init(ngtcp2_path_storage *path, uint32_t local_addr,
|
395
|
+
uint16_t local_port, uint32_t remote_addr,
|
396
|
+
uint16_t remote_port) {
|
397
|
+
ngtcp2_sockaddr_in la, ra;
|
398
|
+
|
399
|
+
addr_init(&la, local_addr, local_port);
|
400
|
+
addr_init(&ra, remote_addr, remote_port);
|
401
|
+
|
402
|
+
ngtcp2_path_storage_init(path, (ngtcp2_sockaddr *)&la, sizeof(la),
|
403
|
+
(ngtcp2_sockaddr *)&ra, sizeof(ra), NULL);
|
404
|
+
}
|
@@ -0,0 +1,191 @@
|
|
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_TEST_HELPER_H
|
26
|
+
#define NGTCP2_TEST_HELPER_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_conn.h"
|
35
|
+
|
36
|
+
/*
|
37
|
+
* strsize macro returns the length of string literal |S|.
|
38
|
+
*/
|
39
|
+
#define strsize(S) (sizeof(S) - 1)
|
40
|
+
|
41
|
+
/*
|
42
|
+
* NGTCP2_APP_ERRxx is an application error code solely used in test
|
43
|
+
* code.
|
44
|
+
*/
|
45
|
+
#define NGTCP2_APP_ERR01 0xff01u
|
46
|
+
#define NGTCP2_APP_ERR02 0xff02u
|
47
|
+
|
48
|
+
/*
|
49
|
+
* NGTCP2_FAKE_AEAD_OVERHEAD is AEAD overhead used in unit tests.
|
50
|
+
* Because we use the same encryption/decryption function for both
|
51
|
+
* handshake and post handshake packets, we have to use AEAD overhead
|
52
|
+
* used in handshake packets.
|
53
|
+
*/
|
54
|
+
#define NGTCP2_FAKE_AEAD_OVERHEAD NGTCP2_INITIAL_AEAD_OVERHEAD
|
55
|
+
|
56
|
+
/* NGTCP2_FAKE_HP_MASK is a header protection mask used in unit
|
57
|
+
tests. */
|
58
|
+
#define NGTCP2_FAKE_HP_MASK "\x00\x00\x00\x00\x00"
|
59
|
+
|
60
|
+
/*
|
61
|
+
* ngtcp2_t_encode_stream_frame encodes STREAM frame into |out| with
|
62
|
+
* the given parameters. If NGTCP2_STREAM_LEN_BIT is set in |flags|,
|
63
|
+
* |datalen| is encoded as Data Length, otherwise it is not written.
|
64
|
+
* To set FIN bit in wire format, set NGTCP2_STREAM_FIN_BIT in
|
65
|
+
* |flags|. This function expects that |out| has enough length to
|
66
|
+
* store entire STREAM frame, excluding the Stream Data.
|
67
|
+
*
|
68
|
+
* This function returns the number of bytes written to |out|.
|
69
|
+
*/
|
70
|
+
size_t ngtcp2_t_encode_stream_frame(uint8_t *out, uint8_t flags,
|
71
|
+
uint64_t stream_id, uint64_t offset,
|
72
|
+
uint16_t datalen);
|
73
|
+
|
74
|
+
/*
|
75
|
+
* ngtcp2_t_encode_ack_frame encodes ACK frame into |out| with the
|
76
|
+
* given parameters. Currently, this function encodes 1 ACK Block
|
77
|
+
* Section. ACK Delay field is always 0.
|
78
|
+
*
|
79
|
+
* This function returns the number of bytes written to |out|.
|
80
|
+
*/
|
81
|
+
size_t ngtcp2_t_encode_ack_frame(uint8_t *out, uint64_t largest_ack,
|
82
|
+
uint64_t first_ack_blklen, uint64_t gap,
|
83
|
+
uint64_t ack_blklen);
|
84
|
+
|
85
|
+
/*
|
86
|
+
* write_pkt_flags writes a QUIC packet containing frames pointed by
|
87
|
+
* |fr| of length |frlen| in |out| whose capacity is |outlen|. This
|
88
|
+
* function returns the number of bytes written.
|
89
|
+
*/
|
90
|
+
size_t write_pkt_flags(uint8_t *out, size_t outlen, uint8_t flags,
|
91
|
+
const ngtcp2_cid *dcid, int64_t pkt_num,
|
92
|
+
ngtcp2_frame *fr, size_t frlen, ngtcp2_crypto_km *ckm);
|
93
|
+
|
94
|
+
/*
|
95
|
+
* write_pkt is write_pkt_flags with flag = NGTCP2_PKT_FLAG_NONE.
|
96
|
+
*/
|
97
|
+
size_t write_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
98
|
+
int64_t pkt_num, ngtcp2_frame *fr, size_t frlen,
|
99
|
+
ngtcp2_crypto_km *ckm);
|
100
|
+
|
101
|
+
/*
|
102
|
+
* write_handshake_pkt writes a QUIC Initial packet containing |frlen|
|
103
|
+
* frames pointed by |fr| into |out| whose capacity is |outlen|. This
|
104
|
+
* function returns the number of bytes written.
|
105
|
+
*/
|
106
|
+
size_t write_initial_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
107
|
+
const ngtcp2_cid *scid, int64_t pkt_num,
|
108
|
+
uint32_t version, const uint8_t *token,
|
109
|
+
size_t tokenlen, ngtcp2_frame *fr, size_t frlen,
|
110
|
+
ngtcp2_crypto_km *ckm);
|
111
|
+
|
112
|
+
/*
|
113
|
+
* write_handshake_pkt writes a QUIC Handshake packet containing
|
114
|
+
* |frlen| frames pointed by |fr| into |out| whose capacity is
|
115
|
+
* |outlen|. This function returns the number of bytes written.
|
116
|
+
*/
|
117
|
+
size_t write_handshake_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
118
|
+
const ngtcp2_cid *scid, int64_t pkt_num,
|
119
|
+
uint32_t version, ngtcp2_frame *fr, size_t frlen,
|
120
|
+
ngtcp2_crypto_km *ckm);
|
121
|
+
|
122
|
+
/*
|
123
|
+
* write_0rtt_pkt writes a QUIC 0RTT packet containing |frlen| frames
|
124
|
+
* pointed by |fr| into |out| whose capacity is |outlen|. This
|
125
|
+
* function returns the number of bytes written.
|
126
|
+
*/
|
127
|
+
size_t write_0rtt_pkt(uint8_t *out, size_t outlen, const ngtcp2_cid *dcid,
|
128
|
+
const ngtcp2_cid *scid, int64_t pkt_num, uint32_t version,
|
129
|
+
ngtcp2_frame *fr, size_t frlen, ngtcp2_crypto_km *ckm);
|
130
|
+
|
131
|
+
/*
|
132
|
+
* open_stream opens new stream denoted by |stream_id|.
|
133
|
+
*/
|
134
|
+
ngtcp2_strm *open_stream(ngtcp2_conn *conn, int64_t stream_id);
|
135
|
+
|
136
|
+
/*
|
137
|
+
* rtb_entry_length returns the length of elements pointed by |ent|
|
138
|
+
* list.
|
139
|
+
*/
|
140
|
+
size_t rtb_entry_length(const ngtcp2_rtb_entry *ent);
|
141
|
+
|
142
|
+
void scid_init(ngtcp2_cid *cid);
|
143
|
+
void dcid_init(ngtcp2_cid *cid);
|
144
|
+
void rcid_init(ngtcp2_cid *cid);
|
145
|
+
|
146
|
+
/*
|
147
|
+
* read_pkt_payloadlen reads long header payload length field from
|
148
|
+
* |pkt|.
|
149
|
+
*/
|
150
|
+
uint64_t read_pkt_payloadlen(const uint8_t *pkt, const ngtcp2_cid *dcid,
|
151
|
+
const ngtcp2_cid *scid);
|
152
|
+
|
153
|
+
/*
|
154
|
+
* write_pkt_payloadlen writes long header payload length field into
|
155
|
+
* |pkt|.
|
156
|
+
*/
|
157
|
+
void write_pkt_payloadlen(uint8_t *pkt, const ngtcp2_cid *dcid,
|
158
|
+
const ngtcp2_cid *scid, uint64_t payloadlen);
|
159
|
+
|
160
|
+
/*
|
161
|
+
* pkt_decode_hd_long decodes long packet header from |pkt| of length
|
162
|
+
* |pktlen|. This function assumes that header protection has been
|
163
|
+
* decrypted.
|
164
|
+
*/
|
165
|
+
ngtcp2_ssize pkt_decode_hd_long(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
166
|
+
size_t pktlen);
|
167
|
+
|
168
|
+
/*
|
169
|
+
* pkt_decode_hd_short decodes long packet header from |pkt| of length
|
170
|
+
* |pktlen|. This function assumes that header protection has been
|
171
|
+
* decrypted.
|
172
|
+
*/
|
173
|
+
ngtcp2_ssize pkt_decode_hd_short(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
174
|
+
size_t pktlen, size_t dcidlen);
|
175
|
+
|
176
|
+
/*
|
177
|
+
* pkt_decode_hd_short_mask decodes long packet header from |pkt| of
|
178
|
+
* length |pktlen|. NGTCP2_FAKE_HP_MASK is used to decrypt header
|
179
|
+
* protection.
|
180
|
+
*/
|
181
|
+
ngtcp2_ssize pkt_decode_hd_short_mask(ngtcp2_pkt_hd *dest, const uint8_t *pkt,
|
182
|
+
size_t pktlen, size_t dcidlen);
|
183
|
+
|
184
|
+
/*
|
185
|
+
* path_init initializes |path| with the given arguments. They form
|
186
|
+
* IPv4 addresses.
|
187
|
+
*/
|
188
|
+
void path_init(ngtcp2_path_storage *path, uint32_t local_addr,
|
189
|
+
uint16_t local_port, uint32_t remote_addr, uint16_t remote_port);
|
190
|
+
|
191
|
+
#endif /* NGTCP2_TEST_HELPER_H */
|