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

1998/0307/ip/ethermedium.c (diff list | history)

1998/0306/sys/src/9/ip/ethermedium.c:45,501998/0307/sys/src/9/ip/ethermedium.c:45,51 (short | long | prev | next)
1998/0306    
	nil,			/* flushroute */ 
	nil,			/* joinmulti */ 
	nil,			/* leavemulti */ 
1998/0307    
	0,			/* don't unbind on last close */ 
1998/0306    
}; 
 
typedef struct	Etherrock Etherrock; 
1998/0306/sys/src/9/ip/ethermedium.c:205,2111998/0307/sys/src/9/ip/ethermedium.c:206,212
1998/0306    
} 
 
/* 
 *  called by ipoput with a single block to write 
1998/0307    
 *  called by ipoput with a single block to write with ifc rlock'd 
1998/0306    
 */ 
static void 
etherbwrite(Ipifc *ifc, Block *bp, int version, uchar *ip) 
1998/0306/sys/src/9/ip/ethermedium.c:215,2311998/0307/sys/src/9/ip/ethermedium.c:216,221
1998/0306    
	uchar mac[6]; 
	Etherrock *er = ifc->arg; 
 
	if(waserror()) { 
		print("etherbwrite failed\n"); 
		ipifccheckout(ifc); 
		return; 
	} 
	if(ipifccheckin(ifc, ðermedium) < 0){ 
		freeb(bp); 
		poperror(); 
		return; 
	} 
                 
	/* get mac address of destination */ 
	a = arpget(bp, version, ðermedium, ip, mac); 
	if(a){ 
1998/0306/sys/src/9/ip/ethermedium.c:233,2391998/0307/sys/src/9/ip/ethermedium.c:223,229
1998/0306    
		bp = multicastarp(a, mac); 
		if(bp == nil){ 
			sendarp(ifc, a); 
			goto out; 
1998/0307    
			return; 
1998/0306    
		} 
	} 
 
1998/0306/sys/src/9/ip/ethermedium.c:261,2701998/0307/sys/src/9/ip/ethermedium.c:251,256
1998/0306    
 
	devtab[er->mchan->type]->bwrite(er->mchan, bp, 0); 
	ifc->out++; 
                 
out: 
	ipifccheckout(ifc); 
	poperror(); 
} 
 
/* 
1998/0306/sys/src/9/ip/ethermedium.c:276,2911998/0307/sys/src/9/ip/ethermedium.c:262,281
1998/0306    
	Ipifc *ifc; 
	Block *bp; 
	Etherrock *er; 
1998/0307    
	int locked = 0; 
1998/0306    
 
	ifc = a; 
	er = ifc->arg; 
	er->readp = up;	/* hide identity under a rock for unbind */ 
	if(waserror()){ 
1998/0307    
		if(locked) 
			runlock(ifc); 
1998/0306    
		er->readp = 0; 
		pexit("hangup", 1); 
	} 
	for(;;){ 
		bp = devtab[er->mchan->type]->bread(er->mchan, ifc->maxmtu, 0); 
1998/0307    
		rlock(ifc);	locked = 1;	USED(locked); 
1998/0306    
		ifc->in++; 
		bp->rp += ifc->m->hsize; 
		if(ifc->lifc == nil) 
1998/0306/sys/src/9/ip/ethermedium.c:292,2971998/0307/sys/src/9/ip/ethermedium.c:282,289
1998/0306    
			freeb(bp); 
		else 
			ipiput(ifc->lifc->local, bp); 
1998/0307    
		runlock(ifc);	locked = 0;	USED(locked); 
 
1998/0306    
	} 
} 
 


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