1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\" libc.info (from glibc distribution)
30 .\" Modified Sat Jul 24 19:12:00 1993 by Rik Faith <faith@cs.unc.edu>
31 .\" Modified Sun Sep 3 20:29:36 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
32 .\" Changed network into host byte order (for inet_network),
33 .\" Andreas Jaeger <aj@arthur.rhein-neckar.de>, 980130.
35 .TH INET 3 2007-07-26 "GNU" "Linux Programmer's Manual"
37 inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
38 inet_netof \- Internet address manipulation routines
41 .B #include <sys/socket.h>
42 .B #include <netinet/in.h>
43 .B #include <arpa/inet.h>
45 .BI "int inet_aton(const char *" cp ", struct in_addr *" inp );
47 .BI "in_addr_t inet_addr(const char *" cp );
49 .BI "in_addr_t inet_network(const char *" cp );
51 .BI "char *inet_ntoa(struct in_addr " in );
53 .BI "struct in_addr inet_makeaddr(int " net ", int " host );
55 .BI "in_addr_t inet_lnaof(struct in_addr " in );
57 .BI "in_addr_t inet_netof(struct in_addr " in );
61 Feature Test Macro Requirements for glibc (see
62 .BR feature_test_macros (7)):
67 _BSD_SOURCE || _SVID_SOURCE
70 converts the Internet host address \fIcp\fP from the
71 standard numbers-and-dots notation into binary data and stores it in
72 the structure that \fIinp\fP points to.
75 nonzero if the address is valid, zero if not.
79 function converts the Internet host address
80 \fIcp\fP from numbers-and-dots notation into binary data in network
82 If the input is invalid,
84 (usually \-1) is returned.
85 This is an \fIobsolete\fP interface to
88 immediately above; it is obsolete because \-1 is a valid address
89 (255.255.255.255), and
91 provides a cleaner way
92 to indicate error return.
97 a number in host byte order suitable for use as an Internet address
98 from \fIcp\fP, which is a string in numbers-and-dots notation.
99 If the input is invalid, \-1 is returned.
103 function converts the Internet host address
104 \fIin\fP given in network byte order to a string in standard
105 numbers-and-dots notation.
106 The string is returned in a statically
107 allocated buffer, which subsequent calls will overwrite.
111 function makes an Internet host address
112 in network byte order by combining the network number \fInet\fP
113 with the local address \fIhost\fP in network \fInet\fP, both in
114 local host byte order.
118 function returns the local host address part
119 of the Internet address \fIin\fP.
120 The local host address is returned
121 in local host byte order.
125 function returns the network number part of
126 the Internet Address \fIin\fP.
127 The network number is returned in
128 local host byte order.
130 The structure \fIin_addr\fP as used in
132 .BR inet_makeaddr (),
142 typedef uint32_t in_addr_t;
150 Note that on the i386 the host byte order is Least Significant Byte
151 first (little endian), whereas the network byte order, as used on the
152 Internet, is Most Significant Byte first (big endian).
159 are specified in POSIX.1-2001.
161 When you using numbers-and-dots notation for addresses,
162 be aware that each number will be interpreted as octal
163 if preceded by a 0 and as hexadecimal if preceded by 0x.
164 For example, \fBinet_aton("226.000.000.037", &t)\fP will
165 interpret the address as \fI226.0.0.31\fP and not \fI226.0.0.37\fP.
167 .BR gethostbyname (3),