aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/utils.c')
-rw-r--r--net/core/utils.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/net/core/utils.c b/net/core/utils.c
index e11a8654f363..7b5970fc9e40 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -16,17 +16,19 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/jiffies.h> 17#include <linux/jiffies.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/inet.h>
19#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/net.h>
20#include <linux/string.h> 22#include <linux/string.h>
21#include <linux/types.h> 23#include <linux/types.h>
22#include <linux/random.h> 24#include <linux/random.h>
23#include <linux/percpu.h> 25#include <linux/percpu.h>
24#include <linux/init.h> 26#include <linux/init.h>
25 27
28#include <asm/byteorder.h>
26#include <asm/system.h> 29#include <asm/system.h>
27#include <asm/uaccess.h> 30#include <asm/uaccess.h>
28 31
29
30/* 32/*
31 This is a maximally equidistributed combined Tausworthe generator 33 This is a maximally equidistributed combined Tausworthe generator
32 based on code from GNU Scientific Library 1.5 (30 Jun 2004) 34 based on code from GNU Scientific Library 1.5 (30 Jun 2004)
@@ -153,3 +155,38 @@ int net_ratelimit(void)
153EXPORT_SYMBOL(net_random); 155EXPORT_SYMBOL(net_random);
154EXPORT_SYMBOL(net_ratelimit); 156EXPORT_SYMBOL(net_ratelimit);
155EXPORT_SYMBOL(net_srandom); 157EXPORT_SYMBOL(net_srandom);
158
159/*
160 * Convert an ASCII string to binary IP.
161 * This is outside of net/ipv4/ because various code that uses IP addresses
162 * is otherwise not dependent on the TCP/IP stack.
163 */
164
165__u32 in_aton(const char *str)
166{
167 unsigned long l;
168 unsigned int val;
169 int i;
170
171 l = 0;
172 for (i = 0; i < 4; i++)
173 {
174 l <<= 8;
175 if (*str != '\0')
176 {
177 val = 0;
178 while (*str != '\0' && *str != '.')
179 {
180 val *= 10;
181 val += *str - '0';
182 str++;
183 }
184 l |= val;
185 if (*str != '\0')
186 str++;
187 }
188 }
189 return(htonl(l));
190}
191
192EXPORT_SYMBOL(in_aton);