spacepaste

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