~kris/9p

9hist

5d6619a9181e92bf003047d9ffc6a0585a07720d — David du Colombier 33 years ago 09d129d
Plan 9 from Bell Labs 1993-02-20
5 files changed, 49 insertions(+), 36 deletions(-)

M pc/adaptec.c
M pc/trap.c
M port/ipdat.h
M port/tcpinput.c
M port/tcpoutput.c
M pc/adaptec.c => pc/adaptec.c +1 -1
@@ 485,7 485,7 @@ resetscsi(void)
	outb(port+Rc, Srst|Scrst);
	delay(500);
	if((rs = inb(port+Rs)) != (Init|Idle)){
		print("adaptec%d: reset status #%2.2ux\n", 0, rs);
		/*print("adaptec%d: reset status #%2.2ux\n", 0, rs);/**/
		return;
	}


M pc/trap.c => pc/trap.c +4 -1
@@ 43,6 43,7 @@ int	int1mask = 0xff;	/* interrupts enabled for second 8259 */
 *  trap/interrupt gates
 */
Segdesc ilt[256];
int	badtrap[256];

typedef struct Handler	Handler;
struct Handler


@@ 261,7 262,9 @@ trap(Ureg *ur)
				panic("%s pc=0x%lux", excname[v], ur->pc);
			}
		}
		print("bad trap type %d pc=0x%lux\n", v, ur->pc);
		if(badtrap[v]++ < 10 || (badtrap[v]%1000) == 0)
			print("bad trap type %d pc=0x%lux: total %d\n", v, ur->pc,
				badtrap[v]);
		return;
	}


M port/ipdat.h => port/ipdat.h +18 -18
@@ 208,20 208,20 @@ struct Tctl
	uchar	type;			/* Listening or active connection */
	uchar	code;			/* Icmp code */		
	struct {
		int	una;		/* Unacked data pointer */
		int	nxt;		/* Next sequence expected */
		int	ptr;		/* Data pointer */
		ulong	una;		/* Unacked data pointer */
		ulong	nxt;		/* Next sequence expected */
		ulong	ptr;		/* Data pointer */
		ushort	wnd;		/* Tcp send window */
		int	up;		/* Urgent data pointer */
		int	wl1;
		int	wl2;
		ulong	up;		/* Urgent data pointer */
		ulong	wl1;
		ulong	wl2;
	} snd;
	struct {
		ulong	nxt;		/* Receive pointer to next byte slot */
		ushort	wnd;		/* Receive window incoming */
		int	up;		/* Urgent pointer */
		ulong	up;		/* Urgent pointer */
	} rcv;
	int	iss;			/* Initial sequence number */
	ulong	iss;			/* Initial sequence number */
	ushort	cwind;			/* Congestion window */
	ushort	ssthresh;		/* Slow start threshold */
	int	resent;			/* Bytes just resent */


@@ 248,7 248,7 @@ struct Tctl
	Timer	timer;			/* Activity timer */
	Timer	acktimer;		/* Acknoledge timer */
	Timer	rtt_timer;		/* Round trip timer */
	int	rttseq;			/* Round trip sequence */
	ulong	rttseq;			/* Round trip sequence */
	int	srtt;			/* Shortened round trip */
	int	mdev;			/* Mean deviation of round trip */
};


