-
Notifications
You must be signed in to change notification settings - Fork 210
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: sa_family_t
should use ADDRESS_FAMILY
from windows-sys
#462
Comments
That seems reasonable. One possible difficulty is that |
it's a valid concern, but I think changing from what's more, how is pub const AF_INET: ADDRESS_FAMILY = 2u16;
pub const AF_INET6: ADDRESS_FAMILY = 23u16; so in this regard, the caller code like this let family = sockaddr.family();
if family == AF_INET {
todo!()
} is technically already "broken" if we keep it as the current definition, and change the return type to |
Fair point.
To be honest, I've only done this on Unix, so I don't have a good answer to this.
Yeah, fair enough. Do you want to send a pr to change the type? |
sure, #463 is created |
This was done in #463. |
in #414
socklen_t
andsa_family_t
were changed to use types fromwindows-sys
, which themselves were added to thewin32metadata
by request, in microsoft/win32metadata#1041 (both asNativeTypedef
s). however,sa_family_t
was later changed toMetadataTypedef
in microsoft/win32metadata#1538 because it was an "invented" handle type (meaning it doesn't exist in any of the Windows SDK header files but only in win32metadata).socklen_t
, on the other hand, does exists in the Windows SDK header "WS2tcpip.h", so it remainsNativeTypedef
.it turns out that the equivalent to POSIX
sa_family_t
in Winsock2 is theADDRESS_FAMILY
type, and it existed forever. I think it's a mistake to request awin32metadata
only typedef while ingoring the proper Windows SDK type,- and I'd suggest we change oursa_family_t
to use the proper type, i.e.windows_sys::Win32::Networking::Winsock::ADDRESS_FAMILY
, which also makes it consistent with other Winsock2 APIs, for instance, inwindows-sys
(and alsowindows
), the type ofSOCKADDR::sa_family
andSOCKADDR_STORAGE::sa_family
isADDRESS_FAMILY
, the constantsAF_INET
,AF_INET6
are defined using typeADDRESS_FAMILY
, and some iphelper functions likeGetIpForwardTable2()
acceptADDRESS_FAMILY
as argument.example code in the `windows` crate where `ADDRESS_FAMILY` is used
SOCKADDR
https://github.com/microsoft/windows-rs/blob/891c469706d314fcf0e3a7913f45970ce11b13f0/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs#L13218-L13223
SOCKADDR_IN::sin_family
https://github.com/microsoft/windows-rs/blob/891c469706d314fcf0e3a7913f45970ce11b13f0/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs#L13314-L13321
AF_INET
andAF_INET6
https://github.com/microsoft/windows-rs/blob/891c469706d314fcf0e3a7913f45970ce11b13f0/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs#L1782-L1785
btw, I discovered #414 when I was investigating the discrepancy of wrapper types from the
windows
crate. microsoft/windows-rs#2627The text was updated successfully, but these errors were encountered: