summaryrefslogtreecommitdiffstats
path: root/man3/inet.3
blob: 033977a0d0b44d3430a977c7e6998f1659a9c216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\" May be distributed under the GNU General Public License
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Sat Jul 24 19:12:00 1993 by Rik Faith (faith@cs.unc.edu)
.TH INET 3  "May 11, 1993" "BSD" "Linux Programmer's Manual"
.SH NAME
inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, 
inet_netof \- Internet address manipulation routines
.SH SYNOPSIS
.nf
.B #include <sys/socket.h>
.B #include <netinet/in.h>
.B #include <arpa/inet.h>
.sp
.BI "unsigned long int inet_addr(const char *" cp );
.sp
.BI "unsigned long int inet_network(const char *" cp );
.sp
.BI "char *inet_ntoa(struct in_addr " in );
.sp
.BI "struct in_addr inet_makeaddr(int " net ", int " host );
.sp
.BI "unsigned long int inet_lnaof(struct in_addr " in );
.sp
.BI "unsigned long int inet_netof(struct in_addr " in );
.fi
.SH DESCRIPTION
The \fBinet_addr()\fP function converts the Internet host address
\fIcp\fP from numbers-and-dots notation into binary data in network
byte order.  If the input is invalid, -1 is returned.
.PP
The \fBinet_network()\fP function extracts the network number in
network byte order from the address \fIcp\fP in numbers-and-dots
notation.  If the input is invalid, -1 is returned.
.PP
The \fBinet_ntoa()\fP function converts the Internet host address
\fIin\fP given in network byte order to a string in standard
numbers-and-dots notation.  The string is returned in a statically
allocated buffer, which subsequent calls will overwrite.
.PP
The \fBinet_makeaddr()\fP function makes an Internet host address
in network byte order by combining the network number \fInet\fP
with the local address \fIhost\fP in network \fInet\fP, both in
local host byte order.
.PP
The \fBinet_lnaof()\fP function returns the local host address part
of the Internet address \fIin\fP.  The local host address is returned
in local host byte order.
.PP
The \fBinet_netof()\fP function returns the network number part of
the Internet Address \fIin\fP.  The network number is returned in
local host byte order.
.PP
The structure \fIin_addr\fP as used in \fBinet_ntoa()\fP,
\fBinet_makeaddr()\fP, \fBinet_lnoaf()\fP and \fBinet_netof()\fP
is defined in \fInetinet/in.h\fP as:
.sp
.RS
.nf
.ne 7
.ta 8n 16n
struct in_addr {
	unsigned long int s_addr;
}
.ta
.fi
.RE
.PP
Note that on the i80x86 the host byte order is Least Significant Byte
first, whereas the network byte order, as used on the Internet, is
Most Significant Byte first.
.SH "CONFORMING TO"
BSD 4.3
.SH SEE ALSO
.BR gethostbyname "(3), " getnetent "(3), " hosts "(5), " networks (5)