xref: /csrg-svn/share/man/man4/inet.4 (revision 47675)
1*47675Scael.\" Copyright (c) 1983, 1991 The Regents of the University of California.
236752Sbostic.\" All rights reserved.
320724Smckusick.\"
443581Strent.\" %sccs.include.redist.man%
520724Smckusick.\"
6*47675Scael.\"     @(#)inet.4	6.6 (Berkeley) 03/28/91
736752Sbostic.\"
8*47675Scael.Dd
9*47675Scael.Dt INET 4
10*47675Scael.Os BSD 4.2
11*47675Scael.Sh NAME
12*47675Scael.Nm inet
13*47675Scael.Nd Internet protocol family
14*47675Scael.Sh SYNOPSIS
15*47675Scael.Fd #include <sys/types.h>
16*47675Scael.Fd #include <netinet/in.h>
17*47675Scael.Sh DESCRIPTION
1820724SmckusickThe Internet protocol family is a collection of protocols
1920724Smckusicklayered atop the
20*47675Scael.Em Internet  Protocol
21*47675Scael.Pq Tn IP
22*47675Scaeltransport layer, and utilizing the Internet address format.
2320724SmckusickThe Internet family provides protocol support for the
24*47675Scael.Dv SOCK_STREAM , SOCK_DGRAM ,
25*47675Scaeland
26*47675Scael.Dv SOCK_RAW
27*47675Scaelsocket types; the
28*47675Scael.Dv SOCK_RAW
29*47675Scaelinterface provides access to the
30*47675Scael.Tn IP
31*47675Scaelprotocol.
32*47675Scael.Sh ADDRESSING
3320724SmckusickInternet addresses are four byte quantities, stored in
34*47675Scaelnetwork standard format (on the
35*47675Scael.Tn VAX
36*47675Scaelthese are word and byte
3720724Smckusickreversed).  The include file
38*47675Scael.Aq Pa netinet/in.h
3920724Smckusickdefines this address
4020724Smckusickas a discriminated union.
41*47675Scael.Pp
4220724SmckusickSockets bound to the Internet protocol family utilize
4320724Smckusickthe following addressing structure,
44*47675Scael.Bd -literal -offset indent
4520724Smckusickstruct sockaddr_in {
4620724Smckusick	short	sin_family;
4720724Smckusick	u_short	sin_port;
4820724Smckusick	struct	in_addr sin_addr;
4920724Smckusick	char	sin_zero[8];
5020724Smckusick};
51*47675Scael.Ed
52*47675Scael.Pp
53*47675ScaelSockets may be created with the local address
54*47675Scael.Dv INADDR_ANY
55*47675Scaelto effect
56*47675Scael.Dq wildcard
57*47675Scaelmatching on incoming messages.
5828255SkarelsThe address in a
59*47675Scael.Xr connect 2
6028255Skarelsor
61*47675Scael.Xr sendto 2
62*47675Scaelcall may be given as
63*47675Scael.Dv INADDR_ANY
64*47675Scaelto mean
65*47675Scael.Dq this host .
66*47675ScaelThe distinguished address
67*47675Scael.Dv INADDR_BROADCAST
6828255Skarelsis allowed as a shorthand for the broadcast address on the primary
6928255Skarelsnetwork if the first network configured supports broadcast.
70*47675Scael.Sh PROTOCOLS
7120724SmckusickThe Internet protocol family is comprised of
72*47675Scaelthe
73*47675Scael.Tn IP
74*47675Scaeltransport protocol, Internet Control
75*47675ScaelMessage Protocol
76*47675Scael.Pq Tn ICMP ,
77*47675ScaelTransmission Control
78*47675ScaelProtocol
79*47675Scael.Pq Tn TCP ,
80*47675Scaeland User Datagram Protocol
81*47675Scael.Pq Tn UDP .
82*47675Scael.Tn TCP
83*47675Scaelis used to support the
84*47675Scael.Dv SOCK_STREAM
85*47675Scaelabstraction while
86*47675Scael.Tn UDP
87*47675Scaelis used to support the
88*47675Scael.Dv SOCK_DGRAM
89*47675Scaelabstraction.  A raw interface to
90*47675Scael.Tn IP
91*47675Scaelis available
92*47675Scaelby creating an Internet socket of type
93*47675Scael.Dv SOCK_RAW .
94*47675ScaelThe
95*47675Scael.Tn ICMP
96*47675Scaelmessage protocol is accessible from a raw socket.
97*47675Scael.Pp
9828255SkarelsThe 32-bit Internet address contains both network and host parts.
9928255SkarelsIt is frequency-encoded; the most-significant bit is clear
10028255Skarelsin Class A addresses, in which the high-order 8 bits are the network
10128255Skarelsnumber.
10228255SkarelsClass B addresses use the high-order 16 bits as the network field,
10328255Skarelsand Class C addresses have a 24-bit network part.
104*47675ScaelSites with a cluster of local networks and a connection to the
105*47675Scael.Tn DARPA
10628255SkarelsInternet may chose to use a single network number for the cluster;
10728255Skarelsthis is done by using subnet addressing.
10828255SkarelsThe local (host) portion of the address is further subdivided
10928255Skarelsinto subnet and host parts.
11028255SkarelsWithin a subnet, each subnet appears to be an individual network;
11128255Skarelsexternally, the entire cluster appears to be a single, uniform
11228255Skarelsnetwork requiring only a single routing entry.
11328255SkarelsSubnet addressing is enabled and examined by the following
114*47675Scael.Xr ioctl 2
11528255Skarelscommands on a datagram socket in the Internet domain;
11628255Skarelsthey have the same form as the
117*47675Scael.Dv SIOCIFADDR
118*47675Scaelcommand (see
119*47675Scael.Xr intro 4 ) .
120*47675Scael.Pp
121*47675Scael.Bl -tag -width SIOCSIFNETMASK
122*47675Scael.It Dv SIOCSIFNETMASK
12328255SkarelsSet interface network mask.
12428255SkarelsThe network mask defines the network part of the address;
12528255Skarelsif it contains more of the address than the address type would indicate,
12628255Skarelsthen subnets are in use.
127*47675Scael.It Dv SIOCGIFNETMASK
12828255SkarelsGet interface network mask.
129*47675Scael.El
130*47675Scael.Sh SEE ALSO
131*47675Scael.Xr ioctl 2 ,
132*47675Scael.Xr socket 2 ,
133*47675Scael.Xr intro 4 ,
134*47675Scael.Xr tcp 4 ,
135*47675Scael.Xr udp 4 ,
136*47675Scael.Xr ip 4 ,
137*47675Scael.Xr icmp 4
138*47675Scael.Rs
139*47675Scael.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
140*47675Scael.%B PS1
141*47675Scael.%N 7
142*47675Scael.Re
143*47675Scael.Rs
144*47675Scael.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
145*47675Scael.%B PS1
146*47675Scael.%N 8
147*47675Scael.Re
148*47675Scael.Sh CAVEAT
14920724SmckusickThe Internet protocol support is subject to change as
15020724Smckusickthe Internet protocols develop.  Users should not depend
15120724Smckusickon details of the current implementation, but rather
15220724Smckusickthe services exported.
153*47675Scael.Sh HISTORY
154*47675ScaelThe
155*47675Scael.Nm
156*47675Scaelprotocol interface appeared in
157*47675Scael.Bx 4.2 .
158