@@ 264,8 264,8 @@ struct	Tcp
{
	Port	source;
	Port	dest;
	int	seq;
	int	ack;
	ulong	seq;
	ulong	ack;
	char	flags;
	ushort	wnd;
	ushort	up;


@@ 477,13 477,13 @@ ushort	ptcl_csum(Block*bp, int, int);
int	pullb(Block **, int);
void	reset(Ipaddr, Ipaddr, char, ushort, Tcp*);
void	tcpsndsyn(Tcpctl*);
int	seq_ge(int, int);
int	seq_gt(int, int);
int	seq_gt(int, int);
int	seq_le(int, int);
int	seq_lt(int, int);
int	seq_within(int, int, int);
int	seq_within(int, int, int);
int	seq_ge(ulong, ulong);
int	seq_gt(ulong, ulong);
int	seq_gt(ulong, ulong);
int	seq_le(ulong, ulong);
int	seq_lt(ulong, ulong);
int	seq_within(ulong, ulong, ulong);
int	seq_within(ulong, ulong, ulong);
void	tcpsetstate(Ipconv *, char);
void	tcpgo(Timer *);
void	tcphalt(Timer *);

M port/tcpinput.c => port/tcpinput.c +25 -15
@@ 308,6 308,10 @@ tcpinput(Ipifc *ifc, Block *bp)
		goto output;
	}

	/*
	 *  keep looping till we've processed this packet plus any
	 *  adjacent packets in the resequence queue
	 */
	for(;;) {
		if(seg.flags & RST) {
			if(tcb->state == Syn_received


@@ 461,16 465,22 @@ tcpinput(Ipifc *ifc, Block *bp)
			}
		}

		while(tcb->reseq) {
		/*
		 *  get next adjacent segment from the requence queue.
		 *  dump/trim any overlapping segments
		 */
		for(;;) {
			if(tcb->reseq == 0)
				goto output;

			if(seq_ge(tcb->rcv.nxt, tcb->reseq->seg.seq) == 0)
				break;
				goto output;

			get_reseq(tcb, &tos, &seg, &bp, &length);

			if(trim(tcb, &seg, &bp, &length) == 0)
				break;
		}
		break;
	}
output:
	tcpoutput(s);


@@ 572,7 582,7 @@ update(Ipconv *s, Tcp *seg)
int
in_window(Tcpctl *tcb, int seq)
{
	return seq_within(seq, tcb->rcv.nxt, (int)(tcb->rcv.nxt+tcb->rcv.wnd-1));
	return seq_within(seq, tcb->rcv.nxt, tcb->rcv.nxt+tcb->rcv.wnd-1);
}

void


@@ 697,8 707,8 @@ trim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length)
			accept++;
		else
		if(len != 0) {
			if(in_window(tcb, (int)(seg->seq+len-1)) || 
			seq_within(tcb->rcv.nxt, seg->seq,(int)(seg->seq+len-1)))
			if(in_window(tcb, seg->seq+len-1) || 
			seq_within(tcb->rcv.nxt, seg->seq,seg->seq+len-1))
				accept++;
		}
	}


@@ 864,7 874,7 @@ localclose(Ipconv *s, char reason[])
}

int
seq_within(int x, int low, int high)
seq_within(ulong x, ulong low, ulong high)
{
	if(low <= high){
		if(low <= x && x <= high)


@@ 878,27 888,27 @@ seq_within(int x, int low, int high)
}

int
seq_lt(int x, int y)
seq_lt(ulong x, ulong y)
{
	return (long)(x-y) < 0;
	return x < y;
}

int
seq_le(int x, int y)
seq_le(ulong x, ulong y)
{
	return (long)(x-y) <= 0;
	return x <= y;
}

int
seq_gt(int x, int y)
seq_gt(ulong x, ulong y)
{
	return (long)(x-y) > 0;
	return x > y;
}

int
seq_ge(int x, int y)
seq_ge(ulong x, ulong y)
{
	return (long)(x-y) >= 0;
	return x >= y;
}

void

M port/tcpoutput.c => port/tcpoutput.c +1 -1
@@ 112,7 112,7 @@ tcpoutput(Ipconv *s)
		/*
		 * keep track of balance of resent data */
		if(tcb->snd.ptr < tcb->snd.nxt)
			tcb->resent += MIN((int)tcb->snd.nxt - (int)tcb->snd.ptr,(int)ssize);
			tcb->resent += MIN(tcb->snd.nxt - tcb->snd.ptr,(int)ssize);

		tcb->snd.ptr += ssize;