~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/net/ipv4/utils.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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.8 2000/10/03 07:29:01 anton 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  *      Display an IP address in readable format. 
 47  */
 48  
 49 char *in_ntoa(__u32 in)
 50 {
 51         static char buff[18];
 52         char *p;
 53 
 54         p = (char *) &in;
 55         sprintf(buff, "%d.%d.%d.%d",
 56                 (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255));
 57         return(buff);
 58 }
 59 
 60 /*
 61  *      Convert an ASCII string to binary IP. 
 62  */
 63  
 64 __u32 in_aton(const char *str)
 65 {
 66         unsigned long l;
 67         unsigned int val;
 68         int i;
 69 
 70         l = 0;
 71         for (i = 0; i < 4; i++) 
 72         {
 73                 l <<= 8;
 74                 if (*str != '\0') 
 75                 {
 76                         val = 0;
 77                         while (*str != '\0' && *str != '.') 
 78                         {
 79                                 val *= 10;
 80                                 val += *str - '';
 81                                 str++;
 82                         }
 83                         l |= val;
 84                         if (*str != '\0') 
 85                                 str++;
 86                 }
 87         }
 88         return(htonl(l));
 89 }
 90 
 91 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.