From 157afa13b1f670ec7e8264056c19785f46cb339c Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Sat, 24 Jan 2026 10:38:52 -0500 Subject: Fix checksum issue --- src/Connection.zig | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/Connection.zig') diff --git a/src/Connection.zig b/src/Connection.zig index 503cb6c..0c33f1a 100644 --- a/src/Connection.zig +++ b/src/Connection.zig @@ -14,12 +14,16 @@ pub fn init(socket: RawSocket, headers: EthIpUdp, connection: SaprusMessage) Con pub fn next(self: Connection, io: Io, buf: []u8) ![]const u8 { _ = io; + log.debug("Awaiting connection message", .{}); const res = try self.socket.receive(buf); + log.debug("Received {} byte connection message", .{res.len}); const connection_res = blk: { const msg: SaprusMessage = try .parse(res[42..]); break :blk msg.connection; }; + log.debug("Payload was {s}", .{connection_res.payload}); + return connection_res.payload; } @@ -29,14 +33,16 @@ pub fn send(self: *Connection, io: Io, buf: []const u8) !void { break :blk io_source.interface(); }; + log.debug("Sending connection message", .{}); + self.connection.connection.payload = buf; const connection_bytes = blk: { var connection_bytes: [2048]u8 = undefined; break :blk self.connection.toBytes(&connection_bytes); }; - self.headers.setPayloadLen(connection_bytes.len); self.headers.ip.id = rand.int(u16); + self.headers.setPayloadLen(connection_bytes.len); const full_msg = blk: { var msg_buf: [2048]u8 = undefined; @@ -47,12 +53,16 @@ pub fn send(self: *Connection, io: Io, buf: []const u8) !void { }; try self.socket.send(full_msg); + + log.debug("Sent {} byte connection message", .{full_msg.len}); } const std = @import("std"); const Io = std.Io; const Writer = std.Io.Writer; +const log = std.log; + const SaprusMessage = @import("./message.zig").Message; const EthIpUdp = @import("./EthIpUdp.zig").EthIpUdp; -- cgit