From 9fbb2d1c22fcc438e4514fffdb13faa44a97dc6a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 17 Sep 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-09-17 --- ip/il.c | 39 ++++++++++++++++++++++++++++++++++++++- ip/ip.c | 5 ++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ip/il.c b/ip/il.c index e6123f89f6d27d131fef08e61ddaa57158c89880..33391b729a4fdc83f6939aca7b579f8beaa7d85b 100644 --- a/ip/il.c +++ b/ip/il.c @@ -191,6 +191,7 @@ void iladvise(Proto*, Block*, char*); int ilnextqt(Ilcb*); void ilcbinit(Ilcb*); int later(ulong, ulong, char*); +void ilreject(Fs*, Ilhdr*); int ilcksum = 1; static int initseq = 25001; @@ -543,6 +544,7 @@ iliput(Proto *il, uchar*, Block *bp) st = "?"; else st = iltype[ih->iltype]; + ilreject(il->f, ih); /* no channel and not sync */ netlog(il->f, Logil, "il: no channel, pkt(%s id %lud ack %lud %I/%ud->%ud)\n", st, nhgetl(ih->ilid), nhgetl(ih->ilack), raddr, sp, dp); goto raise; @@ -573,6 +575,7 @@ iliput(Proto *il, uchar*, Block *bp) s = gen; else { qunlock(il); + ilreject(il->f, ih); /* no listener */ goto raise; } @@ -646,7 +649,7 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp) break; case Ilclose: if(ack == ic->start) - ilhangup(s, "remote close"); + ilhangup(s, "connection rejected"); break; } freeblist(bp); @@ -728,6 +731,7 @@ _ilprocess(Conv *s, Ilhdr *h, Block *bp) freeblist(bp); if(ack < ic->start || ack > ic->next) break; + ic->recvd = id; ilsendctl(s, nil, Ilclose, ic->next, ic->recvd, 0); ic->state = Ilclosing; ilsettimeout(ic); @@ -993,6 +997,39 @@ ilsendctl(Conv *ipc, Ilhdr *inih, int type, ulong id, ulong ack, int ilspec) ipoput(ipc->p->f, bp, 0, ttl, tos); } +void +ilreject(Fs *f, Ilhdr *inih) +{ + Ilhdr *ih; + Block *bp; + + bp = allocb(IL_IPSIZE+IL_HDRSIZE); + bp->wp += IL_IPSIZE+IL_HDRSIZE; + + ih = (Ilhdr *)(bp->rp); + + /* Ip fields */ + ih->proto = IP_ILPROTO; + hnputs(ih->illen, IL_HDRSIZE); + ih->frag[0] = 0; + ih->frag[1] = 0; + hnputl(ih->dst, nhgetl(inih->src)); + hnputl(ih->src, nhgetl(inih->dst)); + hnputs(ih->ilsrc, nhgets(inih->ildst)); + hnputs(ih->ildst, nhgets(inih->ilsrc)); + hnputl(ih->ilid, nhgetl(inih->ilack)); + hnputl(ih->ilack, nhgetl(inih->ilid)); + ih->iltype = Ilclose; + ih->ilspec = 0; + ih->ilsum[0] = 0; + ih->ilsum[1] = 0; + + if(ilcksum) + hnputs(ih->ilsum, ptclcsum(bp, IL_IPSIZE, IL_HDRSIZE)); + + ipoput(f, bp, 0, MAXTTL, DFLTTOS); +} + void ilsettimeout(Ilcb *ic) { diff --git a/ip/ip.c b/ip/ip.c index 429cd381c89930a0ea5fd6052f4ca7f86ab99121..778ec984f75e21dd36ab70c0ba72fd0d8087ca5d 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -182,10 +182,9 @@ ipoput(Fs *f, Block *bp, int gating, int ttl, int tos) if(!gating){ eh->vihl = IP_VER|IP_HLEN; - eh->tos = 0; + eh->ttl = ttl; + eh->tos = tos; } - eh->ttl = ttl; - eh->tos = tos; if(!canrlock(ifc)) goto free;