if.h 12 KB

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