From bdbec30a849807fb5e6841a38cfe0d168e5962b9 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 21 Dec 2023 12:06:05 +0100 Subject: seitan: Add netlink, sendto()/sendmsg(), iovec handling, demo with routes A bit rough at the moment, but it does the trick. Bonus: setsockopt() (with magic values only, not used in any demo yet). Signed-off-by: Stefano Brivio --- cooker/gluten.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'cooker/gluten.c') diff --git a/cooker/gluten.c b/cooker/gluten.c index 4d3aea5..69c9384 100644 --- a/cooker/gluten.c +++ b/cooker/gluten.c @@ -146,6 +146,7 @@ void gluten_add_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id, union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id) { + union value missing = { 0 }; int i; for (i = 0; i < ATTRS_MAX && g->attrs[i].type; i++) { @@ -153,8 +154,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, return g->attrs[i].v; } - die(" attribute '%p' not found", id); - return g->attrs[0].v; /* Pro forma, not actually happening */ + debug(" attribute '%p' not found", id); + return missing; } /** @@ -163,8 +164,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, */ void gluten_init(struct gluten_ctx *g) { - g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION; g->ip.offset = g->lr.offset = g->mr.offset = 0; + g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION; g->dp.type = OFFSET_DATA; g->cp.type = OFFSET_RO_DATA; } @@ -185,3 +186,12 @@ void gluten_write(struct gluten_ctx *g, const char *path) close(fd); } + +void gluten_relocation_add(struct gluten_ctx *g, struct gluten_offset offset) +{ + g->g.header.relocation[g->rel_count++] = offset; + debug(" Added relocation for %s: %u", gluten_offset_name[offset.type], + offset.offset); + if (g->rel_count >= 256) + die("Too many relocations"); +} -- cgit v1.2.3