plan 9 kernel history: overview | file list | diff list

1991/0108/port/devnonet.c (diff list | history)

1991/0102/sys/src/9/port/devnonet.c:16,221991/0108/sys/src/9/port/devnonet.c:16,22 (short | long | prev | next)
1990/1210    
	/* 
	 *  tuning parameters 
	 */ 
1990/1229    
	MSrexmit = 500,		/* retranmission interval in ms */ 
1991/0108    
	MSrexmit = 250,		/* retranmission interval in ms */ 
1990/1210    
	MSack = 50,		/* ms to sit on an ack */ 
 
	/* 
1991/0102/sys/src/9/port/devnonet.c:37,431991/0108/sys/src/9/port/devnonet.c:37,43
1990/1210    
static void	sendmsg(Noconv*, Nomsg*); 
static void	startconv(Noconv*, int, char*, int); 
static void	queueack(Noconv*, int); 
                 
1991/0108    
static void	nonetkproc(void*); 
1990/1210    
static void	nonetiput(Queue*, Block*); 
static void	nonetoput(Queue*, Block*); 
static void	nonetstclose(Queue*); 
1991/0102/sys/src/9/port/devnonet.c:89,941991/0108/sys/src/9/port/devnonet.c:89,100
1990/1210    
}; 
 
/* 
1991/0108    
 *  nonet kproc 
 */ 
static int kstarted; 
static Rendez nonetkr; 
 
/* 
1990/1210    
 *  nonet file system.  most of the calls use dev.c to access the nonet 
 *  directory and stream.c to access the nonet devices. 
 *  create the nonet directory.  the files are `clone' and stream 
1991/0102/sys/src/9/port/devnonet.c:164,1691991/0108/sys/src/9/port/devnonet.c:170,176
1990/1210    
		error(Enoifc); 
	c = devattach('n', spec); 
	c->dev = ifc - noifc; 
1991/0108    
 
1990/1210    
	return c; 
} 
 
1991/0102/sys/src/9/port/devnonet.c:240,2451991/0108/sys/src/9/port/devnonet.c:247,257
1990/1210    
	Noifc *ifc; 
	int line; 
 
1991/0108    
	if(!kstarted){ 
		kproc("nonetack", nonetkproc, 0); 
		kstarted = 1; 
	} 
 
1990/1210    
	if(c->qid.path & CHDIR){ 
		/* 
		 *  directories are read only 
1991/0102/sys/src/9/port/devnonet.c:466,4731991/0108/sys/src/9/port/devnonet.c:478,487
1990/1210    
		} 
	} 
 
1991/0108    
	qlock(cp); 
1990/1210    
	cp->rcvcircuit = -1; 
	cp->state = Cclosed; 
1991/0108    
	qunlock(cp); 
1990/1210    
	poperror(); 
} 
 
1991/0102/sys/src/9/port/devnonet.c:511,5161991/0108/sys/src/9/port/devnonet.c:525,531
1990/1210    
	Noconv *cp; 
	int next; 
	Nomsg *mp; 
1991/0108    
	int retries; 
1990/1210    
 
	cp = (Noconv *)(q->ptr); 
 
1991/0102/sys/src/9/port/devnonet.c:573,5811991/0108/sys/src/9/port/devnonet.c:588,599
1990/1210    
	/* 
	 *  wait for acknowledgement 
	 */ 
1991/0108    
	retries = 0; 
1990/1210    
	while(!mp->acked && cp->state!=Chungup){ 
		sendmsg(cp, mp); 
		tsleep(&mp->r, acked, mp, MSrexmit); 
1991/0108    
		if(retries++ > 100) 
			errors("to many nonet rexmits"); 
1990/1210    
	} 
 
	/* 
1991/0102/sys/src/9/port/devnonet.c:704,7121991/0108/sys/src/9/port/devnonet.c:722,730
1990/1210    
		cp->hdr->flag |= NO_SERVICE; 
		sprint(buf, "%s %s", service, u->p->pgrp->user); 
		c->qid.path = STREAMQID(STREAMID(c->qid.path), Sdataqid); 
1990/1231    
		print("sending request\n"); 
1991/0108    
		DPRINT("sending request\n"); 
1990/1210    
		streamwrite(c, buf, strlen(buf), 1); 
1990/1231    
		print("request sent\n"); 
1991/0108    
		DPRINT("request sent\n"); 
1990/1210    
		c->qid.path = STREAMQID(STREAMID(c->qid.path), Sctlqid); 
	} 
} 
1991/0102/sys/src/9/port/devnonet.c:783,7911991/0108/sys/src/9/port/devnonet.c:801,809
1990/1210    
		 *  stuff the connect message into it 
		 */ 
		f = ((Nohdr *)(call.msg->rptr))->flag; 
