interface.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* Interface function header.
  2. * Copyright (C) 1999 Kunihiro Ishiguro
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. #ifndef _ZEBRA_INTERFACE_H
  22. #define _ZEBRA_INTERFACE_H
  23. #include "redistribute.h"
  24. #include "event_counter.h"
  25. #ifdef HAVE_IRDP
  26. #include "zebra/irdp.h"
  27. #endif
  28. /* For interface multicast configuration. */
  29. #define IF_ZEBRA_MULTICAST_UNSPEC 0
  30. #define IF_ZEBRA_MULTICAST_ON 1
  31. #define IF_ZEBRA_MULTICAST_OFF 2
  32. /* For interface shutdown configuration. */
  33. #define IF_ZEBRA_SHUTDOWN_OFF 0
  34. #define IF_ZEBRA_SHUTDOWN_ON 1
  35. /* Global user-configured default for interface link-detect */
  36. typedef enum {
  37. IF_LINKDETECT_UNSPEC = 0,
  38. IF_LINKDETECT_ON,
  39. IF_LINKDETECT_OFF,
  40. } zebra_if_linkdetect;
  41. /* Global defaults for interfaces */
  42. struct zebra_if_defaults {
  43. /* Link-detect default configuration */
  44. zebra_if_linkdetect linkdetect;
  45. };
  46. #if defined (HAVE_RTADV)
  47. /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
  48. struct rtadvconf
  49. {
  50. /* A flag indicating whether or not the router sends periodic Router
  51. Advertisements and responds to Router Solicitations.
  52. Default: FALSE */
  53. int AdvSendAdvertisements;
  54. /* The maximum time allowed between sending unsolicited multicast
  55. Router Advertisements from the interface, in milliseconds.
  56. MUST be no less than 70 ms [RFC6275 7.5] and no greater
  57. than 1800000 ms [RFC4861 6.2.1].
  58. Default: 600000 milliseconds */
  59. int MaxRtrAdvInterval;
  60. #define RTADV_MAX_RTR_ADV_INTERVAL 600000
  61. /* The minimum time allowed between sending unsolicited multicast
  62. Router Advertisements from the interface, in milliseconds.
  63. MUST be no less than 30 ms [RFC6275 7.5].
  64. MUST be no greater than .75 * MaxRtrAdvInterval.
  65. Default: 0.33 * MaxRtrAdvInterval */
  66. int MinRtrAdvInterval; /* This field is currently unused. */
  67. #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
  68. /* Unsolicited Router Advertisements' interval timer. */
  69. int AdvIntervalTimer;
  70. /* The TRUE/FALSE value to be placed in the "Managed address
  71. configuration" flag field in the Router Advertisement. See
  72. [ADDRCONF].
  73. Default: FALSE */
  74. int AdvManagedFlag;
  75. /* The TRUE/FALSE value to be placed in the "Other stateful
  76. configuration" flag field in the Router Advertisement. See
  77. [ADDRCONF].
  78. Default: FALSE */
  79. int AdvOtherConfigFlag;
  80. /* The value to be placed in MTU options sent by the router. A
  81. value of zero indicates that no MTU options are sent.
  82. Default: 0 */
  83. int AdvLinkMTU;
  84. /* The value to be placed in the Reachable Time field in the Router
  85. Advertisement messages sent by the router. The value zero means
  86. unspecified (by this router). MUST be no greater than 3,600,000
  87. milliseconds (1 hour).
  88. Default: 0 */
  89. u_int32_t AdvReachableTime;
  90. #define RTADV_MAX_REACHABLE_TIME 3600000
  91. /* The value to be placed in the Retrans Timer field in the Router
  92. Advertisement messages sent by the router. The value zero means
  93. unspecified (by this router).
  94. Default: 0 */
  95. int AdvRetransTimer;
  96. /* The default value to be placed in the Cur Hop Limit field in the
  97. Router Advertisement messages sent by the router. The value
  98. should be set to that current diameter of the Internet. The
  99. value zero means unspecified (by this router).
  100. Default: The value specified in the "Assigned Numbers" RFC
  101. [ASSIGNED] that was in effect at the time of implementation. */
  102. int AdvCurHopLimit;
  103. /* The value to be placed in the Router Lifetime field of Router
  104. Advertisements sent from the interface, in seconds. MUST be
  105. either zero or between MaxRtrAdvInterval and 9000 seconds. A
  106. value of zero indicates that the router is not to be used as a
  107. default router.
  108. Default: 3 * MaxRtrAdvInterval */
  109. int AdvDefaultLifetime;
  110. #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
  111. /* A list of prefixes to be placed in Prefix Information options in
  112. Router Advertisement messages sent from the interface.
  113. Default: all prefixes that the router advertises via routing
  114. protocols as being on-link for the interface from which the
  115. advertisement is sent. The link-local prefix SHOULD NOT be
  116. included in the list of advertised prefixes. */
  117. struct list *AdvPrefixList;
  118. /* The TRUE/FALSE value to be placed in the "Home agent"
  119. flag field in the Router Advertisement. See [RFC6275 7.1].
  120. Default: FALSE */
  121. int AdvHomeAgentFlag;
  122. #ifndef ND_RA_FLAG_HOME_AGENT
  123. #define ND_RA_FLAG_HOME_AGENT 0x20
  124. #endif
  125. /* The value to be placed in Home Agent Information option if Home
  126. Flag is set.
  127. Default: 0 */
  128. int HomeAgentPreference;
  129. /* The value to be placed in Home Agent Information option if Home
  130. Flag is set. Lifetime (seconds) MUST not be greater than 18.2
  131. hours.
  132. The value 0 has special meaning: use of AdvDefaultLifetime value.
  133. Default: 0 */
  134. int HomeAgentLifetime;
  135. #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
  136. /* The TRUE/FALSE value to insert or not an Advertisement Interval
  137. option. See [RFC 6275 7.3]
  138. Default: FALSE */
  139. int AdvIntervalOption;
  140. /* The value to be placed in the Default Router Preference field of
  141. a router advertisement. See [RFC 4191 2.1 & 2.2]
  142. Default: 0 (medium) */
  143. int DefaultPreference;
  144. #define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
  145. };
  146. #endif /* HAVE_RTADV */
  147. /* `zebra' daemon local interface structure. */
  148. struct zebra_if
  149. {
  150. /* Shutdown configuration. */
  151. u_char shutdown;
  152. /* Multicast configuration. */
  153. u_char multicast;
  154. /* Router advertise configuration. */
  155. u_char rtadv_enable;
  156. /* Interface specific link-detect configuration state */
  157. zebra_if_linkdetect linkdetect;
  158. /* Installed addresses chains tree. */
  159. struct route_table *ipv4_subnets;
  160. /* Information about up/down changes */
  161. struct event_counter up_events;
  162. struct event_counter down_events;
  163. #if defined(HAVE_RTADV)
  164. struct rtadvconf rtadv;
  165. #endif /* RTADV */
  166. #ifdef HAVE_IRDP
  167. struct irdp_interface irdp;
  168. #endif
  169. #ifdef HAVE_STRUCT_SOCKADDR_DL
  170. union {
  171. /* note that sdl_storage is never accessed, it only exists to make space.
  172. * all actual uses refer to sdl - but use sizeof(sdl_storage)! this fits
  173. * best with C aliasing rules. */
  174. struct sockaddr_dl sdl;
  175. struct sockaddr_storage sdl_storage;
  176. };
  177. #endif
  178. #ifdef SUNOS_5
  179. /* the real IFF_UP state of the primary interface.
  180. * need this to differentiate between all interfaces being
  181. * down (but primary still plumbed) and primary having gone
  182. * ~IFF_UP, and all addresses gone.
  183. */
  184. u_char primary_state;
  185. #endif /* SUNOS_5 */
  186. };
  187. extern void if_delete_update (struct interface *ifp);
  188. extern void if_add_update (struct interface *ifp);
  189. extern void if_up (struct interface *);
  190. extern void if_down (struct interface *);
  191. extern void if_refresh (struct interface *);
  192. extern void if_flags_update (struct interface *, uint64_t);
  193. extern void if_startup_count_up (void);
  194. extern int if_subnet_add (struct interface *, struct connected *);
  195. extern int if_subnet_delete (struct interface *, struct connected *);
  196. #ifdef HAVE_PROC_NET_DEV
  197. extern void ifstat_update_proc (void);
  198. #endif /* HAVE_PROC_NET_DEV */
  199. #ifdef HAVE_NET_RT_IFLIST
  200. extern void ifstat_update_sysctl (void);
  201. #endif /* HAVE_NET_RT_IFLIST */
  202. #ifdef HAVE_PROC_NET_DEV
  203. extern int interface_list_proc (void);
  204. #endif /* HAVE_PROC_NET_DEV */
  205. #ifdef HAVE_PROC_NET_IF_INET6
  206. extern int ifaddr_proc_ipv6 (void);
  207. #endif /* HAVE_PROC_NET_IF_INET6 */
  208. #endif /* _ZEBRA_INTERFACE_H */