2 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
5 .\" Permission is granted to distribute possibly modified copies
6 .\" of this page provided the header is included verbatim,
7 .\" and in case of nontrivial modification author and date
8 .\" of the modification is added to the header.
11 .\" $Id: netdevice.7,v 1.10 2000/08/17 10:09:54 ak Exp $
13 .\" Modified, 2004-11-25, mtk, formatting and a few wording fixes
15 .\" Modified, 2011-11-02, <bidulock@openss7.org>, added many basic
16 .\" but missing ioctls, such as SIOCGIFADDR.
18 .TH NETDEVICE 7 2014-01-24 "Linux" "Linux Programmer's Manual"
20 netdevice \- low-level access to Linux network devices
22 .B "#include <sys/ioctl.h>"
24 .B "#include <net/if.h>"
26 This man page describes the sockets interface which is used to configure
29 Linux supports some standard ioctls to configure network devices.
30 They can be used on any socket's file descriptor regardless of the
39 char ifr_name[IFNAMSIZ]; /* Interface name */
41 struct sockaddr ifr_addr;
42 struct sockaddr ifr_dstaddr;
43 struct sockaddr ifr_broadaddr;
44 struct sockaddr ifr_netmask;
45 struct sockaddr ifr_hwaddr;
51 char ifr_slave[IFNAMSIZ];
52 char ifr_newname[IFNAMSIZ];
59 Normally, the user specifies which device to affect by setting
61 to the name of the interface.
62 All other members of the structure may
65 If an ioctl is marked as privileged, then using it requires an effective
69 If this is not the case,
76 return the name of the interface in
78 This is the only ioctl which returns its result in
82 Retrieve the interface index of the interface into
85 .BR SIOCGIFFLAGS ", " SIOCSIFFLAGS
86 Get or set the active flag word of the device.
88 contains a bit mask of the following values:
89 .\" Do not right adjust text blocks in tables
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.
103 No arp protocol, L2 destination address not set.
105 IFF_PROMISC:Interface is in promiscuous mode.
106 IFF_NOTRAILERS:Avoid use of trailers.
107 IFF_ALLMULTI:Receive all multicast packets.
108 IFF_MASTER:Master of a load balancing bundle.
109 IFF_SLAVE:Slave of a load balancing bundle.
110 IFF_MULTICAST:Supports multicast
111 IFF_PORTSEL:Is able to select media type via ifmap.
112 IFF_AUTOMEDIA:Auto media selection active.
114 The addresses are lost when the interface goes down.
116 IFF_LOWER_UP:Driver signals L1 up (since Linux 2.6.17)
117 IFF_DORMANT:Driver signals dormant (since Linux 2.6.17)
118 IFF_ECHO:Echo sent packets (since Linux 2.6.25)
122 Setting the active flag word is a privileged operation, but any
125 .BR SIOCGIFPFLAGS ", " SIOCSIFPFLAGS
126 Get or set extended (private) flags for the device.
128 contains a bit mask of the following values:
134 IFF_802_1Q_VLAN:Interface is 802.1Q VLAN device.
135 IFF_EBRIDGE:Interface is Ethernet bridging device.
136 IFF_SLAVE_INACTIVE:Interface is inactive bonding slave.
137 IFF_MASTER_8023AD:Interface is 802.3ad bonding master.
138 IFF_MASTER_ALB:Interface is balanced-alb bonding master.
139 IFF_BONDING:Interface is a bonding master or slave.
140 IFF_SLAVE_NEEDARP:Interface needs ARPs for validation.
141 IFF_ISATAP:Interface is RFC4214 ISATAP interface.
144 Setting the extended (private) interface flags is a privileged operation.
146 .BR SIOCGIFADDR ", " SIOCSIFADDR
147 Get or set the address of the device using
149 Setting the interface address is a privileged operation.
150 For compatibility, only
152 addresses are accepted or returned.
154 .BR SIOCGIFDSTADDR ", " SIOCSIFDSTADDR
155 Get or set the destination address of a point-to-point device using
157 For compatibility, only
159 addresses are accepted or returned.
160 Setting the destination address is a privileged operation.
162 .BR SIOCGIFBRDADDR ", " SIOCSIFBRDADDR
163 Get or set the broadcast address for a device using
165 For compatibility, only
167 addresses are accepted or returned.
168 Setting the broadcast address is a privileged operation.
170 .BR SIOCGIFNETMASK ", " SIOCSIFNETMASK
171 Get or set the network mask for a device using
173 For compatibility, only
175 addresses are accepted or returned.
176 Setting the network mask is a privileged operation.
178 .BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
179 Get or set the metric of the device using
181 This is currently not implemented; it sets
183 to 0 if you attempt to read it and returns
185 if you attempt to set it.
187 .BR SIOCGIFMTU ", " SIOCSIFMTU
188 Get or set the MTU (Maximum Transfer Unit) of a device using
190 Setting the MTU is a privileged operation.
192 too small values may cause kernel crashes.
194 .BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
195 Get or set the hardware address of a device using
197 The hardware address is specified in a struct
200 contains the ARPHRD_* device type,
202 the L2 hardware address starting from byte 0.
203 Setting the hardware address is a privileged operation.
205 .B SIOCSIFHWBROADCAST
206 Set the hardware broadcast address of a device from
208 This is a privileged operation.
210 .BR SIOCGIFMAP ", " SIOCSIFMAP
211 Get or set the interface's hardware parameters using
213 Setting the parameters is a privileged operation.
218 unsigned long mem_start;
219 unsigned long mem_end;
220 unsigned short base_addr;
228 The interpretation of the ifmap structure depends on the device driver
229 and the architecture.
231 .BR SIOCADDMULTI ", " SIOCDELMULTI
232 Add an address to or delete an address from the device's link layer
233 multicast filters using
235 These are privileged operations.
240 .BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
241 Get or set the transmit queue length of a device using
243 Setting the transmit queue length is a privileged operation.
246 Changes the name of the interface specified in
250 This is a privileged operation.
251 It is allowed only when the interface
255 Return a list of interface (transport layer) addresses.
257 means only addresses of the
259 (IPv4) family for compatibility.
260 Unlike the others, this ioctl passes an
267 int ifc_len; /* size of buffer */
269 char *ifc_buf; /* buffer address */
270 struct ifreq *ifc_req; /* array of structures */
280 returns the necessary buffer size in bytes
281 for receiving all available addresses in
285 contains a pointer to an array of
287 structures to be filled with all currently active L3 interface addresses.
289 contains the size of the array in bytes.
294 will receive the interface name, and
297 The actual number of bytes transferred is returned in
300 If the size specified by
302 is insufficient to store all the addresses,
303 the kernel will skip the exceeding ones and return success.
304 There is no reliable way of detecting this condition once it has occurred.
305 It is therefore recommended to either determine the necessary buffer size
306 beforehand by calling
310 set to NULL, or to retry the call with a bigger buffer whenever
312 upon return differs by less than
313 .I sizeof(struct ifreq)
314 from its original value.
316 If an error occurs accessing the
323 .\" Slaving isn't supported in 2.2
326 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
327 .\" Get or set the slave device using
329 .\" Setting the slave device is a privileged operation.
331 .\" FIXME . add amateur radio stuff.
333 Most protocols support their own ioctls to configure protocol-specific
335 See the protocol man pages for a description.
336 For configuring IP addresses, see
339 In addition, some devices support private ioctls.
340 These are not described here.
344 and the other ioctls that accept or return only
347 are IP-specific and belong in
350 The names of interfaces with no addresses or that don't have the
352 flag set can be found via
355 Local IPv6 IP addresses can be found via
360 glibc 2.1 is missing the
364 Add the following to your program as a workaround:
369 #define ifr_newname ifr_ifru.ifru_slave
375 .BR capabilities (7),