From b0e93d4b1a61d19d99de24b2c18922a5c9502679 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 8 May 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-05-08 --- ip/devip.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ip/devip.c b/ip/devip.c index fce852f6f2ece87920f5619369fad6917a42d798..63f3384250d7f31f8b94daaaa6f611989a7d697b 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -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)