1 #include <linux/module.h>
2 #include <linux/jiffies.h>
3 #include <linux/kernel.h>
4 #include <linux/ctype.h>
5 #include <linux/inet.h>
8 #include <net/checksum.h>
10 #include <linux/string.h>
11 #include <linux/types.h>
12 #include <linux/percpu.h>
13 #include <linux/init.h>
14 #include <linux/ratelimit.h>
18 #include <asm/byteorder.h>
19 #include <asm/uaccess.h>
21 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
22 void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
23 const __be32 *from, const __be32 *to,
27 ~from[0], ~from[1], ~from[2], ~from[3],
28 to[0], to[1], to[2], to[3],
30 if (skb->ip_summed != CHECKSUM_PARTIAL) {
31 *sum = csum_fold(csum_partial(diff, sizeof(diff),
33 if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr)
34 skb->csum = ~csum_partial(diff, sizeof(diff),
37 *sum = ~csum_fold(csum_partial(diff, sizeof(diff),
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
43 bool __net_get_random_once(void *buf, int nbytes, bool *done,
46 static DEFINE_SPINLOCK(lock);
49 spin_lock_irqsave(&lock, flags);
51 spin_unlock_irqrestore(&lock, flags);
55 get_random_bytes(buf, nbytes);
57 spin_unlock_irqrestore(&lock, flags);
59 atomic_set(done_key, 1);