diff --git a/src/mdns.zig b/src/mdns.zig index 61a1e1d..aaf6079 100644 --- a/src/mdns.zig +++ b/src/mdns.zig @@ -34,8 +34,8 @@ const MSG_BUFF_SIZE = util.consts.MSG_BUFF_SIZE; fn get_mdns_socket(ip_info: util.IPInfo) !socket { const sock = std.c.socket(switch (ip_info.version) { - util.IP_VER_ENUM.IPv4 => std.c.AF.INET, - util.IP_VER_ENUM.IPv6 => std.c.AF.INET6, + .IPv4 => std.c.AF.INET, + .IPv6 => std.c.AF.INET6, else => unreachable, }, std.c.SOCK.DGRAM, std.c.IPPROTO.UDP); if (sock == -1) { @@ -69,8 +69,8 @@ fn construct_mdns_query(domain: util.Domain, ip_info: util.IPInfo, buff: []u8) ! const question_footer = [_]u8{ 0x00, switch (ip_info.version) { - util.IP_VER_ENUM.IPv4 => 0x01, - util.IP_VER_ENUM.IPv6 => 0x1c, + .IPv4 => 0x01, + .IPv6 => 0x1c, else => unreachable, } } ++ // A or AAAA record [_]u8{ 0x00, 0x01 } // IN query @@ -82,8 +82,8 @@ fn construct_mdns_query(domain: util.Domain, ip_info: util.IPInfo, buff: []u8) ! fn get_target_address(ip_info: util.IPInfo) !std.net.Address { const target_addr: []const u8 = switch (ip_info.version) { - util.IP_VER_ENUM.IPv4 => "224.0.0.251", - util.IP_VER_ENUM.IPv6 => blk: { + .IPv4 => "224.0.0.251", + .IPv6 => blk: { var buf: [50]u8 = undefined; var byte_buf = std.io.fixedBufferStream(&buf); const writer = byte_buf.writer(); @@ -165,8 +165,8 @@ fn parse_mdns_response(response: []u8, ip_info: util.IPInfo) !util.IP { pos += ip_len; if (switch (ip_info.version) { - util.IP_VER_ENUM.IPv4 => ip_len != 4, - util.IP_VER_ENUM.IPv6 => ip_len != 16, + .IPv4 => ip_len != 4, + .IPv6 => ip_len != 16, else => unreachable, }) { continue; diff --git a/src/util.zig b/src/util.zig index ffac4bb..e34d84b 100644 --- a/src/util.zig +++ b/src/util.zig @@ -65,7 +65,7 @@ pub fn get_input() !struct { const ip_ver = std.meta.intToEnum(IP_VER_ENUM, std.fmt.parseInt(u3, ip_ver_str, 10) catch return ArgError.InvalidAddressVer) catch return ArgError.InvalidAddressVer; var iface: ?[:0]const u8 = null; - if (ip_ver != IP_VER_ENUM.IPv4) { + if (ip_ver != .IPv4) { iface = args.next() orelse return ArgError.InterfaceRequired; if (std.c.if_nametoindex(iface.?) == 0) { return ArgError.InvalidInterface;