~kris/9p

9hist

7d152294b9fd9da1470b0266c63287f6f69a9607 — David du Colombier 27 years ago c19b796
Plan 9 from Bell Labs 1998-12-30
1 files changed, 22 insertions(+), 13 deletions(-)

M ip/rudp.c
M ip/rudp.c => ip/rudp.c +22 -13
@@ 301,7 301,7 @@ doipoput(Conv *c, Fs *f, Block *bp, int x, int ttl)
	Rudpcb *ucb;

	ucb = (Rudpcb*)c->ptcl;
	if(ucb->randdrop && nrand(10) == 1)
	if(ucb->randdrop && nrand(100) < ucb->randdrop)
		freeblist(bp);
	else
		ipoput(f, bp, x, ttl);


@@ 603,25 603,34 @@ rudpiput(Proto *rudp, uchar *ia, Block *bp)
	qunlock(ucb);
}

static char *rudpunknown = "unknown rudp ctl request";

char*
rudpctl(Conv *c, char **f, int n)
{
	Rudpcb *ucb;
	int x;

	ucb = (Rudpcb*)c->ptcl;
	if(n == 1){
		if(strcmp(f[0], "headers4") == 0){
			ucb->headers = 4;
			return nil;
		} else if(strcmp(f[0], "headers") == 0){
			ucb->headers = 6;
			return nil;
		} else if(strcmp(f[0], "randdrop") == 0){
			ucb->randdrop = 1;
			return nil;
		}
	if(n < 1)
		return rudpunknown;

	if(strcmp(f[0], "headers4") == 0){
		ucb->headers = 4;
		return nil;
	} else if(strcmp(f[0], "headers") == 0){
		ucb->headers = 6;
		return nil;
	} else if(strcmp(f[0], "randdrop") == 0){
		x = 10;		/* default is 10% */
		if(n > 1)
			x = atoi(f[1]);
		if(x > 100 || x < 0)
			return "illegal rudp drop rate";
		ucb->randdrop = x;
		return nil;
	}
	return "unknown control request";
	return rudpunknown;
}

void