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

1999/0625/pc/devether.c (diff list | history)

1999/0402/sys/src/9/pc/devether.c:130,1401999/0625/sys/src/9/pc/devether.c:130,140 (short | long | prev | next)
1997/0327    
} 
 
Block* 
etheriq(Ether* ether, Block* bp, int freebp) 
1999/0625    
etheriq(Ether* ether, Block* bp, int fromwire) 
1997/0327    
{ 
	Etherpkt *pkt; 
1993/1120    
	ushort type; 
1999/0316    
	int len, multi, forme; 
1999/0625    
	int len, multi, tome, fromme; 
1997/0327    
	Netfile **ep, *f, **fp, *fx; 
	Block *xbp; 
1993/1120    
 
1999/0402/sys/src/9/pc/devether.c:150,1561999/0625/sys/src/9/pc/devether.c:150,156
1997/0404    
	/* check for valid multcast addresses */ 
1999/0316    
	if(multi && memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) && ether->prom == 0){ 
1997/0404    
		if(!activemulti(ether, pkt->d, sizeof(pkt->d))){ 
			if(freebp){ 
1999/0625    
			if(fromwire){ 
1997/0404    
				freeb(bp); 
				bp = 0; 
			} 
1999/0402/sys/src/9/pc/devether.c:158,1761999/0625/sys/src/9/pc/devether.c:158,182
1997/0404    
		} 
	} 
 
1999/0316    
	// is it for me? 
	forme = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; 
1999/0625    
	/* 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/0316    
 
1997/0327    
	/* 
	 * Multiplex the packet to all the connections which want it. 
	 * If the packet is not to be used subsequently (freebp != 0), 
1999/0625    
	 * If the packet is not to be used subsequently (fromwire != 0), 
1997/0327    
	 * 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++){ 
1999/0316    
		if((f = *fp) && (f->type == type || f->type < 0) && (forme || multi || f->prom)){ 
1995/0713    
			if(f->type > -2){ 
1997/0327    
				if(freebp && fx == 0) 
1999/0625    
		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) 
1997/0327    
					fx = f; 
				else if(xbp = iallocb(len)){ 
					memmove(xbp->wp, pkt, len); 
1999/0402/sys/src/9/pc/devether.c:190,1961999/0625/sys/src/9/pc/devether.c:196,202
1998/1013    
			ether->soverflows++; 
1997/0327    
		return 0; 
	} 
	if(freebp){ 
1999/0625    
	if(fromwire){ 
1997/0327    
		freeb(bp); 
		return 0; 
	} 
1999/0402/sys/src/9/pc/devether.c:201,2071999/0625/sys/src/9/pc/devether.c:207,213
1993/1120    
static int 
1997/0327    
etheroq(Ether* ether, Block* bp) 
1993/1120    
{ 
1999/0316    
	int len, loopback, s, mine; 
1999/0625    
	int len, loopback, s; 
1997/0327    
	Etherpkt *pkt; 
1993/1120    
 
1997/0327    
	ether->outpackets++; 
1999/0402/sys/src/9/pc/devether.c:217,2281999/0625/sys/src/9/pc/devether.c:223,232
1997/0327    
	 */ 
	pkt = (Etherpkt*)bp->rp; 
	len = BLEN(bp); 
1997/0808    
	loopback = (memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0); 
1999/0316    
	mine = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0; 
	if(mine) 
1999/0625    
	loopback = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0; 
1997/0808    
	if(loopback || memcmp(pkt->d, ether->bcast, sizeof(pkt->d)) == 0 || ether->prom){ 
1997/0327    
		s = splhi(); 
		etheriq(ether, bp, loopback); 
1999/0625    
		etheriq(ether, bp, 0); 
1997/0327    
		splx(s); 
	} 
1994/0702    
 
1999/0402/sys/src/9/pc/devether.c:229,2351999/0625/sys/src/9/pc/devether.c:233,240
1997/0327    
	if(!loopback){ 
		qbwrite(ether->oq, bp); 
		ether->transmit(ether); 
	} 
1999/0625    
	} else 
		freeb(bp); 
1997/0327    
 
	return len; 
1993/1120    
} 


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