xref: /freebsd/share/man/man4/netintro.4 (revision dda5b39711dab90ae1c5624bdd6ff7453177df31)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1983, 1990, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12*dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors
13afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14afe61c15SRodney W. Grimes.\"    without specific prior written permission.
15afe61c15SRodney W. Grimes.\"
16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
27afe61c15SRodney W. Grimes.\"
28afe61c15SRodney W. Grimes.\"     @(#)netintro.4	8.2 (Berkeley) 11/30/93
297f3dea24SPeter Wemm.\" $FreeBSD$
30afe61c15SRodney W. Grimes.\"
31da393f34SGleb Smirnoff.Dd January 26, 2012
32afe61c15SRodney W. Grimes.Dt NETINTRO 4
333d45e180SRuslan Ermilov.Os
34afe61c15SRodney W. Grimes.Sh NAME
35afe61c15SRodney W. Grimes.Nm networking
36afe61c15SRodney W. Grimes.Nd introduction to networking facilities
37afe61c15SRodney W. Grimes.Sh SYNOPSIS
3832eef9aeSRuslan Ermilov.In sys/types.h
3932eef9aeSRuslan Ermilov.In sys/time.h
4032eef9aeSRuslan Ermilov.In sys/socket.h
4132eef9aeSRuslan Ermilov.In net/if.h
4232eef9aeSRuslan Ermilov.In net/route.h
43afe61c15SRodney W. Grimes.Sh DESCRIPTION
44afe61c15SRodney W. GrimesThis section is a general introduction to the networking facilities
45afe61c15SRodney W. Grimesavailable in the system.
46afe61c15SRodney W. GrimesDocumentation in this part of section
47afe61c15SRodney W. Grimes4 is broken up into three areas:
48afe61c15SRodney W. Grimes.Em protocol families
49afe61c15SRodney W. Grimes(domains),
50afe61c15SRodney W. Grimes.Em protocols ,
51afe61c15SRodney W. Grimesand
52afe61c15SRodney W. Grimes.Em network interfaces .
53afe61c15SRodney W. Grimes.Pp
54afe61c15SRodney W. GrimesAll network protocols are associated with a specific
55afe61c15SRodney W. Grimes.Em protocol family .
56afe61c15SRodney W. GrimesA protocol family provides basic services to the protocol
57afe61c15SRodney W. Grimesimplementation to allow it to function within a specific
58b5e7e999SRuslan Ermilovnetwork environment.
59b5e7e999SRuslan ErmilovThese services may include
60afe61c15SRodney W. Grimespacket fragmentation and reassembly, routing, addressing, and
61b5e7e999SRuslan Ermilovbasic transport.
62b5e7e999SRuslan ErmilovA protocol family may support multiple
63afe61c15SRodney W. Grimesmethods of addressing, though the current protocol implementations
64b5e7e999SRuslan Ermilovdo not.
65b5e7e999SRuslan ErmilovA protocol family is normally comprised of a number of protocols, one per
66afe61c15SRodney W. Grimes.Xr socket 2
67b5e7e999SRuslan Ermilovtype.
68b5e7e999SRuslan ErmilovIt is not required that a protocol family support all socket types.
69b5e7e999SRuslan ErmilovA protocol family may contain multiple
70afe61c15SRodney W. Grimesprotocols supporting the same socket abstraction.
71afe61c15SRodney W. Grimes.Pp
72afe61c15SRodney W. GrimesA protocol supports one of the socket abstractions detailed in
73afe61c15SRodney W. Grimes.Xr socket 2 .
74afe61c15SRodney W. GrimesA specific protocol may be accessed either by creating a
75afe61c15SRodney W. Grimessocket of the appropriate type and protocol family, or
76afe61c15SRodney W. Grimesby requesting the protocol explicitly when creating a socket.
77afe61c15SRodney W. GrimesProtocols normally accept only one type of address format,
78afe61c15SRodney W. Grimesusually determined by the addressing structure inherent in
79afe61c15SRodney W. Grimesthe design of the protocol family/network architecture.
80afe61c15SRodney W. GrimesCertain semantics of the basic socket abstractions are
81b5e7e999SRuslan Ermilovprotocol specific.
82b5e7e999SRuslan ErmilovAll protocols are expected to support
83afe61c15SRodney W. Grimesthe basic model for their particular socket type, but may,
84afe61c15SRodney W. Grimesin addition, provide non-standard facilities or extensions
85b5e7e999SRuslan Ermilovto a mechanism.
86b5e7e999SRuslan ErmilovFor example, a protocol supporting the
87afe61c15SRodney W. Grimes.Dv SOCK_STREAM
88afe61c15SRodney W. Grimesabstraction may allow more than one byte of out-of-band
89afe61c15SRodney W. Grimesdata to be transmitted per out-of-band message.
90afe61c15SRodney W. Grimes.Pp
91afe61c15SRodney W. GrimesA network interface is similar to a device interface.
92afe61c15SRodney W. GrimesNetwork interfaces comprise the lowest layer of the
93afe61c15SRodney W. Grimesnetworking subsystem, interacting with the actual transport
94b5e7e999SRuslan Ermilovhardware.
95b5e7e999SRuslan ErmilovAn interface may support one or more protocol families and/or address formats.
96afe61c15SRodney W. GrimesThe SYNOPSIS section of each network interface
97afe61c15SRodney W. Grimesentry gives a sample specification
98afe61c15SRodney W. Grimesof the related drivers for use in providing
99afe61c15SRodney W. Grimesa system description to the
100afe61c15SRodney W. Grimes.Xr config 8
101afe61c15SRodney W. Grimesprogram.
102afe61c15SRodney W. GrimesThe DIAGNOSTICS section lists messages which may appear on the console
103afe61c15SRodney W. Grimesand/or in the system error log,
104afe61c15SRodney W. Grimes.Pa /var/log/messages
105afe61c15SRodney W. Grimes(see
106afe61c15SRodney W. Grimes.Xr syslogd 8 ) ,
107afe61c15SRodney W. Grimesdue to errors in device operation.
108afe61c15SRodney W. Grimes.Sh PROTOCOLS
109afe61c15SRodney W. GrimesThe system currently supports the
110afe61c15SRodney W. GrimesInternet
111afe61c15SRodney W. Grimesprotocols, the Xerox Network Systems(tm) protocols,
112afe61c15SRodney W. Grimesand some of the
113afe61c15SRodney W. Grimes.Tn ISO OSI
114afe61c15SRodney W. Grimesprotocols.
115afe61c15SRodney W. GrimesRaw socket interfaces are provided to the
116afe61c15SRodney W. Grimes.Tn IP
117afe61c15SRodney W. Grimesprotocol
118afe61c15SRodney W. Grimeslayer of the
119afe61c15SRodney W. GrimesInternet, and to the
120afe61c15SRodney W. Grimes.Tn IDP
121afe61c15SRodney W. Grimesprotocol of Xerox
122afe61c15SRodney W. Grimes.Tn NS .
123afe61c15SRodney W. GrimesConsult the appropriate manual pages in this section for more
124afe61c15SRodney W. Grimesinformation regarding the support for each protocol family.
125afe61c15SRodney W. Grimes.Sh ADDRESSING
126afe61c15SRodney W. GrimesAssociated with each protocol family is an address
127b5e7e999SRuslan Ermilovformat.
128b5e7e999SRuslan ErmilovAll network addresses adhere to a general structure,
1296d249eeeSSheldon Hearncalled a sockaddr, described below.
1306d249eeeSSheldon HearnHowever, each protocol
131afe61c15SRodney W. Grimesimposes finer and more specific structure, generally renaming
132afe61c15SRodney W. Grimesthe variant, which is discussed in the protocol family manual
133afe61c15SRodney W. Grimespage alluded to above.
134afe61c15SRodney W. Grimes.Bd -literal -offset indent
135afe61c15SRodney W. Grimesstruct sockaddr {
136afe61c15SRodney W. Grimes    u_char	sa_len;
137afe61c15SRodney W. Grimes    u_char	sa_family;
138afe61c15SRodney W. Grimes    char	sa_data[14];
139afe61c15SRodney W. Grimes};
140afe61c15SRodney W. Grimes.Ed
141afe61c15SRodney W. Grimes.Pp
142afe61c15SRodney W. GrimesThe field
1438996a9d5SRuslan Ermilov.Va sa_len
14448dfd764STom Hukinscontains the total length of the structure,
145afe61c15SRodney W. Grimeswhich may exceed 16 bytes.
146afe61c15SRodney W. GrimesThe following address values for
1478996a9d5SRuslan Ermilov.Va sa_family
148afe61c15SRodney W. Grimesare known to the system
149afe61c15SRodney W. Grimes(and additional formats are defined for possible future implementation):
150afe61c15SRodney W. Grimes.Bd -literal
151afe61c15SRodney W. Grimes#define    AF_UNIX      1    /* local to host (pipes, portals) */
152afe61c15SRodney W. Grimes#define    AF_INET      2    /* internetwork: UDP, TCP, etc. */
153afe61c15SRodney W. Grimes#define    AF_NS        6    /* Xerox NS protocols */
154afe61c15SRodney W. Grimes#define    AF_CCITT     10   /* CCITT protocols, X.25 etc */
155afe61c15SRodney W. Grimes#define    AF_HYLINK    15   /* NSC Hyperchannel */
156afe61c15SRodney W. Grimes#define    AF_ISO       18   /* ISO protocols */
157afe61c15SRodney W. Grimes.Ed
158afe61c15SRodney W. Grimes.Sh ROUTING
159dbcc13f5SRuslan Ermilov.Fx
160afe61c15SRodney W. Grimesprovides some packet routing facilities.
161afe61c15SRodney W. GrimesThe kernel maintains a routing information database, which
162afe61c15SRodney W. Grimesis used in selecting the appropriate network interface when
163afe61c15SRodney W. Grimestransmitting packets.
164afe61c15SRodney W. Grimes.Pp
165afe61c15SRodney W. GrimesA user process (or possibly multiple co-operating processes)
166afe61c15SRodney W. Grimesmaintains this database by sending messages over a special kind
167afe61c15SRodney W. Grimesof socket.
168afe61c15SRodney W. GrimesThis supplants fixed size
169afe61c15SRodney W. Grimes.Xr ioctl 2
170afe61c15SRodney W. Grimesused in earlier releases.
171afe61c15SRodney W. Grimes.Pp
172afe61c15SRodney W. GrimesThis facility is described in
173afe61c15SRodney W. Grimes.Xr route 4 .
174afe61c15SRodney W. Grimes.Sh INTERFACES
175afe61c15SRodney W. GrimesEach network interface in a system corresponds to a
176b5e7e999SRuslan Ermilovpath through which messages may be sent and received.
177b5e7e999SRuslan ErmilovA network interface usually has a hardware device associated with it, though
178afe61c15SRodney W. Grimescertain interfaces such as the loopback interface,
179afe61c15SRodney W. Grimes.Xr lo 4 ,
180afe61c15SRodney W. Grimesdo not.
181afe61c15SRodney W. Grimes.Pp
182afe61c15SRodney W. GrimesThe following
183edf0e5b3SMike Pritchard.Xr ioctl 2
184afe61c15SRodney W. Grimescalls may be used to manipulate network interfaces.
185afe61c15SRodney W. GrimesThe
186edf0e5b3SMike Pritchard.Fn ioctl
187afe61c15SRodney W. Grimesis made on a socket (typically of type
188afe61c15SRodney W. Grimes.Dv SOCK_DGRAM )
189afe61c15SRodney W. Grimesin the desired domain.
190afe61c15SRodney W. GrimesMost of the requests supported in earlier releases
191afe61c15SRodney W. Grimestake an
1928996a9d5SRuslan Ermilov.Vt ifreq
193b5e7e999SRuslan Ermilovstructure as its parameter.
194b5e7e999SRuslan ErmilovThis structure has the form
195afe61c15SRodney W. Grimes.Bd -literal
196afe61c15SRodney W. Grimesstruct	ifreq {
197afe61c15SRodney W. Grimes#define    IFNAMSIZ    16
1987395d17bSTorsten Blum    char    ifr_name[IFNAMSIZ];        /* if name, e.g. "en0" */
199afe61c15SRodney W. Grimes    union {
200afe61c15SRodney W. Grimes        struct    sockaddr ifru_addr;
201afe61c15SRodney W. Grimes        struct    sockaddr ifru_dstaddr;
202afe61c15SRodney W. Grimes        struct    sockaddr ifru_broadaddr;
203215940b3SXin LI        struct    ifreq_buffer ifru_buffer;
20462f76486SMaxim Sobolev        short     ifru_flags[2];
205b385a6c9SDag-Erling Smørgrav        short     ifru_index;
206afe61c15SRodney W. Grimes        int       ifru_metric;
207c18460f9SMike Pritchard        int       ifru_mtu;
208c18460f9SMike Pritchard        int       ifru_phys;
209b385a6c9SDag-Erling Smørgrav        int       ifru_media;
210afe61c15SRodney W. Grimes        caddr_t   ifru_data;
211b385a6c9SDag-Erling Smørgrav        int       ifru_cap[2];
212afe61c15SRodney W. Grimes    } ifr_ifru;
213afe61c15SRodney W. Grimes#define ifr_addr      ifr_ifru.ifru_addr      /* address */
214afe61c15SRodney W. Grimes#define ifr_dstaddr   ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
215afe61c15SRodney W. Grimes#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
216215940b3SXin LI#define ifr_buffer    ifr_ifru.ifru_buffer    /* user supplied buffer with its length */
21762f76486SMaxim Sobolev#define ifr_flags     ifr_ifru.ifru_flags[0]  /* flags (low 16 bits) */
21862f76486SMaxim Sobolev#define ifr_flagshigh ifr_ifru.ifru_flags[1]  /* flags (high 16 bits) */
219afe61c15SRodney W. Grimes#define ifr_metric    ifr_ifru.ifru_metric    /* metric */
220c18460f9SMike Pritchard#define ifr_mtu       ifr_ifru.ifru_mtu       /* mtu */
221c18460f9SMike Pritchard#define ifr_phys      ifr_ifru.ifru_phys      /* physical wire */
222b385a6c9SDag-Erling Smørgrav#define ifr_media     ifr_ifru.ifru_media     /* physical media */
223afe61c15SRodney W. Grimes#define ifr_data      ifr_ifru.ifru_data      /* for use by interface */
224b385a6c9SDag-Erling Smørgrav#define ifr_reqcap    ifr_ifru.ifru_cap[0]    /* requested capabilities */
225b385a6c9SDag-Erling Smørgrav#define ifr_curcap    ifr_ifru.ifru_cap[1]    /* current capabilities */
226b385a6c9SDag-Erling Smørgrav#define ifr_index     ifr_ifru.ifru_index     /* interface index */
227afe61c15SRodney W. Grimes};
228afe61c15SRodney W. Grimes.Ed
229afe61c15SRodney W. Grimes.Pp
230edf0e5b3SMike Pritchard.Fn Ioctl
231afe61c15SRodney W. Grimesrequests to obtain addresses and requests both to set and
232afe61c15SRodney W. Grimesretrieve other data are still fully supported
233afe61c15SRodney W. Grimesand use the
2348996a9d5SRuslan Ermilov.Vt ifreq
235afe61c15SRodney W. Grimesstructure:
236afe61c15SRodney W. Grimes.Bl -tag -width SIOCGIFBRDADDR
237afe61c15SRodney W. Grimes.It Dv SIOCGIFADDR
238afe61c15SRodney W. GrimesGet interface address for protocol family.
239afe61c15SRodney W. Grimes.It Dv SIOCGIFDSTADDR
240afe61c15SRodney W. GrimesGet point to point address for protocol family and interface.
241afe61c15SRodney W. Grimes.It Dv SIOCGIFBRDADDR
242afe61c15SRodney W. GrimesGet broadcast address for protocol family and interface.
243b385a6c9SDag-Erling Smørgrav.It Dv SIOCSIFCAP
244006ed2eeSYaroslav TykhiyAttempt to set the enabled capabilities field for the interface
245006ed2eeSYaroslav Tykhiyto the value of the
246b385a6c9SDag-Erling Smørgrav.Va ifr_reqcap
247b385a6c9SDag-Erling Smørgravfield of the
248b385a6c9SDag-Erling Smørgrav.Vt ifreq
249b385a6c9SDag-Erling Smørgravstructure.
250006ed2eeSYaroslav TykhiyNote that, depending on the particular interface features,
251006ed2eeSYaroslav Tykhiysome capabilities may appear hard-coded to enabled, or toggling
252006ed2eeSYaroslav Tykhiya capability may affect the status of other ones.
253006ed2eeSYaroslav TykhiyThe supported capabilities field is read-only, and the
254b385a6c9SDag-Erling Smørgrav.Va ifr_curcap
255006ed2eeSYaroslav Tykhiyfield is unused by this call.
256006ed2eeSYaroslav Tykhiy.It Dv SIOCGIFCAP
257006ed2eeSYaroslav TykhiyGet the interface capabilities fields.
258006ed2eeSYaroslav TykhiyThe values for supported and enabled capabilities will be returned in the
259006ed2eeSYaroslav Tykhiy.Va ifr_reqcap
260006ed2eeSYaroslav Tykhiyand
261006ed2eeSYaroslav Tykhiy.Va ifr_curcap
262006ed2eeSYaroslav Tykhiyfields of the
263b385a6c9SDag-Erling Smørgrav.Vt ifreq
264006ed2eeSYaroslav Tykhiystructure, respectively.
265215940b3SXin LI.It Dv SIOCGIFDESCR
266215940b3SXin LIGet the interface description, returned in the
267215940b3SXin LI.Va buffer
268215940b3SXin LIfield of
269215940b3SXin LI.Va ifru_buffer
270215940b3SXin LIstruct.
271215940b3SXin LIThe user supplied buffer length should be defined in the
272215940b3SXin LI.Va length
273215940b3SXin LIfield of
274215940b3SXin LI.Va ifru_buffer
275215940b3SXin LIstruct passed in as parameter, and the length would include
276215940b3SXin LIthe terminating nul character.
277215940b3SXin LIIf there is not enough space to hold the interface length,
27857d84848SXin LIno copy would be done and the
27957d84848SXin LI.Va buffer
28057d84848SXin LIfield of
28157d84848SXin LI.Va ifru_buffer
28257d84848SXin LIwould be set to NULL.
283215940b3SXin LIThe kernel will store the buffer length in the
284215940b3SXin LI.Va length
285215940b3SXin LIfield upon return, regardless whether the buffer itself is
286215940b3SXin LIsufficient to hold the data.
287215940b3SXin LI.It Dv SIOCSIFDESCR
288215940b3SXin LISet the interface description to the value of the
289215940b3SXin LI.Va buffer
290215940b3SXin LIfield of
291215940b3SXin LI.Va ifru_buffer
292215940b3SXin LIstruct, with
293215940b3SXin LI.Va length
294215940b3SXin LIfield specifying its length (counting the terminating nul).
295afe61c15SRodney W. Grimes.It Dv SIOCSIFFLAGS
296b5e7e999SRuslan ErmilovSet interface flags field.
297b5e7e999SRuslan ErmilovIf the interface is marked down,
298afe61c15SRodney W. Grimesany processes currently routing packets through the interface
299afe61c15SRodney W. Grimesare notified;
300afe61c15SRodney W. Grimessome interfaces may be reset so that incoming packets are no longer received.
301afe61c15SRodney W. GrimesWhen marked up again, the interface is reinitialized.
302afe61c15SRodney W. Grimes.It Dv SIOCGIFFLAGS
303afe61c15SRodney W. GrimesGet interface flags.
304afe61c15SRodney W. Grimes.It Dv SIOCSIFMETRIC
305afe61c15SRodney W. GrimesSet interface routing metric.
306afe61c15SRodney W. GrimesThe metric is used only by user-level routers.
307afe61c15SRodney W. Grimes.It Dv SIOCGIFMETRIC
308afe61c15SRodney W. GrimesGet interface metric.
309ad37a95bSBrooks Davis.It Dv SIOCIFCREATE
310ad37a95bSBrooks DavisAttempt to create the specified interface.
311ad37a95bSBrooks DavisIf the interface name is given without a unit number the system
312ad37a95bSBrooks Daviswill attempt to create a new interface with an arbitrary unit number.
313a48060a2SDima DorfmanOn successful return the
3148996a9d5SRuslan Ermilov.Va ifr_name
315ad37a95bSBrooks Davisfield will contain the new interface name.
316ad37a95bSBrooks Davis.It Dv SIOCIFDESTROY
317ad37a95bSBrooks DavisAttempt to destroy the specified interface.
318afe61c15SRodney W. Grimes.El
319afe61c15SRodney W. Grimes.Pp
320afe61c15SRodney W. GrimesThere are two requests that make use of a new structure:
321afe61c15SRodney W. Grimes.Bl -tag -width SIOCGIFBRDADDR
322afe61c15SRodney W. Grimes.It Dv SIOCAIFADDR
323afe61c15SRodney W. GrimesAn interface may have more than one address associated with it
324b5e7e999SRuslan Ermilovin some protocols.
325b5e7e999SRuslan ErmilovThis request provides a means to
326afe61c15SRodney W. Grimesadd additional addresses (or modify characteristics of the
327afe61c15SRodney W. Grimesprimary address if the default address for the address family
328b5e7e999SRuslan Ermilovis specified).
329b5e7e999SRuslan ErmilovRather than making separate calls to
330afe61c15SRodney W. Grimesset destination or broadcast addresses, or network masks
331afe61c15SRodney W. Grimes(now an integral feature of multiple protocols)
332afe61c15SRodney W. Grimesa separate structure is used to specify all three facets simultaneously
333afe61c15SRodney W. Grimes(see below).
334afe61c15SRodney W. GrimesOne would use a slightly tailored version of this struct specific
335afe61c15SRodney W. Grimesto each family (replacing each sockaddr by one
336afe61c15SRodney W. Grimesof the family-specific type).
337afe61c15SRodney W. GrimesWhere the sockaddr itself is larger than the
338afe61c15SRodney W. Grimesdefault size, one needs to modify the
339edf0e5b3SMike Pritchard.Fn ioctl
340afe61c15SRodney W. Grimesidentifier itself to include the total size, as described in
341edf0e5b3SMike Pritchard.Fn ioctl .
342afe61c15SRodney W. Grimes.It Dv SIOCDIFADDR
343afe61c15SRodney W. GrimesThis requests deletes the specified address from the list
344b5e7e999SRuslan Ermilovassociated with an interface.
345b5e7e999SRuslan ErmilovIt also uses the
3468996a9d5SRuslan Ermilov.Vt ifaliasreq
347afe61c15SRodney W. Grimesstructure to allow for the possibility of protocols allowing
348afe61c15SRodney W. Grimesmultiple masks or destination addresses, and also adopts the
349afe61c15SRodney W. Grimesconvention that specification of the default address means
350afe61c15SRodney W. Grimesto delete the first address for the interface belonging to
351afe61c15SRodney W. Grimesthe address family in which the original socket was opened.
352afe61c15SRodney W. Grimes.It Dv SIOCGIFCONF
353b5e7e999SRuslan ErmilovGet interface configuration list.
354b5e7e999SRuslan ErmilovThis request takes an
3558996a9d5SRuslan Ermilov.Vt ifconf
356b5e7e999SRuslan Ermilovstructure (see below) as a value-result parameter.
357b5e7e999SRuslan ErmilovThe
3588996a9d5SRuslan Ermilov.Va ifc_len
359afe61c15SRodney W. Grimesfield should be initially set to the size of the buffer
360afe61c15SRodney W. Grimespointed to by
3618996a9d5SRuslan Ermilov.Va ifc_buf .
362afe61c15SRodney W. GrimesOn return it will contain the length, in bytes, of the
363afe61c15SRodney W. Grimesconfiguration list.
364ad37a95bSBrooks Davis.It Dv SIOCIFGCLONERS
365ad37a95bSBrooks DavisGet list of clonable interfaces.
366ad37a95bSBrooks DavisThis request takes an
3678996a9d5SRuslan Ermilov.Vt if_clonereq
368ad37a95bSBrooks Davisstructure (see below) as a value-result parameter.
369ad37a95bSBrooks DavisThe
3708996a9d5SRuslan Ermilov.Va ifcr_count
371ad37a95bSBrooks Davisfield should be set to the number of
372ad37a95bSBrooks Davis.Dv IFNAMSIZ
373ad37a95bSBrooks Davissized strings that can be fit in the buffer pointed to by
3748996a9d5SRuslan Ermilov.Va ifcr_buffer .
3758996a9d5SRuslan ErmilovOn return,
3768996a9d5SRuslan Ermilov.Va ifcr_total
377d1ed27b6SJens Schweikhardtwill be set to the number of clonable interfaces and the buffer pointed
378ad37a95bSBrooks Davisto by
3798996a9d5SRuslan Ermilov.Va ifcr_buffer
380ad37a95bSBrooks Daviswill be filled with the names of clonable interfaces aligned on
381ad37a95bSBrooks Davis.Dv IFNAMSIZ
382ad37a95bSBrooks Davisboundaries.
383afe61c15SRodney W. Grimes.El
384afe61c15SRodney W. Grimes.Bd -literal
385afe61c15SRodney W. Grimes/*
386da393f34SGleb Smirnoff* Structure used in SIOCAIFADDR request.
387afe61c15SRodney W. Grimes*/
388afe61c15SRodney W. Grimesstruct ifaliasreq {
389afe61c15SRodney W. Grimes        char    ifra_name[IFNAMSIZ];   /* if name, e.g. "en0" */
390afe61c15SRodney W. Grimes        struct  sockaddr        ifra_addr;
391afe61c15SRodney W. Grimes        struct  sockaddr        ifra_broadaddr;
392afe61c15SRodney W. Grimes        struct  sockaddr        ifra_mask;
393afe61c15SRodney W. Grimes};
394afe61c15SRodney W. Grimes.Ed
395afe61c15SRodney W. Grimes.Bd -literal
396afe61c15SRodney W. Grimes/*
397afe61c15SRodney W. Grimes* Structure used in SIOCGIFCONF request.
398afe61c15SRodney W. Grimes* Used to retrieve interface configuration
399afe61c15SRodney W. Grimes* for machine (useful for programs which
400afe61c15SRodney W. Grimes* must know all networks accessible).
401afe61c15SRodney W. Grimes*/
402afe61c15SRodney W. Grimesstruct ifconf {
403afe61c15SRodney W. Grimes    int   ifc_len;		/* size of associated buffer */
404afe61c15SRodney W. Grimes    union {
405afe61c15SRodney W. Grimes        caddr_t    ifcu_buf;
406afe61c15SRodney W. Grimes        struct     ifreq *ifcu_req;
407afe61c15SRodney W. Grimes    } ifc_ifcu;
408afe61c15SRodney W. Grimes#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
409afe61c15SRodney W. Grimes#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
410afe61c15SRodney W. Grimes};
411afe61c15SRodney W. Grimes.Ed
412ad37a95bSBrooks Davis.Bd -literal
413ad37a95bSBrooks Davis/* Structure used in SIOCIFGCLONERS request. */
414ad37a95bSBrooks Davisstruct if_clonereq {
415ad37a95bSBrooks Davis        int     ifcr_total;     /* total cloners (out) */
416ad37a95bSBrooks Davis        int     ifcr_count;     /* room for this many in user buffer */
417ad37a95bSBrooks Davis        char    *ifcr_buffer;   /* buffer for cloner names */
418ad37a95bSBrooks Davis};
419ad37a95bSBrooks Davis.Ed
420215940b3SXin LI.Bd -literal
421215940b3SXin LI/* Structure used in SIOCGIFDESCR and SIOCSIFDESCR requests */
422215940b3SXin LIstruct ifreq_buffer {
423215940b3SXin LI        size_t  length;         /* length of the buffer */
424215940b3SXin LI        void   *buffer;         /* pointer to userland space buffer */
425215940b3SXin LI};
426215940b3SXin LI.Ed
427afe61c15SRodney W. Grimes.Sh SEE ALSO
428afe61c15SRodney W. Grimes.Xr ioctl 2 ,
4290b992c1dSWolfram Schneider.Xr socket 2 ,
430afe61c15SRodney W. Grimes.Xr intro 4 ,
431afe61c15SRodney W. Grimes.Xr config 8 ,
432b5e7e999SRuslan Ermilov.Xr routed 8 ,
433b5e7e999SRuslan Ermilov.Xr ifnet 9
434afe61c15SRodney W. Grimes.Sh HISTORY
435afe61c15SRodney W. GrimesThe
436afe61c15SRodney W. Grimes.Nm netintro
437afe61c15SRodney W. Grimesmanual appeared in
438afe61c15SRodney W. Grimes.Bx 4.3 tahoe .
439