summaryrefslogtreecommitdiff
path: root/src/cmd/netstack/udp.c
diff options
context:
space:
mode:
authordzwdz2024-05-04 18:22:23 +0200
committerdzwdz2024-05-04 18:22:23 +0200
commit8c7b8d9e4ec40c38c657851354fc74428f0df1ac (patch)
tree29588306bd4453de86fc5a4ba230537f8f47bea5 /src/cmd/netstack/udp.c
parent32d7e504169351ce6a5542b4f559c7e4d3834b45 (diff)
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.
Diffstat (limited to 'src/cmd/netstack/udp.c')
-rw-r--r--src/cmd/netstack/udp.c11
1 files changed, 7 insertions, 4 deletions
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;