Emulator Issues #13129
openNetwork: Wrong broadcast address used on Android
0%
Description
What's the problem? Describe what went wrong.
This is a general bug in Dolphin's network code for Android that I noticed looking at the code. I didn't open a PR as I'm unsure how to fix that, never programmed anything for Android before. At least now the bug is documented here (if it's a bug and I'm not misunderstanding stuff).
Looking at the function GetSystemDefaultInterface in Source/Core/Core/IOS/Network/IP/Top.cpp, this function is supposed to return a DefaultInterface which according to the struct definition contains IPv4, subnet mask, and broadcast address.
Looking at how that function is implemented, on Windows and Linux it correctly returns IP, netmask and broadcast address.
On Android, the function calls GetNetworkGateway() which is a Java function that returns the Gateway of the current network connection. And then it returns that in place of the broadcast address. Also, it only returns something if the condition "if (addr || netmask || gateway)" is met - shouldn't that be "if (addr && netmask && gateway)" instead so no incomplete data is returned?
The code has that bug ever since it was introduced in PR 9191.
Another related bug is in the function below, GetSystemDefaultInterfaceOrFallback. It uses variable names "IP", "NETMASK" and "GATEWAY", though it returns IP, Netmask and Broadcast address. And the broadcast address that's included in the code there ("10.0.255.255") is neither a valid broadcast address nor a valid gateway address for that network (broadcast for that network would be 10.0.1.255).
Looking at what a real Wii does according to WiiBrew, that IOS call is supposed to return IP, Netmask & Broadcast, so the struct and the Windows/Linux implementation seems correct while the Android implementation is wrong.
Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.
Yes, see https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/IOS/Network/IP/Top.cpp