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