xref: /xnu-10002.1.13/bsd/man/man4/inet.4 (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1*1031c584SApple OSS Distributions.\"	$NetBSD: inet.4,v 1.3 1994/11/30 16:22:18 jtc Exp $
2*1031c584SApple OSS Distributions.\"
3*1031c584SApple OSS Distributions.\" Copyright (c) 1983, 1991, 1993
4*1031c584SApple OSS Distributions.\"	The Regents of the University of California.  All rights reserved.
5*1031c584SApple OSS Distributions.\"
6*1031c584SApple OSS Distributions.\" Redistribution and use in source and binary forms, with or without
7*1031c584SApple OSS Distributions.\" modification, are permitted provided that the following conditions
8*1031c584SApple OSS Distributions.\" are met:
9*1031c584SApple OSS Distributions.\" 1. Redistributions of source code must retain the above copyright
10*1031c584SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer.
11*1031c584SApple OSS Distributions.\" 2. Redistributions in binary form must reproduce the above copyright
12*1031c584SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer in the
13*1031c584SApple OSS Distributions.\"    documentation and/or other materials provided with the distribution.
14*1031c584SApple OSS Distributions.\" 3. All advertising materials mentioning features or use of this software
15*1031c584SApple OSS Distributions.\"    must display the following acknowledgement:
16*1031c584SApple OSS Distributions.\"	This product includes software developed by the University of
17*1031c584SApple OSS Distributions.\"	California, Berkeley and its contributors.
18*1031c584SApple OSS Distributions.\" 4. Neither the name of the University nor the names of its contributors
19*1031c584SApple OSS Distributions.\"    may be used to endorse or promote products derived from this software
20*1031c584SApple OSS Distributions.\"    without specific prior written permission.
21*1031c584SApple OSS Distributions.\"
22*1031c584SApple OSS Distributions.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*1031c584SApple OSS Distributions.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*1031c584SApple OSS Distributions.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*1031c584SApple OSS Distributions.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*1031c584SApple OSS Distributions.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*1031c584SApple OSS Distributions.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*1031c584SApple OSS Distributions.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*1031c584SApple OSS Distributions.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*1031c584SApple OSS Distributions.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*1031c584SApple OSS Distributions.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*1031c584SApple OSS Distributions.\" SUCH DAMAGE.
33*1031c584SApple OSS Distributions.\"
34*1031c584SApple OSS Distributions.\"     @(#)inet.4	8.1 (Berkeley) 6/5/93
35*1031c584SApple OSS Distributions.\"
36*1031c584SApple OSS Distributions.Dd March 18, 2015
37*1031c584SApple OSS Distributions.Dt INET 4
38*1031c584SApple OSS Distributions.Os BSD 4.2
39*1031c584SApple OSS Distributions.Sh NAME
40*1031c584SApple OSS Distributions.Nm inet
41*1031c584SApple OSS Distributions.Nd Internet protocol family
42*1031c584SApple OSS Distributions.Sh SYNOPSIS
43*1031c584SApple OSS Distributions.Fd #include <sys/types.h>
44*1031c584SApple OSS Distributions.Fd #include <netinet/in.h>
45*1031c584SApple OSS Distributions.Sh DESCRIPTION
46*1031c584SApple OSS DistributionsThe Internet protocol family is a collection of protocols
47*1031c584SApple OSS Distributionslayered atop the
48*1031c584SApple OSS Distributions.Em Internet  Protocol
49*1031c584SApple OSS Distributions.Pq Tn IP
50*1031c584SApple OSS Distributionstransport layer, and utilizing the Internet address format.
51*1031c584SApple OSS DistributionsThe Internet family provides protocol support for the
52*1031c584SApple OSS Distributions.Dv SOCK_STREAM , SOCK_DGRAM ,
53*1031c584SApple OSS Distributionsand
54*1031c584SApple OSS Distributions.Dv SOCK_RAW
55*1031c584SApple OSS Distributionssocket types; the
56*1031c584SApple OSS Distributions.Dv SOCK_RAW
57*1031c584SApple OSS Distributionsinterface provides access to the
58*1031c584SApple OSS Distributions.Tn IP
59*1031c584SApple OSS Distributionsprotocol.
60*1031c584SApple OSS Distributions.Sh ADDRESSING
61*1031c584SApple OSS DistributionsInternet addresses are four byte quantities, stored in
62*1031c584SApple OSS Distributionsnetwork standard format (on the
63*1031c584SApple OSS Distributions.Tn VAX
64*1031c584SApple OSS Distributionsthese are word and byte
65*1031c584SApple OSS Distributionsreversed).  The include file
66*1031c584SApple OSS Distributions.Aq Pa netinet/in.h
67*1031c584SApple OSS Distributionsdefines this address
68*1031c584SApple OSS Distributionsas a discriminated union.
69*1031c584SApple OSS Distributions.Pp
70*1031c584SApple OSS DistributionsSockets bound to the Internet protocol family utilize
71*1031c584SApple OSS Distributionsthe following addressing structure,
72*1031c584SApple OSS Distributions.Bd -literal -offset indent
73*1031c584SApple OSS Distributionsstruct sockaddr_in {
74*1031c584SApple OSS Distributions	short	sin_family;
75*1031c584SApple OSS Distributions	u_short	sin_port;
76*1031c584SApple OSS Distributions	struct	in_addr sin_addr;
77*1031c584SApple OSS Distributions	char	sin_zero[8];
78*1031c584SApple OSS Distributions};
79*1031c584SApple OSS Distributions.Ed
80*1031c584SApple OSS Distributions.Pp
81*1031c584SApple OSS DistributionsSockets may be created with the local address
82*1031c584SApple OSS Distributions.Dv INADDR_ANY
83*1031c584SApple OSS Distributionsto effect
84*1031c584SApple OSS Distributions.Dq wildcard
85*1031c584SApple OSS Distributionsmatching on incoming messages.
86*1031c584SApple OSS DistributionsThe address in a
87*1031c584SApple OSS Distributions.Xr connect 2 ,
88*1031c584SApple OSS Distributions.Xr connectx 2
89*1031c584SApple OSS Distributionsor
90*1031c584SApple OSS Distributions.Xr sendto 2
91*1031c584SApple OSS Distributionscall may be given as
92*1031c584SApple OSS Distributions.Dv INADDR_ANY
93*1031c584SApple OSS Distributionsto mean
94*1031c584SApple OSS Distributions.Dq this host .
95*1031c584SApple OSS DistributionsThe distinguished address
96*1031c584SApple OSS Distributions.Dv INADDR_BROADCAST
97*1031c584SApple OSS Distributionsis allowed as a shorthand for the broadcast address on the primary
98*1031c584SApple OSS Distributionsnetwork if the first network configured supports broadcast.
99*1031c584SApple OSS Distributions.Sh PROTOCOLS
100*1031c584SApple OSS DistributionsThe Internet protocol family is comprised of
101*1031c584SApple OSS Distributionsthe
102*1031c584SApple OSS Distributions.Tn IP
103*1031c584SApple OSS Distributionstransport protocol, Internet Control
104*1031c584SApple OSS DistributionsMessage Protocol
105*1031c584SApple OSS Distributions.Pq Tn ICMP ,
106*1031c584SApple OSS DistributionsTransmission Control
107*1031c584SApple OSS DistributionsProtocol
108*1031c584SApple OSS Distributions.Pq Tn TCP ,
109*1031c584SApple OSS Distributionsand User Datagram Protocol
110*1031c584SApple OSS Distributions.Pq Tn UDP .
111*1031c584SApple OSS Distributions.Tn TCP
112*1031c584SApple OSS Distributionsis used to support the
113*1031c584SApple OSS Distributions.Dv SOCK_STREAM
114*1031c584SApple OSS Distributionsabstraction while
115*1031c584SApple OSS Distributions.Tn UDP
116*1031c584SApple OSS Distributionsis used to support the
117*1031c584SApple OSS Distributions.Dv SOCK_DGRAM
118*1031c584SApple OSS Distributionsabstraction.  A raw interface to
119*1031c584SApple OSS Distributions.Tn IP
120*1031c584SApple OSS Distributionsis available
121*1031c584SApple OSS Distributionsby creating an Internet socket of type
122*1031c584SApple OSS Distributions.Dv SOCK_RAW .
123*1031c584SApple OSS DistributionsThe
124*1031c584SApple OSS Distributions.Tn ICMP
125*1031c584SApple OSS Distributionsmessage protocol is accessible from a raw socket.
126*1031c584SApple OSS Distributions.Pp
127*1031c584SApple OSS DistributionsThe 32-bit Internet address contains both network and host parts.
128*1031c584SApple OSS DistributionsIt is frequency-encoded; the most-significant bit is clear
129*1031c584SApple OSS Distributionsin Class A addresses, in which the high-order 8 bits are the network
130*1031c584SApple OSS Distributionsnumber.
131*1031c584SApple OSS DistributionsClass B addresses use the high-order 16 bits as the network field,
132*1031c584SApple OSS Distributionsand Class C addresses have a 24-bit network part.
133*1031c584SApple OSS DistributionsSites with a cluster of local networks and a connection to the
134*1031c584SApple OSS DistributionsInternet may chose to use a single network number for the cluster;
135*1031c584SApple OSS Distributionsthis is done by using subnet addressing.
136*1031c584SApple OSS DistributionsThe local (host) portion of the address is further subdivided
137*1031c584SApple OSS Distributionsinto subnet and host parts.
138*1031c584SApple OSS DistributionsWithin a subnet, each subnet appears to be an individual network;
139*1031c584SApple OSS Distributionsexternally, the entire cluster appears to be a single, uniform
140*1031c584SApple OSS Distributionsnetwork requiring only a single routing entry.
141*1031c584SApple OSS DistributionsSubnet addressing is enabled and examined by the following
142*1031c584SApple OSS Distributions.Xr ioctl 2
143*1031c584SApple OSS Distributionscommands on a datagram socket in the Internet domain;
144*1031c584SApple OSS Distributionsthey have the same form as the
145*1031c584SApple OSS Distributions.Dv SIOCIFADDR
146*1031c584SApple OSS Distributionscommand (see
147*1031c584SApple OSS Distributions.Xr intro 4 ) .
148*1031c584SApple OSS Distributions.Pp
149*1031c584SApple OSS Distributions.Bl -tag -width SIOCSIFNETMASK
150*1031c584SApple OSS Distributions.It Dv SIOCSIFNETMASK
151*1031c584SApple OSS DistributionsSet interface network mask.
152*1031c584SApple OSS DistributionsThe network mask defines the network part of the address;
153*1031c584SApple OSS Distributionsif it contains more of the address than the address type would indicate,
154*1031c584SApple OSS Distributionsthen subnets are in use.
155*1031c584SApple OSS Distributions.It Dv SIOCGIFNETMASK
156*1031c584SApple OSS DistributionsGet interface network mask.
157*1031c584SApple OSS Distributions.El
158*1031c584SApple OSS Distributions.Sh SEE ALSO
159*1031c584SApple OSS Distributions.Xr ioctl 2 ,
160*1031c584SApple OSS Distributions.Xr socket 2 ,
161*1031c584SApple OSS Distributions.Xr icmp 4 ,
162*1031c584SApple OSS Distributions.Xr intro 4 ,
163*1031c584SApple OSS Distributions.Xr ip 4 ,
164*1031c584SApple OSS Distributions.Xr tcp 4 ,
165*1031c584SApple OSS Distributions.Xr udp 4
166*1031c584SApple OSS Distributions.Rs
167*1031c584SApple OSS Distributions.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
168*1031c584SApple OSS Distributions.%B PS1
169*1031c584SApple OSS Distributions.%N 7
170*1031c584SApple OSS Distributions.Re
171*1031c584SApple OSS Distributions.Rs
172*1031c584SApple OSS Distributions.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
173*1031c584SApple OSS Distributions.%B PS1
174*1031c584SApple OSS Distributions.%N 8
175*1031c584SApple OSS Distributions.Re
176*1031c584SApple OSS Distributions.Sh CAVEAT
177*1031c584SApple OSS DistributionsThe Internet protocol support is subject to change as
178*1031c584SApple OSS Distributionsthe Internet protocols develop.  Users should not depend
179*1031c584SApple OSS Distributionson details of the current implementation, but rather
180*1031c584SApple OSS Distributionsthe services exported.
181*1031c584SApple OSS Distributions.Sh HISTORY
182*1031c584SApple OSS DistributionsThe
183*1031c584SApple OSS Distributions.Nm
184*1031c584SApple OSS Distributionsprotocol interface appeared in
185*1031c584SApple OSS Distributions.Bx 4.2 .
186