From cce53a3507eda6894840e47ee7335dbd6b6cd401 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 5 Dec 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-12-05 --- port/stlapd.c | 63 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/port/stlapd.c b/port/stlapd.c index 4e7a8f82a1cfbb8e5468ee784c54bb8150d7e76b..8820b5e5170ef73f65a423ce244b9bae9af55002 100644 --- a/port/stlapd.c +++ b/port/stlapd.c @@ -202,19 +202,25 @@ lapdopen(Queue *q, Stream *s) static void mdl_assign(Lapd *lp) { + char buf[ERRLEN]; + qlock(lp); - if (lp->state != NoTEI) { + if(lp->state != NoTEI){ qunlock(lp); - error(Egreg); + sprint(buf, "mdl_assign: state=%d", lp->state); + kprint("%s\n", buf); + error(buf); } lp->state = WaitTEI; assigntei(lp); lp->t200 = T200; qunlock(lp); sleep(lp, pTEIassigned, lp); - if (lp->state != TEIassigned){ - lapdclose(lp->rq); - error(Egreg); + if(lp->state != TEIassigned){ + /*lapdclose(lp->rq);*/ + sprint(buf, "mdl_assign failed: state=%d", lp->state); + kprint("%s\n", buf); + error(buf); } } @@ -243,29 +249,39 @@ assigntei(Lapd *lp) static void dl_establish(Lapd *lp) { + char buf[ERRLEN]; + qlock(lp); - if (lp->state != TEIassigned) { + if(lp->state != TEIassigned){ qunlock(lp); - error(Egreg); + sprint(buf, "dl_establish: state=%d", lp->state); + kprint("%s\n", buf); + error(buf); } lp->state = WaitEst; sendctl(lp, UCmd, SABME, 0); lp->t200 = T200; qunlock(lp); sleep(lp, pMultiframe, lp); - if (lp->state != Multiframe){ - lapdclose(lp->rq); - error(Egreg); + if(lp->state != Multiframe){ + /*lapdclose(lp->rq);*/ + sprint(buf, "dl_establish failed: state=%d", lp->state); + kprint("%s\n", buf); + error(buf); } } static void dl_release(Lapd *lp) { + char buf[ERRLEN]; + qlock(lp); - if (lp->state != Multiframe) { + if(lp->state != Multiframe){ qunlock(lp); - error(Egreg); + sprint(buf, "dl_release: state=%d", lp->state); + kprint("%s\n", buf); + error(buf); } lp->state = WaitRel; sendctl(lp, UCmd, DISC, 0); @@ -287,17 +303,16 @@ lapdclose(Queue *q) if(lp == 0) return; - if (lp->state == Multiframe) { + if(lp->state == Multiframe){ for(i=0; itr, tEmpty, lp, 2500); /* drain */ dl_release(lp); /* DISC to NT */ - for(i=0; ioutb[i]){ - freeb(lp->outb[i]); - lp->outb[i] = 0; - } } - + for(i=0; ioutb[i]){ + freeb(lp->outb[i]); + lp->outb[i] = 0; + } lp->flags |= Hungup; /* tell kernel proc */ lp->t200 = NOW; wakeup(&lp->timer); @@ -561,6 +576,16 @@ mdl_iput(Queue *q, Block *bp) } else lapderror(lp, Badassign); break; + case 6: /* identity removal */ + DPRINT("id removal: ai=%d\n", ai); + if(lp->state >= TEIassigned && (ai == lp->tei || ai == 127)){ + Block *b = allocb(0); + lp->state = NoTEI; + DPRINT("lapd hangup\n"); + b->type = M_HANGUP; + PUTNEXT(lp->rq, b); + } + break; default: { Block *b = allocb(0);