From 91fdb2c6f8d90032f233a0ea65d4b8f4b8d89321 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Wed, 15 Apr 2026 21:02:32 -0400 Subject: refactor: use packed struct for IpAddr This is more intuitive than using u32 directly, and follows the same pattern as the new MAC addr handling --- src/Client.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Client.zig') diff --git a/src/Client.zig b/src/Client.zig index cbe4d17..0c8bb8f 100644 --- a/src/Client.zig +++ b/src/Client.zig @@ -46,11 +46,11 @@ pub fn sendRelay(self: *Client, io: Io, payload: []const u8, dest: [4]u8) !void const rand = io_source.interface(); var headers: EthIpUdp = .{ - .src_mac = .fromSlice(self.socket.mac), + .src_mac = .fromBytes(self.socket.mac), .ip = .{ .id = rand.int(u16), - .src_addr = 0, //rand.int(u32), - .dst_addr = @bitCast([_]u8{ 255, 255, 255, 255 }), + .src_addr = .fromBytes(.{ 0, 0, 0, 0 }), //rand.int(u32), + .dst_addr = .fromBytes(.{ 255, 255, 255, 255 }), .len = undefined, }, .udp = .{ @@ -86,11 +86,11 @@ pub fn connect(self: Client, io: Io, payload: []const u8) (error{ BpfAttachFaile const rand = io_source.interface(); var headers: EthIpUdp = .{ - .src_mac = .fromSlice(self.socket.mac), + .src_mac = .fromBytes(self.socket.mac), .ip = .{ .id = rand.int(u16), - .src_addr = 0, //rand.int(u32), - .dst_addr = @bitCast([_]u8{ 255, 255, 255, 255 }), + .src_addr = .fromBytes(.{ 0, 0, 0, 0 }), //rand.int(u32), + .dst_addr = .fromBytes(.{ 255, 255, 255, 255 }), .len = undefined, }, .udp = .{ -- cgit