citra-emu
/
citra-canary
Archived
1
0
Fork 0

SOC: Fix setting TTL to default value when TTL = 0 (#6835)

This commit is contained in:
PabloMK7 2023-08-02 22:06:51 +02:00 committed by GitHub
parent b1b6f08926
commit 5b9f4d4129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -301,7 +301,7 @@ std::pair<int, int> SOC_U::TranslateSockOpt(int level, int opt) {
return std::make_pair(SOL_SOCKET, opt); return std::make_pair(SOL_SOCKET, opt);
} }
static void TranslateSockOptDataToPlatform(std::vector<u8>& out, const std::vector<u8>& in, void SOC_U::TranslateSockOptDataToPlatform(std::vector<u8>& out, const std::vector<u8>& in,
int platform_level, int platform_opt) { int platform_level, int platform_opt) {
// linger structure may be different between 3DS and platform // linger structure may be different between 3DS and platform
if (platform_level == SOL_SOCKET && platform_opt == SO_LINGER && if (platform_level == SOL_SOCKET && platform_opt == SO_LINGER &&
@ -331,6 +331,10 @@ static void TranslateSockOptDataToPlatform(std::vector<u8>& out, const std::vect
out = in; out = in;
return; 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)); out.resize(sizeof(int));
std::memcpy(out.data(), &value, sizeof(int)); std::memcpy(out.data(), &value, sizeof(int));
} }

View File

@ -61,8 +61,12 @@ private:
static constexpr u32 SOC_SOL_CONFIG = 0xFFFE; static constexpr u32 SOC_SOL_CONFIG = 0xFFFE;
static constexpr u32 SOC_SOL_SOCKET = 0xFFFF; static constexpr u32 SOC_SOL_SOCKET = 0xFFFF;
static constexpr int SOC_TTL_DEFAULT = 64;
static const std::unordered_map<u64, std::pair<int, int>> sockopt_map; static const std::unordered_map<u64, std::pair<int, int>> sockopt_map;
static std::pair<int, int> TranslateSockOpt(int level, int opt); static std::pair<int, int> TranslateSockOpt(int level, int opt);
static void TranslateSockOptDataToPlatform(std::vector<u8>& out, const std::vector<u8>& in,
int platform_level, int platform_opt);
bool GetSocketBlocking(const SocketHolder& socket_holder); bool GetSocketBlocking(const SocketHolder& socket_holder);
u32 SetSocketBlocking(SocketHolder& socket_holder, bool blocking); u32 SetSocketBlocking(SocketHolder& socket_holder, bool blocking);