1990/1231    
		print("call from %d %s\n", call.circuit, call.raddr); 
1991/0108    
		DPRINT("call from %d %s\n", call.circuit, call.raddr); 
1990/1210    
		startconv(cp, call.circuit, call.raddr, Cconnecting); 
		print("rcving %d byte message\n", call.msg->wptr - call.msg->rptr); 
1991/0108    
		DPRINT("rcving %d byte message\n", call.msg->wptr - call.msg->rptr); 
1990/1210    
		nonetrcvmsg(cp, call.msg); 
		call.msg = 0; 
 
1991/0102/sys/src/9/port/devnonet.c:794,8081991/0108/sys/src/9/port/devnonet.c:812,824
1990/1210    
		 *  grab them 
		 */ 
		if(f & NO_SERVICE){ 
			print("reading service\n"); 
1991/0108    
			DPRINT("reading service\n"); 
1990/1210    
			c->qid.path = STREAMQID(cp - ifc->conv, Sdataqid); 
			n = streamread(c, buf, sizeof(buf)); 
			c->qid.path = STREAMQID(cp - ifc->conv, Sctlqid); 
			print("read %d bytes\n", n); 
			if(n <= 0) 
				error(Ebadctl); 
			buf[n] = 0; 
			print("read %s\n", buf); 
			user = strchr(buf, ' '); 
			if(user){ 
				*user++ = 0; 
1991/0102/sys/src/9/port/devnonet.c:1056,10621991/0108/sys/src/9/port/devnonet.c:1072,1078
1990/1210    
	 *  ignore old messages and process the acknowledgement 
	 */ 
	if(h->mid != mp->mid){ 
		DPRINT("old msg %d instead of %d\n", h->mid, mp->mid); 
1991/0108    
		DPRINT("old msg %d instead of %d r==%d\n", h->mid, mp->mid, r); 
1990/1210    
		if(r == 0){ 
			rcvack(cp, h->ack); 
			if(f & NO_HANGUP) 
1991/0102/sys/src/9/port/devnonet.c:1063,10701991/0108/sys/src/9/port/devnonet.c:1079,1086
1990/1210    
				hangup(cp); 
		} else { 
1991/0102    
			if(r>0){ 
1991/0108    
				rcvack(cp, h->ack); 
1991/0102    
				queueack(cp, h->mid); 
				sendctlmsg(cp, 0, 0); 
			} 
1990/1210    
			cp->bad++; 
		} 
1991/0102/sys/src/9/port/devnonet.c:1238,12441991/0108/sys/src/9/port/devnonet.c:1254,1300
1990/1210    
	return s & 0xffff; 
1990/1229    
} 
 
1991/0108    
/* 
 *  send acknowledges that need to be sent.  this happens at 1/2 
 *  the retransmission interval. 
 */ 
static void 
nonetkproc(void *arg) 
{ 
	Noifc *ifc; 
	Noconv *cp, *ep; 
 
	cp = 0; 
	ifc = 0; 
	if(waserror()){ 
		if(ifc) 
			unlock(ifc); 
		if(cp) 
			qunlock(cp); 
	} 
 
loop: 
	for(ifc = noifc; ifc < &noifc[conf.nnoifc]; ifc++){ 
		if(ifc->wq==0 || !canlock(ifc)) 
			continue; 
		ep = ifc->conv + conf.nnoconv; 
		for(cp = ifc->conv; cp < ep; cp++){ 
			if(cp->state==Cclosed || !canqlock(cp)) 
				continue; 
			if(cp->afirst != cp->anext){ 
				DPRINT("sending ack %d\n", cp->ack[cp->afirst]); 
				sendctlmsg(cp, 0, 0); 
			} 
			qunlock(cp); 
		} 
		unlock(ifc); 
	} 
	tsleep(&nonetkr, return0, 0, MSrexmit/2); 
	goto loop; 
} 
 
1990/1229    
nonettoggle() 
{ 
	pnonet ^= 1; 
1990/1210    
} 
1991/0108    
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)