Penguin
Blame: netdevice(7)
EditPageHistoryDiffInfoLikePages
Annotated edit history of netdevice(7) version 2 showing authors affecting page license. View with all changes included.
Rev Author # Line
1 WikiAdmin 1 NETDEVICE
2 !!!NETDEVICE
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 IOCTLS
7 NOTES
8 BUGS
9 SEE ALSO
10 ----
11 !!NAME
12
13
14 netdevice - Low level access to Linux network devices.
15 !!SYNOPSIS
16 #include <sys/ioctl.h>
17 #include <net/if.h>
18
19 !!DESCRIPTION
20
21
22 This man page describes the sockets interface which is used
23 to configure network devices.
24
25
26 Linux supports some standard ioctls to configure network
27 devices. They can be used on any socket's file descriptor
28 regardless of the family or type. They pass an __ifreq__
29 structure:
30
31
32 struct ifreq {
33 char ifr_name[[IFNAMSIZ];/* Interface name */
34 union {
35 struct sockaddrifr_addr;
36 struct sockaddrifr_dstaddr;
37 struct sockaddrifr_broadaddr;
38 struct sockaddrifr_netmask;
39 struct sockaddrifr_hwaddr;
40 short ifr_flags;
41 int ifr_ifindex;
42 int ifr_metric;
43 int ifr_mtu;
44 struct ifmapifr_map;
45 char ifr_slave[[IFNAMSIZ];
46 char ifr_newname[[IFNAMSIZ];
47 char * ifr_data;
48 };
49 };
50 struct ifconf {
51 int ifc_len; /* size of buffer */
52 union {
53 char * ifc_buf; /* buffer address */
54 struct ifreq *ifc_req; /* array of structures */
55 };
56 };
57
58 Normally, the user specifies which device to affect by setting __ifr_name__ to the name of the interface. All other members of the structure may share memory.
59 !!IOCTLS
60
61
62 If an ioctl is marked as privileged then using it requires
63 an effective user id of 0 or the __CAP_NET_ADMIN__
64 capability. If this is not the case __EPERM__ will be
65 returned.
66
67
68 __SIOCGIFNAME__
69
70
71 Given the __ifr_ifindex__, return the name of the
72 interface in __ifr_name__. This is the only ioctl which
73 returns its result in __ifr_name__.
74
75
76 __SIOCGIFINDEX__
77
78
79 Retrieve the interface index of the interface into
80 __ifr_ifindex__.
81
82
83 __SIOCGIFFLAGS__, __SIOCSIFFLAGS__
84
85
86 Get or set the active flag word of the device.
87 __ifr_flags__ contains a bitmask of the following
88 values:
89
90
91 Setting the active flag word is a privileged operation, but any process may read it.
92
93
94 __SIOCGIFMETRIC__, __SIOCSIFMETRIC__
95
96
97 Get or set the metric of the device using __ifr_metric__.
98 This is currently not implemented; it sets __ifr_metric__
99 to 0 if you attempt to read it and returns __EOPNOTSUPP__
100 if you attempt to set it.
101
102
103 __SIOCGIFMTU__, __SIOCSIFMTU__
104
105
106 Get or set the MTU (Maximum Transfer Unit) of a device using
107 __ifr_mtu__. Setting the MTU is a privileged operation.
108 Setting the MTU to too small values may cause kernel
109 crashes.
110
111
112 __SIOCGIFHWADDR__, __SIOCSIFHWADDR__
113
114
115 Get or set the hardware address of a device using
116 __ifr_hwaddr__. The hardware address is specified in a
117 struct ''sockaddr''. ''sa_family'' contains the
118 ARPHRD_* device type, ''sa_data'' the L2 hardware address
119 starting from byte 0. Setting the hardware address is a
120 privileged operation.
121
122
123 __SIOCSIFHWBROADCAST__
124
125
126 Set the hardware broadcast address of a device from
127 __ifr_hwaddr__. This is a privileged
128 operation.
129
130
131 __SIOCGIFMAP__, __SIOCSIFMAP__
132
133
134 Get or set the interface's hardware parameters using
135 __ifr_map__. Setting the parameters is a privileged
136 operation.
137
138
139 struct ifmap
140 {
141 unsigned long mem_start;
142 unsigned long mem_end;
143 unsigned short base_addr;
144 unsigned char irq;
145 unsigned char dma;
146 unsigned char port;
147 };
148 The interpretation of the ifmap structure depends on the device driver and the architecture.
149
150
151 __SIOCADDMULTI__, __SIOCDELMULTI__
152
153
154 Add an address to or delete an address from the device's
155 link layer multicast filters using __ifr_hwaddr__. These
156 are privileged operations. See also packet(7) for an
157 alternative.
158
159
160 __SIOCGIFTXQLEN__, __SIOCSIFTXQLEN__
161
162
163 Get or set the transmit queue length of a device using
164 __ifr_qlen__. Setting the transmit queue length is a
165 privileged operation.
166
167
168 __SIOCSIFNAME__
169
170
171 Changes the name of the interface specified in
172 __ifr_name__ to __ifr_newname__. This is a privileged
173 operation. It is only allowed when the interface is not
174 up.
175
176
177 __SIOCGIFCONF__
178
179
180 Return a list of interface (transport layer) addresses. This
181 currently means only addresses of the AF_INET (IPv4) family
182 for compatibility. The user passes a __ifconf__ structure
183 as argument to the ioctl. It contains a pointer to an array
184 of ''ifreq'' structures in __ifc_req__ and its length
185 in bytes in __ifc_len.__ The kernel fills the ifreqs with
186 all current L3 interface addresses that are running:
187 ''ifr_name'' contains the interface name (eth0:1 etc.),
188 ''ifr_addr'' the address. The kernel returns with the
189 actual length in ''ifc_len''. If ''ifc_len'' is equal
190 to the original length the buffer probably has overflowed
191 and you should retry with a bigger buffer to get all
192 addresses. When no error occurs the ioctl returns 0;
193 otherwise -1. Overflow is no error.
194
195
196 Most protocols support their own ioctls to configure
197 protocol specific interface options. See the protocol man
198 pages for a description. For configuring IP addresses see
199 ip(7).
200
201
202 In addition some devices support private ioctls. These are
203 not described here.
204 !!NOTES
205
206
207 Strictly seen, __SIOCGIFCONF__ is IP specific and belongs
208 in ip(7).
209
210
211 The names of interfaces with no addresses or that don't have
212 the __IFF_RUNNING__ flag set can be found via
213 ''/proc/net/dev''.
214
215
216 Local IPv6 IP addresses can be found via /proc/net or via
217 rtnetlink(7).
218 !!BUGS
219
220
221 glibc 2.1 is missing the ''ifr_newname'' macro in
222 net/if.h. Add the following to your program as
223 workaround:
224
225
226 #ifndef ifr_newname
227 #define ifr_newname ifr_ifru.ifru_slave
228 #endif
229 !!SEE ALSO
230
231
232 ip(7), proc(7),
233 rtnetlink(7)
234 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.