SOC: Fix setting TTL to default value when TTL = 0 (#6835)
This commit is contained in:
parent
b1b6f08926
commit
5b9f4d4129
@ -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));
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user