diff options
author | dzwdz | 2022-09-04 12:51:14 +0200 |
---|---|---|
committer | dzwdz | 2022-09-04 12:51:14 +0200 |
commit | 15ab70762e4b0a78e6b0186771c726da38629b21 (patch) | |
tree | 94e6dbae1ace74453cf67616d3d84b4e9fbae6ec /src/user/app/netstack | |
parent | f71219e97a50fb0e3d7110f7706f48994bb0eacd (diff) |
user/netstack: make the verb the first component of the path
This makes filtering by the verb much easier, while filtering by the
local ip only slightly harder.
`whitelist /net/connect`
Diffstat (limited to 'src/user/app/netstack')
-rw-r--r-- | src/user/app/netstack/fs.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/user/app/netstack/fs.c b/src/user/app/netstack/fs.c index cbead8f..91e75ef 100644 --- a/src/user/app/netstack/fs.c +++ b/src/user/app/netstack/fs.c @@ -4,9 +4,9 @@ * raw ethernet frames (read-write) * /net/arp * ARP cache (currently read-only) - * /net/0.0.0.0/connect/1.2.3.4/udp/53 + * /net/connect/0.0.0.0/1.2.3.4/udp/53 * connect from 0.0.0.0 (any ip) to 1.2.3.4 on udp port 53 - * /net/0.0.0.0/listen/{tcp,udp}/53 + * /net/listen/0.0.0.0/{tcp,udp}/53 * waits for a connection to any ip on udp port 53 * open() returns once a connection to ip 0.0.0.0 on udp port 53 is received */ @@ -148,17 +148,18 @@ static void fs_open(handle_t reqh, char *path, int flags) { char *save; const char *verb, *proto, *port_s; - uint32_t srcip, dstip; - if (ip_parse(strtok_r(path, "/", &save), &srcip) < 0) + + verb = strtok_r(path, "/", &save); + if (!verb) respond(NULL, -1); + + if (ip_parse(strtok_r(NULL, "/", &save), &srcip) < 0) respond(NULL, -1); if (srcip != 0) { eprintf("unimplemented"); respond(NULL, -1); } - verb = strtok_r(NULL, "/", &save); - if (!verb) respond(NULL, -1); if (strcmp(verb, "listen") == 0) { proto = strtok_r(NULL, "/", &save); if (!proto) respond(NULL, -1); |