~kris/9p

9hist

b0e93d4b1a61d19d99de24b2c18922a5c9502679 — David du Colombier 29 years ago 20f0d54
Plan 9 from Bell Labs 1997-05-08
1 files changed, 13 insertions(+), 12 deletions(-)

M ip/devip.c
M ip/devip.c => ip/devip.c +13 -12
@@ 500,26 500,27 @@ setlport(Conv* c)
	int x, found;

	p = c->p;
	/*
	 * For compatibility with old Plan9/Brazil systems restrict
	 * the port number for now such that it can't sign-extend on
	 * the other end.
	 */
	while(p->nextport < 5000 || p->nextport >= (1<<15))
		p->nextport = nrand(1<<16);

	if(c->restricted)
		pp = &p->nextrport;
	else
		pp = &p->nextport;
	lock(p);
	for(;;(*pp)++){
		if(*pp == 0 || *pp >= (1<<15)) {	/* BSD hack */
			if(c->restricted)
		/*
		 * Fsproto initialises p->nextport to 0 and the restricted
		 * ports (p->nextrport) to 600.
		 * Restricted ports must lie between 600 and 1024.
		 * For the initial condition or if the unrestricted port number
		 * has wrapped round, select a random port between 5000 and 1<<16
		 * to start at.
		 */
		if(c->restricted){
			if(*pp >= 1024)
				*pp = 600;
			else
				*pp = 5000;
		}
		else while(*pp < 5000)
			*pp = nrand(1<<16);

		found = 0;
		for(x = 0; x < p->nc; x++){
			if(p->conv[x] == nil)