-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] Fix Discovery of MAC Address #25111
Conversation
Jenkins build this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find!
Tested on windows 11 and is working.
@@ -248,7 +248,7 @@ bool CNetworkWin32::PingHost(const struct sockaddr& host, unsigned int timeout_m | |||
|
|||
bool CNetworkInterfaceWin32::GetHostMacAddress(unsigned long host, std::string& mac) const | |||
{ | |||
struct sockaddr sockHost; | |||
struct sockaddr sockHost = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct sockaddr sockHost = {}; | |
sockaddr sockHost = {}; |
Seems rare the use of "struct" word here. I mean struct is for define a struct but here is declare a struct already defined in Windows headers.
Same thing in CNetworkWin32::PingHost
and CNetworkInterfaceWin32::GetHostMacAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I didn't question the unnecessary C syntax. That's the reason why the format bot insisted on weird formatting in the initialization. Changed, but it's not broken and I'm not changing the other ones of the file.
sockaddr structure was filled with pointer value instead of the data pointed to.
May 5th v22 nightly User Acceptance Test results: The server wakes from sleep. But...
For me, this is a huge improvement. However, it does throw up the red MAC Discovery Fail message, which will likely cause confusion for some users. |
Description
Fix the CNetworkInterfaceWin32::GetHostMacAddress() function on Windows. It seems to have stopped working with PR #14369 which added support for IPv6.
A pointer dereference was missing and the wrong data was passed to the Windows API ResolveIpNetEntry2() for host discovery. It always failed with error 87 (ERROR_INVALID_PARAMETER).
For style, I could have gone the way below instead for the same result, but is it a safe way to copy structs of various sizes?
Also added a small optimization to look for the host in the OS cache before hitting the wire with a resolution request.
I think this can be backported.
Motivation and context
Should fix the broken WOL issue reported in forum https://forum.kodi.tv/showthread.php?tid=377218 and #25058.
How has this been tested?
Windows 10, IPv4.
The hosts are resolved when activating the WOL setting of Kodi, toast messages appear and a wakeonlan.xml file with valid addresses is generated.
IPv6 support is not in a shape that allows testing of MAC resolution.
What is the effect on users?
Working WOL function on Windows.
Types of change
Checklist: