import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / net / ipv4 / utils.c
1 /*
2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
3  *              operating system.  INET is implemented using the  BSD Socket
4  *              interface as the means of communication with the user level.
5  *
6  *              Various kernel-resident INET utility functions; mainly
7  *              for format conversion and debugging output.
8  *
9  * Version:     $Id: utils.c,v 1.1.1.1 2005/04/11 02:51:13 jack Exp $
10  *
11  * Author:      Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12  *
13  * Fixes:
14  *              Alan Cox        :       verify_area check.
15  *              Alan Cox        :       removed old debugging.
16  *              Andi Kleen      :       add net_ratelimit()  
17  *
18  *              This program is free software; you can redistribute it and/or
19  *              modify it under the terms of the GNU General Public License
20  *              as published by the Free Software Foundation; either version
21  *              2 of the License, or (at your option) any later version.
22  */
23
24 #include <asm/uaccess.h>
25 #include <asm/system.h>
26 #include <linux/types.h>
27 #include <linux/kernel.h>
28 #include <linux/sched.h>
29 #include <linux/string.h>
30 #include <linux/mm.h>
31 #include <linux/socket.h>
32 #include <linux/in.h>
33 #include <linux/errno.h>
34 #include <linux/stat.h>
35 #include <stdarg.h>
36 #include <linux/inet.h>
37 #include <linux/netdevice.h>
38 #include <linux/etherdevice.h>
39 #include <net/ip.h>
40 #include <net/protocol.h>
41 #include <net/tcp.h>
42 #include <linux/skbuff.h>
43
44
45 /*
46  *      Convert an ASCII string to binary IP. 
47  */
48  
49 __u32 in_aton(const char *str)
50 {
51         unsigned long l;
52         unsigned int val;
53         int i;
54
55         l = 0;
56         for (i = 0; i < 4; i++) 
57         {
58                 l <<= 8;
59                 if (*str != '\0') 
60                 {
61                         val = 0;
62                         while (*str != '\0' && *str != '.') 
63                         {
64                                 val *= 10;
65                                 val += *str - '0';
66                                 str++;
67                         }
68                         l |= val;
69                         if (*str != '\0') 
70                                 str++;
71                 }
72         }
73         return(htonl(l));
74 }
75