ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / net / core / utils.c
1 /*
2  *      Generic address resultion entity
3  *
4  *      Authors:
5  *      net_random Alan Cox
6  *      net_ratelimit Andy Kleen
7  *
8  *      Created by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
9  *
10  *      This program is free software; you can redistribute it and/or
11  *      modify it under the terms of the GNU General Public License
12  *      as published by the Free Software Foundation; either version
13  *      2 of the License, or (at your option) any later version.
14  */
15
16 #include <linux/module.h>
17 #include <linux/jiffies.h>
18 #include <linux/kernel.h>
19 #include <linux/mm.h>
20 #include <linux/string.h>
21 #include <linux/types.h>
22
23 #include <asm/system.h>
24 #include <asm/uaccess.h>
25
26 static unsigned long net_rand_seed = 152L;
27
28 unsigned long net_random(void)
29 {
30         net_rand_seed=net_rand_seed*69069L+1;
31         return net_rand_seed^jiffies;
32 }
33
34 void net_srandom(unsigned long entropy)
35 {
36         net_rand_seed ^= entropy;
37         net_random();
38 }
39
40 int net_msg_cost = 5*HZ;
41 int net_msg_burst = 10;
42
43 /* 
44  * All net warning printk()s should be guarded by this function.
45  */ 
46 int net_ratelimit(void)
47 {
48         return __printk_ratelimit(net_msg_cost, net_msg_burst);
49 }
50
51 EXPORT_SYMBOL(net_random);
52 EXPORT_SYMBOL(net_ratelimit);
53 EXPORT_SYMBOL(net_srandom);