plan 9 kernel history: overview | file list | diff list

1999/0515/alphapc/devether.c (diff list | history)

1999/0515/sys/src/9/alphapc/devether.c:130,1402000/0401/sys/src/9/alphapc/devether.c:130,140 (short | long | prev | next)
1999/0415    
} 
 
Block* 
etheriq(Ether* ether, Block* bp, int freebp) 
2000/0401    
etheriq(Ether* ether, Block* bp, int fromwire) 
1999/0415    
{ 
	Etherpkt *pkt; 
	ushort type; 
	int len; 
2000/0401    
	int len, multi, tome, fromme; 
1999/0415    
	Netfile **ep, *f, **fp, *fx; 
	Block *xbp; 
 
1999/0515/sys/src/9/alphapc/devether.c:146,1552000/0401/sys/src/9/alphapc/devether.c:146,156
1999/0415    
	fx = 0; 
	ep = ðer->f[Ntypes]; 
 
2000/0401    
	multi = pkt->d[0] & 1; 
1999/0415    
	/* check for valid multcast addresses */ 
	if((pkt->d[0] & 1) && memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) && ether->prom == 0){ 
2000/0401    
	if(multi && memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) && ether->prom == 0){ 
1999/0415    
		if(!activemulti(ether, pkt->d, sizeof(pkt->d))){ 
			if(freebp){ 
2000/0401    
			if(fromwire){ 
1999/0415    
				freeb(bp); 
				bp = 0; 
			} 
1999/0515/sys/src/9/alphapc/devether.c:157,1722000/0401/sys/src/9/alphapc/devether.c:158,182
1999/0415    
		} 
	} 
 
2000/0401    
	/* is it for me? */ 
	tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; 
	fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; 
 
1999/0415    
	/* 
	 * Multiplex the packet to all the connections which want it. 
	 * If the packet is not to be used subsequently (freebp != 0), 
2000/0401    
	 * If the packet is not to be used subsequently (fromwire != 0), 
1999/0415    
	 * attempt to simply pass it into one of the connections, thereby 
	 * saving a copy of the data (usual case hopefully). 
	 */ 
	for(fp = ether->f; fp < ep; fp++){ 
		if((f = *fp) && (f->type == type || f->type < 0)){ 
			if(f->type > -2){ 
				if(freebp && fx == 0) 
2000/0401    
		if(f = *fp) 
		if(f->type == type || f->type < 0) 
		if(tome || multi || f->prom){ 
			/* Don't want to hear bridged packets */ 
			if(f->bridge && !fromwire && !fromme) 
				continue; 
			if(!f->headersonly){ 
				if(fromwire && fx == 0) 
1999/0415    
					fx = f; 
				else if(xbp = iallocb(len)){ 
					memmove(xbp->wp, pkt, len); 
1999/0515/sys/src/9/alphapc/devether.c:182,1912000/0401/sys/src/9/alphapc/devether.c:192,202
1999/0415    
	} 
 
	if(fx){ 
		qpass(fx->in, bp); 
2000/0401    
		if(qpass(fx->in, bp) < 0) 
			ether->soverflows++; 
1999/0415    
		return 0; 
	} 
	if(freebp){ 
2000/0401    
	if(fromwire){ 
1999/0415    
		freeb(bp); 
		return 0; 
	} 
1999/0515/sys/src/9/alphapc/devether.c:207,2192000/0401/sys/src/9/alphapc/devether.c:218,232
1999/0415    
	 * in promiscuous mode. 
	 * If it's a loopback packet indicate to etheriq that the data isn't 
	 * needed and return, etheriq will pass-on or free the block. 
2000/0401    
	 * To enable bridging to work, only packets that were originated 
	 * by this interface are fed back. 
1999/0415    
	 */ 
	pkt = (Etherpkt*)bp->rp; 
	len = BLEN(bp); 
	loopback = (memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0); 
2000/0401    
	loopback = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; 
1999/0415    
	if(loopback || memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) == 0 || ether->prom){ 
		s = splhi(); 
		etheriq(ether, bp, loopback); 
2000/0401    
		etheriq(ether, bp, 0); 
1999/0415    
		splx(s); 
	} 
 
1999/0515/sys/src/9/alphapc/devether.c:220,2262000/0401/sys/src/9/alphapc/devether.c:233,240
1999/0415    
	if(!loopback){ 
		qbwrite(ether->oq, bp); 
		ether->transmit(ether); 
	} 
2000/0401    
	} else 
		freeb(bp); 
1999/0415    
 
	return len; 
} 
1999/0515/sys/src/9/alphapc/devether.c:354,3622000/0401/sys/src/9/alphapc/devether.c:368,377
1999/0415    
			 */ 
			if(ether->irq == 2) 
				ether->irq = 9; 
			intrenable(VectorPCI+ether->irq, ether->interrupt, ether, ether->tbdf); 
2000/0401    
			snprint(name, sizeof(name), "ether%d", ctlrno); 
			intrenable(ether->irq, ether->interrupt, ether, ether->tbdf, name); 
1999/0415    
 
1999/0515    
			i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %ld", 
2000/0401    
			i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %lud", 
1999/0415    
				ctlrno, ether->type, ether->mbps, ether->port, ether->irq); 
			if(ether->mem) 
				i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem)); 
1999/0515/sys/src/9/alphapc/devether.c:368,3742000/0401/sys/src/9/alphapc/devether.c:383,388
1999/0415    
			sprint(buf+i, "\n"); 
			print(buf); 
 
			snprint(name, sizeof(name), "ether%d", ctlrno); 
			if(ether->mbps == 100){ 
				netifinit(ether, name, Ntypes, 256*1024); 
				if(ether->oq == 0) 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)