| ... | @@ -77,23 +77,23 @@ pub const Address = extern union { | ... | @@ -77,23 +77,23 @@ pub const Address = extern union { |
| 77 | } | 77 | } |
| 78 | | 78 | |
| 79 | pub fn parseIp6(buf: []const u8, port: u16) !Address { | 79 | pub fn parseIp6(buf: []const u8, port: u16) !Address { |
| 80 | return Address{.in6 = try Ip6Address.parse(buf, port) }; | 80 | return Address{ .in6 = try Ip6Address.parse(buf, port) }; |
| 81 | } | 81 | } |
| 82 | | 82 | |
| 83 | pub fn resolveIp6(buf: []const u8, port: u16) !Address { | 83 | pub fn resolveIp6(buf: []const u8, port: u16) !Address { |
| 84 | return Address{.in6 = try Ip6Address.resolve(buf, port) }; | 84 | return Address{ .in6 = try Ip6Address.resolve(buf, port) }; |
| 85 | } | 85 | } |
| 86 | | 86 | |
| 87 | pub fn parseIp4(buf: []const u8, port: u16) !Address { | 87 | pub fn parseIp4(buf: []const u8, port: u16) !Address { |
| 88 | return Address {.in = try Ip4Address.parse(buf, port) }; | 88 | return Address{ .in = try Ip4Address.parse(buf, port) }; |
| 89 | } | 89 | } |
| 90 | | 90 | |
| 91 | pub fn initIp4(addr: [4]u8, port: u16) Address { | 91 | pub fn initIp4(addr: [4]u8, port: u16) Address { |
| 92 | return Address{.in = Ip4Address.init(addr, port) }; | 92 | return Address{ .in = Ip4Address.init(addr, port) }; |
| 93 | } | 93 | } |
| 94 | | 94 | |
| 95 | pub fn initIp6(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Address { | 95 | pub fn initIp6(addr: [16]u8, port: u16, flowinfo: u32, scope_id: u32) Address { |
| 96 | return Address{.in6 = Ip6Address.init(addr, port, flowinfo, scope_id) }; | 96 | return Address{ .in6 = Ip6Address.init(addr, port, flowinfo, scope_id) }; |
| 97 | } | 97 | } |
| 98 | | 98 | |
| 99 | pub fn initUnix(path: []const u8) !Address { | 99 | pub fn initUnix(path: []const u8) !Address { |
| ... | @@ -136,8 +136,8 @@ pub const Address = extern union { | ... | @@ -136,8 +136,8 @@ pub const Address = extern union { |
| 136 | /// on the address family. | 136 | /// on the address family. |
| 137 | pub fn initPosix(addr: *align(4) const os.sockaddr) Address { | 137 | pub fn initPosix(addr: *align(4) const os.sockaddr) Address { |
| 138 | switch (addr.family) { | 138 | switch (addr.family) { |
| 139 | os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).*} }, | 139 | os.AF_INET => return Address{ .in = Ip4Address{ .sa = @ptrCast(*const os.sockaddr_in, addr).* } }, |
| 140 | os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).*} }, | 140 | os.AF_INET6 => return Address{ .in6 = Ip6Address{ .sa = @ptrCast(*const os.sockaddr_in6, addr).* } }, |
| 141 | else => unreachable, | 141 | else => unreachable, |
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| ... | @@ -193,7 +193,7 @@ pub const Ip4Address = extern struct { | ... | @@ -193,7 +193,7 @@ pub const Ip4Address = extern struct { |
| 193 | .sa = .{ | 193 | .sa = .{ |
| 194 | .port = mem.nativeToBig(u16, port), | 194 | .port = mem.nativeToBig(u16, port), |
| 195 | .addr = undefined, | 195 | .addr = undefined, |
| 196 | } | 196 | }, |
| 197 | }; | 197 | }; |
| 198 | const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.sa.addr)[0..]); | 198 | const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.sa.addr)[0..]); |
| 199 | | 199 | |
| ... | @@ -240,7 +240,7 @@ pub const Ip4Address = extern struct { | ... | @@ -240,7 +240,7 @@ pub const Ip4Address = extern struct { |
| 240 | } | 240 | } |
| 241 | | 241 | |
| 242 | pub fn init(addr: [4]u8, port: u16) Ip4Address { | 242 | pub fn init(addr: [4]u8, port: u16) Ip4Address { |
| 243 | return Ip4Address { | 243 | return Ip4Address{ |
| 244 | .sa = os.sockaddr_in{ | 244 | .sa = os.sockaddr_in{ |
| 245 | .port = mem.nativeToBig(u16, port), | 245 | .port = mem.nativeToBig(u16, port), |
| 246 | .addr = @ptrCast(*align(1) const u32, &addr).*, | 246 | .addr = @ptrCast(*align(1) const u32, &addr).*, |
| ... | @@ -598,7 +598,6 @@ pub const Ip6Address = extern struct { | ... | @@ -598,7 +598,6 @@ pub const Ip6Address = extern struct { |
| 598 | } | 598 | } |
| 599 | }; | 599 | }; |
| 600 | | 600 | |
| 601 | | | |
| 602 | pub fn connectUnixSocket(path: []const u8) !fs.File { | 601 | pub fn connectUnixSocket(path: []const u8) !fs.File { |
| 603 | const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0; | 602 | const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0; |
| 604 | const sockfd = try os.socket( | 603 | const sockfd = try os.socket( |