aboutgitcodelistschat:MatrixIRC
path: root/cooker/calls
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-05-02 09:48:50 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-05-02 10:39:32 +0200
commit82b77505f9420f11d614c2ae0f74153ca4ee3cb5 (patch)
treeec93abd39cd8c7ff2818c7446da6cc01864b2ae1 /cooker/calls
parenta2c20b2caf4e9cedb32b0930ffd7ca2e9ec72086 (diff)
downloadseitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.gz
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.bz2
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.lz
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.xz
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.zst
seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.zip
cooker updates spilling all over the place
Only tangentially related: - make seitan C99 again, so that I can build cooker without warnings - make Makefiles make use of the usual conventions about assigning directory paths in variables, drop numbers.h as requirement for cooker and make it convenient to run stand-alone Makefiles - fix up nr_syscalls.sh to be POSIX, otherwise it will give syntax errors on my system - define a single, common way to refer to offsets in gluten, and functions to use those offsets in a safe way. Immediates are gone: cooker will write any bit of "data" to the read-only section - call const what has to be const - define on-disk layout for gluten - add OP_NR (to check syscall numbers), rename OP_COPY_ARGS to OP_LOAD (it loads _selected_ stuff from arguments) As for cooker itself: - drop ARG_ and arg_ prefixes from struct names, and similar - add/rework functions to build OP_NR, OP_LOAD, OP_CMP, and to write constant data to gluten - add parsing for "compound" arguments, but that's not completely hooked into evaluation for numeric arguments yet Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/calls')
-rw-r--r--cooker/calls/net.c91
1 files changed, 51 insertions, 40 deletions
diff --git a/cooker/calls/net.c b/cooker/calls/net.c
index c0949cc..370a3a1 100644
--- a/cooker/calls/net.c
+++ b/cooker/calls/net.c
@@ -39,7 +39,7 @@ n = sendmmsg(fd, *msgvec, vlen, flags)
#include "../cooker.h"
#include "../calls.h"
-static struct arg_num af[] = {
+static struct num af[] = {
{ "unix", AF_UNIX },
{ "ipv4", AF_INET },
{ "ipv6", AF_INET6 },
@@ -49,7 +49,7 @@ static struct arg_num af[] = {
{ 0 },
};
-static struct arg_num socket_types[] = {
+static struct num socket_types[] = {
{ "stream", SOCK_STREAM },
{ "dgram", SOCK_DGRAM },
{ "seq", SOCK_SEQPACKET },
@@ -58,13 +58,13 @@ static struct arg_num socket_types[] = {
{ 0 },
};
-static struct arg_num socket_flags[] = {
+static struct num socket_flags[] = {
{ "nonblock", SOCK_NONBLOCK },
{ "cloexec", SOCK_CLOEXEC },
{ 0 },
};
-static struct arg_num protocols[] = {
+static struct num protocols[] = {
{ "ip", IPPROTO_IP },
{ "icmp", IPPROTO_ICMP },
{ "igmp", IPPROTO_IGMP },
@@ -83,86 +83,97 @@ static struct arg_num protocols[] = {
};
static struct arg socket_args[] = {
- { 0, "family", ARG_INT, 0, { .d_num = af } },
- { 1, "type", ARG_INTMASK, 0, { .d_num = socket_types } },
- { 1, "flags", ARG_INTFLAGS, 0, { .d_num = socket_flags } },
- { 2, "protocol", ARG_INT, 0, { .d_num = protocols } },
+ { 0, "family", INT, 0, { .d_num = af } },
+ { 1, "type", INTMASK, 0, { .d_num = socket_types } },
+ { 1, "flags", INTFLAGS, 0, { .d_num = socket_flags } },
+ { 2, "protocol", INT, 0, { .d_num = protocols } },
{ 0 },
};
-static struct arg_struct connect_addr_unix[] = {
- { "path", ARG_STRING,
+static struct field connect_addr_unix[] = {
+ {
+ "path", STRING,
offsetof(struct sockaddr_un, sun_path),
- UNIX_PATH_MAX, { 0 }
+ UNIX_PATH_MAX, { 0 }
},
{ 0 },
};
-static struct arg_struct connect_addr_ipv4[] = {
- { "port", ARG_PORT,
+static struct field connect_addr_ipv4[] = {
+ {
+ "port", PORT,
offsetof(struct sockaddr_in, sin_port),
- 0, { 0 }
+ 0, { 0 }
},
- { "addr", ARG_IPV4,
+ {
+ "addr", IPV4,
offsetof(struct sockaddr_in, sin_addr),
- 0, { 0 }
+ 0, { 0 }
},
{ 0 },
};
-static struct arg_struct connect_addr_ipv6[] = {
- { "port", ARG_PORT,
+static struct field connect_addr_ipv6[] = {
+ {
+ "port", PORT,
offsetof(struct sockaddr_in6, sin6_port),
- 0, { 0 }
+ 0, { 0 }
},
- { "addr", ARG_IPV6,
+ {
+ "addr", IPV6,
offsetof(struct sockaddr_in6, sin6_addr),
- 0, { 0 }
+ 0, { 0 }
},
{ 0 },
};
-static struct arg_struct connect_addr_nl[] = {
- { "pid", ARG_PID,
+static struct field connect_addr_nl[] = {
+ {
+ "pid", PID,
offsetof(struct sockaddr_nl, nl_pid),
- 0, { 0 }
+ 0, { 0 }
},
- { "groups", ARG_U32,
+ {
+ "groups", U32,
offsetof(struct sockaddr_in6, sin6_addr),
- 0, { 0 }
+ 0, { 0 }
},
{ 0 },
};
-static struct arg_struct connect_family = {
- "family", ARG_INT,
- offsetof(struct sockaddr, sa_family),
- 0, { .d_num = af }
+static struct field connect_family = {
+ "family", INT,
+ offsetof(struct sockaddr, sa_family),
+ 0, { .d_num = af }
};
-static struct arg_select_num connect_addr_select_family[] = {
- { AF_UNIX, ARG_STRUCT, { .d_struct = connect_addr_unix } },
- { AF_INET, ARG_STRUCT, { .d_struct = connect_addr_ipv4 } },
- { AF_INET6, ARG_STRUCT, { .d_struct = connect_addr_ipv6 } },
- { AF_NETLINK, ARG_STRUCT, { .d_struct = connect_addr_nl } },
+static struct select_num connect_addr_select_family[] = {
+ { AF_UNIX, STRUCT, { .d_struct = connect_addr_unix } },
+ { AF_INET, STRUCT, { .d_struct = connect_addr_ipv4 } },
+ { AF_INET6, STRUCT, { .d_struct = connect_addr_ipv6 } },
+ { AF_NETLINK, STRUCT, { .d_struct = connect_addr_nl } },
{ 0 },
};
-static struct arg_select connect_addr_select = {
+static struct select connect_addr_select = {
&connect_family, { .d_num = connect_addr_select_family }
};
static struct arg connect_args[] = {
- { 0, "fd", ARG_INT, 0,
+ {
+ 0, "fd", INT, 0,
{ 0 },
},
- { 0, "path", ARG_FDPATH, 0,
+ {
+ 0, "path", FDPATH, 0,
{ 0 },
},
- { 1, "addr", ARG_SELECT, sizeof(struct sockaddr_storage),
+ {
+ 1, "addr", SELECT, sizeof(struct sockaddr_storage),
{ .d_select = &connect_addr_select },
},
- { 2, "addrlen", ARG_LONG, 0,
+ {
+ 2, "addrlen", LONG, 0,
{ 0 },
},
};