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 $
10 .\" Modified, 2004-11-25, mtk, formatting and a few wording fixes
12 .TH NETDEVICE 7 2009-01-14 "Linux" "Linux Programmer's Manual"
14 netdevice \- Low level access to Linux network devices
16 .B "#include <sys/ioctl.h>"
18 .B "#include <net/if.h>"
20 This man page describes the sockets interface which is used to configure
23 Linux supports some standard ioctls to configure network devices.
24 They can be used on any socket's file descriptor regardless of the
33 char ifr_name[IFNAMSIZ]; /* Interface name */
35 struct sockaddr ifr_addr;
36 struct sockaddr ifr_dstaddr;
37 struct sockaddr ifr_broadaddr;
38 struct sockaddr ifr_netmask;
39 struct sockaddr ifr_hwaddr;
45 char ifr_slave[IFNAMSIZ];
46 char ifr_newname[IFNAMSIZ];
52 int ifc_len; /* size of buffer */
54 char *ifc_buf; /* buffer address */
55 struct ifreq *ifc_req; /* array of structures */
61 Normally, the user specifies which device to affect by setting
63 to the name of the interface.
64 All other members of the structure may
67 If an ioctl is marked as privileged then using it requires an effective
71 If this is not the case
78 return the name of the interface in
80 This is the only ioctl which returns its result in
84 Retrieve the interface index of the interface into
87 .BR SIOCGIFFLAGS ", " SIOCSIFFLAGS
88 Get or set the active flag word of the device.
90 contains a bit mask of the following values:
96 IFF_UP:Interface is running.
97 IFF_BROADCAST:Valid broadcast address set.
98 IFF_DEBUG:Internal debugging flag.
99 IFF_LOOPBACK:Interface is a loopback interface.
100 IFF_POINTOPOINT:Interface is a point-to-point link.
101 IFF_RUNNING:Resources allocated.
102 IFF_NOARP:No arp protocol, L2 destination address not set.
103 IFF_PROMISC:Interface is in promiscuous mode.
104 IFF_NOTRAILERS:Avoid use of trailers.
105 IFF_ALLMULTI:Receive all multicast packets.
106 IFF_MASTER:Master of a load balancing bundle.
107 IFF_SLAVE:Slave of a load balancing bundle.
108 IFF_MULTICAST:Supports multicast
109 IFF_PORTSEL:Is able to select media type via ifmap.
110 IFF_AUTOMEDIA:Auto media selection active.
112 The addresses are lost when the interface goes down.
114 IFF_LOWER_UP:Driver signals L1 up (since Linux 2.6.17)
115 IFF_DORMANT:Driver signals dormant (since Linux 2.6.17)
116 IFF_ECHO:Echo sent packets (since Linux 2.6.25)
120 Setting the active flag word is a privileged operation, but any
123 .BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
124 Get or set the metric of the device using
126 This is currently not implemented; it sets
128 to 0 if you attempt to read it and returns
130 if you attempt to set it.
132 .BR SIOCGIFMTU ", " SIOCSIFMTU
133 Get or set the MTU (Maximum Transfer Unit) of a device using
135 Setting the MTU is a privileged operation.
137 too small values may cause kernel crashes.
139 .BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
140 Get or set the hardware address of a device using
142 The hardware address is specified in a struct
145 contains the ARPHRD_* device type,
147 the L2 hardware address starting from byte 0.
148 Setting the hardware address is a privileged operation.
150 .B SIOCSIFHWBROADCAST
151 Set the hardware broadcast address of a device from
153 This is a privileged operation.
155 .BR SIOCGIFMAP ", " SIOCSIFMAP
156 Get or set the interface's hardware parameters using
158 Setting the parameters is a privileged operation.
163 unsigned long mem_start;
164 unsigned long mem_end;
165 unsigned short base_addr;
173 The interpretation of the ifmap structure depends on the device driver
174 and the architecture.
176 .BR SIOCADDMULTI ", " SIOCDELMULTI
177 Add an address to or delete an address from the device's link layer
178 multicast filters using
180 These are privileged operations.
185 .BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
186 Get or set the transmit queue length of a device using
188 Setting the transmit queue length is a privileged operation.
191 Changes the name of the interface specified in
195 This is a privileged operation.
196 It is only allowed when the interface
200 Return a list of interface (transport layer) addresses.
202 means only addresses of the
204 (IPv4) family for compatibility.
207 structure as argument to the ioctl.
208 It contains a pointer to an array of
212 and its length in bytes in
214 The kernel fills the ifreqs with all current L3 interface addresses that
217 contains the interface name (eth0:1 etc.),
220 The kernel returns with the actual length in
224 is equal to the original length the buffer probably has overflowed
225 and you should retry with a bigger buffer to get all addresses.
226 When no error occurs the ioctl returns 0;
228 Overflow is not an error.
229 .\" Slaving isn't supported in 2.2
232 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
233 .\" Get or set the slave device using
235 .\" Setting the slave device is a privileged operation.
237 .\" FIXME add amateur radio stuff.
239 Most protocols support their own ioctls to configure protocol-specific
241 See the protocol man pages for a description.
242 For configuring IP addresses see
245 In addition some devices support private ioctls.
246 These are not described here.
250 is IP specific and belongs in
253 The names of interfaces with no addresses or that don't have the
255 flag set can be found via
258 Local IPv6 IP addresses can be found via
263 glibc 2.1 is missing the
267 Add the following to your program as a workaround:
272 #define ifr_newname ifr_ifru.ifru_slave
278 .BR capabilities (7),