diff --git a/include/oxen/quic/address.hpp b/include/oxen/quic/address.hpp index c7992ed8..eee7614d 100644 --- a/include/oxen/quic/address.hpp +++ b/include/oxen/quic/address.hpp @@ -246,6 +246,7 @@ namespace oxen::quic return r <=> 0; return oxenc::big_to_host(a.sin_port) <=> oxenc::big_to_host(b.sin_port); } + if (is_ipv6() && other.is_ipv6()) { auto& a = in6(); @@ -258,6 +259,7 @@ namespace oxen::quic } bool operator==(const Address& other) const { return (*this <=> other) == 0; } + bool operator!=(const Address& other) const { return !(*this == other); } // Returns the size of the sockaddr @@ -340,6 +342,12 @@ namespace oxen::quic return *this; } + auto operator<=>(const Path& other) const { return std::tie(local, remote) <=> std::tie(other.local, other.remote); } + + bool operator==(const Path& other) const { return (*this <=> other) == 0; } + + bool operator!=(const Path& other) const { return !(*this == other); } + // template code to pass Path as ngtcp2_path into ngtcp2 functions template requires std::same_as @@ -390,4 +398,15 @@ namespace std return h; } }; + + template <> + struct hash + { + size_t operator()(const oxen::quic::Path& addr) const + { + auto h = hash{}(addr.local); + h ^= hash{}(addr.remote); + return h; + } + }; } // namespace std diff --git a/include/oxen/quic/connection.hpp b/include/oxen/quic/connection.hpp index a795da82..60128cdd 100644 --- a/include/oxen/quic/connection.hpp +++ b/include/oxen/quic/connection.hpp @@ -129,9 +129,9 @@ namespace oxen::quic template void send_datagram(std::vector&& buf) { - send_datagram( - std::basic_string_view{buf.data(), buf.size()}, - std::make_shared>(std::move(buf))); + auto keep_alive = std::make_shared>(std::move(buf)); + std::basic_string_view view{keep_alive->data(), keep_alive->size()}; + send_datagram(view, std::move(keep_alive)); } template