4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / share / man / man4 / inet.4
CommitLineData
5ebe7d4b
KB
1.\" Copyright (c) 1983, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
97ee408e 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
97ee408e 5.\"
5ebe7d4b 6.\" @(#)inet.4 8.1 (Berkeley) %G%
1324d254 7.\"
9903e566
CL
8.Dd
9.Dt INET 4
10.Os BSD 4.2
11.Sh NAME
12.Nm inet
13.Nd Internet protocol family
14.Sh SYNOPSIS
15.Fd #include <sys/types.h>
16.Fd #include <netinet/in.h>
17.Sh DESCRIPTION
97ee408e
KM
18The Internet protocol family is a collection of protocols
19layered atop the
9903e566
CL
20.Em Internet Protocol
21.Pq Tn IP
22transport layer, and utilizing the Internet address format.
97ee408e 23The Internet family provides protocol support for the
9903e566
CL
24.Dv SOCK_STREAM , SOCK_DGRAM ,
25and
26.Dv SOCK_RAW
27socket types; the
28.Dv SOCK_RAW
29interface provides access to the
30.Tn IP
31protocol.
32.Sh ADDRESSING
97ee408e 33Internet addresses are four byte quantities, stored in
9903e566
CL
34network standard format (on the
35.Tn VAX
36these are word and byte
97ee408e 37reversed). The include file
9903e566 38.Aq Pa netinet/in.h
97ee408e
KM
39defines this address
40as a discriminated union.
9903e566 41.Pp
97ee408e
KM
42Sockets bound to the Internet protocol family utilize
43the following addressing structure,
9903e566 44.Bd -literal -offset indent
97ee408e
KM
45struct sockaddr_in {
46 short sin_family;
47 u_short sin_port;
48 struct in_addr sin_addr;
49 char sin_zero[8];
50};
9903e566
CL
51.Ed
52.Pp
53Sockets may be created with the local address
54.Dv INADDR_ANY
55to effect
56.Dq wildcard
57matching on incoming messages.
8c7f03f8 58The address in a
9903e566 59.Xr connect 2
8c7f03f8 60or
9903e566
CL
61.Xr sendto 2
62call may be given as
63.Dv INADDR_ANY
64to mean
65.Dq this host .
66The distinguished address
67.Dv INADDR_BROADCAST
8c7f03f8
MK
68is allowed as a shorthand for the broadcast address on the primary
69network if the first network configured supports broadcast.
9903e566 70.Sh PROTOCOLS
97ee408e 71The Internet protocol family is comprised of
9903e566
CL
72the
73.Tn IP
74transport protocol, Internet Control
75Message Protocol
76.Pq Tn ICMP ,
77Transmission Control
78Protocol
79.Pq Tn TCP ,
80and User Datagram Protocol
81.Pq Tn UDP .
82.Tn TCP
83is used to support the
84.Dv SOCK_STREAM
85abstraction while
86.Tn UDP
87is used to support the
88.Dv SOCK_DGRAM
89abstraction. A raw interface to
90.Tn IP
91is available
92by creating an Internet socket of type
93.Dv SOCK_RAW .
94The
95.Tn ICMP
96message protocol is accessible from a raw socket.
97.Pp
8c7f03f8
MK
98The 32-bit Internet address contains both network and host parts.
99It is frequency-encoded; the most-significant bit is clear
100in Class A addresses, in which the high-order 8 bits are the network
101number.
102Class B addresses use the high-order 16 bits as the network field,
103and Class C addresses have a 24-bit network part.
9903e566 104Sites with a cluster of local networks and a connection to the
8c7f03f8
MK
105Internet may chose to use a single network number for the cluster;
106this is done by using subnet addressing.
107The local (host) portion of the address is further subdivided
108into subnet and host parts.
109Within a subnet, each subnet appears to be an individual network;
110externally, the entire cluster appears to be a single, uniform
111network requiring only a single routing entry.
112Subnet addressing is enabled and examined by the following
9903e566 113.Xr ioctl 2
8c7f03f8
MK
114commands on a datagram socket in the Internet domain;
115they have the same form as the
9903e566
CL
116.Dv SIOCIFADDR
117command (see
118.Xr intro 4 ) .
119.Pp
120.Bl -tag -width SIOCSIFNETMASK
121.It Dv SIOCSIFNETMASK
8c7f03f8
MK
122Set interface network mask.
123The network mask defines the network part of the address;
124if it contains more of the address than the address type would indicate,
125then subnets are in use.
9903e566 126.It Dv SIOCGIFNETMASK
8c7f03f8 127Get interface network mask.
9903e566
CL
128.El
129.Sh SEE ALSO
130.Xr ioctl 2 ,
131.Xr socket 2 ,
132.Xr intro 4 ,
133.Xr tcp 4 ,
134.Xr udp 4 ,
135.Xr ip 4 ,
136.Xr icmp 4
137.Rs
138.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
139.%B PS1
140.%N 7
141.Re
142.Rs
143.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
144.%B PS1
145.%N 8
146.Re
147.Sh CAVEAT
97ee408e
KM
148The Internet protocol support is subject to change as
149the Internet protocols develop. Users should not depend
150on details of the current implementation, but rather
151the services exported.
9903e566
CL
152.Sh HISTORY
153The
154.Nm
155protocol interface appeared in
156.Bx 4.2 .