xref: /openbsd-src/share/man/man4/inet.4 (revision 3a3fbb3f2e2521ab7c4a56b7ff7462ebd9095ec5)
1.\"	$OpenBSD: inet.4,v 1.9 2001/11/13 13:54:25 mpech 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).
68The include file
69.Aq Pa netinet/in.h
70defines this address as a discriminated union.
71.Pp
72Sockets bound to the Internet protocol family utilize
73the following addressing structure,
74.Bd -literal -offset indent
75struct sockaddr_in {
76	u_int8_t	sin_len;
77	sa_family_t	sin_family;
78	in_port_t	sin_port;
79	struct		in_addr sin_addr;
80	int8_t		sin_zero[8];
81};
82.Ed
83.Pp
84Sockets may be created with the local address
85.Dv INADDR_ANY
86to effect
87.Dq wildcard
88matching on incoming messages.
89The address in a
90.Xr connect 2
91or
92.Xr sendto 2
93call may be given as
94.Dv INADDR_ANY
95to mean
96.Dq this host .
97The distinguished address
98.Dv INADDR_BROADCAST
99is allowed as a shorthand for the broadcast address on the primary
100network if the first network configured supports broadcast.
101.Sh PROTOCOLS
102The Internet protocol family is comprised of
103the
104.Tn IP
105transport protocol, Internet Control
106Message Protocol
107.Pq Tn ICMP ,
108Transmission Control
109Protocol
110.Pq Tn TCP ,
111and User Datagram Protocol
112.Pq Tn UDP .
113.Tn TCP
114is used to support the
115.Dv SOCK_STREAM
116abstraction while
117.Tn UDP
118is used to support the
119.Dv SOCK_DGRAM
120abstraction.
121A raw interface to
122.Tn IP
123is available
124by creating an Internet socket of type
125.Dv SOCK_RAW .
126The
127.Tn ICMP
128message protocol is accessible from a raw socket.
129.Pp
130The 32-bit Internet address contains both network and host parts.
131It is frequency-encoded; the most-significant bit is clear
132in Class A addresses, in which the high-order 8 bits are the network
133number.
134Class B addresses use the high-order 16 bits as the network field,
135and Class C addresses have a 24-bit network part.
136Sites with a cluster of local networks and a connection to the
137Internet may chose to use a single network number for the cluster;
138this is done by using subnet addressing.
139The local (host) portion of the address is further subdivided
140into subnet and host parts.
141Within a subnet, each subnet appears to be an individual network;
142externally, the entire cluster appears to be a single, uniform
143network requiring only a single routing entry.
144Subnet addressing is enabled and examined by the following
145.Xr ioctl 2
146commands on a datagram socket in the Internet domain;
147they have the same form as the
148.Dv SIOCIFADDR
149command (see
150.Xr netintro 4 ) .
151.Pp
152.Bl -tag -width SIOCSIFNETMASK
153.It Dv SIOCSIFNETMASK
154Set interface network mask.
155The network mask defines the network part of the address;
156if it contains more of the address than the address type would indicate,
157then subnets are in use.
158.It Dv SIOCGIFNETMASK
159Get interface network mask.
160.El
161.Sh SEE ALSO
162.Xr ioctl 2 ,
163.Xr socket 2 ,
164.Xr icmp 4 ,
165.Xr ip 4 ,
166.Xr netintro 4 ,
167.Xr tcp 4 ,
168.Xr udp 4
169.Rs
170.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
171.%B PS1
172.%N 7
173.Re
174.Rs
175.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
176.%B PS1
177.%N 8
178.Re
179.Sh CAVEATS
180The Internet protocol support is subject to change as
181the Internet protocols develop.
182Users should not depend on details of the current implementation, but rather
183the services exported.
184.Sh HISTORY
185The
186.Nm
187protocol interface appeared in
188.Bx 4.2 .
189