summaryrefslogtreecommitdiffstats
path: root/compat.h
blob: 49eb49de03c1100a28a35e65607a15df37733f14 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *  Quicktun tunnel driver - compatiblity definitions
 *  Copyright (C) 2011 Matthias Schiffer <mschiffer@universe-factory.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 */

#ifndef __QUICKTUN_COMPAT_H
#define __QUICKTUN_COMPAT_H

#include <linux/version.h>
#include <net/inet_sock.h>
#include <net/route.h>


#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)

static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk,
						   __be32 daddr, __be32 saddr,
						   __be16 dport, __be16 sport,
						   __u8 proto, __u8 tos, int oif)
{
	struct rtable *rt;
	struct flowi fl = {
		.nl_u = {
			.ip4_u = {
				.saddr  = saddr,
				.daddr  = daddr,
				.tos    = tos,
			}
		},
		.oif    = oif,
		.proto  = proto
	};

	if (ip_route_output_key(net, &rt, &fl))
		return NULL;

	return rt;

}

#endif


#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)

static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
{
	skb->dev = dev;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
	skb->rxhash = 0;
#endif

	skb_set_queue_mapping(skb, 0);
	skb_dst_drop(skb);
	nf_reset(skb);
}

#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)

#define RTABLE_DST(rtable) (&(rtable)->u.dst)

#else

#define RTABLE_DST(rtable) (&(rtable)->dst)

#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)

#define rcu_dereference_protected(p, c) rcu_dereference(p)

#endif

#endif /* __QUICKTUN_COMPAT_H */