~kris/9p

9hist

aaf0177750d55669d64e54cdb59e4f6872e9a295 — David du Colombier 23 years ago 6585faa
Plan 9 from Bell Labs 2003-02-13
3 files changed, 24 insertions(+), 4 deletions(-)

M ip/ip.c
M ip/tcp.c
M port/portdat.h
M ip/ip.c => ip/ip.c +1 -1
@@ 441,7 441,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
	h = (Ip4hdr*)(bp->rp);

	/* dump anything that whose header doesn't checksum */
	if(ipcsum(&h->vihl)) {
	if((bp->flag & Bipck) == 0 && ipcsum(&h->vihl)) {
		ip->stats[InHdrErrors]++;
		netlog(f, Logip, "ip: checksum error %V\n", h->src);
		freeblist(bp);

M ip/tcp.c => ip/tcp.c +15 -1
@@ 361,7 361,7 @@ struct Tcppriv
 *  it that number gets acked by the other end, we shut down the connection.
 *  Look for tcpporthogedefense in the code.
 */
int tcpporthogdefense = 1;
int tcpporthogdefense = 0;

int	addreseq(Tcpctl*, Tcppriv*, Tcp*, Block*, ushort);
void	getreseq(Tcpctl*, Tcp*, Block**, ushort*);


@@ 3013,6 3013,18 @@ tcpadvise(Proto *tcp, Block *bp, char *msg)
	freeblist(bp);
}

static char*
tcpporthogdefensectl(char *val)
{
	if(strcmp(val, "on") == 0)
		tcpporthogdefense = 1;
	else if(strcmp(val, "off") == 0)
		tcpporthogdefense = 0;
	else
		return "unknown value for tcpporthogdefense";
	return nil;
}

/* called with c qlocked */
char*
tcpctl(Conv* c, char** f, int n)


@@ 3023,6 3035,8 @@ tcpctl(Conv* c, char** f, int n)
		return tcpstartka(c, f, n);
	if(n >= 1 && strcmp(f[0], "checksum") == 0)
		return tcpsetchecksum(c, f, n);
	if(n >= 1 && strcmp(f[0], "tcpporthogdefense") == 0)
		return tcpporthogdefensectl(f[1]);
	return "unknown control request";
}


M port/portdat.h => port/portdat.h +8 -2
@@ 124,10 124,15 @@ enum
	CCACHE	= 0x0080,		/* client cache */
};

/* flag values */
enum
{
	BINTR	=	(1<<0),
	BFREE	=	(1<<1),
	Bipck	=	(1<<2),		/* ip checksum */
	Budpck	=	(1<<3),		/* udp checksum */
	Btcpck	=	(1<<4),		/* tcp checksum */
	Bpktck	=	(1<<5),		/* packet checksum */
};

struct Block


@@ 137,9 142,10 @@ struct Block
	uchar*	rp;			/* first unconsumed byte */
	uchar*	wp;			/* first empty byte */
	uchar*	lim;			/* 1 past the end of the buffer */
	uchar*	base;		/* start of the buffer */
	uchar*	base;			/* start of the buffer */
	void	(*free)(Block*);
	ulong	flag;
	ushort	flag;
	ushort	checksum;		/* IP checksum of complete packet (minus media header) */
};
#define BLEN(s)	((s)->wp - (s)->rp)
#define BALLOC(s) ((s)->lim - (s)->base)