From 87456054d6fe82f92137e22ab9043f712d0cea5f Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 19 Feb 2012 19:30:04 +0100 Subject: [PATCH] Move the sockopt mapping to the toplevel (needed for GETSOCKOPT too) --- .../Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index 41ceb7c545..a0c78e4a65 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -609,6 +609,19 @@ static int inet_pton(const char *src, unsigned char *dst) 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 _BufferIn, u32 BufferInSize, u32 _BufferOut, u32 BufferOutSize) @@ -773,18 +786,6 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, 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 level = Memory::Read_U32(_BufferIn + 4); 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 int nat_level = -1, nat_optname = -1; - for (int i = 0; i < sizeof (level_mapping) / sizeof (level_mapping[0]); ++i) - if (level == level_mapping[i][1]) - nat_level = level_mapping[i][0]; + for (int i = 0; i < sizeof (opt_level_mapping) / sizeof (opt_level_mapping[0]); ++i) + if (level == opt_level_mapping[i][1]) + nat_level = opt_level_mapping[i][0]; - for (int i = 0; i < sizeof (optname_mapping) / sizeof (optname_mapping[0]); ++i) - if (optname == optname_mapping[i][1]) - nat_optname = optname_mapping[i][0]; + for (int i = 0; i < sizeof (opt_name_mapping) / sizeof (opt_name_mapping[0]); ++i) + if (optname == opt_name_mapping[i][1]) + nat_optname = opt_name_mapping[i][0]; if (nat_level == -1 || nat_optname == -1) {