Interpreting the fist two bytes of the `sockaddr` struct as `sa_family`
produces incorrect behaviour on macOS and (presumbly) BSD.
This change uses both Unix and Windows socket headers to convert the libpcap provided sockaddr before duplicating it.
This fixes sockaddr being always NULL on macOS/BSD and ipv6 addresses not working in general since `AF_INET6` differs on Windows(23), macOS(30) and Linux(10)
For reference https://www.ibm.com/docs/en/i/7.3?topic=family-af-inet-address and this is from the <sys/socket.h> on macOS
```
/*
* [XSI] Structure used by kernel to store most addresses.
*/
struct sockaddr {
__uint8_t sa_len; /* total length */
sa_family_t sa_family; /* [XSI] address family */
char sa_data[14]; /* [XSI] addr value (actually larger) */
};
```
--
v6: wpcap: Build devices in unixlib for find_all_devices.
wpcap: Split device allocation and build in find_all_devices.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1015
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50955
The problem which this patchset aims to solve is (sometimes) huge timeout on TCP listening port availability on Linux after the listening socket was closed one or another way. By default, the listening port will also be blocked for the whole time accepted socket waits through lengthy timeouts (sometimes; most surely when the listening process with an active connection was force killed, but not limited to this condition).
BSD SO_REUSEADDR socket option is aimed mainly to avoid that extra wait on binding already closed listening socket address. From [1]: "Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For AF_INET sockets this means that a socket may bind, except when there is an active listening socket bound to the address.".
Unix SO_REUSEADDR does not really allow reusing address in the Winsock sense. It will just allow to ditch the timeout (which is always the case on Windows without any specific options). Unfortunately it is not the only effect of the option. It still won't allow listening on the address simultaneously (unlike Winsock SO_REUSEADDR which allows simultaneous listening), or binding to an address which is being listened. But it will allow to bind different sockets for the same address which is not the Winsock behaviour when Winsock SO_REUSEADDR is set.
So the patchset enables SO_REUSEADDR on every TCP socket and introduces the bound address tracking which will allow to return an error from bind() when needed.
Not related to this patchset, but Winsock SO_REUSEADDR is somewhat closer to BSD SO_REUSEPORT, although is different in a way that _REUSEPORT will load balance connections between listeners while with Winsock _REUSEADDR the connections will always go to the first listener.
I hope that the bound addresses tracking introduced in these patches may be reused in the future. E. g., maybe it might be helpful on the way of implementing the todos introduced by my extended tests (those todos are not related to this patchset and exist both with and without it).
1. https://man7.org/linux/man-pages/man7/socket.7.html
--
v2: server: Set Unix SO_REUSEADDR on all the TCP sockets.
server: Track SO_REUSEADDR value.
ntdll: Move SO_REUSEADDR handling to server.
ws2_32/tests: Also test TCP6 in test_so_reuseaddr().
ws2_32/tests: Add tests for reusing address without SO_REUSEADDR.
ws2_32/tests: Make test_so_reuseaddr() more conclusive.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1111
Overwatch 2 doesn't like the win32u `-syscall` conversion that happened a while back, because it hooks KiUserCallbackDispatcher. This MR fixes it up to match what Overwatch 2 expects.
--
v2: ntdll: Pass KiUserCallbackDispatcher parameters on stack.
ntdll: Add 5-byte nop to start of KiUserCallbackDispatcher.
ntdll: Align stack pointer when calling KiUserCallbackDispatcher.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1152
--
v2: vkd3d-shader/hlsl: Propagate copies for resource store instructions.
vkd3d-shader/hlsl: Write SM4 UAV store instructions.
vkd3d-shader/hlsl: Parse UAV stores.
vkd3d-shader/hlsl: Implement typed UAV loads.
vkd3d-shader/hlsl: Write SM4 UAV declarations.
vkd3d-shader/hlsl: Allocate UAVs.
tests: Add a test for storing to a UAV array.
tests: Add more tests for UAV allocation.
tests: Fix constructor declaration in the partial UAV write test.
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/36