aboutsummaryrefslogtreecommitdiff
path: root/muswd.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-03-04 23:32:47 +0000
committerrodri <rgl@antares-labs.eu>2023-03-04 23:32:47 +0000
commit941d146cea7d0c2ce872e599622a5c9e01d37fe2 (patch)
tree0fe67a2d7f4f906b1e33acee2b1d70d2e03e1fa5 /muswd.c
parent9712ec712cc6a57d416ef2b1e86d15ef161016df (diff)
downloadmusw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.tar.gz
musw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.tar.bz2
musw-941d146cea7d0c2ce872e599622a5c9e01d37fe2.zip
implemented client reconnection loop.
currently not working. there seems to be a problem with 9front's udp stack. needs investigation.
Diffstat (limited to 'muswd.c')
-rw-r--r--muswd.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/muswd.c b/muswd.c
index fd4f183..cc5c73a 100644
--- a/muswd.c
+++ b/muswd.c
@@ -98,14 +98,22 @@ nudgeconns(ulong curts)
elapsed = curts - (*ncp)->lastrecvts;
elapsednudge = curts - (*ncp)->lastnudgets;
- if((*ncp)->state == NCSConnected && elapsed > ConnTimeout)
- popconn(*ncp);
- else if((*ncp)->state == NCSConnected && elapsednudge > 1000){ /* every second */
- f = newframe(&(*ncp)->udp, NSnudge, (*ncp)->lastseq+1, 0, 0, nil);
- signframe(f, (*ncp)->dh.priv);
- sendp(egress, f);
-
- (*ncp)->lastnudgets = curts;
+ switch((*ncp)->state){
+ case NCSConnected:
+ if(elapsed > ConnTimeout)
+ popconn(*ncp);
+ else if(elapsednudge > 1000){ /* every second */
+ f = newframe(&(*ncp)->udp, NSnudge, (*ncp)->lastseq+1, 0, 0, nil);
+ signframe(f, (*ncp)->dh.priv);
+ sendp(egress, f);
+
+ (*ncp)->lastnudgets = curts;
+ }
+ break;
+ case NCSConnecting:
+ if(elapsed > ConnTimeout)
+ popconn(*ncp);
+ break;
}
}
}
@@ -132,7 +140,7 @@ threadnetrecv(void *arg)
if(debug){
rport = frame->udp.rport[0]<<8 | frame->udp.rport[1];
lport = frame->udp.lport[0]<<8 | frame->udp.lport[1];
- fprint(2, "%I!%ud → %I!%ud | rcvd %Φ\n",
+ fprint(2, "%I!%ud ← %I!%ud | rcvd %Φ\n",
frame->udp.laddr, lport, frame->udp.raddr, rport, frame);
}
}