1INET(3)                    Linux Programmer's Manual                   INET(3)
2
3
4

NAME

6       inet_aton,    inet_addr,    inet_network,   inet_ntoa,   inet_makeaddr,
7       inet_lnaof, inet_netof - Internet address manipulation routines
8

SYNOPSIS

10       #include <sys/socket.h>
11       #include <netinet/in.h>
12       #include <arpa/inet.h>
13
14       int inet_aton(const char *cp, struct in_addr *inp);
15
16       in_addr_t inet_addr(const char *cp);
17
18       in_addr_t inet_network(const char *cp);
19
20       char *inet_ntoa(struct in_addr in);
21
22       struct in_addr inet_makeaddr(int net, int host);
23
24       in_addr_t inet_lnaof(struct in_addr in);
25
26       in_addr_t inet_netof(struct in_addr in);
27

DESCRIPTION

29       inet_aton() converts the Internet host address  cp  from  the  standard
30       numbers-and-dots  notation into binary data and stores it in the struc‐
31       ture that inp points to. inet_aton() returns non-zero if the address is
32       valid, zero if not.
33
34       The  inet_addr()  function  converts  the Internet host address cp from
35       numbers-and-dots notation into binary data in network byte  order.   If
36       the input is invalid, INADDR_NONE (usually -1) is returned.  This is an
37       obsolete interface to inet_aton(), described immediately above;  it  is
38       obsolete   because   -1  is  a  valid  address  (255.255.255.255),  and
39       inet_aton() provides a cleaner way to indicate error return.
40
41       The inet_network() function extracts a number in host byte order  suit‐
42       able  for use as an Internet address from cp, which is a string in num‐
43       bers-and-dots notation.  If the input is invalid, -1 is returned.
44
45       The inet_ntoa() function converts the Internet host address in given in
46       network  byte  order to a string in standard numbers-and-dots notation.
47       The string is returned in a statically allocated buffer,  which  subse‐
48       quent calls will overwrite.
49
50       The  inet_makeaddr() function makes an Internet host address in network
51       byte order by combining the network number net with the  local  address
52       host in network net, both in local host byte order.
53
54       The  inet_lnaof()  function  returns the local host address part of the
55       Internet address in.  The local host address is returned in local  host
56       byte order.
57
58       The inet_netof() function returns the network number part of the Inter‐
59       net Address in.  The network number is  returned  in  local  host  byte
60       order.
61
62       The   structure   in_addr  as  used  in  inet_ntoa(),  inet_makeaddr(),
63       inet_lnoaf() and inet_netof() is defined in netinet/in.h as:
64
65              struct in_addr {
66                      unsigned long int s_addr;
67              }
68
69       Note that on the i80x86 the host byte order is Least  Significant  Byte
70       first  (little  endian), whereas the network byte order, as used on the
71       Internet, is Most Significant Byte first (big endian).
72

NOTE

74       When you using numbers-and-dots notation for addresses, be  aware  that
75       each  number  will  be  interpreted  as octal if preceded by a 0 and as
76       hexadecimal     if     preceded     by      0x.       For      example,
77       inet_aton("226.000.000.037",   &t)   will   interpret  the  address  as
78       226.0.0.31 and not 226.0.0.37.
79

GLIBC NOTES

81       In order to expose the declaration of inet_aton(), one of  the  feature
82       test macros _BSD_SOURCE, _SVID_SOURCE, or _GNU_SOURCE must be defined.
83

CONFORMING TO

85       4.3BSD.   inet_addr(),  inet_aton(),  and  inet_ntoa() are specified in
86       POSIX.1-2001.
87

SEE ALSO

89       gethostbyname(3), getnetent(3), inet_ntop(3),  inet_pton(3),  hosts(5),
90       networks(5)
91
92
93
94BSD                               2001-07-25                           INET(3)
Impressum