Write relay message to the network

This commit is contained in:
2026-01-19 12:51:43 -05:00
parent d7dedd243e
commit c66b95bf89
2 changed files with 9 additions and 3 deletions

View File

@@ -189,6 +189,10 @@ pub fn main(init: std.process.Init) !void {
};
std.debug.print("full message = {any}\n", .{full_msg});
var socket: RawSocket = try .init("enp7s0");
defer socket.deinit();
try socket.send(full_msg);
}
fn parseDest(in: ?[]const u8) [4]u8 {
@@ -222,7 +226,7 @@ const RawSocket = struct {
fd: i32,
sockaddr_ll: std.posix.sockaddr.ll,
fn init(ifname: []const u8) RawSocket {
fn init(ifname: []const u8) !RawSocket {
const socket: i32 = @intCast(std.os.linux.socket(AF.PACKET, SOCK.RAW, 0));
var ifr: std.posix.ifreq = std.mem.zeroInit(std.posix.ifreq, .{});
@@ -265,7 +269,9 @@ const RawSocket = struct {
};
}
fn deinit() void {}
fn deinit(self: *RawSocket) void {
_ = self;
}
fn send(self: RawSocket, payload: []const u8) !void {
const sent_bytes = std.os.linux.sendto(