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.
This commit is contained in:
Léo Lam 2018-04-19 19:21:55 +02:00
parent 3ce271991b
commit 32d51f1699
1 changed files with 8 additions and 3 deletions

View File

@ -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);