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

📄 ipsec_proc.c

📁 This a good VPN source
💻 C
📖 第 1 页 / 共 3 页
字号:
	ipsec_eroute_get_info,	NULL, NULL, NULL, NULL, NULL};struct proc_dir_entry ipsec_spi ={	0,	9, "ipsec_spi",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	ipsec_spi_get_info,	NULL, NULL, NULL, NULL, NULL};struct proc_dir_entry ipsec_spigrp ={	0,	12, "ipsec_spigrp",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	ipsec_spigrp_get_info,	NULL, NULL, NULL, NULL, NULL};struct proc_dir_entry ipsec_tncfg ={	0,	11, "ipsec_tncfg",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	ipsec_tncfg_get_info,	NULL, NULL, NULL, NULL, NULL};struct proc_dir_entry ipsec_version ={	0,	13, "ipsec_version",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	ipsec_version_get_info,	NULL, NULL, NULL, NULL, NULL};#ifdef CONFIG_KLIPS_DEBUGstruct proc_dir_entry ipsec_klipsdebug ={	0,	16, "ipsec_klipsdebug",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	ipsec_klipsdebug_get_info,	NULL, NULL, NULL, NULL, NULL};#endif /* CONFIG_KLIPS_DEBUG */#endif /* !PROC_FS_2325 */#endif /* CONFIG_PROC_FS */#if defined(PROC_FS_2325) struct ipsec_proc_list {	char                   *name;	struct proc_dir_entry **parent;	struct proc_dir_entry **dir;	read_proc_t            *readthing;	write_proc_t           *writething;	void                   *data;};static struct ipsec_proc_list proc_items[]={#ifdef CONFIG_KLIPS_DEBUG	{"klipsdebug", &proc_net_ipsec_dir, NULL,             ipsec_klipsdebug_get_info, NULL, NULL},#endif	{"eroute",     &proc_net_ipsec_dir, &proc_eroute_dir, NULL, NULL, NULL},	{"all",        &proc_eroute_dir,    NULL,             ipsec_eroute_get_info,     NULL, NULL},	{"spi",        &proc_net_ipsec_dir, &proc_spi_dir,    NULL, NULL, NULL},	{"all",        &proc_spi_dir,       NULL,             ipsec_spi_get_info,        NULL, NULL},	{"spigrp",     &proc_net_ipsec_dir, &proc_spigrp_dir, NULL, NULL, NULL},	{"all",        &proc_spigrp_dir,    NULL,             ipsec_spigrp_get_info,     NULL, NULL},	{"birth",      &proc_net_ipsec_dir, &proc_birth_dir,  NULL,      NULL, NULL},	{"ipv4",       &proc_birth_dir,     NULL,             ipsec_birth_info, ipsec_birth_set, (void *)&ipsec_ipv4_birth_packet},	{"ipv6",       &proc_birth_dir,     NULL,             ipsec_birth_info, ipsec_birth_set, (void *)&ipsec_ipv6_birth_packet},	{"tncfg",      &proc_net_ipsec_dir, NULL,             ipsec_tncfg_get_info,      NULL, NULL},	{"xforms",     &proc_net_ipsec_dir, NULL,             ipsec_xform_get_info,      NULL, NULL},	{"stats",      &proc_net_ipsec_dir, &proc_stats_dir,  NULL,      NULL, NULL},	{"trap_count", &proc_stats_dir,     NULL,             ipsec_stats_get_int_info, NULL, &ipsec_xmit_trap_count},	{"trap_sendcount", &proc_stats_dir, NULL,             ipsec_stats_get_int_info, NULL, &ipsec_xmit_trap_sendcount},	{"version",    &proc_net_ipsec_dir, NULL,             ipsec_version_get_info,    NULL, NULL},	{NULL,         NULL,                NULL,             NULL,      NULL, NULL}};#endif		intipsec_proc_init(){	int error = 0;#ifdef IPSEC_PROC_SUBDIRS	struct proc_dir_entry *item;#endif	/*	 * just complain because pluto won't run without /proc!	 */#ifndef CONFIG_PROC_FS #error You must have PROC_FS built in to use KLIPS#endif        /* for 2.0 kernels */#if !defined(PROC_FS_2325) && !defined(PROC_FS_21)	error |= proc_register_dynamic(&proc_net, &ipsec_eroute);	error |= proc_register_dynamic(&proc_net, &ipsec_spi);	error |= proc_register_dynamic(&proc_net, &ipsec_spigrp);	error |= proc_register_dynamic(&proc_net, &ipsec_tncfg);	error |= proc_register_dynamic(&proc_net, &ipsec_version);#ifdef CONFIG_KLIPS_DEBUG	error |= proc_register_dynamic(&proc_net, &ipsec_klipsdebug);#endif /* CONFIG_KLIPS_DEBUG */#endif	/* for 2.2 kernels */#if !defined(PROC_FS_2325) && defined(PROC_FS_21)	error |= proc_register(proc_net, &ipsec_eroute);	error |= proc_register(proc_net, &ipsec_spi);	error |= proc_register(proc_net, &ipsec_spigrp);	error |= proc_register(proc_net, &ipsec_tncfg);	error |= proc_register(proc_net, &ipsec_version);#ifdef CONFIG_KLIPS_DEBUG	error |= proc_register(proc_net, &ipsec_klipsdebug);#endif /* CONFIG_KLIPS_DEBUG */#endif	/* for 2.4 kernels */#if defined(PROC_FS_2325)	/* create /proc/net/ipsec */	/* zero these out before we initialize /proc/net/ipsec/birth/stuff */	memset(&ipsec_ipv4_birth_packet, 0, sizeof(struct ipsec_birth_reply));	memset(&ipsec_ipv6_birth_packet, 0, sizeof(struct ipsec_birth_reply));	proc_net_ipsec_dir = proc_mkdir("ipsec", proc_net);	if(proc_net_ipsec_dir == NULL) {		/* no point in continuing */		return 1;	} 		{		struct ipsec_proc_list *it;		it=proc_items;		while(it->name!=NULL) {			if(it->dir) {				/* make a dir instead */				item = proc_mkdir(it->name, *it->parent);				*it->dir = item;			} else {				item = create_proc_entry(it->name, 0400, *it->parent);			}			if(item) {				item->read_proc  = it->readthing;				item->write_proc = it->writething;				item->data       = it->data;#ifdef MODULE				item->owner = THIS_MODULE;#endif			} else {				error |= 1;			}			it++;		}	}		/* now create some symlinks to provide compatibility */	proc_symlink("ipsec_eroute", proc_net, "ipsec/eroute/all");	proc_symlink("ipsec_spi",    proc_net, "ipsec/spi/all");	proc_symlink("ipsec_spigrp", proc_net, "ipsec/spigrp/all");	proc_symlink("ipsec_tncfg",  proc_net, "ipsec/tncfg");	proc_symlink("ipsec_version",proc_net, "ipsec/version");	proc_symlink("ipsec_klipsdebug",proc_net,"ipsec/klipsdebug");#endif /* !PROC_FS_2325 */	return error;}voidipsec_proc_cleanup(){	/* for 2.0 and 2.2 kernels */#if !defined(PROC_FS_2325) #ifdef CONFIG_KLIPS_DEBUG	if (proc_net_unregister(ipsec_klipsdebug.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_klipsdebug\n");#endif /* CONFIG_KLIPS_DEBUG */	if (proc_net_unregister(ipsec_version.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_version\n");	if (proc_net_unregister(ipsec_eroute.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_eroute\n");	if (proc_net_unregister(ipsec_spi.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_spi\n");	if (proc_net_unregister(ipsec_spigrp.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_spigrp\n");	if (proc_net_unregister(ipsec_tncfg.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_tncfg\n");#endif	/* for 2.4 kernels */#if defined(PROC_FS_2325)	{		struct ipsec_proc_list *it;		/* find end of list */		it=proc_items;		while(it->name!=NULL) {			it++;		}		it--;		do {			remove_proc_entry(it->name, *it->parent);			it--;		} while(it > proc_items);	}#ifdef CONFIG_KLIPS_DEBUG	remove_proc_entry("ipsec_klipsdebug", proc_net);#endif /* CONFIG_KLIPS_DEBUG */	remove_proc_entry("ipsec_eroute",     proc_net);	remove_proc_entry("ipsec_spi",        proc_net);	remove_proc_entry("ipsec_spigrp",     proc_net);	remove_proc_entry("ipsec_tncfg",      proc_net);	remove_proc_entry("ipsec_version",    proc_net);	remove_proc_entry("ipsec",            proc_net);#endif /* 2.4 kernel */}/* * $Log: ipsec_proc.c,v $ * Revision 1.34  2004/12/03 21:25:57  mcr * 	compile time fixes for running on 2.6. * 	still experimental. * * Revision 1.33  2004/08/17 03:27:23  mcr * 	klips 2.6 edits. * * Revision 1.32  2004/08/03 18:19:08  mcr * 	in 2.6, use "net_device" instead of #define device->net_device. * 	this probably breaks 2.0 compiles. * * Revision 1.31  2004/07/10 19:11:18  mcr * 	CONFIG_IPSEC -> CONFIG_KLIPS. * * Revision 1.30  2004/04/25 21:23:11  ken * Pull in dhr's changes from FreeS/WAN 2.06 * * Revision 1.29  2004/04/06 02:49:26  mcr * 	pullup of algo code from alg-branch. * * Revision 1.28  2004/03/28 20:29:58  paul *      <hugh_> ssize_t, not ssized_t * * Revision 1.27  2004/03/28 20:27:20  paul * Included tested and confirmed fixes mcr made and dhr verified for * snprint statements. Changed one other snprintf to use ipsec_snprintf * so it wouldnt break compatibility with 2.0/2.2 kernels. Verified with * dhr. (thanks dhr!) * * Revision 1.26  2004/02/09 22:07:06  mcr * 	added information about nat-traversal setting to spi-output. * * Revision 1.25.4.1  2004/04/05 04:30:46  mcr * 	patches for alg-branch to compile/work with 2.x openswan * * Revision 1.25  2003/10/31 02:27:55  mcr * 	pulled up port-selector patches and sa_id elimination. * * Revision 1.24.4.1  2003/10/29 01:30:41  mcr * 	elimited "struct sa_id". * * Revision 1.24  2003/06/20 01:42:21  mcr * 	added counters to measure how many ACQUIREs we send to pluto, * 	and how many are successfully sent. * * Revision 1.23  2003/04/03 17:38:09  rgb * Centralised ipsec_kfree_skb and ipsec_dev_{get,put}. * * Revision 1.22  2002/09/20 15:40:57  rgb * Renamed saref macros for consistency and brevity. * * Revision 1.21  2002/09/20 05:01:35  rgb * Print ref and  reftable, refentry seperately. * * Revision 1.20  2002/09/19 02:35:39  mcr * 	do not define structures needed by /proc/net/ipsec/ if we * 	aren't going create that directory. * * Revision 1.19  2002/09/10 01:43:25  mcr * 	fixed problem in /-* comment. * * Revision 1.18  2002/09/03 16:22:11  mcr * 	fixed initialization of birth/stuff values - some simple * 	screw ups in the code. * 	removed debugging that was left in by mistake. * * Revision 1.17  2002/09/02 17:54:53  mcr * 	changed how the table driven /proc entries are created so that * 	making subdirs is now explicit rather than implicit. * * Revision 1.16  2002/08/30 01:23:37  mcr * 	reorganized /proc creating code to clear up ifdefs, * 	make the 2.4 code table driven, and put things into * 	/proc/net/ipsec subdir. Symlinks are left for compatibility. * * Revision 1.15  2002/08/13 19:01:25  mcr * 	patches from kenb to permit compilation of FreeSWAN on ia64. * 	des library patched to use proper DES_LONG type for ia64. * * Revision 1.14  2002/07/26 08:48:31  rgb * Added SA ref table code. * * Revision 1.13  2002/07/24 18:44:54  rgb * Type fiddling to tame ia64 compiler. * * Revision 1.12  2002/05/27 18:56:07  rgb * Convert to dynamic ipsec device allocation. * * Revision 1.11  2002/05/23 07:14:50  rgb * Added refcount code. * Cleaned up %p variants to 0p%p for test suite cleanup. * Convert "usecount" to "refcount" to remove ambiguity. * * Revision 1.10  2002/04/24 07:55:32  mcr * 	#include patches and Makefiles for post-reorg compilation. * * Revision 1.9  2002/04/24 07:36:28  mcr * Moved from ./klips/net/ipsec/ipsec_proc.c,v * * Revision 1.8  2002/01/29 17:17:55  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.7  2002/01/29 04:00:52  mcr * 	more excise of kversions.h header. * * Revision 1.6  2002/01/29 02:13:17  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.5  2002/01/12 02:54:30  mcr * 	beginnings of /proc/net/ipsec dir. * * Revision 1.4  2001/12/11 02:21:05  rgb * Don't include module version here, fixing 2.2 compile bug. * * Revision 1.3  2001/12/05 07:19:44  rgb * Fixed extraneous #include "version.c" bug causing modular KLIPS failure. * * Revision 1.2  2001/11/26 09:16:14  rgb * Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes. * * Revision 1.74  2001/11/22 05:44:11  henry * new version stuff * * Revision 1.1.2.1  2001/09/25 02:19:40  mcr * 	/proc manipulation code moved to new ipsec_proc.c * * * Local variables: * c-file-style: "linux" * End: * */

⌨️ 快捷键说明

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