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