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

1997/0530/ip/gre.c (diff list | history)

1997/0524/sys/src/9/ip/gre.c:11,181997/0530/sys/src/9/ip/gre.c:11,18 (short | long | prev | next)
1997/0327    
 
enum 
{ 
	GRE_IPHDRSIZE	= 20,		/* size of ip header */ 
	GRE_HDRSIZE	= 4,		/* minimum size of GRE header */ 
1997/0530    
	GRE_IPONLY	= 12,		/* size of ip header */ 
	GRE_IPPLUSGRE	= 12,		/* minimum size of GRE header */ 
1997/0327    
	IP_GREPROTO	= 47, 
 
	GRErxms		= 200, 
1997/0524/sys/src/9/ip/gre.c:122,1271997/0530/sys/src/9/ip/gre.c:122,128
1997/0327    
{ 
	GREhdr *ghp; 
1997/0524    
	Block *bp; 
1997/0530    
	ulong raddr, laddr; 
1997/0327    
 
	USED(l); 
 
1997/0524/sys/src/9/ip/gre.c:130,1491997/0530/sys/src/9/ip/gre.c:131,157
1997/0327    
		return; 
 
	/* Make space to fit ip header (gre header already there) */ 
	bp = padblock(bp, GRE_IPHDRSIZE); 
1997/0530    
	bp = padblock(bp, GRE_IPONLY); 
1997/0327    
	if(bp == nil) 
		return; 
 
	/* make sure the message has a GRE header */ 
	bp = pullupblock(bp, GRE_IPHDRSIZE+GRE_HDRSIZE); 
1997/0530    
	bp = pullupblock(bp, GRE_IPONLY+GRE_IPPLUSGRE); 
1997/0327    
	if(bp == nil) 
		return; 
 
	ghp = (GREhdr *)(bp->rp); 
 
1997/0530    
	raddr = nhgetl(ghp->src); 
	laddr = nhgetl(ghp->dst); 
	if(raddr == 0) 
		raddr = c->raddr; 
	if(laddr == 0 || Mediaforme(ghp->dst) <= 0) 
		laddr = c->laddr; 
 
1997/0327    
	ghp->proto = IP_GREPROTO; 
	hnputl(ghp->dst, c->raddr); 
	hnputl(ghp->src, c->laddr); 
1997/0530    
	hnputl(ghp->dst, raddr); 
	hnputl(ghp->src, laddr); 
1997/0327    
	hnputs(ghp->eproto, c->rport); 
1997/0522    
	ghp->frag[0] = 0; 
	ghp->frag[1] = 0; 
1997/0524/sys/src/9/ip/gre.c:184,1951997/0530/sys/src/9/ip/gre.c:192,203
1997/0327    
	/* 
	 * Trim the packet down to data size 
	 */ 
	len = nhgets(ghp->len) - GRE_IPHDRSIZE; 
	if(len < GRE_HDRSIZE){ 
1997/0530    
	len = nhgets(ghp->len) - GRE_IPONLY; 
	if(len < GRE_IPPLUSGRE){ 
1997/0327    
		freeblist(bp); 
		return; 
	} 
	bp = trimblock(bp, GRE_IPHDRSIZE, len); 
1997/0530    
	bp = trimblock(bp, GRE_IPONLY, len); 
1997/0327    
	if(bp == nil){ 
		gre.lenerr++; 
		return; 


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