We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
if_nametoindex
1 parent d5db027 commit 9a5ba5eCopy full SHA for 9a5ba5e
lib/std/net.zig
@@ -752,6 +752,19 @@ fn if_nametoindex(name: []const u8) IPv6InterfaceError!u32 {
752
return @as(u32, @bitCast(index));
753
}
754
755
+ if (native_os == .windows) {
756
+ if (name.len >= posix.IFNAMESIZE)
757
+ return error.NameTooLong;
758
+
759
+ var interface_name: [posix.IFNAMESIZE:0]u8 = undefined;
760
+ @memcpy(interface_name[0..name.len], name);
761
+ interface_name[name.len] = 0;
762
+ const index = std.os.windows.ws2_32.if_nametoindex(@as([*:0]const u8, &interface_name));
763
+ if (index == 0)
764
+ return error.InterfaceNotFound;
765
+ return index;
766
+ }
767
768
@compileError("std.net.if_nametoindex unimplemented for this OS");
769
770
0 commit comments