]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/inet.3
sync
[thirdparty/man-pages.git] / man3 / inet.3
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4.\"
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.
8.\"
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.
c13182ef 13.\"
fea681da
MK
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
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
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.
34.\"
35.TH INET 3 2001-07-25 "BSD" "Linux Programmer's Manual"
36.SH NAME
c13182ef 37inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof,
fea681da
MK
38inet_netof \- Internet address manipulation routines
39.SH SYNOPSIS
40.nf
41.B #include <sys/socket.h>
42.B #include <netinet/in.h>
43.B #include <arpa/inet.h>
44.sp
45.BI "int inet_aton(const char *" cp ", struct in_addr *" inp );
46.sp
47.BI "in_addr_t inet_addr(const char *" cp );
48.sp
49.BI "in_addr_t inet_network(const char *" cp );
50.sp
51.BI "char *inet_ntoa(struct in_addr " in );
52.sp
53.BI "struct in_addr inet_makeaddr(int " net ", int " host );
54.sp
55.BI "in_addr_t inet_lnaof(struct in_addr " in );
56.sp
57.BI "in_addr_t inet_netof(struct in_addr " in );
58.fi
59.SH DESCRIPTION
63aa9df0 60\fBinet_aton\fP() converts the Internet host address \fIcp\fP from the
fea681da 61standard numbers-and-dots notation into binary data and stores it in
e511ffb6 62the structure that \fIinp\fP points to. \fBinet_aton\fP() returns
f59a3f19 63non-zero if the address is valid, zero if not.
fea681da 64.PP
63aa9df0 65The \fBinet_addr\fP() function converts the Internet host address
fea681da 66\fIcp\fP from numbers-and-dots notation into binary data in network
c13182ef
MK
67byte order.
68If the input is invalid, INADDR_NONE (usually \-1) is returned.
e511ffb6 69This is an \fIobsolete\fP interface to \fBinet_aton\fP(), described
fea681da 70immediately above; it is obsolete because \-1 is a valid address
e511ffb6 71(255.255.255.255), and \fBinet_aton\fP() provides a cleaner way
fea681da
MK
72to indicate error return.
73.PP
7cc028fb
MK
74The \fBinet_network\fP() function extracts
75a number in host byte order suitable for use as an Internet address
c13182ef 76from \fIcp\fP, which is a string in numbers-and-dots notation.
7cc028fb 77If the input is invalid, \-1 is returned.
fea681da 78.PP
63aa9df0 79The \fBinet_ntoa\fP() function converts the Internet host address
fea681da 80\fIin\fP given in network byte order to a string in standard
c13182ef
MK
81numbers-and-dots notation.
82The string is returned in a statically
fea681da
MK
83allocated buffer, which subsequent calls will overwrite.
84.PP
63aa9df0 85The \fBinet_makeaddr\fP() function makes an Internet host address
fea681da
MK
86in network byte order by combining the network number \fInet\fP
87with the local address \fIhost\fP in network \fInet\fP, both in
88local host byte order.
89.PP
63aa9df0 90The \fBinet_lnaof\fP() function returns the local host address part
c13182ef
MK
91of the Internet address \fIin\fP.
92The local host address is returned
fea681da
MK
93in local host byte order.
94.PP
63aa9df0 95The \fBinet_netof\fP() function returns the network number part of
c13182ef
MK
96the Internet Address \fIin\fP.
97The network number is returned in
fea681da
MK
98local host byte order.
99.PP
63aa9df0
MK
100The structure \fIin_addr\fP as used in \fBinet_ntoa\fP(),
101\fBinet_makeaddr\fP(), \fBinet_lnoaf\fP() and \fBinet_netof\fP()
fea681da
MK
102is defined in \fInetinet/in.h\fP as:
103.sp
104.RS
105.nf
fea681da 106struct in_addr {
cf0a9ace 107 unsigned long int s_addr;
fea681da 108}
fea681da
MK
109.fi
110.RE
111.PP
112Note that on the i80x86 the host byte order is Least Significant Byte
9559eb50
MK
113first (little endian), whereas the network byte order, as used on the
114Internet, is Most Significant Byte first (big endian).
115.SH NOTE
116When you using numbers-and-dots notation for addresses,
117be aware that each number will be interpreted as octal
c13182ef 118if preceded by a 0 and as hexadecimal if preceded by 0x.
9559eb50 119For example, \fBinet_aton("226.000.000.037", &t)\fP will
688abfbe 120interpret the address as \fI226.0.0.31\fP and not \fI226.0.0.37\fP.
9b7116b1 121.SH "GLIBC NOTES"
c13182ef 122In order to expose the declaration of
9b7116b1 123.BR inet_aton (),
c13182ef 124one of the feature test macros _BSD_SOURCE, _SVID_SOURCE, or
803ef335 125_GNU_SOURCE must be defined.
fea681da 126.SH "CONFORMING TO"
68e1685c
MK
1274.3BSD.
128.BR inet_addr (),
129.BR inet_aton (),
130and
131.BR inet_ntoa ()
132are specified in POSIX.1-2001.
fea681da
MK
133.SH "SEE ALSO"
134.BR gethostbyname (3),
135.BR getnetent (3),
136.BR inet_ntop (3),
137.BR inet_pton (3),
138.BR hosts (5),
139.BR networks (5)