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
29 .\" $FreeBSD: src/share/man/man4/netintro.4,v 1.10.2.6 2002/08/30 14:23:38 sobomax Exp $
30 .\" $DragonFly: src/share/man/man4/netintro.4,v 1.4 2008/05/02 02:05:05 swildner Exp $
37 .Nd introduction to networking facilities
45 This section is a general introduction to the networking facilities
46 available in the system.
47 Documentation in this part of section
48 4 is broken up into three areas:
53 .Em network interfaces .
55 All network protocols are associated with a specific
57 A protocol family provides basic services to the protocol
58 implementation to allow it to function within a specific
59 network environment. These services may include
60 packet fragmentation and reassembly, routing, addressing, and
61 basic transport. A protocol family may support multiple
62 methods of addressing, though the current protocol implementations
63 do not. A protocol family is normally comprised of a number
66 type. It is not required that a protocol family support
67 all socket types. A protocol family may contain multiple
68 protocols supporting the same socket abstraction.
70 A protocol supports one of the socket abstractions detailed in
72 A specific protocol may be accessed either by creating a
73 socket of the appropriate type and protocol family, or
74 by requesting the protocol explicitly when creating a socket.
75 Protocols normally accept only one type of address format,
76 usually determined by the addressing structure inherent in
77 the design of the protocol family/network architecture.
78 Certain semantics of the basic socket abstractions are
79 protocol specific. All protocols are expected to support
80 the basic model for their particular socket type, but may,
81 in addition, provide non-standard facilities or extensions
82 to a mechanism. For example, a protocol supporting the
84 abstraction may allow more than one byte of out-of-band
85 data to be transmitted per out-of-band message.
87 A network interface is similar to a device interface.
88 Network interfaces comprise the lowest layer of the
89 networking subsystem, interacting with the actual transport
90 hardware. An interface may support one or more protocol
91 families and/or address formats.
92 The SYNOPSIS section of each network interface
93 entry gives a sample specification
94 of the related drivers for use in providing
95 a system description to the
98 The DIAGNOSTICS section lists messages which may appear on the console
99 and/or in the system error log,
100 .Pa /var/log/messages
103 due to errors in device operation.
105 The system currently supports the
107 protocols, the Xerox Network Systems(tm) protocols,
111 Raw socket interfaces are provided to the
119 Consult the appropriate manual pages in this section for more
120 information regarding the support for each protocol family.
122 Associated with each protocol family is an address
123 format. All network address adhere to a general structure,
124 called a sockaddr, described below.
125 However, each protocol
126 imposes finer and more specific structure, generally renaming
127 the variant, which is discussed in the protocol family manual
128 page alluded to above.
129 .Bd -literal -offset indent
139 contains the total length of the structure,
140 which may exceed 16 bytes.
141 The following address values for
143 are known to the system
144 (and additional formats are defined for possible future implementation):
146 #define AF_UNIX 1 /* local to host (pipes, portals) */
147 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
148 #define AF_NS 6 /* Xerox NS protocols */
149 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
150 #define AF_HYLINK 15 /* NSC Hyperchannel */
151 #define AF_ISO 18 /* ISO protocols */
155 provides some packet routing facilities.
156 The kernel maintains a routing information database, which
157 is used in selecting the appropriate network interface when
158 transmitting packets.
160 A user process (or possibly multiple co-operating processes)
161 maintains this database by sending messages over a special kind
163 This supplants fixed size
165 used in earlier releases.
167 This facility is described in
170 Each network interface in a system corresponds to a
171 path through which messages may be sent and received. A network
172 interface usually has a hardware device associated with it, though
173 certain interfaces such as the loopback interface,
179 calls may be used to manipulate network interfaces.
182 is made on a socket (typically of type
184 in the desired domain.
185 Most of the requests supported in earlier releases
188 structure as its parameter. This structure has the form
192 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
194 struct sockaddr ifru_addr;
195 struct sockaddr ifru_dstaddr;
196 struct sockaddr ifru_broadaddr;
203 #define ifr_addr ifr_ifru.ifru_addr /* address */
204 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
205 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
206 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
207 #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
208 #define ifr_metric ifr_ifru.ifru_metric /* metric */
209 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
210 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
211 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
215 Calls which are now deprecated are:
216 .Bl -tag -width ".Dv SIOCGIFBRDADDR"
218 Set interface address for protocol family. Following the address
219 assignment, the ``initialization'' routine for
220 the interface is called.
221 .It Dv SIOCSIFDSTADDR
222 Set point to point address for protocol family and interface.
223 .It Dv SIOCSIFBRDADDR
224 Set broadcast address for protocol family and interface.
228 requests to obtain addresses and requests both to set and
229 retrieve other data are still fully supported
233 .Bl -tag -width ".Dv SIOCGIFBRDADDR"
235 Get interface address for protocol family.
236 .It Dv SIOCGIFDSTADDR
237 Get point to point address for protocol family and interface.
238 .It Dv SIOCGIFBRDADDR
239 Get broadcast address for protocol family and interface.
241 Set interface flags field. If the interface is marked down,
242 any processes currently routing packets through the interface
244 some interfaces may be reset so that incoming packets are no longer received.
245 When marked up again, the interface is reinitialized.
249 Set interface routing metric.
250 The metric is used only by user-level routers.
252 Get interface metric.
254 Attempt to create the specified interface.
255 If the interface name is given without a unit number the system
256 will attempt to create a new interface with an arbitrary unit number.
257 On successful return the
259 field will contain the new interface name.
261 Attempt to destroy the specified interface.
264 There are two requests that make use of a new structure:
265 .Bl -tag -width ".Dv SIOCGIFBRDADDR"
267 An interface may have more than one address associated with it
268 in some protocols. This request provides a means to
269 add additional addresses (or modify characteristics of the
270 primary address if the default address for the address family
271 is specified). Rather than making separate calls to
272 set destination or broadcast addresses, or network masks
273 (now an integral feature of multiple protocols)
274 a separate structure is used to specify all three facets simultaneously
276 One would use a slightly tailored version of this struct specific
277 to each family (replacing each sockaddr by one
278 of the family-specific type).
279 Where the sockaddr itself is larger than the
280 default size, one needs to modify the
282 identifier itself to include the total size, as described in
285 This requests deletes the specified address from the list
286 associated with an interface. It also uses the
288 structure to allow for the possibility of protocols allowing
289 multiple masks or destination addresses, and also adopts the
290 convention that specification of the default address means
291 to delete the first address for the interface belonging to
292 the address family in which the original socket was opened.
294 Get interface configuration list. This request takes an
296 structure (see below) as a value-result parameter. The
298 field should be initially set to the size of the buffer
301 On return it will contain the length, in bytes, of the
303 .It Dv SIOCIFGCLONERS
304 Get list of clonable interfaces.
305 This request takes an
307 structure (see below) as a value-result parameter.
310 field should be set to the number of
312 sized strings that can be fit in the buffer pointed to by
316 will be set to the number of clonable interfaces and the buffer pointed
319 will be filled with the names of clonable interfaces aligned on
325 * Structure used in SIOCAIFCONF request.
328 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
329 struct sockaddr ifra_addr;
330 struct sockaddr ifra_broadaddr;
331 struct sockaddr ifra_mask;
336 * Structure used in SIOCGIFCONF request.
337 * Used to retrieve interface configuration
338 * for machine (useful for programs which
339 * must know all networks accessible).
342 int ifc_len; /* size of associated buffer */
345 struct ifreq *ifcu_req;
347 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
348 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
352 /* Structure used in SIOCIFGCLONERS request. */
354 int ifcr_total; /* total cloners (out) */
355 int ifcr_count; /* room for this many in user buffer */
356 char *ifcr_buffer; /* buffer for cloner names */