]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/utils.c
[NET]: Move in_aton from net/ipv4/utils.c to net/core/utils.c
[linux-2.6-omap-h63xx.git] / net / core / utils.c
index e11a8654f36390f30162e11b6cdbad3d0ee73a26..88eb8b68e26b2c21b18a6e5f1256f24d6104d36c 100644 (file)
 #include <linux/percpu.h>
 #include <linux/init.h>
 
+#include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
-
 /*
   This is a maximally equidistributed combined Tausworthe generator
   based on code from GNU Scientific Library 1.5 (30 Jun 2004)
@@ -153,3 +153,38 @@ int net_ratelimit(void)
 EXPORT_SYMBOL(net_random);
 EXPORT_SYMBOL(net_ratelimit);
 EXPORT_SYMBOL(net_srandom);
+
+/*
+ * Convert an ASCII string to binary IP.
+ * This is outside of net/ipv4/ because various code that uses IP addresses
+ * is otherwise not dependent on the TCP/IP stack.
+ */
+
+__u32 in_aton(const char *str)
+{
+       unsigned long l;
+       unsigned int val;
+       int i;
+
+       l = 0;
+       for (i = 0; i < 4; i++)
+       {
+               l <<= 8;
+               if (*str != '\0')
+               {
+                       val = 0;
+                       while (*str != '\0' && *str != '.')
+                       {
+                               val *= 10;
+                               val += *str - '0';
+                               str++;
+                       }
+                       l |= val;
+                       if (*str != '\0')
+                               str++;
+               }
+       }
+       return(htonl(l));
+}
+
+EXPORT_SYMBOL(in_aton);