| ... | ... | @@ -184,7 +184,6 @@ pub const Address = extern union { |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | pub fn resolveIp6(buf: []const u8, port: u16) !Address { |
| 187 | | // FIXME: implement if_nametoindex |
| 188 | 187 | // FIXME: this is a very bad implementation, since it's only a copy |
| 189 | 188 | // of parseIp6 with alphanumerical scope id support |
| 190 | 189 | var result = Address{ |
| ... | ... | @@ -205,7 +204,7 @@ pub const Address = extern union { |
| 205 | 204 | var abbrv = false; |
| 206 | 205 | |
| 207 | 206 | var scope_id = false; |
| 208 | | var scope_id_value: [32]u8 = undefined; |
| 207 | var scope_id_value: [16]u8 = undefined; |
| 209 | 208 | var scope_id_index: usize = 0; |
| 210 | 209 | |
| 211 | 210 | for (buf) |c, i| { |
| ... | ... | @@ -273,10 +272,13 @@ pub const Address = extern union { |
| 273 | 272 | return error.Incomplete; |
| 274 | 273 | } |
| 275 | 274 | |
| 276 | | const resolved_scope_id = std.fmt.parseInt(u32, scope_id_value, 10) catch |err| blk: { |
| 277 | | if (err != err.InvalidCharacter) return err; |
| 278 | | break :blk if_nametoindex(scope_id_value); |
| 279 | | }; |
| 275 | var resolved_scope_id: u32 = 0; |
| 276 | if (std.mem.len(scope_id_value) > 0) { |
| 277 | resolved_scope_id = std.fmt.parseInt(u32, &scope_id_value, 10) catch |err| blk: { |
| 278 | if (err != error.InvalidCharacter) return err; |
| 279 | break :blk try if_nametoindex(&scope_id_value); |
| 280 | }; |
| 281 | } |
| 280 | 282 | |
| 281 | 283 | result.in6.scope_id = resolved_scope_id; |
| 282 | 284 | |
| ... | ... | @@ -522,7 +524,7 @@ fn if_nametoindex(name: []const u8) !u32 { |
| 522 | 524 | var sockfd = try os.socket(os.AF_UNIX, os.SOCK_DGRAM | os.SOCK_CLOEXEC, 0); |
| 523 | 525 | defer os.close(sockfd); |
| 524 | 526 | |
| 525 | | std.mem.copy(u8, ifr.ifr_ifrn.name, &name); |
| 527 | std.mem.copy(u8, &ifr.ifr_ifrn.name, name); |
| 526 | 528 | |
| 527 | 529 | const rc = os.system.syscall3( |
| 528 | 530 | os.linux.SYS_ioctl, |