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 | |
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')
-rw-r--r-- | src/user/app/httpd/httpd.c | 2 | ||||
-rw-r--r-- | src/user/app/netstack/fs.c | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/user/app/httpd/httpd.c b/src/user/app/httpd/httpd.c index 1aaebc5..9141a39 100644 --- a/src/user/app/httpd/httpd.c +++ b/src/user/app/httpd/httpd.c @@ -65,7 +65,7 @@ static void handle(FILE *c) { } int main(int argc, char **argv) { - const char *path = (argc > 1) ? argv[1] : "/net/0.0.0.0/listen/tcp/80"; + const char *path = (argc > 1) ? argv[1] : "/net/listen/0.0.0.0/tcp/80"; handle_t conn; for (;;) { conn = _syscall_open(path, strlen(path), 0); 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); |