From 9201820097ef333e967f72450dc18ea727c30e2e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 24 Aug 2022 00:22:48 +0200 Subject: user/netstack: TCP outgoing I got on IRC! --- src/user/app/netstack/fs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/user/app/netstack/fs.c') diff --git a/src/user/app/netstack/fs.c b/src/user/app/netstack/fs.c index b50e778..f4d9625 100644 --- a/src/user/app/netstack/fs.c +++ b/src/user/app/netstack/fs.c @@ -185,6 +185,25 @@ static void fs_open(handle_t reqh, char *path) { respond(NULL, -1); proto = strtok_r(NULL, "/", &save); if (!proto) respond(NULL, -1); + if (strcmp(proto, "tcp") == 0) { + port_s = strtok_r(NULL, "/", &save); + if (port_s) { + uint16_t port = strtol(port_s, NULL, 0); + h = malloc(sizeof *h); + memset(h, 0, sizeof *h); + h->type = H_TCP; + h->tcp.c = tcpc_new((struct tcp){ + .dst = port, + .ip.dst = dstip, + }, tcp_recv_callback, tcp_close_callback, h); + if (h->tcp.c) { + respond(h, 0); + } else { + free(h); + respond(NULL, -1); + } + } + } if (strcmp(proto, "udp") == 0) { port_s = strtok_r(NULL, "/", &save); if (port_s) { -- cgit v1.2.3