xref: /original-bsd/share/man/man4/inet.4 (revision c3e32dec)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)inet.4	8.1 (Berkeley) 06/05/93
7.\"
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
18The Internet protocol family is a collection of protocols
19layered atop the
20.Em Internet  Protocol
21.Pq Tn IP
22transport layer, and utilizing the Internet address format.
23The Internet family provides protocol support for the
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
33Internet addresses are four byte quantities, stored in
34network standard format (on the
35.Tn VAX
36these are word and byte
37reversed).  The include file
38.Aq Pa netinet/in.h
39defines this address
40as a discriminated union.
41.Pp
42Sockets bound to the Internet protocol family utilize
43the following addressing structure,
44.Bd -literal -offset indent
45struct sockaddr_in {
46	short	sin_family;
47	u_short	sin_port;
48	struct	in_addr sin_addr;
49	char	sin_zero[8];
50};
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.
58The address in a
59.Xr connect 2
60or
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
68is allowed as a shorthand for the broadcast address on the primary
69network if the first network configured supports broadcast.
70.Sh PROTOCOLS
71The Internet protocol family is comprised of
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
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.
104Sites with a cluster of local networks and a connection to the
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
113.Xr ioctl 2
114commands on a datagram socket in the Internet domain;
115they have the same form as the
116.Dv SIOCIFADDR
117command (see
118.Xr intro 4 ) .
119.Pp
120.Bl -tag -width SIOCSIFNETMASK
121.It Dv SIOCSIFNETMASK
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.
126.It Dv SIOCGIFNETMASK
127Get interface network mask.
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
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.
152.Sh HISTORY
153The
154.Nm
155protocol interface appeared in
156.Bx 4.2 .
157