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