⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radij.c

📁 This a good VPN source
💻 C
📖 第 1 页 / 共 3 页
字号:
		while ((rn = base)) {			base = rn->rj_dupedkey;#ifdef CONFIG_KLIPS_DEBUG			if(debug_radij) {				printk("klips_debug:rj_walktree: "				       "while: base=0p%p rn=0p%p rj_b=%d rj_flags=%x",				       base,				       rn,				       rn->rj_b,				       rn->rj_flags);				rn->rj_b >= 0 ?					printk(" node off=%x\n",					       rn->rj_off) :					printk(" leaf key = %08x->%08x\n",					       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_key)->sen_ip_src.s_addr),					       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_key)->sen_ip_dst.s_addr))					;			}#endif /* CONFIG_KLIPS_DEBUG */			if (!(rn->rj_flags & RJF_ROOT) && (error = (*f)(rn, w)))				return (-error);		}		rn = next;		if (rn->rj_flags & RJF_ROOT)			return (0);	}	/* NOTREACHED */}intrj_inithead(head, off)	void **head;	int off;{	register struct radij_node_head *rnh;	register struct radij_node *t, *tt, *ttt;	if (*head)		return (1);	R_Malloc(rnh, struct radij_node_head *, sizeof (*rnh));	if (rnh == NULL)		return (0);	Bzero(rnh, sizeof (*rnh));	*head = rnh;	t = rj_newpair(rj_zeroes, off, rnh->rnh_nodes);	ttt = rnh->rnh_nodes + 2;	t->rj_r = ttt;	t->rj_p = t;	tt = t->rj_l;	tt->rj_flags = t->rj_flags = RJF_ROOT | RJF_ACTIVE;	tt->rj_b = -1 - off;	*ttt = *tt;	ttt->rj_key = rj_ones;	rnh->rnh_addaddr = rj_addroute;	rnh->rnh_deladdr = rj_delete;	rnh->rnh_matchaddr = rj_match;	rnh->rnh_walktree = rj_walktree;	rnh->rnh_treetop = t;	return (1);}voidrj_init(){	char *cp, *cplim;	if (maj_keylen == 0) {		printk("klips_debug:rj_init: "		       "radij functions require maj_keylen be set\n");		return;	}	R_Malloc(rj_zeroes, char *, 3 * maj_keylen);	if (rj_zeroes == NULL)		panic("rj_init");	Bzero(rj_zeroes, 3 * maj_keylen);	rj_ones = cp = rj_zeroes + maj_keylen;	maskedKey = cplim = rj_ones + maj_keylen;	while (cp < cplim)		*cp++ = -1;	if (rj_inithead((void **)&mask_rjhead, 0) == 0)		panic("rj_init 2");}voidrj_preorder(struct radij_node *rn, int l){	int i;		if (rn == NULL){		printk("klips_debug:rj_preorder: "		       "NULL pointer\n");		return;	}		if (rn->rj_b >= 0){		rj_preorder(rn->rj_l, l+1);		rj_preorder(rn->rj_r, l+1);		printk("klips_debug:");		for (i=0; i<l; i++)			printk("*");		printk(" off = %d\n",		       rn->rj_off);	} else {		printk("klips_debug:");		for (i=0; i<l; i++)			printk("@");		printk(" flags = %x",		       (u_int)rn->rj_flags);		if (rn->rj_flags & RJF_ACTIVE) {			printk(" @key=0p%p",			       rn->rj_key);			printk(" key = %08x->%08x",			       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_key)->sen_ip_src.s_addr),			       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_key)->sen_ip_dst.s_addr));			printk(" @mask=0p%p",			       rn->rj_mask);			if (rn->rj_mask)				printk(" mask = %08x->%08x",				       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_mask)->sen_ip_src.s_addr),				       (u_int)ntohl(((struct sockaddr_encap *)rn->rj_mask)->sen_ip_dst.s_addr));			if (rn->rj_dupedkey)				printk(" dupedkey = 0p%p",				       rn->rj_dupedkey);		}		printk("\n");	}}#ifdef RJ_DEBUGDEBUG_NO_STATIC void traverse(struct radij_node *p){  rj_preorder(p, 0);}#endif /* RJ_DEBUG */voidrj_dumptrees(void){	rj_preorder(rnh->rnh_treetop, 0);}voidrj_free_mkfreelist(void){	struct radij_mask *mknp, *mknp2;	mknp = rj_mkfreelist;	while(mknp)	{		mknp2 = mknp;		mknp = mknp->rm_mklist;		kfree(mknp2);	}}intradijcleartree(void){	return rj_walktree(rnh, ipsec_rj_walker_delete, NULL);}intradijcleanup(void){	int error = 0;	error = radijcleartree();	rj_free_mkfreelist();/*	rj_walktree(mask_rjhead, ipsec_rj_walker_delete, NULL); */  	if(mask_rjhead) {		kfree(mask_rjhead);	}	if(rj_zeroes) {		kfree(rj_zeroes);	}	if(rnh) {		kfree(rnh);	}	return error;}/* * $Log: radij.c,v $ * Revision 1.47  2004/07/10 19:11:18  mcr * 	CONFIG_IPSEC -> CONFIG_KLIPS. * * Revision 1.46  2004/04/06 02:49:26  mcr * 	pullup of algo code from alg-branch. * * Revision 1.45  2003/10/31 02:27:55  mcr * 	pulled up port-selector patches and sa_id elimination. * * Revision 1.44.30.1  2003/10/29 01:30:41  mcr * 	elimited "struct sa_id". * * Revision 1.44  2002/07/24 18:44:54  rgb * Type fiddling to tame ia64 compiler. * * Revision 1.43  2002/05/23 07:14:11  rgb * Cleaned up %p variants to 0p%p for test suite cleanup. * * Revision 1.42  2002/04/24 07:55:32  mcr * 	#include patches and Makefiles for post-reorg compilation. * * Revision 1.41  2002/04/24 07:36:35  mcr * Moved from ./klips/net/ipsec/radij.c,v * * Revision 1.40  2002/01/29 17:17:58  mcr * 	moved include of ipsec_param.h to after include of linux/kernel.h * 	otherwise, it seems that some option that is set in ipsec_param.h * 	screws up something subtle in the include path to kernel.h, and * 	it complains on the snprintf() prototype. * * Revision 1.39  2002/01/29 04:00:55  mcr * 	more excise of kversions.h header. * * Revision 1.38  2002/01/29 02:13:19  mcr * 	introduction of ipsec_kversion.h means that include of * 	ipsec_param.h must preceed any decisions about what files to * 	include to deal with differences in kernel source. * * Revision 1.37  2001/10/18 04:45:23  rgb * 2.4.9 kernel deprecates linux/malloc.h in favour of linux/slab.h, * lib/freeswan.h version macros moved to lib/kversions.h. * Other compiler directive cleanups. * * Revision 1.36  2001/08/22 13:43:51  henry * eliminate the single use of min() to avoid problems with Linus changing it * * Revision 1.35  2001/06/15 04:57:29  rgb * Clarified error return codes. * Changed mask add already exists to EEXIST. * Changed mask delete did not exist to ENOENT. * * Revision 1.34  2001/05/03 19:44:26  rgb * Fix sign of error return codes for rj_addroute(). * * Revision 1.33  2001/02/27 22:24:56  rgb * Re-formatting debug output (line-splitting, joining, 1arg/line). * Check for satoa() return codes. * * Revision 1.32  2001/02/27 06:23:15  rgb * Debug line splitting. * * Revision 1.31  2000/11/06 04:35:21  rgb * Clear table *before* releasing other items in radijcleanup. * * Revision 1.30  2000/09/20 04:07:40  rgb * Changed static functions to DEBUG_NO_STATIC to reveal function names in * oopsen. * * Revision 1.29  2000/09/12 03:25:02  rgb * Moved radij_c_version printing to ipsec_version_get_info(). * * Revision 1.28  2000/09/08 19:12:56  rgb * Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG. * * Revision 1.27  2000/07/28 14:58:32  rgb * Changed kfree_s to kfree, eliminating extra arg to fix 2.4.0-test5. * * Revision 1.26  2000/05/10 23:11:37  rgb * Comment out most of the startup version information. * * Revision 1.25  2000/01/21 06:21:47  rgb * Change return codes to negative on error. * * Revision 1.24  1999/11/18 04:09:20  rgb * Replaced all kernel version macros to shorter, readable form. * * Revision 1.23  1999/11/17 15:53:41  rgb * Changed all occurrences of #include "../../../lib/freeswan.h" * to #include <freeswan.h> which works due to -Ilibfreeswan in the * klips/net/ipsec/Makefile. * * Revision 1.22  1999/10/15 22:17:28  rgb * Modify radijcleanup() to call radijcleartree(). * * Revision 1.21  1999/10/08 18:37:34  rgb * Fix end-of-line spacing to sate whining PHMs. * * Revision 1.20  1999/10/01 15:44:54  rgb * Move spinlock header include to 2.1> scope. * * Revision 1.19  1999/10/01 08:35:52  rgb * Add spinlock include to shut up compiler for 2.0.38. * * Revision 1.18  1999/09/23 18:02:52  rgb * De-alarm the search failure message so it doesn't sound so grave. * * Revision 1.17  1999/05/25 21:26:01  rgb * Fix rj_walktree() sanity checking bug. * * Revision 1.16  1999/05/09 03:25:38  rgb * Fix bug introduced by 2.2 quick-and-dirty patch. * * Revision 1.15  1999/05/05 22:02:33  rgb * Add a quick and dirty port to 2.2 kernels by Marc Boucher <marc@mbsi.ca>. * * Revision 1.14  1999/04/29 15:24:15  rgb * Add sanity checking for null pointer arguments. * Standardise an error return method. * * Revision 1.13  1999/04/11 00:29:02  henry * GPL boilerplate * * Revision 1.12  1999/04/06 04:54:28  rgb * Fix/Add RCSID Id: and Log: bits to make PHMDs happy.  This includes * patch shell fixes. * * Revision 1.11  1999/02/17 16:52:53  rgb * Convert DEBUG_IPSEC to KLIPS_PRINT * Clean out unused cruft. * * Revision 1.10  1999/01/22 06:30:05  rgb * Cruft clean-out. * 64-bit clean-up. * * Revision 1.9  1998/12/01 13:22:04  rgb * Added support for debug printing of version info. * * Revision 1.8  1998/11/30 13:22:55  rgb * Rationalised all the klips kernel file headers.  They are much shorter * now and won't conflict under RH5.2. * * Revision 1.7  1998/10/25 02:43:26  rgb * Change return type on rj_addroute and rj_delete and add and argument * to the latter to be able to transmit more infomation about errors. * * Revision 1.6  1998/10/19 14:30:06  rgb * Added inclusion of freeswan.h. * * Revision 1.5  1998/10/09 04:33:27  rgb * Added 'klips_debug' prefix to all klips printk debug statements. * Fixed output formatting slightly. * * Revision 1.4  1998/07/28 00:06:59  rgb * Add debug detail to tree traversing. * * Revision 1.3  1998/07/14 18:07:58  rgb * Add a routine to clear the eroute tree. * * Revision 1.2  1998/06/25 20:03:22  rgb * Cleanup #endif comments.  Debug output for rj_init. * * Revision 1.1  1998/06/18 21:30:22  henry * move sources from klips/src to klips/net/ipsec to keep stupid kernel * build scripts happier about symlinks * * Revision 1.8  1998/05/25 20:34:15  rgb * Remove temporary ipsec_walk, rj_deltree and rj_delnodes functions. * * Rename ipsec_rj_walker (ipsec_walk) to ipsec_rj_walker_procprint and * add ipsec_rj_walker_delete. * * Recover memory for eroute table on unload of module. * * Revision 1.7  1998/05/21 12:58:58  rgb * Moved 'extern' definitions to ipsec_radij.h to support /proc 3k limit fix. * * Revision 1.6  1998/04/23 20:57:29  rgb * Cleaned up compiler warnings for unused debugging functions. * * Revision 1.5  1998/04/22 16:51:38  rgb * Tidy up radij debug code from recent rash of modifications to debug code. * * Revision 1.4  1998/04/21 21:28:56  rgb * Rearrange debug switches to change on the fly debug output from user * space.  Only kernel changes checked in at this time.  radij.c was also * changed to temporarily remove buggy debugging code in rj_delete causing * an OOPS and hence, netlink device open errors. * * Revision 1.3  1998/04/14 17:30:37  rgb * Fix up compiling errors for radij tree memory reclamation. * * Revision 1.2  1998/04/12 22:03:25  rgb * Updated ESP-3DES-HMAC-MD5-96, * 	ESP-DES-HMAC-MD5-96, * 	AH-HMAC-MD5-96, * 	AH-HMAC-SHA1-96 since Henry started freeswan cvs repository * from old standards (RFC182[5-9] to new (as of March 1998) drafts. * * Fixed eroute references in /proc/net/ipsec*. * * Started to patch module unloading memory leaks in ipsec_netlink and * radij tree unloading. * * Revision 1.1  1998/04/09 03:06:15  henry * sources moved up from linux/net/ipsec * * Revision 1.1.1.1  1998/04/08 05:35:03  henry * RGB's ipsec-0.8pre2.tar.gz ipsec-0.8 * * Revision 0.4  1997/01/15 01:28:15  ji * No changes. * * Revision 0.3  1996/11/20 14:39:04  ji * Minor cleanups. * Rationalized debugging code. * * Revision 0.2  1996/11/02 00:18:33  ji * First limited release. * * */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -