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