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

📄 ipsec_proc.c

📁 FREESWAN VPN源代码包
💻 C
📖 第 1 页 / 共 2 页
字号:
			if(!sa_p->ips_inext)			{				sa_p2 = sa_p;				while(sa_p2) {					sa_len = satoa(sa_p2->ips_said,						       0, sa, SATOA_BUF);										len += sprintf(buffer + len, "%s ",						       sa_len ? sa : " (error)");					sa_p2 = sa_p2->ips_onext;				}				len += sprintf(buffer + len, "\n");				pos = begin + len;				if(pos < offset) {					len = 0;					begin = pos;				}				if (pos > offset + length) {					goto done_spigrp_i;				}			}		}	} done_spigrp_i:		spin_unlock_bh(&tdb_lock);	*start = buffer + (offset - begin);	/* Start of wanted data */	len -= (offset - begin);			/* Start slop */	if (len > length)		len = length;	return len;}IPSEC_PROCFS_DEBUG_NO_STATICintipsec_tncfg_get_info(char *buffer,		     char **start,		     off_t offset,		     int length     IPSEC_PROC_LAST_ARG){	int len = 0;	off_t pos = 0, begin = 0;	int i;	char name[9];	struct device *dev, *privdev;	struct ipsecpriv *priv;	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_tncfg_get_info: "		    "buffer=0x%p, *start=0x%x, offset=%d, length=%d\n",		    buffer,		    (u_int)*start,		    (int)offset,		    length);	for(i = 0; i < IPSEC_NUM_IF; i++) {		sprintf(name, "ipsec%d", i);		dev = ipsec_dev_get(name);		if(dev) {			priv = (struct ipsecpriv *)(dev->priv);			len += sprintf(buffer + len, "%s",				       dev->name);			if(priv) {				privdev = (struct device *)(priv->dev);				len += sprintf(buffer + len, " -> %s",					       privdev ? privdev->name : "NULL");				len += sprintf(buffer + len, " mtu=%d(%d) -> %d",					       dev->mtu,					       priv->mtu,					       privdev ? privdev->mtu : 0);			} else {				KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,					    "klips_debug:ipsec_tncfg_get_info: device '%s' has no private data space!\n",					    dev->name);			}			len += sprintf(buffer + len, "\n");			pos = begin + len;			if(pos < offset) {				len = 0;				begin = pos;			}			else if (pos > offset + length)	{				break;			}		}	}	*start = buffer + (offset - begin);	/* Start of wanted data */	len -= (offset - begin);			/* Start slop */	if (len > length)		len = length;	return len;}IPSEC_PROCFS_DEBUG_NO_STATICintipsec_version_get_info(char *buffer,		       char **start,		       off_t offset,		       int length  IPSEC_PROC_LAST_ARG){	int len = 0;	off_t begin = 0;	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_version_get_info: "		    "buffer=0x%p, *start=0x%x, offset=%d, length=%d\n",		    buffer,		    (u_int)*start,		    (int)offset,		    length);	len += sprintf(buffer + len, "FreeS/WAN version: %s\n",		       ipsec_version_code());#if 0	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_version_get_info: "		    "ipsec_init version: %s\n",		    ipsec_init_c_version);	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_version_get_info: "		    "ipsec_tunnel version: %s\n",		    ipsec_tunnel_c_version);	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_version_get_info: "		    "ipsec_netlink version: %s\n",		    ipsec_netlink_c_version);	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_version_get_info: "		    "radij_c_version: %s\n",		    radij_c_version);#endif	*start = buffer + (offset - begin);	/* Start of wanted data */	len -= (offset - begin);			/* Start slop */	if (len > length)		len = length;	return len;}#ifdef CONFIG_IPSEC_DEBUGIPSEC_PROCFS_DEBUG_NO_STATICintipsec_klipsdebug_get_info(char *buffer,			  char **start,			  off_t offset,			  int length      IPSEC_PROC_LAST_ARG){	int len = 0;	off_t begin = 0;	KLIPS_PRINT(debug_tunnel & DB_TN_PROCFS,		    "klips_debug:ipsec_klipsdebug_get_info: "		    "buffer=0x%p, *start=0x%x, offset=%d, length=%d\n",		    buffer,		    (u_int)*start,		    (int)offset,		    length);	len += sprintf(buffer + len, "debug_tunnel=%08x.\n", debug_tunnel);	len += sprintf(buffer + len, "debug_netlink=%08x.\n", debug_netlink);	len += sprintf(buffer + len, "debug_xform=%08x.\n", debug_xform);	len += sprintf(buffer + len, "debug_eroute=%08x.\n", debug_eroute);	len += sprintf(buffer + len, "debug_spi=%08x.\n", debug_spi);	len += sprintf(buffer + len, "debug_radij=%08x.\n", debug_radij);	len += sprintf(buffer + len, "debug_esp=%08x.\n", debug_esp);	len += sprintf(buffer + len, "debug_ah=%08x.\n", debug_ah);	len += sprintf(buffer + len, "debug_rcv=%08x.\n", debug_rcv);	len += sprintf(buffer + len, "debug_pfkey=%08x.\n", debug_pfkey);	*start = buffer + (offset - begin);	/* Start of wanted data */	len -= (offset - begin);			/* Start slop */	if (len > length)		len = length;	return len;}#endif /* CONFIG_IPSEC_DEBUG */#ifndef PROC_FS_2325struct proc_dir_entry ipsec_eroute ={	0,	12, "ipsec_eroute",	S_IFREG | S_IRUGO, 1, 0, 0, 0,	&proc_net_inode_operations,	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_IPSEC_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_IPSEC_DEBUG */#endif /* !PROC_FS_2325 */#endif /* CONFIG_PROC_FS */intipsec_proc_init(){	int error = 0;	/* compile a dummy function if no /proc/-fs */	/* XXX-mcr probably should just complain because pluto won't	 * run without /proc!	 */#ifdef CONFIG_PROC_FS #  ifndef PROC_FS_2325#    ifdef 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_IPSEC_DEBUG	error |= proc_register(proc_net, &ipsec_klipsdebug);#      endif /* CONFIG_IPSEC_DEBUG */#    else /* 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_IPSEC_DEBUG	error |= proc_register_dynamic(&proc_net, &ipsec_klipsdebug);#      endif /* CONFIG_IPSEC_DEBUG */#    endif /* PROC_FS_21 */#  else /* !PROC_FS_2325 */	/* create /proc/net/ipsec */#if 0	proc_net_ipsec_dir = proc_mkdir("ipsec", proc_net);	if(proc_net_ipsec_dir == NULL) {		error |= 1;	} else{		error |= proc_register();	}		#endif	proc_net_create ("ipsec_eroute", 0, ipsec_eroute_get_info);	proc_net_create ("ipsec_spi", 0, ipsec_spi_get_info);	proc_net_create ("ipsec_spigrp", 0, ipsec_spigrp_get_info);	proc_net_create ("ipsec_tncfg", 0, ipsec_tncfg_get_info);	proc_net_create ("ipsec_version", 0, ipsec_version_get_info);#    ifdef CONFIG_IPSEC_DEBUG	proc_net_create ("ipsec_klipsdebug", 0, ipsec_klipsdebug_get_info);#    endif /* CONFIG_IPSEC_DEBUG */#  endif /* !PROC_FS_2325 */#endif /* CONFIG_PROC_FS */	return error;}voidipsec_proc_cleanup(){#ifdef CONFIG_PROC_FS#  ifndef PROC_FS_2325#    ifdef CONFIG_IPSEC_DEBUG	if (proc_net_unregister(ipsec_klipsdebug.low_ino) != 0)		printk("klips_debug:ipsec_cleanup: "		       "cannot unregister /proc/net/ipsec_klipsdebug\n");#    endif /* CONFIG_IPSEC_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");#  else /* !PROC_FS_2325 */#    ifdef CONFIG_IPSEC_DEBUG	proc_net_remove ("ipsec_klipsdebug");#    endif /* CONFIG_IPSEC_DEBUG */	proc_net_remove ("ipsec_eroute");	proc_net_remove ("ipsec_spi");	proc_net_remove ("ipsec_spigrp");	proc_net_remove ("ipsec_tncfg");	proc_net_remove ("ipsec_version");#  endif /* !PROC_FS_2325 */#endif          /* CONFIG_PROC_FS */}/* * $Log: ipsec_proc.c,v $ * Revision 1.1.1.1  2002/09/05 03:13:17  ken * 1.98b * * 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 + -