~kris/9p

9hist

1da7635fb60b5dead74670e1171d9236e501792a — David du Colombier 29 years ago 027b100
Plan 9 from Bell Labs 1997-08-15
7 files changed, 44 insertions(+), 39 deletions(-)

M ip/devip.c
M ip/igmp.c
M ip/ip.c
M ip/ip.h
M ip/netlog.c
M ip/udp.c
M pc/devata.c
M ip/devip.c => ip/devip.c +2 -2
@@ 542,7 542,7 @@ static void
setladdrport(Conv* c, char* str)
{
	char *p;
	uchar addr[Ipaddrlen];
	uchar addr[IPaddrlen];

	p = strchr(str, '!');
	if(p == nil) {


@@ 567,7 567,7 @@ static char*
setraddrport(Conv* c, char* str)
{
	char *p;
	uchar addr[Ipaddrlen];
	uchar addr[IPaddrlen];

	p = strchr(str, '!');
	if(p == nil)

M ip/igmp.c => ip/igmp.c +5 -5
@@ 32,14 32,14 @@ struct IGMPpkt
	byte	Unused;	
	byte	proto;		/* Protocol */
	byte	cksum[2];	/* checksum of ip portion */
	byte	src[Ipaddrlen];		/* Ip source */
	byte	dst[Ipaddrlen];		/* Ip destination */
	byte	src[IPaddrlen];		/* Ip source */
	byte	dst[IPaddrlen];		/* Ip destination */

	/* igmp header */
	byte	vertype;	/* version and type */
	byte	unused;
	byte	igmpcksum[2];		/* checksum of igmp portion */
	byte	group[Ipaddrlen];	/* multicast group */
	byte	group[IPaddrlen];	/* multicast group */
};

/*


@@ 84,7 84,7 @@ igmpsendreport(Media *m, byte *addr)
	hnputl(p->dst, Ipallsys);
	p->vertype = (1<<4) | IGMPreport;
	p->proto = IP_IGMPPROTO;
	memmove(p->group, addr, Ipaddrlen);
	memmove(p->group, addr, IPaddrlen);
	hnputs(p->igmpcksum, ptclcsum(bp, IGMP_IPHDRSIZE, IGMP_HDRSIZE));
	netlog(Logigmp, "igmpreport %I\n", p->group);
	ipoput(bp, 0, 1);	/* TTL of 1 */


@@ 103,7 103,7 @@ igmpproc(void *a)
{
	IGMPrep *rp, **lrp;
	Multicast *mp, **lmp;
	byte ip[Ipaddrlen];
	byte ip[IPaddrlen];

	USED(a);


M ip/ip.c => ip/ip.c +1 -1
@@ 105,7 105,7 @@ ipoput(Block *bp, int gating, int ttl)

	if(isbmcast(eh->dst)){
		m = Mediaroute(eh->src, nil);
		memmove(gate, eh->dst, Ipaddrlen);
		memmove(gate, eh->dst, IPaddrlen);
	} else
		m = Mediaroute(eh->dst, gate);
	if(m == nil){

M ip/ip.h => ip/ip.h +1 -1
@@ 21,7 21,7 @@ enum

	MAXTTL=		255,

	Ipaddrlen=	4,
	IPaddrlen=	4,
	Ipbcast=	0xffffffff,	/* ip broadcast address */
	Ipbcastobs=	0,		/* obsolete (but still used) ip broadcast addr */
	Ipallsys=	0xe0000001,	/* multicast for all systems */

M ip/netlog.c => ip/netlog.c +1 -1
@@ 151,7 151,7 @@ netlogctl(char* s, int len)
	int i, n, set;
	Logflag *f;
	char *fields[10], *p, buf[256];
	uchar addr[Ipaddrlen];
	uchar addr[IPaddrlen];

	if(len == 0)
		return Ebadnetctl;

M ip/udp.c => ip/udp.c +15 -11
@@ 204,6 204,8 @@ udpiput(Media *m, Block *bp)
	Udpcb *ucb;
	Ipaddr raddr, laddr;
	ushort rport, lport;
	uchar dst[IPaddrlen];
	uchar src[IPaddrlen];

	USED(m);
	uh = (Udphdr*)(bp->rp);


@@ 217,11 219,13 @@ udpiput(Media *m, Block *bp)
	laddr = nhgetl(uh->udpdst);
	lport = nhgets(uh->udpdport);
	rport = nhgets(uh->udpsport);
	memmove(src, uh->udpsrc, IPaddrlen);
	memmove(dst, uh->udpdst, IPaddrlen);

	if(udpsum && nhgets(uh->udpcksum)) {
		if(ptclcsum(bp, UDP_IPHDR, len+UDP_PHDRSIZE)) {
			udp.csumerr++;
			netlog(Logudp, "udp: checksum error %I\n", uh->udpsrc);
			netlog(Logudp, "udp: checksum error %I\n", src);
			freeblist(bp);
			return;
		}


@@ 238,8 242,8 @@ udpiput(Media *m, Block *bp)
	}

	if(*p == nil) {
		netlog(Logudp, "udp: no conv %I.%d -> %I.%d\n", uh->udpsrc, rport,
			uh->udpdst, lport);
		netlog(Logudp, "udp: no conv %I.%d -> %I.%d\n", src, rport,
			dst, lport);
		freeblist(bp);
		return;
	}


@@ 250,14 254,14 @@ udpiput(Media *m, Block *bp)
	len -= (UDP_HDRSIZE-UDP_PHDRSIZE);
	bp = trimblock(bp, UDP_IPHDR+UDP_HDRSIZE, len);
	if(bp == nil){
		netlog(Logudp, "udp: len err %I.%d -> %I.%d\n", uh->udpsrc, rport,
			uh->udpdst, lport);
		netlog(Logudp, "udp: len err %I.%d -> %I.%d\n", src, rport,
			dst, lport);
		udp.lenerr++;
		return;
	}

	netlog(Logudpmsg, "udp: %I.%d -> %I.%d l %d\n", uh->udpsrc, rport,
		uh->udpdst, lport, len);
	netlog(Logudpmsg, "udp: %I.%d -> %I.%d l %d\n", src, rport,
		dst, lport, len);

	ucb = (Udpcb*)c->ptcl;



@@ 265,7 269,7 @@ udpiput(Media *m, Block *bp)
		/* pass the src address */
		bp = padblock(bp, UDP_USEAD);
		hnputl(bp->rp, raddr);
		if(Mediaforme(uh->udpdst) > 0)
		if(Mediaforme(dst) > 0)
			hnputl(bp->rp+4, laddr);
		else
			hnputl(bp->rp+4, m->myip[0]);


@@ 279,7 283,7 @@ udpiput(Media *m, Block *bp)
			c->rport = rport;

			/* reply with the same ip address (if not broadcast) */
			if(Mediaforme(uh->udpdst) > 0)
			if(Mediaforme(dst) > 0)
				c->laddr = laddr;
			else
				c->laddr = m->myip[0];


@@ 289,8 293,8 @@ udpiput(Media *m, Block *bp)
		bp = concatblock(bp);

	if(qfull(c->rq)){
		netlog(Logudp, "udp: qfull %I.%d -> %I.%d\n", uh->udpsrc, rport,
			uh->udpdst, lport);
		netlog(Logudp, "udp: qfull %I.%d -> %I.%d\n", src, rport,
			dst, lport);
		freeblist(bp);
	}else
		qpass(c->rq, bp);

M pc/devata.c => pc/devata.c +19 -18
@@ 11,7 11,7 @@
#include	"../port/error.h"


#define DPRINT if(0)print
#define DPRINT if(1)print
#define XPRINT if(0)print
#define ILOCK(x)
#define IUNLOCK(x)


@@ 156,7 156,6 @@ struct Controller
	int	pbase;		/* base port */
	uchar	ctlrno;
	int	tbdf;
	uchar	resetok;

	/*
	 *  current operation


@@ 343,7 342,7 @@ atadrivealloc(Controller* ctlr, int driveno, int atapi)
}

static int
atactlrprobe(int ctlrno, int irq)
atactlrprobe(int ctlrno, int irq, int resetok)
{
	Controller *ctlr;
	int atapi, mask, port;


@@ 359,8 358,9 @@ atactlrprobe(int ctlrno, int irq)
	port = pbase[ctlrno];
	outb(port+Pdh, DHmagic);
	microdelay(1);
	if((inb(port+Pdh) & 0xFF) != DHmagic){
		DPRINT("ata%d: DHmagic not ok\n", ctlrno);
	status = inb(port+Pdh) & 0xFF;
	if(status != DHmagic){
		DPRINT("ata%d: DHmagic not ok == %ux\n", ctlrno, status);
		return -1;
	}
	DPRINT("ata%d: DHmagic ok\n", ctlrno);


@@ 387,7 387,7 @@ atactlrprobe(int ctlrno, int irq)
	 * ATAPI signature straight off. If we find it there will be no probe
	 * done for a slave. Tough.
	 */
	if(ctlr->resetok){
	if(resetok){
		outb(port+Pctrl, Srst|nIEN);
		delay(10);
		outb(port+Pctrl, 0);


@@ 487,7 487,7 @@ skipedd:
static void
atactlrreset(void)
{
	int ctlrno, driveno, i, slave, spindown;
	int ctlrno, driveno, i, resetok, slave, spindown;
	ISAConf isa;

	cmd640b();


@@ 500,9 500,7 @@ atactlrreset(void)
		if(isa.irq == 0 && (isa.irq = defirq[ctlrno]) == 0)
			continue;

		if(atactlrprobe(ctlrno, VectorPIC+isa.irq))
			continue;
	
		driveno = resetok = spindown = 0;
		for(i = 0; i < isa.nopt; i++){
			DPRINT("ata%d: opt %s\n", ctlrno, isa.opt[i]);
			if(strncmp(isa.opt[i], "spindown", 8) == 0){


@@ 514,21 512,24 @@ atactlrreset(void)
					slave = 1;
				else
					continue;
				driveno = ctlrno*2+slave;
				if(atadrive[driveno] == 0)
					continue;
				if((spindown = strtol(&isa.opt[i][10], 0, 0)) == 0)
					continue;
				if(spindown < (Hardtimeout+2000)/1000)
					spindown = (Hardtimeout+2000)/1000;
				atadrive[driveno]->spindown = spindown;
				spindownmask |= (1<<driveno);
				DPRINT("ata%d: opt spindownmask %ux\n",
					ctlrno, spindownmask);
				driveno = ctlrno*2+slave;
			}
			else if(strcmp(isa.opt[i], "reset") == 0)
				atactlr[ctlrno]->resetok = 1;
				resetok = 1;
		}

		if(atactlrprobe(ctlrno, VectorPIC+isa.irq, resetok))
			continue;

		if(spindown == 0 || atadrive[driveno] == 0)
			continue;
		atadrive[driveno]->spindown = spindown;
		spindownmask |= (1<<driveno);
		DPRINT("ata%d: opt spindownmask %ux\n", ctlrno, spindownmask);
	}

	if(spindownmask)