From 8c7b8d9e4ec40c38c657851354fc74428f0df1ac Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 4 May 2024 18:22:23 +0200 Subject: user/ntpfs: implement a basic ntp client time() will probably end up doing io. That sounded bad at first, but Plan 9 does that too (see /sys/src/libc/9sys/nsec.c), so it's probably fine. I might need better service management soon. Also, dunno what it should return before it makes contact with NTP. I could implement RTC support, but eh. Doesn't feel that necessary. I'll also need to remember how the hell threading works, so it can talk with the ntp daemon on another thread. --- src/cmd/netstack/udp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/cmd/netstack/udp.c') diff --git a/src/cmd/netstack/udp.c b/src/cmd/netstack/udp.c index 285af41..3b53b47 100644 --- a/src/cmd/netstack/udp.c +++ b/src/cmd/netstack/udp.c @@ -55,10 +55,13 @@ struct udp_conn *udpc_new( c->lport = u.src ? u.src : 50000; // TODO randomize source ports c->rport = u.dst; if (arpcache_get(c->rip, &c->rmac) < 0) { - // TODO make arp request, wait for reply - warnx("IP not in ARP cache, unimplemented"); - free(c); - return NULL; + // TODO wait for ARP reply + arp_request(c->rip); + if (arpcache_get(state.gateway, &c->rmac) < 0) { + warnx("neither target nor gateway not in ARP cache, dropping"); + free(c); + return NULL; + } } c->on_recv = on_recv; c->carg = carg; -- cgit v1.2.3