-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Implement if_nametoindex
for windows
#22555
base: master
Are you sure you want to change the base?
Conversation
Thanks! |
CI failures look related to me. |
I'd be happy to merge any changes or fixes, if that is something that would be beneficial. Anything else I can contribute to this? |
Well one of the tests you enabled to run on Windows is failing there:
So that needs to be resolved. |
I also saw that. What I didn't get: To me it seems like the codepath where the |
Seems that this condition doesn't trigger: Lines 530 to 532 in 0679358
Because when running on Windows with libc Lines 5783 to 5790 in 0679358
So I'd suggest making that test string 12 characters longer ( "ff01::fb%wlp3s0s0s0s0s0s0s0s0s0s0s0s0s0s0" |
I was also looking at that piece of code, but didn't make the |
Windows has a different max length for their interface names, leading to test cases not having the expected result
0679358
to
f954764
Compare
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.
Seems that the "ff01::fb%12345678901234" test string, since its scope id was only 14 characters long, was triggering one of the different error.Overflow
s that happen later on:
Lines 584 to 597 in f954764
} else { | |
const digit = try std.fmt.charToDigit(c, 16); | |
{ | |
const ov = @mulWithOverflow(x, 16); | |
if (ov[1] != 0) return error.Overflow; | |
x = ov[0]; | |
} | |
{ | |
const ov = @addWithOverflow(x, digit); | |
if (ov[1] != 0) return error.Overflow; | |
x = ov[0]; | |
} | |
saw_any_digits = true; | |
} |
Revert a change, as that was supposed to target a different test case
This implements the
if_nametoindex
function for windows.I noticed zig threw a compile error when trying to compile the zigdig example code for windows.
If I read the code correctly, and looking at issue #20530, this seems also hinder all IP resolution on windows, even though
if_nametoindex
is only called in the ipv4 codepath.I pieced this code together from looking at the darwin implementation and the old std.x namespace, which also contained an implementation for windows.
This seems to pass all test, except for this one
zig/lib/std/net/test.zig
Line 79 in d5db027
error.Overflow
case should be handled beforeif_nametoindex
is even called. If someone can help me fix this case, I'd be happy for any pointers.I'm also happy about any other pointers and things I should fix.