From 1d040510bb5ad54b7cd19b7116d2f12b00ab512b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 17 Jul 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-07-17 --- port/devdk.c | 61 +++++++++++++++++++++++++++++++++++++------------ port/devip.c | 4 ++-- port/devlance.c | 6 ++++- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/port/devdk.c b/port/devdk.c index 8392530efb3cc55762fea41a6e11e57b5acac25f..a4265f88161ec00d351ce5ffa02c975e1965fe71 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -96,7 +96,6 @@ struct Line { char addr[64]; char raddr[64]; char ruser[32]; - char other[32]; Dk *dp; /* interface contianing this line */ }; @@ -140,6 +139,18 @@ typedef enum { Lackwait, /* incoming call waiting for ack/nak */ Laccepting, /* waiting for user to accept or reject the call */ } Lstate; +char *dkstate[] = +{ + [Lclosed] "Closed", + [Lopened] "Opened", + [Lconnected] "Established", + [Lrclose] "Rclose", + [Llclose] "Lclose", + [Ldialing] "Dialing", + [Llistening] "Listen", + [Lackwait] "Ackwait", + [Laccepting] "Accepting", +}; /* * map datakit error to errno @@ -197,7 +208,7 @@ static int dklisten(Chan*); static void dkfilladdr(Chan*, char*, int); static void dkfillraddr(Chan*, char*, int); static void dkfillruser(Chan*, char*, int); -static void dkfillother(Chan*, char*, int); +static void dkfillstatus(Chan*, char*, int); extern Qinfo dkinfo; @@ -577,16 +588,16 @@ dkmuxconfig(Queue *q, Block *bp) dp->net.listen = dklisten; dp->net.clone = dkcloneline; dp->net.ninfo = 5; - dp->net.info[0].name = "addr"; + dp->net.info[0].name = "local"; dp->net.info[0].fill = dkfilladdr; - dp->net.info[1].name = "raddr"; + dp->net.info[1].name = "remote"; dp->net.info[1].fill = dkfillraddr; dp->net.info[2].name = "ruser"; dp->net.info[2].fill = dkfillruser; - dp->net.info[3].name = "stats"; + dp->net.info[3].name = "urpstats"; dp->net.info[3].fill = urpfillstats; - dp->net.info[4].name = "other"; - dp->net.info[4].fill = dkfillother; + dp->net.info[4].name = "status"; + dp->net.info[4].fill = dkfillstatus; dp->restart = restart; dp->urpwindow = window; dp->wq = WR(q); @@ -858,22 +869,38 @@ dkopencsc(Dk *dp) void dkfilladdr(Chan *c, char *buf, int len) { - strncpy(buf, dk[c->dev]->linep[STREAMID(c->qid.path)]->addr, len); + if(len < sizeof(dk[0]->linep[0]->addr)+2) + error(Ebadarg); + sprint(buf, "%s\n", dk[c->dev]->linep[STREAMID(c->qid.path)]->addr); } void dkfillraddr(Chan *c, char *buf, int len) { - strncpy(buf, dk[c->dev]->linep[STREAMID(c->qid.path)]->raddr, len); + if(len < sizeof(dk[0]->linep[0]->raddr)+2) + error(Ebadarg); + sprint(buf, "%s\n", dk[c->dev]->linep[STREAMID(c->qid.path)]->raddr); } void dkfillruser(Chan *c, char *buf, int len) { - strncpy(buf, dk[c->dev]->linep[STREAMID(c->qid.path)]->ruser, len); + if(len < sizeof(dk[0]->linep[0]->ruser)+2) + error(Ebadarg); + sprint(buf, "%s\n", dk[c->dev]->linep[STREAMID(c->qid.path)]->ruser); } void -dkfillother(Chan *c, char *buf, int len) +dkfillstatus(Chan *c, char *buf, int len) { - strncpy(buf, dk[c->dev]->linep[STREAMID(c->qid.path)]->other, len); + Dk *dp; + Line *lp; + int line; + char lbuf[65]; + + line = STREAMID(c->qid.path); + dp = dk[c->dev]; + lp = linealloc(dp, line, 1); + sprint(lbuf, "%s/%d %d %s window %d\n", dp->name, line, + lp->state != Lclosed ? 1 : 0, dkstate[lp->state], lp->window); + strncpy(buf, lbuf, len); } /* @@ -1082,7 +1109,6 @@ dkcall(int type, Chan *c, char *addr, char *nuser, char *machine) */ strncpy(lp->addr, addr, sizeof(lp->addr)-1); strncpy(lp->raddr, addr, sizeof(lp->raddr)-1); - sprint(lp->other, "w=%d", lp->window); /* * reset the protocol @@ -1105,6 +1131,7 @@ dklisten(Chan *c) int from; Chan *dc; static int dts; + char *cp; dp = dk[c->dev]; from = STREAMID(c->qid.path); @@ -1213,9 +1240,15 @@ dklisten(Chan *c) /* * Line 1 is `my-dk-name.service[.more-things]'. - * Special characters are escaped by '\'s. + * Special characters are escaped by '\'s. Convert to + * a plan 9 address, i.e. system!service. */ strncpy(lp->addr, line[1], sizeof(lp->addr)-1); + if(cp = strchr(lp->addr, '.')){ + *cp = '!'; + if(cp = strchr(cp, '.')) + *cp = 0; + } /* * the rest is variable length diff --git a/port/devip.c b/port/devip.c index 7f216a2b4ddcbd22b6fac119ea782e2ebb3c3f14..7e6e207b04cbb7deeb7419a74d4553bc8eff45ca 100644 --- a/port/devip.c +++ b/port/devip.c @@ -712,7 +712,7 @@ ipremotefill(Chan *c, char *buf, int len) if(len < 24) error(Ebadarg); cp = ipcreateconv(ipifc[c->dev], STREAMID(c->qid.path)); - sprint(buf, "%d.%d.%d.%d %d\n", fmtaddr(cp->dst), cp->pdst); + sprint(buf, "%d.%d.%d.%d!%d\n", fmtaddr(cp->dst), cp->pdst); } void @@ -723,7 +723,7 @@ iplocalfill(Chan *c, char *buf, int len) if(len < 24) error(Ebadarg); cp = ipcreateconv(ipifc[c->dev], STREAMID(c->qid.path)); - sprint(buf, "%d.%d.%d.%d %d\n", fmtaddr(Myip[Myself]), cp->psrc); + sprint(buf, "%d.%d.%d.%d!%d\n", fmtaddr(Myip[Myself]), cp->psrc); } void diff --git a/port/devlance.c b/port/devlance.c index 07df4afe04667eb095e7d47184d278312e69e958..462b35bd8dba797708ff94f23b639b772a1b855f 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -765,8 +765,8 @@ lanceup(Etherpkt *p, int len) bp->wptr += len; bp->flags |= S_DELIM; PUTNEXT(e->q, bp); + poperror(); } - poperror(); qunlock(e); } } @@ -794,6 +794,10 @@ lancekproc(void *arg) Block *bp; USED(arg); + + while(waserror()) + print("lancekproc err %s\n", u->error); + for(;;){ qlock(&l.rlock); while(bp = getq(&l.self)){