summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux/netfilter_ipv4/ip_set_compat.h
blob: 96c2024c942740bbe76ca45776aceead75ed20f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _IP_SET_COMPAT_H
#define _IP_SET_COMPAT_H

#ifdef __KERNEL__
#include <linux/version.h>

/* Arrgh */
#ifdef MODULE
#define __MOD_INC(foo)		__MOD_INC_USE_COUNT(foo)
#define __MOD_DEC(foo)		__MOD_DEC_USE_COUNT(foo)
#else
#define __MOD_INC(foo)		1
#define __MOD_DEC(foo)
#endif

/* Backward compatibility */
#ifndef __nocast
#define __nocast
#endif
#ifndef __bitwise__
#define __bitwise__
#endif

/* Compatibility glue code */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#include <linux/interrupt.h>
#define DEFINE_RWLOCK(x)                rwlock_t x = RW_LOCK_UNLOCKED
#define try_module_get(x)		__MOD_INC(x)
#define module_put(x)                   __MOD_DEC(x)
#define __clear_bit(nr, addr)		clear_bit(nr, addr)
#define __set_bit(nr, addr)		set_bit(nr, addr)
#define __test_and_set_bit(nr, addr)	test_and_set_bit(nr, addr)
#define __test_and_clear_bit(nr, addr)	test_and_clear_bit(nr, addr)

typedef unsigned __bitwise__ gfp_t;

static inline void *kzalloc(size_t size, gfp_t flags)
{
	void *data = kmalloc(size, flags);
	
	if (data)
		memset(data, 0, size);
	
	return data;
}
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#define __KMEM_CACHE_T__	kmem_cache_t
#else
#define __KMEM_CACHE_T__	struct kmem_cache
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#define ip_hdr(skb)		((skb)->nh.iph)
#define skb_mac_header(skb)	((skb)->mac.raw)
#define eth_hdr(skb)		((struct ethhdr *)skb_mac_header(skb))
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
#include <linux/netfilter.h>
#define KMEM_CACHE_CREATE(name, size) \
	kmem_cache_create(name, size, 0, 0, NULL, NULL)
#else
#define KMEM_CACHE_CREATE(name, size) \
	kmem_cache_create(name, size, 0, 0, NULL)
#endif
  

#endif /* __KERNEL__ */
#endif /* _IP_SET_COMPAT_H */