Commit | Line | Data |
---|---|---|
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 |
18 | The Internet protocol family is a collection of protocols |
19 | layered atop the | |
9903e566 CL |
20 | .Em Internet Protocol |
21 | .Pq Tn IP | |
22 | transport layer, and utilizing the Internet address format. | |
97ee408e | 23 | The Internet family provides protocol support for the |
9903e566 CL |
24 | .Dv SOCK_STREAM , SOCK_DGRAM , |
25 | and | |
26 | .Dv SOCK_RAW | |
27 | socket types; the | |
28 | .Dv SOCK_RAW | |
29 | interface provides access to the | |
30 | .Tn IP | |
31 | protocol. | |
32 | .Sh ADDRESSING | |
97ee408e | 33 | Internet addresses are four byte quantities, stored in |
9903e566 CL |
34 | network standard format (on the |
35 | .Tn VAX | |
36 | these are word and byte | |
97ee408e | 37 | reversed). The include file |
9903e566 | 38 | .Aq Pa netinet/in.h |
97ee408e KM |
39 | defines this address |
40 | as a discriminated union. | |
9903e566 | 41 | .Pp |
97ee408e KM |
42 | Sockets bound to the Internet protocol family utilize |
43 | the following addressing structure, | |
9903e566 | 44 | .Bd -literal -offset indent |
97ee408e KM |
45 | struct 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 | |
53 | Sockets may be created with the local address | |
54 | .Dv INADDR_ANY | |
55 | to effect | |
56 | .Dq wildcard | |
57 | matching on incoming messages. | |
8c7f03f8 | 58 | The address in a |
9903e566 | 59 | .Xr connect 2 |
8c7f03f8 | 60 | or |
9903e566 CL |
61 | .Xr sendto 2 |
62 | call may be given as | |
63 | .Dv INADDR_ANY | |
64 | to mean | |
65 | .Dq this host . | |
66 | The distinguished address | |
67 | .Dv INADDR_BROADCAST | |
8c7f03f8 MK |
68 | is allowed as a shorthand for the broadcast address on the primary |
69 | network if the first network configured supports broadcast. | |
9903e566 | 70 | .Sh PROTOCOLS |
97ee408e | 71 | The Internet protocol family is comprised of |
9903e566 CL |
72 | the |
73 | .Tn IP | |
74 | transport protocol, Internet Control | |
75 | Message Protocol | |
76 | .Pq Tn ICMP , | |
77 | Transmission Control | |
78 | Protocol | |
79 | .Pq Tn TCP , | |
80 | and User Datagram Protocol | |
81 | .Pq Tn UDP . | |
82 | .Tn TCP | |
83 | is used to support the | |
84 | .Dv SOCK_STREAM | |
85 | abstraction while | |
86 | .Tn UDP | |
87 | is used to support the | |
88 | .Dv SOCK_DGRAM | |
89 | abstraction. A raw interface to | |
90 | .Tn IP | |
91 | is available | |
92 | by creating an Internet socket of type | |
93 | .Dv SOCK_RAW . | |
94 | The | |
95 | .Tn ICMP | |
96 | message protocol is accessible from a raw socket. | |
97 | .Pp | |
8c7f03f8 MK |
98 | The 32-bit Internet address contains both network and host parts. |
99 | It is frequency-encoded; the most-significant bit is clear | |
100 | in Class A addresses, in which the high-order 8 bits are the network | |
101 | number. | |
102 | Class B addresses use the high-order 16 bits as the network field, | |
103 | and Class C addresses have a 24-bit network part. | |
9903e566 | 104 | Sites with a cluster of local networks and a connection to the |
8c7f03f8 MK |
105 | Internet may chose to use a single network number for the cluster; |
106 | this is done by using subnet addressing. | |
107 | The local (host) portion of the address is further subdivided | |
108 | into subnet and host parts. | |
109 | Within a subnet, each subnet appears to be an individual network; | |
110 | externally, the entire cluster appears to be a single, uniform | |
111 | network requiring only a single routing entry. | |
112 | Subnet addressing is enabled and examined by the following | |
9903e566 | 113 | .Xr ioctl 2 |
8c7f03f8 MK |
114 | commands on a datagram socket in the Internet domain; |
115 | they have the same form as the | |
9903e566 CL |
116 | .Dv SIOCIFADDR |
117 | command (see | |
118 | .Xr intro 4 ) . | |
119 | .Pp | |
120 | .Bl -tag -width SIOCSIFNETMASK | |
121 | .It Dv SIOCSIFNETMASK | |
8c7f03f8 MK |
122 | Set interface network mask. |
123 | The network mask defines the network part of the address; | |
124 | if it contains more of the address than the address type would indicate, | |
125 | then subnets are in use. | |
9903e566 | 126 | .It Dv SIOCGIFNETMASK |
8c7f03f8 | 127 | Get 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 |
148 | The Internet protocol support is subject to change as |
149 | the Internet protocols develop. Users should not depend | |
150 | on details of the current implementation, but rather | |
151 | the services exported. | |
9903e566 CL |
152 | .Sh HISTORY |
153 | The | |
154 | .Nm | |
155 | protocol interface appeared in | |
156 | .Bx 4.2 . |