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