~kris/9p

9hist

de44ee0db0e4ef787d36b14b3da52f55dd4e40c7 — David du Colombier 28 years ago 59f7739
Plan 9 from Bell Labs 1998-07-09
2 files changed, 16 insertions(+), 9 deletions(-)

M ip/devip.c
M ip/ipifc.c
M ip/devip.c => ip/devip.c +1 -2
@@ 573,8 573,7 @@ ipread(Chan *ch, void *a, long n, vlong off)
		buf = smalloc(Statelen);
		x = f->p[PROTO(ch->qid)];
		c = x->conv[CONV(ch->qid)];
		m = sprint(buf, "%s/%d %d ", c->p->name, c->x, c->inuse);
		(*x->state)(c, buf, Statelen-m-2);
		(*x->state)(c, buf, Statelen-2);
		rv = readstr(offset, p, n, buf);
		free(buf);
		return rv;

M ip/ipifc.c => ip/ipifc.c +15 -7
@@ 135,7 135,11 @@ ipifcbind(Conv *c, char **argv, int argc)
	ifc->m = m;
	ifc->minmtu = ifc->m->minmtu;
	ifc->maxmtu = ifc->m->maxmtu;
	ifc->conv->inuse++;
	if(ifc->m->unbindonclose == 0){
		lock(ifc->conv);
		ifc->conv->inuse++;
		unlock(ifc->conv);
	}
	ifc->ifcid++;

	wunlock(ifc);


@@ 161,11 165,16 @@ ipifcunbind(Ipifc *ifc)
	wlock(ifc);

	/* dissociate routes */
	ifc->conv->inuse--;
	if(ifc->m != nil && ifc->m->unbindonclose == 0){
		lock(ifc->conv);
		ifc->conv->inuse--;
		unlock(ifc->conv);
	}
	ifc->ifcid++;

	/* disassociate device */
	(*ifc->m->unbind)(ifc);
	if(ifc->m != nil && ifc->m->unbind)
		(*ifc->m->unbind)(ifc);
	memset(ifc->dev, 0, sizeof(ifc->dev));
	ifc->arg = nil;



@@ 199,15 208,14 @@ ipifcstate(Conv *c, char *state, int n)

	ifc = (Ipifc*)c->ptcl;

	m = snprint(state, n, "%-12.12s %-5d", ifc->dev, ifc->maxmtu);

	rlock(ifc);
	m = 0;
	for(lifc = ifc->lifc; lifc; lifc = lifc->next) {
		m += snprint(state, n, "%-12.12s %-5d", ifc->dev, ifc->maxmtu);
	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
		m += snprint(state+m, n - m,
			" %-20.20I %-20.20M %-20.20I %-7d %-7d %-7d %-7d\n",
				lifc->local, lifc->mask, lifc->remote,
				ifc->in, ifc->out, ifc->inerr, ifc->outerr);
	}
	runlock(ifc);
	return m;
}