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

📄 ipsec_rcv.c

📁 网上下到的一个很详细介绍VPN基础知识的资料
💻 C
📖 第 1 页 / 共 4 页
字号:
	return(0);}struct inet_protocol ah_protocol ={	ipsec_rcv,				/* AH handler */	NULL,				/* TUNNEL error control */	0,				/* next */	IPPROTO_AH,			/* protocol ID */	0,				/* copy */	NULL,				/* data */	"AH"				/* name */};struct inet_protocol esp_protocol = {	ipsec_rcv,			/* ESP handler          */	NULL,				/* TUNNEL error control */	0,				/* next */	IPPROTO_ESP,			/* protocol ID */	0,				/* copy */	NULL,				/* data */	"ESP"				/* name */};#if 0/* We probably don't want to install a pure IPCOMP protocol handler, but   only want to handle IPCOMP if it is encapsulated inside an ESP payload   (which is already handled) */#ifdef CONFIG_IPSEC_IPCOMPstruct inet_protocol comp_protocol ={	ipsec_rcv,			/* COMP handler		*/	NULL,				/* COMP error control	*/	0,				/* next */	IPPROTO_COMP,			/* protocol ID */	0,				/* copy */	NULL,				/* data */	"COMP"				/* name */};#endif /* CONFIG_IPSEC_IPCOMP */#endif/* * $Log: ipsec_rcv.c,v $ * Revision 1.87  2001/06/13 20:58:40  rgb * Added parentheses around assignment used as truth value to silence * compiler. * * Revision 1.86  2001/06/07 22:25:23  rgb * Added a source address policy check for tunnel mode.  It still does * not check client addresses and masks. * Only decapsulate IPIP if it is expected. * * Revision 1.85  2001/05/30 08:14:02  rgb * Removed vestiges of esp-null transforms. * * Revision 1.84  2001/05/27 06:12:11  rgb * Added structures for pid, packet count and last access time to eroute. * Added packet count to beginning of /proc/net/ipsec_eroute. * * Revision 1.83  2001/05/04 16:45:47  rgb * Remove unneeded code.  ipp is not used after this point. * * Revision 1.82  2001/05/04 16:36:00  rgb * Fix skb_cow() call for 2.4.4. (SS) * * Revision 1.81  2001/05/02 14:46:53  rgb * Fix typo for compiler directive to pull IPH back. * * Revision 1.80  2001/04/30 19:46:34  rgb * Update for 2.4.4.  We now receive the skb with skb->data pointing to * h.raw. * * Revision 1.79  2001/04/23 15:01:15  rgb * Added spin_lock() check to prevent double-locking for multiple * transforms and hence kernel lock-ups with SMP kernels. * Minor spin_unlock() adjustments to unlock before non-dependant prints * and IPSEC device stats updates. * * Revision 1.78  2001/04/21 23:04:24  rgb * Check if soft expire has already been sent before sending another to * prevent ACQUIRE flooding. * * Revision 1.77  2001/03/16 07:35:20  rgb * Ditch extra #if 1 around now permanent policy checking code. * * Revision 1.76  2001/02/27 22:24:54  rgb * Re-formatting debug output (line-splitting, joining, 1arg/line). * Check for satoa() return codes. * * Revision 1.75  2001/02/19 22:28:30  rgb * Minor change to virtual device discovery code to assert which I/F has * been found. * * Revision 1.74  2000/11/25 03:50:36  rgb * Oops fix by minor re-arrangement of code to avoid accessing a freed tdb. * * Revision 1.73  2000/11/09 20:52:15  rgb * More spinlock shuffling, locking earlier and unlocking later in rcv to * include ipcomp and prevent races, renaming some tdb variables that got * forgotten, moving some unlocks to include tdbs and adding a missing * unlock.  Thanks to Svenning for some of these. * * Revision 1.72  2000/11/09 20:11:22  rgb * Minor shuffles to fix non-standard kernel config option selection. * * Revision 1.71  2000/11/06 04:36:18  rgb * Ditched spin_lock_irqsave in favour of spin_lock. * Minor initial protocol check rewrite. * Clean up debug printing. * Clean up tdb handling on ipcomp. * Fixed transport mode null pointer de-reference without ipcomp. * Add Svenning's adaptive content compression. * Disabled registration of ipcomp handler. * * Revision 1.70  2000/10/30 23:41:43  henry * Hans-Joerg Hoexer's null-pointer fix * * Revision 1.69  2000/10/10 18:54:16  rgb * Added a fix for incoming policy check with ipcomp enabled but * uncompressible. * * Revision 1.68  2000/09/22 17:53:12  rgb * Fixed ipcomp tdb pointers update for policy checking. * * Revision 1.67  2000/09/21 03:40:58  rgb * Added more debugging to try and track down the cpi outward copy problem. * * Revision 1.66  2000/09/20 04:00:10  rgb * Changed static functions to DEBUG_NO_STATIC to reveal function names for * debugging oopsen. * * Revision 1.65  2000/09/19 07:07:16  rgb * Added debugging to inbound policy check for ipcomp. * Added missing spin_unlocks (thanks Svenning!). * Fixed misplaced tdbnext pointers causing mismatched ipip policy check. * Protect ipcomp policy check following ipip decap with sysctl switch. * * Revision 1.64  2000/09/18 21:27:29  rgb * 2.0 fixes. * * Revision 1.63  2000/09/18 02:35:50  rgb * Added policy checking to ipcomp and re-enabled policy checking by * default. * Optimised satoa calls. * * Revision 1.62  2000/09/17 21:02:32  rgb * Clean up debugging, removing slow timestamp debug code. * * Revision 1.61  2000/09/16 01:07:55  rgb * Fixed erroneous ref from struct ipcomp to struct ipcomphdr. * * Revision 1.60  2000/09/15 11:37:01  rgb * Merge in heavily modified Svenning Soerensen's <svenning@post5.tele.dk> * IPCOMP zlib deflate code. * * Revision 1.59  2000/09/15 04:56:20  rgb * Remove redundant satoa() call, reformat comment. * * Revision 1.58  2000/09/13 08:00:52  rgb * Flick on inbound policy checking. * * Revision 1.57  2000/09/12 03:22:19  rgb * Converted inbound_policy_check to sysctl. * Re-enabled policy backcheck. * Moved policy checks to top and within tdb lock. * * Revision 1.56  2000/09/08 19:12:56  rgb * Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG. * * Revision 1.55  2000/08/28 18:15:46  rgb * Added MB's nf-debug reset patch. * * Revision 1.54  2000/08/27 01:41:26  rgb * More minor tweaks to the bad padding debug code. * * Revision 1.53  2000/08/24 16:54:16  rgb * Added KLIPS_PRINTMORE macro to continue lines without KERN_INFO level * info. * Tidied up device reporting at the start of ipsec_rcv. * Tidied up bad padding debugging and processing. * * Revision 1.52  2000/08/20 21:36:03  rgb * Activated pfkey_expire() calls. * Added a hard/soft expiry parameter to pfkey_expire(). * Added sanity checking to avoid propagating zero or smaller-length skbs * from a bogus decryption. * Re-arranged the order of soft and hard expiry to conform to RFC2367. * Clean up references to CONFIG_IPSEC_PFKEYv2. * * Revision 1.51  2000/08/18 21:23:30  rgb * Improve bad padding warning so that the printk buffer doesn't get * trampled. * * Revision 1.50  2000/08/01 14:51:51  rgb * Removed _all_ remaining traces of DES. * * Revision 1.49  2000/07/28 13:50:53  rgb * Changed enet_statistics to net_device_stats and added back compatibility * for pre-2.1.19. * * Revision 1.48  2000/05/10 19:14:40  rgb * Only check usetime against soft and hard limits if the tdb has been * used. * Cast output of ntohl so that the broken prototype doesn't make our * compile noisy. * * Revision 1.47  2000/05/09 17:45:43  rgb * Fix replay bitmap corruption bug upon receipt of bogus packet * with correct SPI.  This was a DoS. * * Revision 1.46  2000/03/27 02:31:58  rgb * Fixed authentication failure printout bug. * * Revision 1.45  2000/03/22 16:15:37  rgb * Fixed renaming of dev_get (MB). * * Revision 1.44  2000/03/16 08:17:24  rgb * Hardcode PF_KEYv2 support. * Fixed minor bug checking AH header length. * * Revision 1.43  2000/03/14 12:26:59  rgb * Added skb->nfct support for clearing netfilter conntrack bits (MB). * * Revision 1.42  2000/01/26 10:04:04  rgb * Fixed inbound policy checking on transport mode bug. * Fixed noisy 2.0 printk arguments. * * Revision 1.41  2000/01/24 20:58:02  rgb * Improve debugging/reporting support for (disabled) inbound * policy checking. * * Revision 1.40  2000/01/22 23:20:10  rgb * Fixed up inboud policy checking code. * Cleaned out unused crud. * * Revision 1.39  2000/01/21 06:15:29  rgb * Added sanity checks on skb_push(), skb_pull() to prevent panics. * Fixed cut-and-paste debug_tunnel to debug_rcv. * Added inbound policy checking code, disabled. * Simplified output code by updating ipp to post-IPIP decapsulation. * * Revision 1.38  1999/12/22 05:08:36  rgb * Checked for null skb, skb->dev, skb->data, skb->dev->name, dev->name, * protocol and take appropriate action for sanity. * Set ipsecdev to NULL if device could not be determined. * Fixed NULL stats access bug if device could not be determined. * * Revision 1.37  1999/12/14 20:07:59  rgb * Added a default switch case to catch bogus encalg values. * * Revision 1.36  1999/12/07 18:57:57  rgb * Fix PFKEY symbol compile error (SADB_*) without pfkey enabled. * * Revision 1.35  1999/12/01 22:15:35  rgb * Add checks for LARVAL and DEAD SAs. * Change state of SA from MATURE to DYING when a soft lifetime is * reached and print debug warning. * * Revision 1.34  1999/11/23 23:04:03  rgb * Use provided macro ADDRTOA_BUF instead of hardcoded value. * Sort out pfkey and freeswan headers, putting them in a library path. * * Revision 1.33  1999/11/19 01:10:06  rgb * Enable protocol handler structures for static linking. * * Revision 1.32  1999/11/18 04:09:19  rgb * Replaced all kernel version macros to shorter, readable form. * * Revision 1.31  1999/11/17 15:53:39  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.30  1999/10/26 15:09:07  rgb * Used debug compiler directives to shut up compiler for decl/assign * statement. * * Revision 1.29  1999/10/16 18:25:37  rgb * Moved SA lifetime expiry checks before packet processing. * Expire SA on replay counter rollover. * * Revision 1.28  1999/10/16 04:23:07  rgb * Add stats for replaywin_errs, replaywin_max_sequence_difference, * authentication errors, encryption size errors, encryption padding * errors, and time since last packet. * * Revision 1.27  1999/10/16 00:30:47  rgb * Added SA lifetime counting. * * Revision 1.26  1999/10/15 22:14:37  rgb * Add debugging. * * Revision 1.25  1999/10/08 18:37:34  rgb * Fix end-of-line spacing to sate whining PHMs. * * Revision 1.24  1999/10/03 18:54:51  rgb * Spinlock support for 2.3.xx. * Don't forget to undo spinlocks on error! * * Revision 1.23  1999/10/01 15:44:53  rgb * Move spinlock header include to 2.1> scope. * * Revision 1.22  1999/10/01 00:01:54  rgb * Added tdb structure locking. * * Revision 1.21  1999/09/18 11:42:12  rgb * Add Marc Boucher's tcpdump cloned packet fix. * * Revision 1.20  1999/09/17 23:50:25  rgb * Add Marc Boucher's hard_header_len patches. * * Revision 1.19  1999/09/10 05:31:36  henry * tentative fix for 2.0.38-crash bug (move chunk of new code into 2.2 #ifdef) * * Revision 1.18  1999/08/28 08:28:06  rgb * Delete redundant sanity check. * * Revision 1.17  1999/08/28 02:00:58  rgb * Add an extra sanity check for null skbs. * * Revision 1.16  1999/08/27 05:21:38  rgb * Clean up skb->data/raw/nh/h manipulation. * Add Marc Boucher's mods to aid tcpdump. * * Revision 1.15  1999/08/25 14:22:40  rgb * Require 4-octet boundary check only for ESP. * * Revision 1.14  1999/08/11 08:36:44  rgb * Add compiler directives to allow configuring out AH, ESP or transforms. * * Revision 1.13  1999/08/03 17:10:49  rgb * Cosmetic fixes and clarification to debug output. * * Revision 1.12  1999/05/09 03:25:36  rgb * Fix bug introduced by 2.2 quick-and-dirty patch. * * Revision 1.11  1999/05/08 21:23:57  rgb * Add casting to silence the 2.2.x compile. * * Revision 1.10  1999/05/05 22:02:31  rgb * Add a quick and dirty port to 2.2 kernels by Marc Boucher <marc@mbsi.ca>. * * Revision 1.9  1999/04/29 15:18:01  rgb * hange debugging to respond only to debug_rcv. * Change gettdb parameter to a pointer to reduce stack loading and * facilitate parameter sanity checking. * * Revision 1.8  1999/04/15 15:37:24  rgb * Forward check changes from POST1_00 branch. * * Revision 1.4.2.2  1999/04/13 20:32:45  rgb * Move null skb sanity check. * Silence debug a bit more when off. * Use stats more effectively. * * Revision 1.4.2.1  1999/03/30 17:10:32  rgb * Update AH+ESP bugfix. * * Revision 1.7  1999/04/11 00:28:59  henry * GPL boilerplate * * Revision 1.6  1999/04/06 04:54:27  rgb * Fix/Add RCSID Id: and Log: bits to make PHMDs happy.  This includes * patch shell fixes. * * Revision 1.5  1999/03/17 15:39:23  rgb * Code clean-up. * Bundling bug fix. * ESP_NULL esphlen and IV bug fix. * * Revision 1.4  1999/02/17 16:51:02  rgb * Ditch NET_IPIP dependancy. * Decapsulate recursively for an entire bundle. * * Revision 1.3  1999/02/12 21:22:47  rgb * Convert debugging printks to KLIPS_PRINT macro. * Clean-up cruft. * Process IPIP tunnels internally. * * Revision 1.2  1999/01/26 02:07:36  rgb * Clean up debug code when switched off. * Remove references to INET_GET_PROTOCOL. * * Revision 1.1  1999/01/21 20:29:11  rgb * Converted from transform switching to algorithm switching. * * * Id: ipsec_esp.c,v 1.16 1998/12/02 03:08:11 rgb Exp $ * * Log: ipsec_esp.c,v $ * Revision 1.16  1998/12/02 03:08:11  rgb * Fix incoming I/F bug in AH and clean up inconsistencies in the I/F * discovery routine in both AH and ESP. * * Revision 1.15  1998/11/30 13:22:51  rgb * Rationalised all the klips kernel file headers.  They are much shorter * now and won't conflict under RH5.2. * * Revision 1.14  1998/11/10 05:55:37  rgb * Add even more detail to 'wrong I/F' debug statement. * * Revision 1.13  1998/11/10 05:01:30  rgb * Clean up debug output to be quiet when disabled. * Add more detail to 'wrong I/F' debug statement. * * Revision 1.12  1998/10/31 06:39:32  rgb * Fixed up comments in #endif directives. * Tidied up debug printk output. * Convert to addrtoa and satoa where possible. * * Revision 1.11  1998/10/27 00:49:30  rgb * AH+ESP bundling bug has been squished. * Cosmetic brace fixing in code. * Newlines added before calls to ipsec_print_ip. * Fix debug output function ID's. * * Revision 1.10  1998/10/22 06:37:22  rgb * Fixed run-on error message to fit 80 columns. * * Revision 1.9  1998/10/20 02:41:04  rgb * Fixed a replay window size sanity test bug. * * Revision 1.8  1998/10/19 18:55:27  rgb * Added inclusion of freeswan.h. * sa_id structure implemented and used: now includes protocol. * \n bugfix to printk debug message. * * Revision 1.7  1998/10/09 04:23:03  rgb * Fixed possible DoS caused by invalid transform called from an ESP * packet.  This should not be a problem when protocol is added to the SA. * Sanity check added for null xf_input routine.  Sanity check added for null * socket buffer returned from xf_input routine. * Added 'klips_debug' prefix to all klips printk debug statements. * * Revision 1.6  1998/07/14 15:56:04  rgb * Set sdb->dev to virtual ipsec I/F. * * Revision 1.5  1998/06/30 18:07:46  rgb * Change for ah/esp_protocol stuct visible only if module. * * Revision 1.4  1998/06/30 00:12:46  rgb * Clean up a module compile error. * * Revision 1.3  1998/06/25 19:28:06  rgb * Readjust premature unloading of module on packet receipt. * Make protocol structure abailable to rest of kernel. * Use macro for protocol number. * * Revision 1.2  1998/06/23 02:49:34  rgb * Fix minor #include bug that prevented compiling without debugging. * Added code to check for presence of IPIP protocol if an incoming packet * is IPIP encapped. * * Revision 1.1  1998/06/18 21:27:44  henry * move sources from klips/src to klips/net/ipsec, to keep stupid * kernel-build scripts happier in the presence of symlinks * * Revision 1.9  1998/06/14 23:48:42  rgb * Fix I/F name comparison oops bug. * * Revision 1.8  1998/06/11 07:20:04  rgb * Stats fixed for rx_packets. * * Revision 1.7  1998/06/11 05:53:34  rgb * Added stats for rx error and good packet reporting. * * Revision 1.6  1998/06/05 02:27:28  rgb * Add rx_errors stats. * Fix DoS bug:  skb's not being freed on dropped packets. * * Revision 1.5  1998/05/27 21:21:29  rgb * Fix DoS potential bug.  skb was not being freed if the packet was bad. * * Revision 1.4  1998/05/18 22:31:37  rgb * Minor change in debug output and comments. * * Revision 1.3  1998/04/21 21:29:02  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.2  1998/04/12 22:03:19  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:05:59  henry * sources moved up from linux/net/ipsec * * Revision 1.1.1.1  1998/04/08 05:35:04  henry * RGB's ipsec-0.8pre2.tar.gz ipsec-0.8 * * Revision 0.4  1997/01/15 01:28:15  ji * Minor cosmetic changes. * * Revision 0.3  1996/11/20 14:35:48  ji * Minor Cleanup. * 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 + -