PageRenderTime 51ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/freeswan/klips/net/ipsec/ipsec_kversion.h

https://bitbucket.org/thelearninglabs/uclinux-distro-tll-public
C Header | 187 lines | 109 code | 29 blank | 49 comment | 2 complexity | 6fc182ddec13e7b01b7cb441a9a3fe92 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, Unlicense, GPL-2.0, GPL-3.0, CC-BY-SA-3.0, AGPL-1.0, ISC, MIT, 0BSD, LGPL-2.0
  1. #ifndef _FREESWAN_KVERSIONS_H
  2. /*
  3. * header file for FreeS/WAN library functions
  4. * Copyright (C) 1998, 1999, 2000 Henry Spencer.
  5. * Copyright (C) 1999, 2000, 2001 Richard Guy Briggs
  6. *
  7. * This library is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Library General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  14. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
  15. * License for more details.
  16. *
  17. * RCSID $Id: ipsec_kversion.h,v 1.2.2.1 2002/04/12 03:21:43 mcr Exp $
  18. */
  19. #define _FREESWAN_KVERSIONS_H /* seen it, no need to see it again */
  20. /*
  21. * this file contains a series of atomic defines that depend upon
  22. * kernel version numbers. The kernel versions are arranged
  23. * in version-order number (which is often not chronological)
  24. * and each clause enables or disables a feature.
  25. */
  26. /*
  27. * First, assorted kernel-version-dependent trickery.
  28. */
  29. #include <linux/version.h>
  30. #ifndef KERNEL_VERSION
  31. #define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
  32. #endif
  33. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
  34. #define HEADER_CACHE_BIND_21
  35. #endif
  36. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
  37. #define SPINLOCK
  38. #define PROC_FS_21
  39. #define NETLINK_SOCK
  40. #define NET_21
  41. #endif
  42. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,19)
  43. #define net_device_stats enet_statistics
  44. #endif
  45. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
  46. #define SPINLOCK_23
  47. #define NETDEV_23
  48. # ifndef CONFIG_IP_ALIAS
  49. # define CONFIG_IP_ALIAS
  50. # endif
  51. #endif
  52. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,25)
  53. #define PROC_FS_2325
  54. #undef PROC_FS_21
  55. #endif
  56. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30)
  57. #define PROC_NO_DUMMY
  58. #endif
  59. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,35)
  60. #define SKB_COPY_EXPAND
  61. #endif
  62. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,37)
  63. #define IP_SELECT_IDENT
  64. #endif
  65. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,50)) && defined(CONFIG_NETFILTER)
  66. #define SKB_RESET_NFCT
  67. #endif
  68. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,2)
  69. #define IP_SELECT_IDENT_NEW
  70. #endif
  71. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
  72. #define IPH_is_SKB_PULLED
  73. #define SKB_COW_NEW
  74. #define PROTO_HANDLER_SINGLE_PARM
  75. #define IP_FRAGMENT_LINEARIZE 1
  76. #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
  77. # ifdef REDHAT_BOGOSITY
  78. # define IP_SELECT_IDENT_NEW
  79. # define IPH_is_SKB_PULLED
  80. # define SKB_COW_NEW
  81. # define PROTO_HANDLER_SINGLE_PARM
  82. # endif /* REDHAT_BOGOSITY */
  83. #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
  84. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
  85. #define MALLOC_SLAB
  86. #define LINUX_KERNEL_HAS_SNPRINTF
  87. #endif
  88. #ifdef NET_21
  89. # include <linux/in6.h>
  90. #else
  91. /* old kernel in.h has some IPv6 stuff, but not quite enough */
  92. # define s6_addr16 s6_addr
  93. # define AF_INET6 10
  94. # define uint8_t __u8
  95. # define uint16_t __u16
  96. # define uint32_t __u32
  97. # define uint64_t __u64
  98. #endif
  99. #ifndef SPINLOCK
  100. # include <linux/bios32.h>
  101. /* simulate spin locks and read/write locks */
  102. typedef struct {
  103. volatile char lock;
  104. } spinlock_t;
  105. typedef struct {
  106. volatile unsigned int lock;
  107. } rwlock_t;
  108. # define spin_lock_init(x) { (x)->lock = 0;}
  109. # define rw_lock_init(x) { (x)->lock = 0; }
  110. # define spin_lock(x) { while ((x)->lock) barrier(); (x)->lock=1;}
  111. # define spin_lock_irq(x) { cli(); spin_lock(x);}
  112. # define spin_lock_irqsave(x,flags) { save_flags(flags); spin_lock_irq(x);}
  113. # define spin_unlock(x) { (x)->lock=0;}
  114. # define spin_unlock_irq(x) { spin_unlock(x); sti();}
  115. # define spin_unlock_irqrestore(x,flags) { spin_unlock(x); restore_flags(flags);}
  116. # define read_lock(x) spin_lock(x)
  117. # define read_lock_irq(x) spin_lock_irq(x)
  118. # define read_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
  119. # define read_unlock(x) spin_unlock(x)
  120. # define read_unlock_irq(x) spin_unlock_irq(x)
  121. # define read_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
  122. # define write_lock(x) spin_lock(x)
  123. # define write_lock_irq(x) spin_lock_irq(x)
  124. # define write_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
  125. # define write_unlock(x) spin_unlock(x)
  126. # define write_unlock_irq(x) spin_unlock_irq(x)
  127. # define write_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
  128. #endif /* !SPINLOCK */
  129. #ifndef SPINLOCK_23
  130. # define spin_lock_bh(x) spin_lock_irq(x)
  131. # define spin_unlock_bh(x) spin_unlock_irq(x)
  132. # define read_lock_bh(x) read_lock_irq(x)
  133. # define read_unlock_bh(x) read_unlock_irq(x)
  134. # define write_lock_bh(x) write_lock_irq(x)
  135. # define write_unlock_bh(x) write_unlock_irq(x)
  136. #endif /* !SPINLOCK_23 */
  137. #endif /* _FREESWAN_KVERSIONS_H */
  138. /*
  139. * $Log: ipsec_kversion.h,v $
  140. * Revision 1.2.2.1 2002/04/12 03:21:43 mcr
  141. * fixes for compilation on RH 7.1
  142. *
  143. * Revision 1.3 2002/04/12 03:21:17 mcr
  144. * three parameter version of ip_select_ident appears first
  145. * in 2.4.2 (RH7.1) not 2.4.4.
  146. *
  147. * Revision 1.2 2002/03/08 21:35:22 rgb
  148. * Defined LINUX_KERNEL_HAS_SNPRINTF to shut up compiler warnings after
  149. * 2.4.9. (Andreas Piesk).
  150. *
  151. * Revision 1.1 2002/01/29 02:11:42 mcr
  152. * removal of kversions.h - sources that needed it now use ipsec_param.h.
  153. * updating of IPv6 structures to match latest in6.h version.
  154. * removed dead code from freeswan.h that also duplicated kversions.h
  155. * code.
  156. *
  157. *
  158. */