blob: 259617a551f25197ddf60d4e812acabad449c6df [file] [log] [blame]
Ben Cheng224b54f2013-10-15 18:26:18 -07001/*
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
11 * Ross Biro
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
Christopher Ferris59ac31a2016-05-19 12:25:22 -070022#include <linux/libc-compat.h> /* for compatibility with glibc */
Ben Cheng224b54f2013-10-15 18:26:18 -070023#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
Christopher Ferris0543f742017-07-26 13:09:46 -070027#ifndef __KERNEL__
28#include <sys/socket.h> /* for struct sockaddr. */
29#endif
30
Christopher Ferris59ac31a2016-05-19 12:25:22 -070031#if __UAPI_DEF_IF_IFNAMSIZ
Ben Cheng224b54f2013-10-15 18:26:18 -070032#define IFNAMSIZ 16
Christopher Ferris59ac31a2016-05-19 12:25:22 -070033#endif /* __UAPI_DEF_IF_IFNAMSIZ */
Ben Cheng224b54f2013-10-15 18:26:18 -070034#define IFALIASZ 256
35#include <linux/hdlc/ioctl.h>
36
Christopher Ferris59ac31a2016-05-19 12:25:22 -070037/* For glibc compatibility. An empty enum does not compile. */
Christopher Ferris33185402017-01-13 13:28:52 -080038#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \
Christopher Ferris59ac31a2016-05-19 12:25:22 -070039 __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
Christopher Ferris31475242014-09-02 17:43:51 -070040/**
41 * enum net_device_flags - &struct net_device flags
42 *
43 * These are the &struct net_device flags, they can be set by drivers, the
44 * kernel and some can be triggered by userspace. Userspace can query and
45 * set these flags using userspace utilities but there is also a sysfs
46 * entry available for all dev flags which can be queried and set. These flags
47 * are shared for all types of net_devices. The sysfs entries are available
48 * via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
49 * are annotated below, note that only a few flags can be toggled and some
Christopher Ferrisccfaccd2016-08-24 12:11:31 -070050 * other flags are always preserved from the original net_device flags
Christopher Ferris31475242014-09-02 17:43:51 -070051 * even if you try to set them via sysfs. Flags which are always preserved
52 * are kept under the flag grouping @IFF_VOLATILE. Flags which are volatile
53 * are annotated below as such.
54 *
55 * You should have a pretty good reason to be extending these flags.
56 *
57 * @IFF_UP: interface is up. Can be toggled through sysfs.
58 * @IFF_BROADCAST: broadcast address valid. Volatile.
59 * @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
60 * @IFF_LOOPBACK: is a loopback net. Volatile.
61 * @IFF_POINTOPOINT: interface is has p-p link. Volatile.
62 * @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
63 * Volatile.
64 * @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
65 * @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
66 * @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
67 * @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
68 * sysfs.
69 * @IFF_MASTER: master of a load balancer. Volatile.
70 * @IFF_SLAVE: slave of a load balancer. Volatile.
71 * @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
72 * @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
73 * @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
74 * @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
75 * through sysfs.
76 * @IFF_LOWER_UP: driver signals L1 up. Volatile.
77 * @IFF_DORMANT: driver signals dormant. Volatile.
78 * @IFF_ECHO: echo sent packets. Volatile.
79 */
80enum net_device_flags {
Christopher Ferris59ac31a2016-05-19 12:25:22 -070081/* for compatibility with glibc net/if.h */
82#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
Christopher Ferris31475242014-09-02 17:43:51 -070083 IFF_UP = 1<<0, /* sysfs */
84 IFF_BROADCAST = 1<<1, /* volatile */
85 IFF_DEBUG = 1<<2, /* sysfs */
86 IFF_LOOPBACK = 1<<3, /* volatile */
87 IFF_POINTOPOINT = 1<<4, /* volatile */
88 IFF_NOTRAILERS = 1<<5, /* sysfs */
89 IFF_RUNNING = 1<<6, /* volatile */
90 IFF_NOARP = 1<<7, /* sysfs */
91 IFF_PROMISC = 1<<8, /* sysfs */
92 IFF_ALLMULTI = 1<<9, /* sysfs */
93 IFF_MASTER = 1<<10, /* volatile */
94 IFF_SLAVE = 1<<11, /* volatile */
95 IFF_MULTICAST = 1<<12, /* sysfs */
96 IFF_PORTSEL = 1<<13, /* sysfs */
97 IFF_AUTOMEDIA = 1<<14, /* sysfs */
98 IFF_DYNAMIC = 1<<15, /* sysfs */
Christopher Ferris59ac31a2016-05-19 12:25:22 -070099#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
100#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
Christopher Ferris31475242014-09-02 17:43:51 -0700101 IFF_LOWER_UP = 1<<16, /* volatile */
102 IFF_DORMANT = 1<<17, /* volatile */
103 IFF_ECHO = 1<<18, /* volatile */
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700104#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
Christopher Ferris31475242014-09-02 17:43:51 -0700105};
Christopher Ferris33185402017-01-13 13:28:52 -0800106#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */
Ben Cheng224b54f2013-10-15 18:26:18 -0700107
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700108/* for compatibility with glibc net/if.h */
109#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
Christopher Ferris31475242014-09-02 17:43:51 -0700110#define IFF_UP IFF_UP
111#define IFF_BROADCAST IFF_BROADCAST
112#define IFF_DEBUG IFF_DEBUG
113#define IFF_LOOPBACK IFF_LOOPBACK
114#define IFF_POINTOPOINT IFF_POINTOPOINT
115#define IFF_NOTRAILERS IFF_NOTRAILERS
116#define IFF_RUNNING IFF_RUNNING
117#define IFF_NOARP IFF_NOARP
118#define IFF_PROMISC IFF_PROMISC
119#define IFF_ALLMULTI IFF_ALLMULTI
120#define IFF_MASTER IFF_MASTER
121#define IFF_SLAVE IFF_SLAVE
122#define IFF_MULTICAST IFF_MULTICAST
123#define IFF_PORTSEL IFF_PORTSEL
124#define IFF_AUTOMEDIA IFF_AUTOMEDIA
125#define IFF_DYNAMIC IFF_DYNAMIC
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700126#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */
127
128#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
Christopher Ferris31475242014-09-02 17:43:51 -0700129#define IFF_LOWER_UP IFF_LOWER_UP
130#define IFF_DORMANT IFF_DORMANT
131#define IFF_ECHO IFF_ECHO
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700132#endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
Ben Cheng224b54f2013-10-15 18:26:18 -0700133
134#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
135 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
136
Ben Cheng224b54f2013-10-15 18:26:18 -0700137#define IF_GET_IFACE 0x0001 /* for querying only */
138#define IF_GET_PROTO 0x0002
139
140/* For definitions see hdlc.h */
141#define IF_IFACE_V35 0x1000 /* V.35 serial interface */
142#define IF_IFACE_V24 0x1001 /* V.24 serial interface */
143#define IF_IFACE_X21 0x1002 /* X.21 serial interface */
144#define IF_IFACE_T1 0x1003 /* T1 telco serial interface */
145#define IF_IFACE_E1 0x1004 /* E1 telco serial interface */
146#define IF_IFACE_SYNC_SERIAL 0x1005 /* can't be set by software */
147#define IF_IFACE_X21D 0x1006 /* X.21 Dual Clocking (FarSite) */
148
149/* For definitions see hdlc.h */
150#define IF_PROTO_HDLC 0x2000 /* raw HDLC protocol */
151#define IF_PROTO_PPP 0x2001 /* PPP protocol */
152#define IF_PROTO_CISCO 0x2002 /* Cisco HDLC protocol */
153#define IF_PROTO_FR 0x2003 /* Frame Relay protocol */
154#define IF_PROTO_FR_ADD_PVC 0x2004 /* Create FR PVC */
155#define IF_PROTO_FR_DEL_PVC 0x2005 /* Delete FR PVC */
156#define IF_PROTO_X25 0x2006 /* X.25 */
157#define IF_PROTO_HDLC_ETH 0x2007 /* raw HDLC, Ethernet emulation */
158#define IF_PROTO_FR_ADD_ETH_PVC 0x2008 /* Create FR Ethernet-bridged PVC */
159#define IF_PROTO_FR_DEL_ETH_PVC 0x2009 /* Delete FR Ethernet-bridged PVC */
160#define IF_PROTO_FR_PVC 0x200A /* for reading PVC status */
161#define IF_PROTO_FR_ETH_PVC 0x200B
162#define IF_PROTO_RAW 0x200C /* RAW Socket */
163
164/* RFC 2863 operational status */
165enum {
166 IF_OPER_UNKNOWN,
167 IF_OPER_NOTPRESENT,
168 IF_OPER_DOWN,
169 IF_OPER_LOWERLAYERDOWN,
170 IF_OPER_TESTING,
171 IF_OPER_DORMANT,
172 IF_OPER_UP,
173};
174
175/* link modes */
176enum {
177 IF_LINK_MODE_DEFAULT,
178 IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */
179};
180
181/*
182 * Device mapping structure. I'd just gone off and designed a
183 * beautiful scheme using only loadable modules with arguments
184 * for driver options and along come the PCMCIA people 8)
185 *
186 * Ah well. The get() side of this is good for WDSETUP, and it'll
187 * be handy for debugging things. The set side is fine for now and
188 * being very small might be worth keeping for clean configuration.
189 */
190
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700191/* for compatibility with glibc net/if.h */
192#if __UAPI_DEF_IF_IFMAP
Ben Cheng224b54f2013-10-15 18:26:18 -0700193struct ifmap {
194 unsigned long mem_start;
195 unsigned long mem_end;
196 unsigned short base_addr;
197 unsigned char irq;
198 unsigned char dma;
199 unsigned char port;
200 /* 3 bytes spare */
201};
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700202#endif /* __UAPI_DEF_IF_IFMAP */
Ben Cheng224b54f2013-10-15 18:26:18 -0700203
204struct if_settings {
205 unsigned int type; /* Type of physical device or protocol */
206 unsigned int size; /* Size of the data allocated by the caller */
207 union {
208 /* {atm/eth/dsl}_settings anyone ? */
209 raw_hdlc_proto __user *raw_hdlc;
210 cisco_proto __user *cisco;
211 fr_proto __user *fr;
212 fr_proto_pvc __user *fr_pvc;
213 fr_proto_pvc_info __user *fr_pvc_info;
214
215 /* interface settings */
216 sync_serial_settings __user *sync;
217 te1_settings __user *te1;
218 } ifs_ifsu;
219};
220
221/*
222 * Interface request structure used for socket
223 * ioctl's. All interface ioctl's must have parameter
224 * definitions which begin with ifr_name. The
225 * remainder may be interface specific.
226 */
227
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700228/* for compatibility with glibc net/if.h */
229#if __UAPI_DEF_IF_IFREQ
Ben Cheng224b54f2013-10-15 18:26:18 -0700230struct ifreq {
231#define IFHWADDRLEN 6
232 union
233 {
234 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
235 } ifr_ifrn;
236
237 union {
238 struct sockaddr ifru_addr;
239 struct sockaddr ifru_dstaddr;
240 struct sockaddr ifru_broadaddr;
241 struct sockaddr ifru_netmask;
242 struct sockaddr ifru_hwaddr;
243 short ifru_flags;
244 int ifru_ivalue;
245 int ifru_mtu;
246 struct ifmap ifru_map;
247 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
248 char ifru_newname[IFNAMSIZ];
249 void __user * ifru_data;
250 struct if_settings ifru_settings;
251 } ifr_ifru;
252};
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700253#endif /* __UAPI_DEF_IF_IFREQ */
Ben Cheng224b54f2013-10-15 18:26:18 -0700254
255#define ifr_name ifr_ifrn.ifrn_name /* interface name */
256#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
257#define ifr_addr ifr_ifru.ifru_addr /* address */
258#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
259#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
260#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
261#define ifr_flags ifr_ifru.ifru_flags /* flags */
262#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
263#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
264#define ifr_map ifr_ifru.ifru_map /* device map */
265#define ifr_slave ifr_ifru.ifru_slave /* slave device */
266#define ifr_data ifr_ifru.ifru_data /* for use by interface */
267#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
268#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
269#define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */
270#define ifr_newname ifr_ifru.ifru_newname /* New name */
271#define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
272
273/*
274 * Structure used in SIOCGIFCONF request.
275 * Used to retrieve interface configuration
276 * for machine (useful for programs which
277 * must know all networks accessible).
278 */
279
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700280/* for compatibility with glibc net/if.h */
281#if __UAPI_DEF_IF_IFCONF
Ben Cheng224b54f2013-10-15 18:26:18 -0700282struct ifconf {
283 int ifc_len; /* size of buffer */
284 union {
285 char __user *ifcu_buf;
286 struct ifreq __user *ifcu_req;
287 } ifc_ifcu;
288};
Christopher Ferris59ac31a2016-05-19 12:25:22 -0700289#endif /* __UAPI_DEF_IF_IFCONF */
290
Ben Cheng224b54f2013-10-15 18:26:18 -0700291#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
292#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
293
294#endif /* _LINUX_IF_H */