From 32d51f1699e90efd62c7f091690d6b0f2966e7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 19 Apr 2018 19:21:55 +0200 Subject: [PATCH] IOS/SO: Re-implement GetInterfaceOpt(0x4003) Use the newly added GetSystemDefaultInterfaceOrFallback() to return actual information for the default interface, not just dummy interface details. This also fixes GetInterfaceOpt(0x4003) and gethostid() returning inconsistent information. Prior to this change, GetInterfaceOpt(0x4003) would return 10.0.1.30 and gethostid would give a totally unrelated IP. --- Source/Core/Core/IOS/Network/IP/Top.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index ce418cf7fe..622cddbf67 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -884,11 +884,16 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req break; case 0x4003: // ip addr table + { + // XXX: this isn't exactly right; the buffer can be larger than 12 bytes, in which case + // SO can write 12 more bytes. Memory::Write_U32(0xC, request.io_vectors[1].address); - Memory::Write_U32(inet_addr(10, 0, 1, 30), request.io_vectors[0].address); - Memory::Write_U32(inet_addr(255, 255, 255, 0), request.io_vectors[0].address + 4); - Memory::Write_U32(inet_addr(10, 0, 255, 255), request.io_vectors[0].address + 8); + const DefaultInterface interface = GetSystemDefaultInterfaceOrFallback(); + Memory::Write_U32(Common::swap32(interface.inet), request.io_vectors[0].address); + Memory::Write_U32(Common::swap32(interface.netmask), request.io_vectors[0].address + 4); + Memory::Write_U32(Common::swap32(interface.broadcast), request.io_vectors[0].address + 8); break; + } case 0x4005: // hardcoded value Memory::Write_U32(0x20, request.io_vectors[0].address);