diff --git a/external/ngtcp2 b/external/ngtcp2 index 51e95c8d8..15ba6021c 160000 --- a/external/ngtcp2 +++ b/external/ngtcp2 @@ -1 +1 @@ -Subproject commit 51e95c8d8972abd69515d9790e8fbb774262d9ea +Subproject commit 15ba6021ca352e2e60f9b43f4b96d2e97a42f60b diff --git a/llarp/quic/address.hpp b/llarp/quic/address.hpp index 42150ed3e..5f7bc3522 100644 --- a/llarp/quic/address.hpp +++ b/llarp/quic/address.hpp @@ -21,7 +21,7 @@ namespace llarp::quic class Address { sockaddr_in6 saddr{}; - ngtcp2_addr a{sizeof(saddr), reinterpret_cast(&saddr), nullptr}; + ngtcp2_addr a{sizeof(saddr), reinterpret_cast(&saddr)}; public: Address() = default; @@ -102,8 +102,7 @@ namespace llarp::quic Address local_, remote_; public: - ngtcp2_path path{ - {local_.sockaddr_size(), local_, nullptr}, {remote_.sockaddr_size(), remote_, nullptr}}; + ngtcp2_path path{{local_.sockaddr_size(), local_}, {remote_.sockaddr_size(), remote_}, nullptr}; // Public accessors are const: const Address& local = local_; diff --git a/llarp/quic/connection.cpp b/llarp/quic/connection.cpp index c3b21d597..8d7cc8728 100644 --- a/llarp/quic/connection.cpp +++ b/llarp/quic/connection.cpp @@ -244,6 +244,7 @@ namespace llarp::quic int stream_close_cb( ngtcp2_conn* conn, + uint32_t flags, int64_t stream_id, uint64_t app_error_code, void* user_data, @@ -275,17 +276,13 @@ namespace llarp::quic return 0; } - int - rand( - uint8_t* dest, - size_t destlen, - const ngtcp2_rand_ctx* rand_ctx, - [[maybe_unused]] ngtcp2_rand_usage usage) + void + rand(uint8_t* dest, size_t destlen, const ngtcp2_rand_ctx* rand_ctx) { LogTrace("######################", __func__); randombytes_buf(dest, destlen); - return 0; } + int get_new_connection_id( ngtcp2_conn* conn_, ngtcp2_cid* cid_, uint8_t* token, size_t cidlen, void* user_data) @@ -406,7 +403,7 @@ namespace llarp::quic settings.initial_ts = get_timestamp(); // FIXME: IPv6 - settings.max_udp_payload_size = NGTCP2_MAX_PKTLEN_IPV4; + settings.max_udp_payload_size = Endpoint::max_pkt_size_v4; settings.cc_algo = NGTCP2_CC_ALGO_CUBIC; // settings.initial_rtt = ???; # NGTCP2's default is 333ms @@ -1185,8 +1182,7 @@ namespace llarp::quic ngtcp2_conn_get_local_transport_params(*this, &tparams); assert(conn_buffer.empty()); - static_assert(NGTCP2_MAX_PKTLEN_IPV4 > NGTCP2_MAX_PKTLEN_IPV6); - conn_buffer.resize(NGTCP2_MAX_PKTLEN_IPV4); + conn_buffer.resize(Endpoint::max_pkt_size_v4); auto* buf = u8data(conn_buffer); auto* bufend = buf + conn_buffer.size(); diff --git a/llarp/quic/connection.hpp b/llarp/quic/connection.hpp index 828e99d23..be8eb715c 100644 --- a/llarp/quic/connection.hpp +++ b/llarp/quic/connection.hpp @@ -123,7 +123,7 @@ namespace llarp::quic }; // Packet data storage for a packet we are currently sending - std::array send_buffer{}; + std::array send_buffer{}; size_t send_buffer_size = 0; ngtcp2_pkt_info send_pkt_info{}; diff --git a/llarp/quic/endpoint.cpp b/llarp/quic/endpoint.cpp index 16444c1a4..5d57e9010 100644 --- a/llarp/quic/endpoint.cpp +++ b/llarp/quic/endpoint.cpp @@ -199,7 +199,7 @@ namespace llarp::quic void Endpoint::send_version_negotiation(const version_info& vi, const Address& source) { - std::array buf; + std::array buf; std::array versions; std::iota(versions.begin() + 1, versions.end(), NGTCP2_PROTO_VER_MIN); // we're supposed to send some 0x?a?a?a?a version to trigger version negotiation @@ -234,11 +234,13 @@ namespace llarp::quic Path path; ngtcp2_pkt_info pi; - auto write_close_func = - application ? ngtcp2_conn_write_application_close : ngtcp2_conn_write_connection_close; + auto write_close_func = application ? ngtcp2_conn_write_application_close_versioned + : ngtcp2_conn_write_connection_close_versioned; + auto written = write_close_func( conn, path, + NGTCP2_PKT_INFO_VERSION, &pi, u8data(conn.conn_buffer), conn.conn_buffer.size(), diff --git a/llarp/quic/endpoint.hpp b/llarp/quic/endpoint.hpp index 53a850ea4..cfbf92c54 100644 --- a/llarp/quic/endpoint.hpp +++ b/llarp/quic/endpoint.hpp @@ -64,8 +64,8 @@ namespace llarp::quic // Max theoretical size of a UDP packet is 2^16-1 minus IP/UDP header overhead static constexpr size_t max_buf_size = 64 * 1024; // Max size of a UDP packet that we'll send - static constexpr size_t max_pkt_size_v4 = NGTCP2_MAX_PKTLEN_IPV4; - static constexpr size_t max_pkt_size_v6 = NGTCP2_MAX_PKTLEN_IPV6; + static constexpr size_t max_pkt_size_v4 = NGTCP2_MAX_UDP_PAYLOAD_SIZE; + static constexpr size_t max_pkt_size_v6 = NGTCP2_MAX_UDP_PAYLOAD_SIZE; using primary_conn_ptr = std::shared_ptr; using alias_conn_ptr = std::weak_ptr;