Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / include / uapi / linux / if.h
CommitLineData
1da177e4
LT
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Global definitions for the INET interface module.
7 *
8 * Version: @(#)if.h 1.0.2 04/18/93
9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
02c30a84 11 * Ross Biro
1da177e4
LT
12 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#ifndef _LINUX_IF_H
20#define _LINUX_IF_H
21
4a91cb61 22#include <linux/libc-compat.h> /* for compatibility with glibc */
1da177e4
LT
23#include <linux/types.h> /* for "__kernel_caddr_t" et al */
24#include <linux/socket.h> /* for "struct sockaddr" et al */
25#include <linux/compiler.h> /* for "__user" et al */
26
4a91cb61 27#if __UAPI_DEF_IF_IFNAMSIZ
1da177e4 28#define IFNAMSIZ 16
4a91cb61 29#endif /* __UAPI_DEF_IF_IFNAMSIZ */
0b815a1a 30#define IFALIASZ 256
1da177e4
LT
31#include <linux/hdlc/ioctl.h>
32
4a91cb61
MR
33/* For glibc compatibility. An empty enum does not compile. */
34#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && \
35 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
589f5816
LR
36/**
37 * enum net_device_flags - &struct net_device flags
38 *
39 * These are the &struct net_device flags, they can be set by drivers, the
40 * kernel and some can be triggered by userspace. Userspace can query and
41 * set these flags using userspace utilities but there is also a sysfs
42 * entry available for all dev flags which can be queried and set. These flags
43 * are shared for all types of net_devices. The sysfs entries are available
44 * via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
45 * are annotated below, note that only a few flags can be toggled and some
93e68cd6 46 * other flags are always preserved from the original net_device flags
589f5816
LR
47 * even if you try to set them via sysfs. Flags which are always preserved
48 * are kept under the flag grouping @IFF_VOLATILE. Flags which are volatile
49 * are annotated below as such.
50 *
51 * You should have a pretty good reason to be extending these flags.
52 *
53 * @IFF_UP: interface is up. Can be toggled through sysfs.
54 * @IFF_BROADCAST: broadcast address valid. Volatile.
55 * @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
56 * @IFF_LOOPBACK: is a loopback net. Volatile.
57 * @IFF_POINTOPOINT: interface is has p-p link. Volatile.
58 * @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
59 * Volatile.
60 * @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
61 * @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
62 * @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
63 * @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
64 * sysfs.
65 * @IFF_MASTER: master of a load balancer. Volatile.
66 * @IFF_SLAVE: slave of a load balancer. Volatile.
67 * @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
68 * @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
69 * @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
70 * @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
71 * through sysfs.
72 * @IFF_LOWER_UP: driver signals L1 up. Volatile.
73 * @IFF_DORMANT: driver signals dormant. Volatile.
74 * @IFF_ECHO: echo sent packets. Volatile.
75 */
76enum net_device_flags {
4a91cb61
MR
77/* for compatibility with glibc net/if.h */
78#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
589f5816
LR
79 IFF_UP = 1<<0, /* sysfs */
80 IFF_BROADCAST = 1<<1, /* volatile */
81 IFF_DEBUG = 1<<2, /* sysfs */
82 IFF_LOOPBACK = 1<<3, /* volatile */
83 IFF_POINTOPOINT = 1<<4, /* volatile */
84 IFF_NOTRAILERS = 1<<5, /* sysfs */
85 IFF_RUNNING = 1<<6, /* volatile */
86 IFF_NOARP = 1<<7, /* sysfs */
87 IFF_PROMISC = 1<<8, /* sysfs */
88 IFF_ALLMULTI = 1<<9, /* sysfs */
89 IFF_MASTER = 1<<10, /* volatile */
90 IFF_SLAVE = 1<<11, /* volatile */
91 IFF_MULTICAST = 1<<12, /* sysfs */
92 IFF_PORTSEL = 1<<13, /* sysfs */
93 IFF_AUTOMEDIA = 1<<14, /* sysfs */
94 IFF_DYNAMIC = 1<<15, /* sysfs */
4a91cb61
MR
95#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
96#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
589f5816
LR
97 IFF_LOWER_UP = 1<<16, /* volatile */
98 IFF_DORMANT = 1<<17, /* volatile */
99 IFF_ECHO = 1<<18, /* volatile */
4a91cb61 100#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
589f5816 101};
4a91cb61 102#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */
b00055aa 103
4a91cb61
MR
104/* for compatibility with glibc net/if.h */
105#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
589f5816
LR
106#define IFF_UP IFF_UP
107#define IFF_BROADCAST IFF_BROADCAST
108#define IFF_DEBUG IFF_DEBUG
109#define IFF_LOOPBACK IFF_LOOPBACK
110#define IFF_POINTOPOINT IFF_POINTOPOINT
111#define IFF_NOTRAILERS IFF_NOTRAILERS
112#define IFF_RUNNING IFF_RUNNING
113#define IFF_NOARP IFF_NOARP
114#define IFF_PROMISC IFF_PROMISC
115#define IFF_ALLMULTI IFF_ALLMULTI
116#define IFF_MASTER IFF_MASTER
117#define IFF_SLAVE IFF_SLAVE
118#define IFF_MULTICAST IFF_MULTICAST
119#define IFF_PORTSEL IFF_PORTSEL
120#define IFF_AUTOMEDIA IFF_AUTOMEDIA
121#define IFF_DYNAMIC IFF_DYNAMIC
4a91cb61
MR
122#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
123
124#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
589f5816
LR
125#define IFF_LOWER_UP IFF_LOWER_UP
126#define IFF_DORMANT IFF_DORMANT
127#define IFF_ECHO IFF_ECHO
4a91cb61 128#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
cd05acfe
OH
129
130#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
b00055aa
SR
131 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
132
1da177e4
LT
133#define IF_GET_IFACE 0x0001 /* for querying only */
134#define IF_GET_PROTO 0x0002
135
136/* For definitions see hdlc.h */
137#define IF_IFACE_V35 0x1000 /* V.35 serial interface */
138#define IF_IFACE_V24 0x1001 /* V.24 serial interface */
139#define IF_IFACE_X21 0x1002 /* X.21 serial interface */
140#define IF_IFACE_T1 0x1003 /* T1 telco serial interface */
141#define IF_IFACE_E1 0x1004 /* E1 telco serial interface */
142#define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */
143#define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */
144
145/* For definitions see hdlc.h */
146#define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */
147#define IF_PROTO_PPP 0x2001 /* PPP protocol */
148#define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */
149#define IF_PROTO_FR 0x2003 /* Frame Relay protocol */
150#define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */
151#define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */
152#define IF_PROTO_X25 0x2006 /* X.25 */
153#define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */
154#define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */
155#define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */
156#define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */
157#define IF_PROTO_FR_ETH_PVC 0x200B
158#define IF_PROTO_RAW 0x200C /* RAW Socket */
159
b00055aa
SR
160/* RFC 2863 operational status */
161enum {
162 IF_OPER_UNKNOWN,
163 IF_OPER_NOTPRESENT,
164 IF_OPER_DOWN,
165 IF_OPER_LOWERLAYERDOWN,
166 IF_OPER_TESTING,
167 IF_OPER_DORMANT,
168 IF_OPER_UP,
169};
170
171/* link modes */
172enum {
173 IF_LINK_MODE_DEFAULT,
174 IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */
175};
1da177e4
LT
176
177/*
178 * Device mapping structure. I'd just gone off and designed a
179 * beautiful scheme using only loadable modules with arguments
180 * for driver options and along come the PCMCIA people 8)
181 *
182 * Ah well. The get() side of this is good for WDSETUP, and it'll
183 * be handy for debugging things. The set side is fine for now and
184 * being very small might be worth keeping for clean configuration.
185 */
186
4a91cb61
MR
187/* for compatibility with glibc net/if.h */
188#if __UAPI_DEF_IF_IFMAP
d94d9fee 189struct ifmap {
1da177e4
LT
190 unsigned long mem_start;
191 unsigned long mem_end;
192 unsigned short base_addr;
193 unsigned char irq;
194 unsigned char dma;
195 unsigned char port;
196 /* 3 bytes spare */
197};
4a91cb61 198#endif /* __UAPI_DEF_IF_IFMAP */
1da177e4 199
d94d9fee 200struct if_settings {
1da177e4
LT
201 unsigned int type; /* Type of physical device or protocol */
202 unsigned int size; /* Size of the data allocated by the caller */
203 union {
204 /* {atm/eth/dsl}_settings anyone ? */
205 raw_hdlc_proto __user *raw_hdlc;
206 cisco_proto __user *cisco;
207 fr_proto __user *fr;
208 fr_proto_pvc __user *fr_pvc;
209 fr_proto_pvc_info __user *fr_pvc_info;
210
211 /* interface settings */
212 sync_serial_settings __user *sync;
213 te1_settings __user *te1;
214 } ifs_ifsu;
215};
216
217/*
218 * Interface request structure used for socket
219 * ioctl's. All interface ioctl's must have parameter
220 * definitions which begin with ifr_name. The
221 * remainder may be interface specific.
222 */
223
4a91cb61
MR
224/* for compatibility with glibc net/if.h */
225#if __UAPI_DEF_IF_IFREQ
d94d9fee 226struct ifreq {
1da177e4
LT
227#define IFHWADDRLEN 6
228 union
229 {
230 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
231 } ifr_ifrn;
232
233 union {
234 struct sockaddr ifru_addr;
235 struct sockaddr ifru_dstaddr;
236 struct sockaddr ifru_broadaddr;
237 struct sockaddr ifru_netmask;
238 struct sockaddr ifru_hwaddr;
239 short ifru_flags;
240 int ifru_ivalue;
241 int ifru_mtu;
242 struct ifmap ifru_map;
243 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
244 char ifru_newname[IFNAMSIZ];
245 void __user * ifru_data;
246 struct if_settings ifru_settings;
247 } ifr_ifru;
248};
4a91cb61 249#endif /* __UAPI_DEF_IF_IFREQ */
1da177e4
LT
250
251#define ifr_name ifr_ifrn.ifrn_name /* interface name */
252#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
253#define ifr_addr ifr_ifru.ifru_addr /* address */
254#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
255#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
256#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
257#define ifr_flags ifr_ifru.ifru_flags /* flags */
258#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
259#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
260#define ifr_map ifr_ifru.ifru_map /* device map */
261#define ifr_slave ifr_ifru.ifru_slave /* slave device */
262#define ifr_data ifr_ifru.ifru_data /* for use by interface */
263#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
264#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
265#define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */
266#define ifr_newname ifr_ifru.ifru_newname /* New name */
267#define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
268
269/*
270 * Structure used in SIOCGIFCONF request.
271 * Used to retrieve interface configuration
272 * for machine (useful for programs which
273 * must know all networks accessible).
274 */
275
4a91cb61
MR
276/* for compatibility with glibc net/if.h */
277#if __UAPI_DEF_IF_IFCONF
d94d9fee 278struct ifconf {
1da177e4 279 int ifc_len; /* size of buffer */
d94d9fee 280 union {
1da177e4
LT
281 char __user *ifcu_buf;
282 struct ifreq __user *ifcu_req;
283 } ifc_ifcu;
284};
4a91cb61
MR
285#endif /* __UAPI_DEF_IF_IFCONF */
286
1da177e4
LT
287#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
288#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
289
1da177e4 290#endif /* _LINUX_IF_H */