diff options
| author | Robby Zambito <contact@robbyzambito.me> | 2026-04-15 19:44:48 -0400 |
|---|---|---|
| committer | Tangled <noreply@tangled.org> | 2026-04-16 04:56:23 +0300 |
| commit | 7077aae9ceedc48fd5329f204163f1fbdd9d0ba8 (patch) | |
| tree | 9e60bba563b40c936f7ad330fca5f263d18af2d8 /src/EthIpUdp.zig | |
| parent | 1f500b9b0a9999dafbbb01d57a9574b0537deedc (diff) | |
fix: convert MacAddr from vector to int
Still expose a vector / slice API with .fromSlice,
Diffstat (limited to 'src/EthIpUdp.zig')
| -rw-r--r-- | src/EthIpUdp.zig | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/EthIpUdp.zig b/src/EthIpUdp.zig index 251ed64..b286db2 100644 --- a/src/EthIpUdp.zig +++ b/src/EthIpUdp.zig @@ -53,8 +53,19 @@ pub const EthIpUdp = packed struct(u336) { // 42 bytes * 8 bits = 336 // --- Ethernet --- eth_type: u16 = std.os.linux.ETH.P.IP, - src_mac: @Vector(6, u8), - dst_mac: @Vector(6, u8) = @splat(0xff), + src_mac: MacAddr, + dst_mac: MacAddr = .fromSlice(@splat(0xff)), + + pub const MacAddr = packed struct { + int: I, + + pub const V = @Vector(6, u8); + pub const I = @Int(.unsigned, @bitSizeOf(V)); + + pub fn fromSlice(s: V) MacAddr { + return .{ .int = @bitCast(s) }; + } + }; pub fn toBytes(self: @This()) [336 / 8]u8 { var res: [336 / 8]u8 = undefined; |
