]>
Commit | Line | Data |
---|---|---|
1 | .\" $NetBSD: netintro.4,v 1.4 1995/10/19 08:03:40 jtc Exp $ | |
2 | .\" | |
3 | .\" Copyright (c) 1983, 1990, 1991, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. All advertising materials mentioning features or use of this software | |
15 | .\" must display the following acknowledgement: | |
16 | .\" This product includes software developed by the University of | |
17 | .\" California, Berkeley and its contributors. | |
18 | .\" 4. Neither the name of the University nor the names of its contributors | |
19 | .\" may be used to endorse or promote products derived from this software | |
20 | .\" without specific prior written permission. | |
21 | .\" | |
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | .\" SUCH DAMAGE. | |
33 | .\" | |
34 | .\" @(#)netintro.4 8.2 (Berkeley) 11/30/93 | |
35 | .\" | |
36 | .Dd November 30, 1993 | |
37 | .Dt NETINTRO 4 | |
38 | .Os BSD 4.2 | |
39 | .Sh NAME | |
40 | .Nm networking | |
41 | .Nd introduction to networking facilities | |
42 | .Sh SYNOPSIS | |
43 | .Fd #include <sys/socket.h> | |
44 | .Fd #include <net/route.h> | |
45 | .Fd #include <net/if.h> | |
46 | .Sh DESCRIPTION | |
47 | This section is a general introduction to the networking facilities | |
48 | available in the system. | |
49 | Documentation in this part of section | |
50 | 4 is broken up into three areas: | |
51 | .Em protocol families | |
52 | (domains), | |
53 | .Em protocols , | |
54 | and | |
55 | .Em network interfaces . | |
56 | .Pp | |
57 | All network protocols are associated with a specific | |
58 | .Em protocol family . | |
59 | A protocol family provides basic services to the protocol | |
60 | implementation to allow it to function within a specific | |
61 | network environment. These services may include | |
62 | packet fragmentation and reassembly, routing, addressing, and | |
63 | basic transport. A protocol family may support multiple | |
64 | methods of addressing, though the current protocol implementations | |
65 | do not. A protocol family is normally comprised of a number | |
66 | of protocols, one per | |
67 | .Xr socket 2 | |
68 | type. It is not required that a protocol family support | |
69 | all socket types. A protocol family may contain multiple | |
70 | protocols supporting the same socket abstraction. | |
71 | .Pp | |
72 | A protocol supports one of the socket abstractions detailed in | |
73 | .Xr socket 2 . | |
74 | A specific protocol may be accessed either by creating a | |
75 | socket of the appropriate type and protocol family, or | |
76 | by requesting the protocol explicitly when creating a socket. | |
77 | Protocols normally accept only one type of address format, | |
78 | usually determined by the addressing structure inherent in | |
79 | the design of the protocol family/network architecture. | |
80 | Certain semantics of the basic socket abstractions are | |
81 | protocol specific. All protocols are expected to support | |
82 | the basic model for their particular socket type, but may, | |
83 | in addition, provide non-standard facilities or extensions | |
84 | to a mechanism. For example, a protocol supporting the | |
85 | .Dv SOCK_STREAM | |
86 | abstraction may allow more than one byte of out-of-band | |
87 | data to be transmitted per out-of-band message. | |
88 | .Pp | |
89 | A network interface is similar to a device interface. | |
90 | Network interfaces comprise the lowest layer of the | |
91 | networking subsystem, interacting with the actual transport | |
92 | hardware. An interface may support one or more protocol | |
93 | families and/or address formats. | |
94 | The SYNOPSIS section of each network interface | |
95 | entry gives a sample specification | |
96 | of the related drivers for use in providing | |
97 | a system description to the | |
98 | .Xr config 8 | |
99 | program. | |
100 | The DIAGNOSTICS section lists messages which may appear on the console | |
101 | and/or in the system error log, | |
102 | .Pa /var/log/messages | |
103 | (see | |
104 | .Xr syslogd 8 ) , | |
105 | due to errors in device operation. | |
106 | .Sh PROTOCOLS | |
107 | The system currently supports the | |
108 | Internet | |
109 | protocols, the Xerox Network Systems(tm) protocols, | |
110 | and some of the | |
111 | .Tn ISO OSI | |
112 | protocols. | |
113 | Raw socket interfaces are provided to the | |
114 | .Tn IP | |
115 | protocol | |
116 | layer of the | |
117 | Internet, and to the | |
118 | .Tn IDP | |
119 | protocol of Xerox | |
120 | .Tn NS . | |
121 | Consult the appropriate manual pages in this section for more | |
122 | information regarding the support for each protocol family. | |
123 | .Sh ADDRESSING | |
124 | Associated with each protocol family is an address | |
125 | format. All network address adhere to a general structure, | |
126 | called a sockaddr, described below. However, each protocol | |
127 | imposes finer and more specific structure, generally renaming | |
128 | the variant, which is discussed in the protocol family manual | |
129 | page alluded to above. | |
130 | .Bd -literal -offset indent | |
131 | struct sockaddr { | |
132 | u_char sa_len; | |
133 | u_char sa_family; | |
134 | char sa_data[14]; | |
135 | }; | |
136 | .Ed | |
137 | .Pp | |
138 | The field | |
139 | .Ar sa_len | |
140 | contains the total length of the structure, | |
141 | which may exceed 16 bytes. | |
142 | The following address values for | |
143 | .Ar sa_family | |
144 | are known to the system | |
145 | (and additional formats are defined for possible future implementation): | |
146 | .Bd -literal | |
147 | #define AF_UNIX 1 /* local to host (pipes) */ | |
148 | #define AF_INET 2 /* IPv4: UDP, TCP, etc. */ | |
149 | #define AF_INET6 30 /* IPv6: UDP, TCP, etc. */ | |
150 | #define AF_NS 6 /* Xerox NS protocols */ | |
151 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ | |
152 | #define AF_HYLINK 15 /* NSC Hyperchannel */ | |
153 | #define AF_ISO 18 /* ISO protocols */ | |
154 | .Ed | |
155 | .Sh ROUTING | |
156 | Mac OS X provides some packet routing facilities. | |
157 | The kernel maintains a routing information database, which | |
158 | is used in selecting the appropriate network interface when | |
159 | transmitting packets. | |
160 | .Pp | |
161 | A user process (or possibly multiple co-operating processes) | |
162 | maintains this database by sending messages over a special kind | |
163 | of socket. | |
164 | This supplants fixed size | |
165 | .Xr ioctl 2 | |
166 | used in earlier releases. | |
167 | .Pp | |
168 | This facility is described in | |
169 | .Xr route 4 . | |
170 | .Sh INTERFACES | |
171 | Each network interface in a system corresponds to a | |
172 | path through which messages may be sent and received. A network | |
173 | interface usually has a hardware device associated with it, though | |
174 | certain interfaces such as the loopback interface, | |
175 | .Xr lo 4 , | |
176 | do not. | |
177 | .Pp | |
178 | The following | |
179 | .Xr ioctl | |
180 | calls may be used to manipulate network interfaces. | |
181 | The | |
182 | .Xr ioctl | |
183 | is made on a socket (typically of type | |
184 | .Dv SOCK_DGRAM ) | |
185 | in the desired domain. | |
186 | Most of the requests supported in earlier releases | |
187 | take an | |
188 | .Ar ifreq | |
189 | structure as its parameter. This structure has the form | |
190 | .Bd -literal | |
191 | struct ifreq { | |
192 | #define IFNAMSIZ 16 | |
193 | char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
194 | union { | |
195 | struct sockaddr ifru_addr; | |
196 | struct sockaddr ifru_dstaddr; | |
197 | struct sockaddr ifru_broadaddr; | |
198 | short ifru_flags; | |
199 | int ifru_metric; | |
200 | caddr_t ifru_data; | |
201 | } ifr_ifru; | |
202 | #define ifr_addr ifr_ifru.ifru_addr /* address */ | |
203 | #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ | |
204 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ | |
205 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ | |
206 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ | |
207 | #define ifr_data ifr_ifru.ifru_data /* for use by interface */ | |
208 | }; | |
209 | .Ed | |
210 | .Pp | |
211 | Calls which are now deprecated are: | |
212 | .Bl -tag -width SIOCGIFBRDADDR | |
213 | .It Dv SIOCSIFADDR | |
214 | Set interface address for protocol family. Following the address | |
215 | assignment, the ``initialization'' routine for | |
216 | the interface is called. | |
217 | .It Dv SIOCSIFDSTADDR | |
218 | Set point to point address for protocol family and interface. | |
219 | .It Dv SIOCSIFBRDADDR | |
220 | Set broadcast address for protocol family and interface. | |
221 | .El | |
222 | .Pp | |
223 | .Xr Ioctl | |
224 | requests to obtain addresses and requests both to set and | |
225 | retrieve other data are still fully supported | |
226 | and use the | |
227 | .Ar ifreq | |
228 | structure: | |
229 | .Bl -tag -width SIOCGIFBRDADDR | |
230 | .It Dv SIOCGIFADDR | |
231 | Get interface address for protocol family. | |
232 | .It Dv SIOCGIFDSTADDR | |
233 | Get point to point address for protocol family and interface. | |
234 | .It Dv SIOCGIFBRDADDR | |
235 | Get broadcast address for protocol family and interface. | |
236 | .It Dv SIOCSIFFLAGS | |
237 | Set interface flags field. If the interface is marked down, | |
238 | any processes currently routing packets through the interface | |
239 | are notified; | |
240 | some interfaces may be reset so that incoming packets are no longer received. | |
241 | When marked up again, the interface is reinitialized. | |
242 | .It Dv SIOCGIFFLAGS | |
243 | Get interface flags. | |
244 | .It Dv SIOCSIFMETRIC | |
245 | Set interface routing metric. | |
246 | The metric is used only by user-level routers. | |
247 | .It Dv SIOCGIFMETRIC | |
248 | Get interface metric. | |
249 | .El | |
250 | .Pp | |
251 | There are two requests that make use of a new structure: | |
252 | .Bl -tag -width SIOCGIFBRDADDR | |
253 | .It Dv SIOCAIFADDR | |
254 | An interface may have more than one address associated with it | |
255 | in some protocols. This request provides a means to | |
256 | add additional addresses (or modify characteristics of the | |
257 | primary address if the default address for the address family | |
258 | is specified). Rather than making separate calls to | |
259 | set destination or broadcast addresses, or network masks | |
260 | (now an integral feature of multiple protocols) | |
261 | a separate structure is used to specify all three facets simultaneously | |
262 | (see below). | |
263 | One would use a slightly tailored version of this struct specific | |
264 | to each family (replacing each sockaddr by one | |
265 | of the family-specific type). | |
266 | Where the sockaddr itself is larger than the | |
267 | default size, one needs to modify the | |
268 | .Xr ioctl | |
269 | identifier itself to include the total size, as described in | |
270 | .Xr ioctl . | |
271 | .It Dv SIOCDIFADDR | |
272 | This requests deletes the specified address from the list | |
273 | associated with an interface. It also uses the | |
274 | .Ar if_aliasreq | |
275 | structure to allow for the possibility of protocols allowing | |
276 | multiple masks or destination addresses, and also adopts the | |
277 | convention that specification of the default address means | |
278 | to delete the first address for the interface belonging to | |
279 | the address family in which the original socket was opened. | |
280 | .It Dv SIOCGIFCONF | |
281 | Get interface configuration list. This request takes an | |
282 | .Ar ifconf | |
283 | structure (see below) as a value-result parameter. The | |
284 | .Ar ifc_len | |
285 | field should be initially set to the size of the buffer | |
286 | pointed to by | |
287 | .Ar ifc_buf . | |
288 | On return it will contain the length, in bytes, of the | |
289 | configuration list. | |
290 | .El | |
291 | .Bd -literal | |
292 | /* | |
293 | * Structure used in SIOCAIFADDR request. | |
294 | */ | |
295 | struct ifaliasreq { | |
296 | char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | |
297 | struct sockaddr ifra_addr; | |
298 | struct sockaddr ifra_broadaddr; | |
299 | struct sockaddr ifra_mask; | |
300 | }; | |
301 | .Ed | |
302 | .Pp | |
303 | .Bd -literal | |
304 | /* | |
305 | * Structure used in SIOCGIFCONF request. | |
306 | * Used to retrieve interface configuration | |
307 | * for machine (useful for programs which | |
308 | * must know all networks accessible). | |
309 | */ | |
310 | struct ifconf { | |
311 | int ifc_len; /* size of associated buffer */ | |
312 | union { | |
313 | caddr_t ifcu_buf; | |
314 | struct ifreq *ifcu_req; | |
315 | } ifc_ifcu; | |
316 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ | |
317 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ | |
318 | }; | |
319 | .Ed | |
320 | .Sh SEE ALSO | |
321 | .Xr ioctl 2 , | |
322 | .Xr socket 2 , | |
323 | .Xr intro 4 , | |
324 | .Xr config 5 , | |
325 | .Xr routed 8 | |
326 | .Sh HISTORY | |
327 | The | |
328 | .Nm netintro | |
329 | manual appeared in | |
330 | .Bx 4.3 tahoe . |