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 .\" Modified, 2011-11-02, <bidulock@openss7.org>, added many basic
13 .\" but missing ioctls, such as SIOCGIFADDR.
15 .TH NETDEVICE 7 2012-04-26 "Linux" "Linux Programmer's Manual"
17 netdevice \- low-level access to Linux network devices
19 .B "#include <sys/ioctl.h>"
21 .B "#include <net/if.h>"
23 This man page describes the sockets interface which is used to configure
26 Linux supports some standard ioctls to configure network devices.
27 They can be used on any socket's file descriptor regardless of the
36 char ifr_name[IFNAMSIZ]; /* Interface name */
38 struct sockaddr ifr_addr;
39 struct sockaddr ifr_dstaddr;
40 struct sockaddr ifr_broadaddr;
41 struct sockaddr ifr_netmask;
42 struct sockaddr ifr_hwaddr;
48 char ifr_slave[IFNAMSIZ];
49 char ifr_newname[IFNAMSIZ];
55 int ifc_len; /* size of buffer */
57 char *ifc_buf; /* buffer address */
58 struct ifreq *ifc_req; /* array of structures */
64 Normally, the user specifies which device to affect by setting
66 to the name of the interface.
67 All other members of the structure may
70 If an ioctl is marked as privileged then using it requires an effective
74 If this is not the case
81 return the name of the interface in
83 This is the only ioctl which returns its result in
87 Retrieve the interface index of the interface into
90 .BR SIOCGIFFLAGS ", " SIOCSIFFLAGS
91 Get or set the active flag word of the device.
93 contains a bit mask of the following values:
94 .\" Do not right adjust text blocks in tables
101 IFF_UP:Interface is running.
102 IFF_BROADCAST:Valid broadcast address set.
103 IFF_DEBUG:Internal debugging flag.
104 IFF_LOOPBACK:Interface is a loopback interface.
105 IFF_POINTOPOINT:Interface is a point-to-point link.
106 IFF_RUNNING:Resources allocated.
108 No arp protocol, L2 destination address not set.
110 IFF_PROMISC:Interface is in promiscuous mode.
111 IFF_NOTRAILERS:Avoid use of trailers.
112 IFF_ALLMULTI:Receive all multicast packets.
113 IFF_MASTER:Master of a load balancing bundle.
114 IFF_SLAVE:Slave of a load balancing bundle.
115 IFF_MULTICAST:Supports multicast
116 IFF_PORTSEL:Is able to select media type via ifmap.
117 IFF_AUTOMEDIA:Auto media selection active.
119 The addresses are lost when the interface goes down.
121 IFF_LOWER_UP:Driver signals L1 up (since Linux 2.6.17)
122 IFF_DORMANT:Driver signals dormant (since Linux 2.6.17)
123 IFF_ECHO:Echo sent packets (since Linux 2.6.25)
128 Setting the active flag word is a privileged operation, but any
131 .BR SIOCGIFPFLAGS ", " SIOCSIFPFLAGS
132 Get or set extended (private) flags for the device.
134 contains a bit mask of the following values:
140 IFF_802_1Q_VLAN:Interface is 802.1Q VLAN device.
141 IFF_EBRIDGE:Interface is Ethernet bridging device.
142 IFF_SLAVE_INACTIVE:Interface is inactive bonding slave.
143 IFF_MASTER_8023AD:Interface is 802.3ad bonding master.
144 IFF_MASTER_ALB:Interface is balanced-alb bonding master.
145 IFF_BONDING:Interface is a bonding master or slave.
146 IFF_SLAVE_NEEDARP:Interface needs ARPs for validation.
147 IFF_ISATAP:Interface is RFC4214 ISATAP interface.
150 Setting the extended (private) interface flags is a privileged operation.
152 .BR SIOCGIFADDR ", " SIOCSIFADDR
153 Get or set the address of the device using
155 Setting the interface address is a privileged operation.
156 For compatibility, only
158 addresses are accepted or returned.
160 .BR SIOCGIFDSTADDR ", " SIOCSIFDSTADDR
161 Get or set the destination address of a point-to-point device using
163 For compatibility, only
165 addresses are accepted or returned.
166 Setting the destination address is a privileged operation.
168 .BR SIOCGIFBRDADDR ", " SIOCSIFBRDADDR
169 Get or set the broadcast address for a device using
171 For compatibility, only
173 addresses are accepted or returned.
174 Setting the broadcast address is a privileged operation.
176 .BR SIOCGIFNETMASK ", " SIOCSIFNETMASK
177 Get or set the network mask for a device using
179 For compatibility, only
181 addresses are accepted or returned.
182 Setting the network mask is a privileged operation.
184 .BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
185 Get or set the metric of the device using
187 This is currently not implemented; it sets
189 to 0 if you attempt to read it and returns
191 if you attempt to set it.
193 .BR SIOCGIFMTU ", " SIOCSIFMTU
194 Get or set the MTU (Maximum Transfer Unit) of a device using
196 Setting the MTU is a privileged operation.
198 too small values may cause kernel crashes.
200 .BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
201 Get or set the hardware address of a device using
203 The hardware address is specified in a struct
206 contains the ARPHRD_* device type,
208 the L2 hardware address starting from byte 0.
209 Setting the hardware address is a privileged operation.
211 .B SIOCSIFHWBROADCAST
212 Set the hardware broadcast address of a device from
214 This is a privileged operation.
216 .BR SIOCGIFMAP ", " SIOCSIFMAP
217 Get or set the interface's hardware parameters using
219 Setting the parameters is a privileged operation.
224 unsigned long mem_start;
225 unsigned long mem_end;
226 unsigned short base_addr;
234 The interpretation of the ifmap structure depends on the device driver
235 and the architecture.
237 .BR SIOCADDMULTI ", " SIOCDELMULTI
238 Add an address to or delete an address from the device's link layer
239 multicast filters using
241 These are privileged operations.
246 .BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
247 Get or set the transmit queue length of a device using
249 Setting the transmit queue length is a privileged operation.
252 Changes the name of the interface specified in
256 This is a privileged operation.
257 It is only allowed when the interface
261 Return a list of interface (transport layer) addresses.
263 means only addresses of the
265 (IPv4) family for compatibility.
268 structure as argument to the ioctl.
269 It contains a pointer to an array of
273 and its length in bytes in
275 The kernel fills the ifreqs with all current L3 interface addresses that
278 contains the interface name (eth0:1 etc.),
281 The kernel returns with the actual length in
285 is equal to the original length the buffer probably has overflowed
286 and you should retry with a bigger buffer to get all addresses.
287 When no error occurs the ioctl returns 0;
289 Overflow is not an error.
290 .\" Slaving isn't supported in 2.2
293 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
294 .\" Get or set the slave device using
296 .\" Setting the slave device is a privileged operation.
298 .\" FIXME add amateur radio stuff.
300 Most protocols support their own ioctls to configure protocol-specific
302 See the protocol man pages for a description.
303 For configuring IP addresses see
306 In addition some devices support private ioctls.
307 These are not described here.
311 and the other ioctls that only accept or return
314 are IP specific and belong in
317 The names of interfaces with no addresses or that don't have the
319 flag set can be found via
322 Local IPv6 IP addresses can be found via
327 glibc 2.1 is missing the
331 Add the following to your program as a workaround:
336 #define ifr_newname ifr_ifru.ifru_slave
342 .BR capabilities (7),