summaryrefslogtreecommitdiffstats
path: root/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'compat.h')
-rw-r--r--compat.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/compat.h b/compat.h
new file mode 100644
index 0000000..39cb8ac
--- /dev/null
+++ b/compat.h
@@ -0,0 +1,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 */