Move the sockopt mapping to the toplevel (needed for GETSOCKOPT too)

This commit is contained in:
Pierre Bourdon 2012-02-19 19:30:04 +01:00
parent 2c9109936c
commit 87456054d6
1 changed files with 19 additions and 18 deletions

View File

@ -609,6 +609,19 @@ static int inet_pton(const char *src, unsigned char *dst)
return (1); return (1);
} }
// Maps SOCKOPT level from native to Wii
static int opt_level_mapping[][2] = {
{ SOL_SOCKET, 0xFFFF }
};
// Maps SOCKOPT optname from native to Wii
static int opt_name_mapping[][2] = {
{ SO_REUSEADDR, 0x4 },
{ SO_SNDBUF, 0x1001 },
{ SO_RCVBUF, 0x1002 },
{ SO_ERROR, 0x1009 }
};
u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
u32 _BufferIn, u32 BufferInSize, u32 _BufferIn, u32 BufferInSize,
u32 _BufferOut, u32 BufferOutSize) u32 _BufferOut, u32 BufferOutSize)
@ -773,18 +786,6 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
case IOCTL_SO_SETSOCKOPT: case IOCTL_SO_SETSOCKOPT:
{ {
// Maps level from native to Wii
int level_mapping[][2] = {
{ SOL_SOCKET, 0xFFFF }
};
// Maps optname from native to Wii
int optname_mapping[][2] = {
{ SO_REUSEADDR, 0x4 },
{ SO_SNDBUF, 0x1001 },
{ SO_RCVBUF, 0x1002 },
};
u32 S = Memory::Read_U32(_BufferIn); u32 S = Memory::Read_U32(_BufferIn);
u32 level = Memory::Read_U32(_BufferIn + 4); u32 level = Memory::Read_U32(_BufferIn + 4);
u32 optname = Memory::Read_U32(_BufferIn + 8); u32 optname = Memory::Read_U32(_BufferIn + 8);
@ -804,13 +805,13 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command,
// Do the level/optname translation // Do the level/optname translation
int nat_level = -1, nat_optname = -1; int nat_level = -1, nat_optname = -1;
for (int i = 0; i < sizeof (level_mapping) / sizeof (level_mapping[0]); ++i) for (int i = 0; i < sizeof (opt_level_mapping) / sizeof (opt_level_mapping[0]); ++i)
if (level == level_mapping[i][1]) if (level == opt_level_mapping[i][1])
nat_level = level_mapping[i][0]; nat_level = opt_level_mapping[i][0];
for (int i = 0; i < sizeof (optname_mapping) / sizeof (optname_mapping[0]); ++i) for (int i = 0; i < sizeof (opt_name_mapping) / sizeof (opt_name_mapping[0]); ++i)
if (optname == optname_mapping[i][1]) if (optname == opt_name_mapping[i][1])
nat_optname = optname_mapping[i][0]; nat_optname = opt_name_mapping[i][0];
if (nat_level == -1 || nat_optname == -1) if (nat_level == -1 || nat_optname == -1)
{ {