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.1 2003/12/20 03:31:53 bbbush Exp $
9 .TH NETDEVICE 7 1999-05-02 "Linux Man Page" "Linux Programmer's Manual"
11 netdevice \- Low level access to Linux network devices.
13 .B "#include <sys/ioctl.h>"
15 .B "#include <net/if.h>"
17 This man page describes the sockets interface which is used to configure
20 Linux supports some standard ioctls to configure network devices. They
21 can be used on any socket's file descriptor regardless of the family or type.
29 char ifr_name[IFNAMSIZ]; /* Interface name */
31 struct sockaddr ifr_addr;
32 struct sockaddr ifr_dstaddr;
33 struct sockaddr ifr_broadaddr;
34 struct sockaddr ifr_netmask;
35 struct sockaddr ifr_hwaddr;
41 char ifr_slave[IFNAMSIZ];
42 char ifr_newname[IFNAMSIZ];
48 int ifc_len; /* size of buffer */
50 char * ifc_buf; /* buffer address */
51 struct ifreq *ifc_req; /* array of structures */
57 Normally, the user specifies which device to affect by setting
59 to the name of the interface. All other members of the structure may
63 If an ioctl is marked as privileged then using it requires an effective
66 capability. If this is not the case
74 return the name of the interface in
76 This is the only ioctl which returns its result in
81 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 bitmask of the following values:
95 IFF_UP:Interface is running.
96 IFF_BROADCAST:Valid broadcast address set.
97 IFF_DEBUG:Internal debugging flag.
98 IFF_LOOPBACK:Interface is a loopback interface.
99 IFF_POINTOPOINT:Interface is a point-to-point link.
100 IFF_RUNNING:Resources allocated.
101 IFF_NOARP:No arp protocol, L2 destination address not set.
102 IFF_PROMISC:Interface is in promiscuous mode.
103 IFF_NOTRAILERS:Avoid use of trailers.
104 IFF_ALLMULTI:Receive all multicast packets.
105 IFF_MASTER:Master of a load balancing bundle.
106 IFF_SLAVE:Slave of a load balancing bundle.
107 IFF_MULTICAST:Supports multicast
108 IFF_PORTSEL:Is able to select media type via ifmap.
109 IFF_AUTOMEDIA:Auto media selection active.
111 The addresses are lost when the interface goes down.
115 Setting the active flag word is a privileged operation, but any
118 .BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
119 Get or set the metric of the device using
121 This is currently not implemented; it sets
123 to 0 if you attempt to read it and returns
125 if you attempt to set it.
127 .BR SIOCGIFMTU ", " SIOCSIFMTU
128 Get or set the MTU (Maximum Transfer Unit) of a device using
130 Setting the MTU is a privileged operation. Setting the MTU to
131 too small values may cause kernel crashes.
133 .BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
134 Get or set the hardware address of a device using
136 The hardware address is specified in a struct
139 contains the ARPHRD_* device type,
141 the L2 hardware address starting from byte 0.
142 Setting the hardware address is a privileged operation.
144 .B SIOCSIFHWBROADCAST
145 Set the hardware broadcast address of a device from
147 This is a privileged operation.
149 .BR SIOCGIFMAP ", " SIOCSIFMAP
150 Get or set the interface's hardware parameters using
152 Setting the parameters is a privileged operation.
158 unsigned long mem_start;
159 unsigned long mem_end;
160 unsigned short base_addr;
168 The interpretation of the ifmap structure depends on the device driver
169 and the architecture.
171 .BR SIOCADDMULTI ", " SIOCDELMULTI
172 Add an address to or delete an address from the device's link layer
173 multicast filters using
175 These are privileged operations.
180 .BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
181 Get or set the transmit queue length of a device using
183 Setting the transmit queue length is a privileged operation.
186 Changes the name of the interface specified in
190 This is a privileged operation. It is only allowed when the interface
194 Return a list of interface (transport layer) addresses. This currently
195 means only addresses of the AF_INET (IPv4) family for compatibility.
198 structure as argument to the ioctl. It contains a pointer to an array of
202 and its length in bytes in
204 The kernel fills the ifreqs with all current L3 interface addresses that
207 contains the interface name (eth0:1 etc.),
210 The kernel returns with the actual length in
214 is equal to the original length the buffer probably has overflowed
215 and you should retry with a bigger buffer to get all addresses.
216 When no error occurs the ioctl returns 0;
217 otherwise \-1. Overflow is no error.
218 \" XXX Slaving isn't supported in 2.2
220 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
221 .\" Get or set the slave device using
223 .\" Setting the slave device is a privileged operation.
225 .\" XXX add amateur radio stuff.
227 Most protocols support their own ioctls to configure protocol specific
228 interface options. See the protocol man pages for a description.
229 For configuring IP addresses see
232 In addition some devices support private ioctls. These are not described here.
236 is IP specific and belongs in
239 The names of interfaces with no addresses or that don't have the
241 flag set can be found via
244 Local IPv6 IP addresses can be found via /proc/net or via
247 glibc 2.1 is missing the
249 macro in net/if.h. Add the following to your program as workaround:
255 #define ifr_newname ifr_ifru.ifru_slave