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. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)netintro.4 8.2 (Berkeley) 11/30/93
40 .Nd introduction to networking facilities
48 This section is a general introduction to the networking facilities
49 available in the system.
50 Documentation in this part of section
51 4 is broken up into three areas:
56 .Em network interfaces .
58 All network protocols are associated with a specific
60 A protocol family provides basic services to the protocol
61 implementation to allow it to function within a specific
63 These services may include
64 packet fragmentation and reassembly, routing, addressing, and
66 A protocol family may support multiple
67 methods of addressing, though the current protocol implementations
69 A protocol family is normally comprised of a number of protocols, one per
72 It is not required that a protocol family support all socket types.
73 A protocol family may contain multiple
74 protocols supporting the same socket abstraction.
76 A protocol supports one of the socket abstractions detailed in
78 A specific protocol may be accessed either by creating a
79 socket of the appropriate type and protocol family, or
80 by requesting the protocol explicitly when creating a socket.
81 Protocols normally accept only one type of address format,
82 usually determined by the addressing structure inherent in
83 the design of the protocol family/network architecture.
84 Certain semantics of the basic socket abstractions are
86 All protocols are expected to support
87 the basic model for their particular socket type, but may,
88 in addition, provide non-standard facilities or extensions
90 For example, a protocol supporting the
92 abstraction may allow more than one byte of out-of-band
93 data to be transmitted per out-of-band message.
95 A network interface is similar to a device interface.
96 Network interfaces comprise the lowest layer of the
97 networking subsystem, interacting with the actual transport
99 An interface may support one or more protocol families and/or address formats.
100 The SYNOPSIS section of each network interface
101 entry gives a sample specification
102 of the related drivers for use in providing
103 a system description to the
106 The DIAGNOSTICS section lists messages which may appear on the console
107 and/or in the system error log,
108 .Pa /var/log/messages
111 due to errors in device operation.
113 The system currently supports the
115 protocols, the Xerox Network Systems(tm) protocols,
119 Raw socket interfaces are provided to the
127 Consult the appropriate manual pages in this section for more
128 information regarding the support for each protocol family.
130 Associated with each protocol family is an address
132 All network addresses adhere to a general structure,
133 called a sockaddr, described below.
134 However, each protocol
135 imposes finer and more specific structure, generally renaming
136 the variant, which is discussed in the protocol family manual
137 page alluded to above.
138 .Bd -literal -offset indent
148 contains the total length of the structure,
149 which may exceed 16 bytes.
150 The following address values for
152 are known to the system
153 (and additional formats are defined for possible future implementation):
155 #define AF_UNIX 1 /* local to host (pipes, portals) */
156 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
157 #define AF_NS 6 /* Xerox NS protocols */
158 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
159 #define AF_HYLINK 15 /* NSC Hyperchannel */
160 #define AF_ISO 18 /* ISO protocols */
164 provides some packet routing facilities.
165 The kernel maintains a routing information database, which
166 is used in selecting the appropriate network interface when
167 transmitting packets.
169 A user process (or possibly multiple co-operating processes)
170 maintains this database by sending messages over a special kind
172 This supplants fixed size
174 used in earlier releases.
176 This facility is described in
179 Each network interface in a system corresponds to a
180 path through which messages may be sent and received.
181 A network interface usually has a hardware device associated with it, though
182 certain interfaces such as the loopback interface,
188 calls may be used to manipulate network interfaces.
191 is made on a socket (typically of type
193 in the desired domain.
194 Most of the requests supported in earlier releases
197 structure as its parameter.
198 This structure has the form
202 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
204 struct sockaddr ifru_addr;
205 struct sockaddr ifru_dstaddr;
206 struct sockaddr ifru_broadaddr;
216 #define ifr_addr ifr_ifru.ifru_addr /* address */
217 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
218 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
219 #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
220 #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
221 #define ifr_metric ifr_ifru.ifru_metric /* metric */
222 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
223 #define ifr_phys ifr_ifru.ifru_phys /* physical wire */
224 #define ifr_media ifr_ifru.ifru_media /* physical media */
225 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
226 #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
227 #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
228 #define ifr_index ifr_ifru.ifru_index /* interface index */
232 Calls which are now deprecated are:
233 .Bl -tag -width SIOCGIFBRDADDR
235 Set interface address for protocol family.
236 Following the address assignment, the
238 routine for the interface is called.
239 .It Dv SIOCSIFDSTADDR
240 Set point to point address for protocol family and interface.
241 .It Dv SIOCSIFBRDADDR
242 Set broadcast address for protocol family and interface.
246 requests to obtain addresses and requests both to set and
247 retrieve other data are still fully supported
251 .Bl -tag -width SIOCGIFBRDADDR
253 Get interface address for protocol family.
254 .It Dv SIOCGIFDSTADDR
255 Get point to point address for protocol family and interface.
256 .It Dv SIOCGIFBRDADDR
257 Get broadcast address for protocol family and interface.
259 Attempt to set the enabled capabilities field for the interface
265 Note that, depending on the particular interface features,
266 some capabilities may appear hard-coded to enabled, or toggling
267 a capability may affect the status of other ones.
268 The supported capabilities field is read-only, and the
270 field is unused by this call.
272 Get the interface capabilities fields.
273 The values for supported and enabled capabilities will be returned in the
279 structure, respectively.
281 Set interface flags field.
282 If the interface is marked down,
283 any processes currently routing packets through the interface
285 some interfaces may be reset so that incoming packets are no longer received.
286 When marked up again, the interface is reinitialized.
290 Set interface routing metric.
291 The metric is used only by user-level routers.
293 Get interface metric.
295 Attempt to create the specified interface.
296 If the interface name is given without a unit number the system
297 will attempt to create a new interface with an arbitrary unit number.
298 On successful return the
300 field will contain the new interface name.
302 Attempt to destroy the specified interface.
305 There are two requests that make use of a new structure:
306 .Bl -tag -width SIOCGIFBRDADDR
308 An interface may have more than one address associated with it
310 This request provides a means to
311 add additional addresses (or modify characteristics of the
312 primary address if the default address for the address family
314 Rather than making separate calls to
315 set destination or broadcast addresses, or network masks
316 (now an integral feature of multiple protocols)
317 a separate structure is used to specify all three facets simultaneously
319 One would use a slightly tailored version of this struct specific
320 to each family (replacing each sockaddr by one
321 of the family-specific type).
322 Where the sockaddr itself is larger than the
323 default size, one needs to modify the
325 identifier itself to include the total size, as described in
328 This requests deletes the specified address from the list
329 associated with an interface.
332 structure to allow for the possibility of protocols allowing
333 multiple masks or destination addresses, and also adopts the
334 convention that specification of the default address means
335 to delete the first address for the interface belonging to
336 the address family in which the original socket was opened.
338 Get interface configuration list.
339 This request takes an
341 structure (see below) as a value-result parameter.
344 field should be initially set to the size of the buffer
347 On return it will contain the length, in bytes, of the
349 .It Dv SIOCIFGCLONERS
350 Get list of clonable interfaces.
351 This request takes an
353 structure (see below) as a value-result parameter.
356 field should be set to the number of
358 sized strings that can be fit in the buffer pointed to by
362 will be set to the number of clonable interfaces and the buffer pointed
365 will be filled with the names of clonable interfaces aligned on
371 * Structure used in SIOCAIFCONF request.
374 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
375 struct sockaddr ifra_addr;
376 struct sockaddr ifra_broadaddr;
377 struct sockaddr ifra_mask;
383 * Structure used in SIOCGIFCONF request.
384 * Used to retrieve interface configuration
385 * for machine (useful for programs which
386 * must know all networks accessible).
389 int ifc_len; /* size of associated buffer */
392 struct ifreq *ifcu_req;
394 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
395 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
400 /* Structure used in SIOCIFGCLONERS request. */
402 int ifcr_total; /* total cloners (out) */
403 int ifcr_count; /* room for this many in user buffer */
404 char *ifcr_buffer; /* buffer for cloner names */