summaryrefslogtreecommitdiffstats
path: root/compat.h
blob: 39cb8ac4f3768463c73b85f9d45eddb8718985d7 (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
#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

#endif /* __QUICKTUN_COMPAT_H */