From 5b9f4d4129c2f4e523b1fad584aee513bb37c8f5 Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Wed, 2 Aug 2023 22:06:51 +0200 Subject: [PATCH] SOC: Fix setting TTL to default value when TTL = 0 (#6835) --- src/core/hle/service/soc/soc_u.cpp | 6 +++++- src/core/hle/service/soc/soc_u.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/soc/soc_u.cpp b/src/core/hle/service/soc/soc_u.cpp index 1b91fdaae9..f07dffafb1 100644 --- a/src/core/hle/service/soc/soc_u.cpp +++ b/src/core/hle/service/soc/soc_u.cpp @@ -301,7 +301,7 @@ std::pair SOC_U::TranslateSockOpt(int level, int opt) { return std::make_pair(SOL_SOCKET, opt); } -static void TranslateSockOptDataToPlatform(std::vector& out, const std::vector& in, +void SOC_U::TranslateSockOptDataToPlatform(std::vector& out, const std::vector& in, int platform_level, int platform_opt) { // linger structure may be different between 3DS and platform if (platform_level == SOL_SOCKET && platform_opt == SO_LINGER && @@ -331,6 +331,10 @@ static void TranslateSockOptDataToPlatform(std::vector& out, const std::vect out = in; return; } + // Setting TTL to 0 means resetting it to the default value. + if (platform_level == IPPROTO_IP && platform_opt == IP_TTL && value == 0) { + value = SOC_TTL_DEFAULT; + } out.resize(sizeof(int)); std::memcpy(out.data(), &value, sizeof(int)); } diff --git a/src/core/hle/service/soc/soc_u.h b/src/core/hle/service/soc/soc_u.h index 4c56d31525..56329e1ed9 100644 --- a/src/core/hle/service/soc/soc_u.h +++ b/src/core/hle/service/soc/soc_u.h @@ -61,8 +61,12 @@ private: static constexpr u32 SOC_SOL_CONFIG = 0xFFFE; static constexpr u32 SOC_SOL_SOCKET = 0xFFFF; + static constexpr int SOC_TTL_DEFAULT = 64; + static const std::unordered_map> sockopt_map; static std::pair TranslateSockOpt(int level, int opt); + static void TranslateSockOptDataToPlatform(std::vector& out, const std::vector& in, + int platform_level, int platform_opt); bool GetSocketBlocking(const SocketHolder& socket_holder); u32 SetSocketBlocking(SocketHolder& socket_holder, bool blocking);