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

📄 eroute.c

📁 FREESWAN VPN源代码包
💻 C
📖 第 1 页 / 共 3 页
字号:
				program_name, ipaddr_txt, error);			pfkey_extensions_free(extensions);			exit(1);		}		if(debug) {			fprintf(stdout, "%s: DEBUG: pfkey_address_build successful for dst flow.\n", program_name);		}				maskof(&s_subnet, &pfkey_address_smask_ska); /* src mask */		add_port(eroute_af, &pfkey_address_smask_ska, src_port ? ~0:0);		if((error = pfkey_address_build(&extensions[SADB_X_EXT_ADDRESS_SRC_MASK],						SADB_X_EXT_ADDRESS_SRC_MASK,						0,						0,						sockaddrof(&pfkey_address_smask_ska)))) {			addrtot(&pfkey_address_smask_ska, 0, ipaddr_txt, sizeof(ipaddr_txt));			fprintf(stderr, "%s: Trouble building address_smask extension (%s), error=%d.\n",				program_name, ipaddr_txt, error);			pfkey_extensions_free(extensions);			exit(1);		}		if(debug) {			fprintf(stdout, "%s: DEBUG: pfkey_address_build successful for src mask.\n", program_name);		}				maskof(&d_subnet, &pfkey_address_dmask_ska); /* dst mask */		add_port(eroute_af, &pfkey_address_dmask_ska, dst_port ? ~0:0);		if((error = pfkey_address_build(&extensions[SADB_X_EXT_ADDRESS_DST_MASK],						SADB_X_EXT_ADDRESS_DST_MASK,						0,						0,						sockaddrof(&pfkey_address_dmask_ska)))) {			addrtot(&pfkey_address_dmask_ska, 0, ipaddr_txt, sizeof(ipaddr_txt));			fprintf(stderr, "%s: Trouble building address_dmask extension (%s), error=%d.\n",				program_name, ipaddr_txt, error);			pfkey_extensions_free(extensions);			exit(1);		}		if(debug) {			fprintf(stdout, "%s: DEBUG: pfkey_address_build successful for dst mask.\n", program_name);		}	}		if (transport_proto != 0) {		if ((error = pfkey_x_protocol_build(&extensions[SADB_X_EXT_PROTOCOL],						    transport_proto))) {			fprintf(stderr, "%s: Trouble building transport"				" protocol extension, error=%d.\n",				program_name, error);			exit(1);		}	}	if((error = pfkey_msg_build(&pfkey_msg, extensions, EXT_BITS_IN))) {		fprintf(stderr, "%s: Trouble building pfkey message, error=%d.\n",			program_name, error);		pfkey_extensions_free(extensions);		pfkey_msg_free(&pfkey_msg);		exit(1);	}	if(debug) {		fprintf(stdout, "%s: DEBUG: pfkey_msg_build successful.\n", program_name);	}	if((error = write(pfkey_sock,			  pfkey_msg,			  pfkey_msg->sadb_msg_len * IPSEC_PFKEYv2_ALIGN)) !=	   pfkey_msg->sadb_msg_len * IPSEC_PFKEYv2_ALIGN) {		fprintf(stderr, "%s: pfkey write failed, returning %d with errno=%d.\n",			program_name, error, errno);		pfkey_extensions_free(extensions);		pfkey_msg_free(&pfkey_msg);		switch(errno) {		case EINVAL:			fprintf(stderr, "Invalid argument, check kernel log messages for specifics.\n");			break;		case ENXIO:			if((action_type == EMT_SETEROUTE) ||			   (action_type == EMT_REPLACEROUTE)) {				fprintf(stderr, "Invalid mask.\n");				break;			}			if(action_type == EMT_DELEROUTE) {				fprintf(stderr, "Mask not found.\n");				break;			}		case EFAULT:			if((action_type == EMT_SETEROUTE) ||			   (action_type == EMT_REPLACEROUTE)) {				fprintf(stderr, "Invalid address.\n");				break;			}			if(action_type == EMT_DELEROUTE) {				fprintf(stderr, "Address not found.\n");				break;			}		case EACCES:			fprintf(stderr, "access denied.  ");			if(getuid() == 0) {				fprintf(stderr, "Check permissions.  Should be 600.\n");			} else {				fprintf(stderr, "You must be root to open this file.\n");			}			break;		case EUNATCH:			fprintf(stderr, "KLIPS not loaded.\n");			break;		case EBUSY:			fprintf(stderr, "KLIPS is busy.  Most likely a serious internal error occured in a previous command.  Please report as much detail as possible to development team.\n");			break;		case ENODEV:			fprintf(stderr, "KLIPS not loaded or enabled.\n");			fprintf(stderr, "No device?!?\n");			break;		case ENOBUFS:			fprintf(stderr, "No kernel memory to allocate SA.\n");			break;		case ESOCKTNOSUPPORT:			fprintf(stderr, "Algorithm support not available in the kernel.  Please compile in support.\n");			break;		case EEXIST:			fprintf(stderr, "eroute already in use.  Delete old one first.\n");			break;		case ENOENT:			if((action_type == EMT_INEROUTE)) {				fprintf(stderr, "non-existant IPIP SA.\n");				break;			}			fprintf(stderr, "eroute doesn't exist.  Can't delete.\n");			break;		default:			fprintf(stderr, "Unknown socket write error %d.  Please report as much detail as possible to development team.\n", errno);		}/*		fprintf(stderr, "%s: socket write returned errno %d\n",		program_name, errno);*/		exit(1);	}	if(debug) {		fprintf(stdout, "%s: DEBUG: pfkey write successful.\n", program_name);	}	if(pfkey_msg) {		pfkey_extensions_free(extensions);		pfkey_msg_free(&pfkey_msg);	}	(void) close(pfkey_sock);  /* close the socket */	if(debug) {		fprintf(stdout, "%s: DEBUG: write ok\n", program_name);	}	exit(0);}/* * $Log: eroute.c,v $ * Revision 1.2  2002/12/12 03:32:07  ken * Upgraded to X.509 0.9.16 w/manual merges for NAT-T support * * Revision 1.1.1.1  2002/09/05 03:13:19  ken * 1.98b * * Revision 1.49  2002/03/08 21:44:04  rgb * Update for all GNU-compliant --version strings. * * Revision 1.48  2002/02/15 19:54:11  rgb * Purged dead code. * * Revision 1.47  2001/11/09 01:42:36  rgb * Re-formatted usage text for clarity. * * Revision 1.46  2001/10/02 17:03:45  rgb * Check error return for all "tto*" calls and report errors.  This, in * conjuction with the fix to "tto*" will detect AF not set. * * Revision 1.45  2001/09/07 22:12:27  rgb * Added EAFNOSUPPORT error return explanation for KLIPS not loaded. * * Revision 1.44  2001/07/06 19:49:33  rgb * Renamed EMT_RPLACEROUTE to EMT_REPLACEROUTE for clarity and logical text * searching. * Added EMT_INEROUTE for supporting incoming policy checks. * Added inbound policy checking code for IPIP SAs. * * Revision 1.43  2001/06/15 05:02:05  rgb * Fixed error return messages and codes. * * Revision 1.42  2001/06/14 19:35:14  rgb * Update copyright date. * * Revision 1.41  2001/05/21 02:02:54  rgb * Eliminate 1-letter options. * * Revision 1.40  2001/05/16 04:39:57  rgb * Fix --label option to add to command name rather than replace it. * Fix 'print table' option to ignore --label and --debug options. * * Revision 1.39  2001/02/26 19:59:03  rgb * Added a number of missing ntohl() conversions for debug output. * Implement magic SAs %drop, %reject, %trap, %hold, %pass as part * of the new SPD and to support opportunistic. * Enforced spi > 0x100 requirement, now that pass uses a magic SA. * * Revision 1.38  2000/09/17 18:56:48  rgb * Added IPCOMP support. * * Revision 1.37  2000/09/12 22:36:08  rgb * Gerhard's IPv6 support. * Restructured to remove unused extensions from CLEARFLOW messages. * Added debugging. * * Revision 1.36  2000/09/08 19:17:31  rgb * Removed all references to CONFIG_IPSEC_PFKEYv2. * * Revision 1.35  2000/08/27 01:46:52  rgb * Update copyright dates and remove no longer used resolve_ip(). * * Revision 1.34  2000/07/26 03:41:45  rgb * Changed all printf's to fprintf's.  Fixed tncfg's usage to stderr. * * Revision 1.33  2000/07/13 21:54:49  rgb * Remove old cruft from a time when libfreeswan didn't exist and I checked * name lookup errors with the default address. * * Revision 1.32  2000/06/21 16:51:27  rgb * Added no additional argument option to usage text. * * Revision 1.31  2000/03/16 06:40:49  rgb * Hardcode PF_KEYv2 support. * * Revision 1.30  2000/01/22 23:22:46  rgb * Use new function proto2satype(). * * Revision 1.29  2000/01/21 09:42:32  rgb * Replace resolve_ip() with atoaddr() from freeswanlib. * * Revision 1.28  2000/01/21 06:22:28  rgb * Changed to AF_ENCAP macro. * Added --debug switch to command line. * Added pfkeyv2 support to completely avoid netlink. * * Revision 1.27  1999/12/07 18:27:10  rgb * Added headers to silence fussy compilers. * Converted local functions to static to limit scope. * * Revision 1.26  1999/11/25 09:07:44  rgb * Fixed printf % escape bug. * Clarified assignment in conditional with parens. * * Revision 1.25  1999/11/23 23:06:26  rgb * Sort out pfkey and freeswan headers, putting them in a library path. * * Revision 1.24  1999/06/10 15:55:14  rgb * Add error return code. * * Revision 1.23  1999/04/15 15:37:27  rgb * Forward check changes from POST1_00 branch. * * Revision 1.19.2.2  1999/04/13 20:58:10  rgb * Add argc==1 --> /proc/net/ipsec_*. * * Revision 1.19.2.1  1999/03/30 17:01:36  rgb * Make main() return type explicit. * * Revision 1.22  1999/04/11 00:12:08  henry * GPL boilerplate * * Revision 1.21  1999/04/06 04:54:37  rgb * Fix/Add RCSID Id: and Log: bits to make PHMDs happy.  This includes * patch shell fixes. * * Revision 1.20  1999/03/17 15:40:54  rgb * Make explicit main() return type of int. * * Revision 1.19  1999/01/26 05:51:01  rgb * Updated to use %passthrough instead of bypass. * * Revision 1.18  1999/01/22 06:34:52  rgb * Update to include SAID command line parameter. * Add IPSEC 'bypass' switch. * Add error-checking. * Cruft clean-out. * * Revision 1.17  1998/11/29 00:52:26  rgb * Add explanation to warning about default source or destination. * * Revision 1.16  1998/11/12 21:08:03  rgb * Add --label option to identify caller from scripts. * * Revision 1.15  1998/10/27 00:33:27  rgb * Make output error text more fatal-sounding. * * Revision 1.14  1998/10/26 01:28:38  henry * use SA_* protocol names, not IPPROTO_*, to avoid compile problems * * Revision 1.13  1998/10/25 02:44:56  rgb * Institute more precise error return codes from eroute commands. * * Revision 1.12  1998/10/19 18:58:55  rgb * Added inclusion of freeswan.h. * a_id structure implemented and used: now includes protocol. * * Revision 1.11  1998/10/09 18:47:29  rgb * Add 'optionfrom' to get more options from a named file. * * Revision 1.10  1998/10/09 04:34:58  rgb * Changed help output from stderr to stdout. * Changed error messages from stdout to stderr. * Added '--replace' option. * Deleted old commented out cruft. * * Revision 1.9  1998/08/18 17:18:13  rgb * Delete old commented out cruft. * Reduce destination and source default subnet to warning, not fatal. * * Revision 1.8  1998/08/05 22:24:45  rgb * Change includes to accomodate RH5.x * * Revision 1.7  1998/07/29 20:49:08  rgb * Change to use 0x-prefixed hexadecimal for spi's. * * Revision 1.6  1998/07/28 00:14:24  rgb * Convert from positional parameters to long options. * Add --clean option. * Add hostname lookup support. * * Revision 1.5  1998/07/14 18:13:28  rgb * Restructured for better argument checking. * Added command to clear the eroute table. * * Revision 1.4  1998/07/09 18:14:10  rgb * Added error checking to IP's and keys. * Made most error messages more specific rather than spamming usage text. * Added more descriptive kernel error return codes and messages. * Converted all spi translations to unsigned. * Removed all invocations of perror. * * Revision 1.3  1998/05/27 18:48:19  rgb * Adding --help and --version directives. * * Revision 1.2  1998/04/13 03:15:29  rgb * Commands are now distinguishable from arguments when invoking usage. * * Revision 1.1.1.1  1998/04/08 05:35:10  henry * RGB's ipsec-0.8pre2.tar.gz ipsec-0.8 * * Revision 0.3  1996/11/20 14:51:32  ji * Fixed problems with #include paths. * Changed (incorrect) references to ipsp into ipsec. * * Revision 0.2  1996/11/08 15:45:24  ji * First limited release. * * */

⌨️ 快捷键说明

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