]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/netdevice.7
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man7 / netdevice.7
CommitLineData
fea681da
MK
1'\" t
2.\" Don't change the first line, it tells man that tbl is needed.
3.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4.\" Permission is granted to distribute possibly modified copies
5.\" of this page provided the header is included verbatim,
6.\" and in case of nontrivial modification author and date
7.\" of the modification is added to the header.
8.\" $Id: netdevice.7,v 1.10 2000/08/17 10:09:54 ak Exp $
bab7e1c7
MK
9.\"
10.\" Modified, 2004-11-25, mtk, formatting and a few wording fixes
11.\"
c13182ef 12.TH NETDEVICE 7 1999-05-02 "Linux Man Page" "Linux Programmer's Manual"
fea681da
MK
13.SH NAME
14netdevice \- Low level access to Linux network devices
15.SH SYNOPSIS
16.B "#include <sys/ioctl.h>"
17.br
18.B "#include <net/if.h>"
19.SH DESCRIPTION
20This man page describes the sockets interface which is used to configure
21network devices.
22
c13182ef
MK
23Linux supports some standard ioctls to configure network devices.
24They can be used on any socket's file descriptor regardless of the
25family or type.
26They pass an
27.B ifreq
fea681da
MK
28structure:
29
30.nf
fea681da 31struct ifreq {
bab7e1c7
MK
32 char ifr_name[IFNAMSIZ]; /* Interface name */
33 union {
34 struct sockaddr ifr_addr;
35 struct sockaddr ifr_dstaddr;
36 struct sockaddr ifr_broadaddr;
37 struct sockaddr ifr_netmask;
38 struct sockaddr ifr_hwaddr;
39 short ifr_flags;
40 int ifr_ifindex;
41 int ifr_metric;
42 int ifr_mtu;
43 struct ifmap ifr_map;
44 char ifr_slave[IFNAMSIZ];
45 char ifr_newname[IFNAMSIZ];
46 char * ifr_data;
47 };
fea681da
MK
48};
49
c13182ef 50struct ifconf {
bab7e1c7 51 int ifc_len; /* size of buffer */
c13182ef
MK
52 union {
53 char * ifc_buf; /* buffer address */
bab7e1c7 54 struct ifreq * ifc_req; /* array of structures */
c13182ef
MK
55 };
56};
fea681da
MK
57.fi
58
59Normally, the user specifies which device to affect by setting
60.B ifr_name
c13182ef
MK
61to the name of the interface.
62All other members of the structure may
63share memory.
fea681da
MK
64.SH IOCTLS
65If an ioctl is marked as privileged then using it requires an effective
357cf3fe 66user ID of 0 or the
fea681da 67.B CAP_NET_ADMIN
c13182ef
MK
68capability.
69If this is not the case
fea681da
MK
70.B EPERM
71will be returned.
fea681da
MK
72.TP
73.B SIOCGIFNAME
74Given the
75.BR ifr_ifindex ,
76return the name of the interface in
77.BR ifr_name .
78This is the only ioctl which returns its result in
79.BR ifr_name .
fea681da
MK
80.TP
81.B SIOCGIFINDEX
82Retrieve the interface index of the interface into
83.BR ifr_ifindex .
fea681da
MK
84.TP
85.BR SIOCGIFFLAGS ", " SIOCSIFFLAGS
86Get or set the active flag word of the device.
87.B ifr_flags
88contains a bitmask of the following values:
fea681da
MK
89.TS
90tab(:);
91c s
92l l.
93Device flags
94IFF_UP:Interface is running.
95IFF_BROADCAST:Valid broadcast address set.
96IFF_DEBUG:Internal debugging flag.
97IFF_LOOPBACK:Interface is a loopback interface.
98IFF_POINTOPOINT:Interface is a point-to-point link.
99IFF_RUNNING:Resources allocated.
100IFF_NOARP:No arp protocol, L2 destination address not set.
101IFF_PROMISC:Interface is in promiscuous mode.
102IFF_NOTRAILERS:Avoid use of trailers.
103IFF_ALLMULTI:Receive all multicast packets.
104IFF_MASTER:Master of a load balancing bundle.
105IFF_SLAVE:Slave of a load balancing bundle.
106IFF_MULTICAST:Supports multicast
107IFF_PORTSEL:Is able to select media type via ifmap.
108IFF_AUTOMEDIA:Auto media selection active.
109IFF_DYNAMIC:T{
110The addresses are lost when the interface goes down.
111T}
c13182ef 112.TE
fea681da
MK
113Setting the active flag word is a privileged operation, but any
114process may read it.
115.TP
116.BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
117Get or set the metric of the device using
118.BR ifr_metric .
119This is currently not implemented; it sets
120.B ifr_metric
121to 0 if you attempt to read it and returns
122.B EOPNOTSUPP
123if you attempt to set it.
124.TP
125.BR SIOCGIFMTU ", " SIOCSIFMTU
126Get or set the MTU (Maximum Transfer Unit) of a device using
127.BR ifr_mtu .
c13182ef
MK
128Setting the MTU is a privileged operation.
129Setting the MTU to
fea681da
MK
130too small values may cause kernel crashes.
131.TP
132.BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
133Get or set the hardware address of a device using
134.BR ifr_hwaddr .
135The hardware address is specified in a struct
136.IR sockaddr .
c13182ef
MK
137.I sa_family
138contains the ARPHRD_* device type,
fea681da 139.I sa_data
c13182ef 140the L2 hardware address starting from byte 0.
fea681da
MK
141Setting the hardware address is a privileged operation.
142.TP
143.B SIOCSIFHWBROADCAST
144Set the hardware broadcast address of a device from
145.BR ifr_hwaddr .
146This is a privileged operation.
147.TP
148.BR SIOCGIFMAP ", " SIOCSIFMAP
149Get or set the interface's hardware parameters using
150.BR ifr_map .
151Setting the parameters is a privileged operation.
152
153.nf
56185b42 154struct ifmap {
bab7e1c7
MK
155 unsigned long mem_start;
156 unsigned long mem_end;
c13182ef
MK
157 unsigned short base_addr;
158 unsigned char irq;
159 unsigned char dma;
160 unsigned char port;
fea681da 161};
fea681da
MK
162.fi
163
164The interpretation of the ifmap structure depends on the device driver
165and the architecture.
166.TP
167.BR SIOCADDMULTI ", " SIOCDELMULTI
168Add an address to or delete an address from the device's link layer
169multicast filters using
170.BR ifr_hwaddr .
171These are privileged operations.
172See also
173.BR packet (7)
174for an alternative.
175.TP
176.BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
177Get or set the transmit queue length of a device using
178.BR ifr_qlen .
179Setting the transmit queue length is a privileged operation.
180.TP
181.B SIOCSIFNAME
c13182ef 182Changes the name of the interface specified in
fea681da
MK
183.BR ifr_name
184to
185.BR ifr_newname .
c13182ef
MK
186This is a privileged operation.
187It is only allowed when the interface
fea681da
MK
188is not up.
189.TP
190.B SIOCGIFCONF
c13182ef
MK
191Return a list of interface (transport layer) addresses.
192This currently
193means only addresses of the AF_INET (IPv4) family for compatibility.
194The user passes a
fea681da 195.B ifconf
c13182ef
MK
196structure as argument to the ioctl.
197It contains a pointer to an array of
fea681da 198.I ifreq
c13182ef 199structures in
fea681da 200.B ifc_req
c13182ef 201and its length in bytes in
a5e0a0e4 202.BR ifc_len .
fea681da 203The kernel fills the ifreqs with all current L3 interface addresses that
c13182ef
MK
204are running:
205.I ifr_name
206contains the interface name (eth0:1 etc.),
fea681da
MK
207.I ifr_addr
208the address.
c13182ef 209The kernel returns with the actual length in
fea681da 210.IR ifc_len .
c13182ef 211If
fea681da
MK
212.I ifc_len
213is equal to the original length the buffer probably has overflowed
214and you should retry with a bigger buffer to get all addresses.
215When no error occurs the ioctl returns 0;
c13182ef
MK
216otherwise \-1.
217Overflow is not an error.
4c44fdf1 218.\" FIXME Slaving isn't supported in 2.2
bbbc07bc 219.\" .
fea681da
MK
220.\" .TP
221.\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
222.\" Get or set the slave device using
223.\" .BR ifr_slave .
224.\" Setting the slave device is a privileged operation.
225.\" .PP
a749f870 226.\" FIXME add amateur radio stuff.
fea681da 227.PP
c13182ef
MK
228Most protocols support their own ioctls to configure protocol specific
229interface options.
230See the protocol man pages for a description.
231For configuring IP addresses see
fea681da
MK
232.BR ip (7).
233.PP
c13182ef 234In addition some devices support private ioctls.
56185b42 235These are not described here.
fea681da 236.SH NOTES
bab7e1c7 237Strictly speaking,
c13182ef
MK
238.B SIOCGIFCONF
239is IP specific and belongs in
fea681da
MK
240.BR ip (7).
241.LP
242The names of interfaces with no addresses or that don't have the
c13182ef 243.B IFF_RUNNING
fea681da
MK
244flag set can be found via
245.IR /proc/net/dev .
246.LP
c13182ef 247Local IPv6 IP addresses can be found via /proc/net or via
fea681da
MK
248.BR rtnetlink (7).
249.SH BUGS
c13182ef
MK
250glibc 2.1 is missing the
251.I ifr_newname
252macro in net/if.h.
253Add the following to your program as a workaround:
fea681da
MK
254.sp
255.RS
256.nf
fea681da
MK
257#ifndef ifr_newname
258#define ifr_newname ifr_ifru.ifru_slave
259#endif
fea681da
MK
260.fi
261.RE
262.SH "SEE ALSO"
263.BR capabilities (7),
264.BR ip (7),
265.BR proc (7),
266.BR rtnetlink (7)