1 .\" Copyright (c) 1983, 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)netintro.4 8.2 (Berkeley) 11/30/93
36 .Nd introduction to networking facilities
44 This section is a general introduction to the networking facilities
45 available in the system.
46 Documentation in this part of section
47 4 is broken up into three areas:
52 .Em network interfaces .
54 All network protocols are associated with a specific
56 A protocol family provides basic services to the protocol
57 implementation to allow it to function within a specific
59 These services may include
60 packet fragmentation and reassembly, routing, addressing, and
62 A protocol family may support multiple
63 methods of addressing, though the current protocol implementations
65 A protocol family is normally comprised of a number of protocols, one per
68 It is not required that a protocol family support all socket types.
69 A protocol family may contain multiple
70 protocols supporting the same socket abstraction.
72 A protocol supports one of the socket abstractions detailed in
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
82 All protocols are expected to support
83 the basic model for their particular socket type, but may,
84 in addition, provide non-standard facilities or extensions
86 For example, a protocol supporting the
88 abstraction may allow more than one byte of out-of-band
89 data to be transmitted per out-of-band message.
91 A network interface is similar to a device interface.
92 Network interfaces comprise the lowest layer of the
93 networking subsystem, interacting with the actual transport
95 An interface may support one or more protocol families and/or address formats.
96 The SYNOPSIS section of each network interface
97 entry gives a sample specification
98 of the related drivers for use in providing
99 a system description to the
102 The DIAGNOSTICS section lists messages which may appear on the console
103 and/or in the system error log,
104 .Pa /var/log/messages
107 due to errors in device operation.
109 The system currently supports the
111 protocols, the Xerox Network Systems(tm) protocols,
115 Raw socket interfaces are provided to the
123 Consult the appropriate manual pages in this section for more
124 information regarding the support for each protocol family.
126 Associated with each protocol family is an address
128 All network addresses adhere to a general structure,
129 called a sockaddr, described below.
130 However, each protocol
131 imposes finer and more specific structure, generally renaming
132 the variant, which is discussed in the protocol family manual
133 page alluded to above.
134 .Bd -literal -offset indent
144 contains the total length of the structure,
145 which may exceed 16 bytes.
146 The following address values for
148 are known to the system
149 (and additional formats are defined for possible future implementation):
151 #define AF_UNIX 1 /* local to host (pipes, portals) */
152 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
153 #define AF_NS 6 /* Xerox NS protocols */
154 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
155 #define AF_HYLINK 15 /* NSC Hyperchannel */
156 #define AF_ISO 18 /* ISO protocols */
160 provides some packet routing facilities.
161 The kernel maintains a routing information database, which
162 is used in selecting the appropriate network interface when
163 transmitting packets.
165 A user process (or possibly multiple co-operating processes)
166 maintains this database by sending messages over a special kind
168 This supplants fixed size
170 used in earlier releases.
172 This facility is described in
175 Each network interface in a system corresponds to a
176 path through which messages may be sent and received.
177 A network interface usually has a hardware device associated with it, though
178 certain interfaces such as the loopback interface,
184 calls may be used to manipulate network interfaces.
187 is made on a socket (typically of type
189 in the desired domain.
190 Most of the requests supported in earlier releases
193 structure as its parameter.
194 This structure has the form
198 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
200 struct sockaddr ifru_addr;
201 struct sockaddr ifru_dstaddr;
202 struct sockaddr ifru_broadaddr;
203 struct ifreq_buffer ifru_buffer;
213 #define ifr_addr ifr_ifru.ifru_addr /* address */
214 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
215 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
216 #define ifr_buffer ifr_ifru.ifru_buffer /* user supplied buffer with its length */
217 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
218 #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
219 #define ifr_metric ifr_ifru.ifru_metric /* metric */
220 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
221 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
222 #define ifr_media ifr_ifru.ifru_media /* physical media */
223 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
224 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
225 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
226 #define ifr_index ifr_ifru.ifru_index /* interface index */
231 requests to obtain addresses and requests both to set and
232 retrieve other data are still fully supported
236 .Bl -tag -width SIOCGIFBRDADDR
238 Get interface address for protocol family.
239 .It Dv SIOCGIFDSTADDR
240 Get point to point address for protocol family and interface.
241 .It Dv SIOCGIFBRDADDR
242 Get broadcast address for protocol family and interface.
244 Attempt to set the enabled capabilities field for the interface
250 Note that, depending on the particular interface features,
251 some capabilities may appear hard-coded to enabled, or toggling
252 a capability may affect the status of other ones.
253 The supported capabilities field is read-only, and the
255 field is unused by this call.
257 Get the interface capabilities fields.
258 The values for supported and enabled capabilities will be returned in the
264 structure, respectively.
266 Get the interface description, returned in the
271 The user supplied buffer length should be defined in the
275 struct passed in as parameter, and the length would include
276 the terminating nul character.
277 If there is not enough space to hold the interface length,
278 no copy would be done and the
282 would be set to NULL.
283 The kernel will store the buffer length in the
285 field upon return, regardless whether the buffer itself is
286 sufficient to hold the data.
288 Set the interface description to the value of the
294 field specifying its length (counting the terminating nul).
296 Set interface flags field.
297 If the interface is marked down,
298 any processes currently routing packets through the interface
300 some interfaces may be reset so that incoming packets are no longer received.
301 When marked up again, the interface is reinitialized.
305 Set interface routing metric.
306 The metric is used only by user-level routers.
308 Get interface metric.
310 Attempt to create the specified interface.
311 If the interface name is given without a unit number the system
312 will attempt to create a new interface with an arbitrary unit number.
313 On successful return the
315 field will contain the new interface name.
317 Attempt to destroy the specified interface.
320 There are two requests that make use of a new structure:
321 .Bl -tag -width SIOCGIFBRDADDR
323 An interface may have more than one address associated with it
325 This request provides a means to
326 add additional addresses (or modify characteristics of the
327 primary address if the default address for the address family
329 Rather than making separate calls to
330 set destination or broadcast addresses, or network masks
331 (now an integral feature of multiple protocols)
332 a separate structure is used to specify all three facets simultaneously
334 One would use a slightly tailored version of this struct specific
335 to each family (replacing each sockaddr by one
336 of the family-specific type).
337 Where the sockaddr itself is larger than the
338 default size, one needs to modify the
340 identifier itself to include the total size, as described in
343 This requests deletes the specified address from the list
344 associated with an interface.
347 structure to allow for the possibility of protocols allowing
348 multiple masks or destination addresses, and also adopts the
349 convention that specification of the default address means
350 to delete the first address for the interface belonging to
351 the address family in which the original socket was opened.
353 Get interface configuration list.
354 This request takes an
356 structure (see below) as a value-result parameter.
359 field should be initially set to the size of the buffer
362 On return it will contain the length, in bytes, of the
364 .It Dv SIOCIFGCLONERS
365 Get list of clonable interfaces.
366 This request takes an
368 structure (see below) as a value-result parameter.
371 field should be set to the number of
373 sized strings that can be fit in the buffer pointed to by
377 will be set to the number of clonable interfaces and the buffer pointed
380 will be filled with the names of clonable interfaces aligned on
386 * Structure used in SIOCAIFADDR request.
389 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
390 struct sockaddr ifra_addr;
391 struct sockaddr ifra_broadaddr;
392 struct sockaddr ifra_mask;
397 * Structure used in SIOCGIFCONF request.
398 * Used to retrieve interface configuration
399 * for machine (useful for programs which
400 * must know all networks accessible).
403 int ifc_len; /* size of associated buffer */
406 struct ifreq *ifcu_req;
408 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
409 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
413 /* Structure used in SIOCIFGCLONERS request. */
415 int ifcr_total; /* total cloners (out) */
416 int ifcr_count; /* room for this many in user buffer */
417 char *ifcr_buffer; /* buffer for cloner names */
421 /* Structure used in SIOCGIFDESCR and SIOCSIFDESCR requests */
422 struct ifreq_buffer {
423 size_t length; /* length of the buffer */
424 void *buffer; /* pointer to userland space buffer */