removed old FreeS/WAN cvs revision entries
[strongswan.git] / src / libfreeswan / ipsec_kversion.h
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.1 2004/03/15 20:35:25 as Exp $
18 */
19 #define _FREESWAN_KVERSIONS_H /* seen it, no need to see it again */
20
21 /*
22 * this file contains a series of atomic defines that depend upon
23 * kernel version numbers. The kernel versions are arranged
24 * in version-order number (which is often not chronological)
25 * and each clause enables or disables a feature.
26 */
27
28 /*
29 * First, assorted kernel-version-dependent trickery.
30 */
31 #include <linux/version.h>
32 #ifndef KERNEL_VERSION
33 #define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
34 #endif
35
36 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
37 #define HEADER_CACHE_BIND_21
38 #endif
39
40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
41 #define SPINLOCK
42 #define PROC_FS_21
43 #define NETLINK_SOCK
44 #define NET_21
45 #endif
46
47 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,19)
48 #define net_device_stats enet_statistics
49 #endif
50
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
52 #define SPINLOCK_23
53 #define NETDEV_23
54 # ifndef CONFIG_IP_ALIAS
55 # define CONFIG_IP_ALIAS
56 # endif
57 #include <linux/socket.h>
58 #include <linux/skbuff.h>
59 #include <linux/netlink.h>
60 # ifdef NETLINK_XFRM
61 # define NETDEV_25
62 # endif
63 #endif
64
65 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,25)
66 #define PROC_FS_2325
67 #undef PROC_FS_21
68 #endif
69
70 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30)
71 #define PROC_NO_DUMMY
72 #endif
73
74 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,35)
75 #define SKB_COPY_EXPAND
76 #endif
77
78 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,37)
79 #define IP_SELECT_IDENT
80 #endif
81
82 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,50)) && defined(CONFIG_NETFILTER)
83 #define SKB_RESET_NFCT
84 #endif
85
86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,2)
87 #define IP_SELECT_IDENT_NEW
88 #endif
89
90 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
91 #define IPH_is_SKB_PULLED
92 #define SKB_COW_NEW
93 #define PROTO_HANDLER_SINGLE_PARM
94 #define IP_FRAGMENT_LINEARIZE 1
95 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
96 # ifdef REDHAT_BOGOSITY
97 # define IP_SELECT_IDENT_NEW
98 # define IPH_is_SKB_PULLED
99 # define SKB_COW_NEW
100 # define PROTO_HANDLER_SINGLE_PARM
101 # endif /* REDHAT_BOGOSITY */
102 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
103
104 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
105 #define MALLOC_SLAB
106 #define LINUX_KERNEL_HAS_SNPRINTF
107 #endif
108
109 #ifdef NET_21
110 # include <linux/in6.h>
111 #else
112 /* old kernel in.h has some IPv6 stuff, but not quite enough */
113 # define s6_addr16 s6_addr
114 # define AF_INET6 10
115 # define uint8_t __u8
116 # define uint16_t __u16
117 # define uint32_t __u32
118 # define uint64_t __u64
119 #endif
120
121 #ifdef NET_21
122 # define ipsec_kfree_skb(a) kfree_skb(a)
123 #else /* NET_21 */
124 # define ipsec_kfree_skb(a) kfree_skb(a, FREE_WRITE)
125 #endif /* NET_21 */
126
127 #ifdef NETDEV_23
128 # define device net_device
129 # define ipsec_dev_get dev_get_by_name
130 # define __ipsec_dev_get __dev_get_by_name
131 # define ipsec_dev_put(x) dev_put(x)
132 # define __ipsec_dev_put(x) __dev_put(x)
133 # define ipsec_dev_hold(x) dev_hold(x)
134 #else /* NETDEV_23 */
135 # define ipsec_dev_get dev_get
136 # define __ipsec_dev_put(x)
137 # define ipsec_dev_put(x)
138 # define ipsec_dev_hold(x)
139 #endif /* NETDEV_23 */
140
141 #ifndef SPINLOCK
142 # include <linux/bios32.h>
143 /* simulate spin locks and read/write locks */
144 typedef struct {
145 volatile char lock;
146 } spinlock_t;
147
148 typedef struct {
149 volatile unsigned int lock;
150 } rwlock_t;
151
152 # define spin_lock_init(x) { (x)->lock = 0;}
153 # define rw_lock_init(x) { (x)->lock = 0; }
154
155 # define spin_lock(x) { while ((x)->lock) barrier(); (x)->lock=1;}
156 # define spin_lock_irq(x) { cli(); spin_lock(x);}
157 # define spin_lock_irqsave(x,flags) { save_flags(flags); spin_lock_irq(x);}
158
159 # define spin_unlock(x) { (x)->lock=0;}
160 # define spin_unlock_irq(x) { spin_unlock(x); sti();}
161 # define spin_unlock_irqrestore(x,flags) { spin_unlock(x); restore_flags(flags);}
162
163 # define read_lock(x) spin_lock(x)
164 # define read_lock_irq(x) spin_lock_irq(x)
165 # define read_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
166
167 # define read_unlock(x) spin_unlock(x)
168 # define read_unlock_irq(x) spin_unlock_irq(x)
169 # define read_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
170
171 # define write_lock(x) spin_lock(x)
172 # define write_lock_irq(x) spin_lock_irq(x)
173 # define write_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
174
175 # define write_unlock(x) spin_unlock(x)
176 # define write_unlock_irq(x) spin_unlock_irq(x)
177 # define write_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
178 #endif /* !SPINLOCK */
179
180 #ifndef SPINLOCK_23
181 # define spin_lock_bh(x) spin_lock_irq(x)
182 # define spin_unlock_bh(x) spin_unlock_irq(x)
183
184 # define read_lock_bh(x) read_lock_irq(x)
185 # define read_unlock_bh(x) read_unlock_irq(x)
186
187 # define write_lock_bh(x) write_lock_irq(x)
188 # define write_unlock_bh(x) write_unlock_irq(x)
189 #endif /* !SPINLOCK_23 */
190
191 #endif /* _FREESWAN_KVERSIONS_H */