interface.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. #ifdef HAVE_IRDP
  25. #include "zebra/irdp.h"
  26. #endif
  27. /* For interface multicast configuration. */
  28. #define IF_ZEBRA_MULTICAST_UNSPEC 0
  29. #define IF_ZEBRA_MULTICAST_ON 1
  30. #define IF_ZEBRA_MULTICAST_OFF 2
  31. /* For interface shutdown configuration. */
  32. #define IF_ZEBRA_SHUTDOWN_OFF 0
  33. #define IF_ZEBRA_SHUTDOWN_ON 1
  34. /* Router advertisement feature. */
  35. #if (defined(LINUX_IPV6) && (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1)) || defined(KAME)
  36. #ifdef HAVE_RTADV
  37. #define RTADV
  38. #endif
  39. #endif
  40. #ifdef RTADV
  41. /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
  42. struct rtadvconf
  43. {
  44. /* A flag indicating whether or not the router sends periodic Router
  45. Advertisements and responds to Router Solicitations.
  46. Default: FALSE */
  47. int AdvSendAdvertisements;
  48. /* The maximum time allowed between sending unsolicited multicast
  49. Router Advertisements from the interface, in milliseconds.
  50. MUST be no less than 70 ms [RFC6275 7.5] and no greater
  51. than 1800000 ms [RFC4861 6.2.1].
  52. Default: 600000 milliseconds */
  53. int MaxRtrAdvInterval;
  54. #define RTADV_MAX_RTR_ADV_INTERVAL 600000
  55. /* The minimum time allowed between sending unsolicited multicast
  56. Router Advertisements from the interface, in milliseconds.
  57. MUST be no less than 30 ms [RFC6275 7.5].
  58. MUST be no greater than .75 * MaxRtrAdvInterval.
  59. Default: 0.33 * MaxRtrAdvInterval */
  60. int MinRtrAdvInterval; /* This field is currently unused. */
  61. #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
  62. /* Unsolicited Router Advertisements' interval timer. */
  63. int AdvIntervalTimer;
  64. /* The TRUE/FALSE value to be placed in the "Managed address
  65. configuration" flag field in the Router Advertisement. See
  66. [ADDRCONF].
  67. Default: FALSE */
  68. int AdvManagedFlag;
  69. /* The TRUE/FALSE value to be placed in the "Other stateful
  70. configuration" flag field in the Router Advertisement. See
  71. [ADDRCONF].
  72. Default: FALSE */
  73. int AdvOtherConfigFlag;
  74. /* The value to be placed in MTU options sent by the router. A
  75. value of zero indicates that no MTU options are sent.
  76. Default: 0 */
  77. int AdvLinkMTU;
  78. /* The value to be placed in the Reachable Time field in the Router
  79. Advertisement messages sent by the router. The value zero means
  80. unspecified (by this router). MUST be no greater than 3,600,000
  81. milliseconds (1 hour).
  82. Default: 0 */
  83. u_int32_t AdvReachableTime;
  84. #define RTADV_MAX_REACHABLE_TIME 3600000
  85. /* The value to be placed in the Retrans Timer field in the Router
  86. Advertisement messages sent by the router. The value zero means
  87. unspecified (by this router).
  88. Default: 0 */
  89. int AdvRetransTimer;
  90. /* The default value to be placed in the Cur Hop Limit field in the
  91. Router Advertisement messages sent by the router. The value
  92. should be set to that current diameter of the Internet. The
  93. value zero means unspecified (by this router).
  94. Default: The value specified in the "Assigned Numbers" RFC
  95. [ASSIGNED] that was in effect at the time of implementation. */
  96. int AdvCurHopLimit;
  97. /* The value to be placed in the Router Lifetime field of Router
  98. Advertisements sent from the interface, in seconds. MUST be
  99. either zero or between MaxRtrAdvInterval and 9000 seconds. A
  100. value of zero indicates that the router is not to be used as a
  101. default router.
  102. Default: 3 * MaxRtrAdvInterval */
  103. int AdvDefaultLifetime;
  104. #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
  105. /* A list of prefixes to be placed in Prefix Information options in
  106. Router Advertisement messages sent from the interface.
  107. Default: all prefixes that the router advertises via routing
  108. protocols as being on-link for the interface from which the
  109. advertisement is sent. The link-local prefix SHOULD NOT be
  110. included in the list of advertised prefixes. */
  111. struct list *AdvPrefixList;
  112. /* The TRUE/FALSE value to be placed in the "Home agent"
  113. flag field in the Router Advertisement. See [RFC6275 7.1].
  114. Default: FALSE */
  115. int AdvHomeAgentFlag;
  116. #ifndef ND_RA_FLAG_HOME_AGENT
  117. #define ND_RA_FLAG_HOME_AGENT 0x20
  118. #endif
  119. /* The value to be placed in Home Agent Information option if Home
  120. Flag is set.
  121. Default: 0 */
  122. int HomeAgentPreference;
  123. /* The value to be placed in Home Agent Information option if Home
  124. Flag is set. Lifetime (seconds) MUST not be greater than 18.2
  125. hours.
  126. The value 0 has special meaning: use of AdvDefaultLifetime value.
  127. Default: 0 */
  128. int HomeAgentLifetime;
  129. #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
  130. /* The TRUE/FALSE value to insert or not an Advertisement Interval
  131. option. See [RFC 6275 7.3]
  132. Default: FALSE */
  133. int AdvIntervalOption;
  134. /* The value to be placed in the Default Router Preference field of
  135. a router advertisement. See [RFC 4191 2.1 & 2.2]
  136. Default: 0 (medium) */
  137. int DefaultPreference;
  138. #define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
  139. };
  140. #endif /* RTADV */
  141. /* `zebra' daemon local interface structure. */
  142. struct zebra_if
  143. {
  144. /* Shutdown configuration. */
  145. u_char shutdown;
  146. /* Multicast configuration. */
  147. u_char multicast;
  148. /* Router advertise configuration. */
  149. u_char rtadv_enable;
  150. /* Installed addresses chains tree. */
  151. struct route_table *ipv4_subnets;
  152. #ifdef RTADV
  153. struct rtadvconf rtadv;
  154. #endif /* RTADV */
  155. #ifdef HAVE_IRDP
  156. struct irdp_interface irdp;
  157. #endif
  158. #ifdef SUNOS_5
  159. /* the real IFF_UP state of the primary interface.
  160. * need this to differentiate between all interfaces being
  161. * down (but primary still plumbed) and primary having gone
  162. * ~IFF_UP, and all addresses gone.
  163. */
  164. u_char primary_state;
  165. #endif /* SUNOS_5 */
  166. };
  167. extern void if_delete_update (struct interface *ifp);
  168. extern void if_add_update (struct interface *ifp);
  169. extern void if_up (struct interface *);
  170. extern void if_down (struct interface *);
  171. extern void if_refresh (struct interface *);
  172. extern void if_flags_update (struct interface *, uint64_t);
  173. extern int if_subnet_add (struct interface *, struct connected *);
  174. extern int if_subnet_delete (struct interface *, struct connected *);
  175. #ifdef HAVE_PROC_NET_DEV
  176. extern void ifstat_update_proc (void);
  177. #endif /* HAVE_PROC_NET_DEV */
  178. #ifdef HAVE_NET_RT_IFLIST
  179. extern void ifstat_update_sysctl (void);
  180. #endif /* HAVE_NET_RT_IFLIST */
  181. #ifdef HAVE_PROC_NET_DEV
  182. extern int interface_list_proc (void);
  183. #endif /* HAVE_PROC_NET_DEV */
  184. #ifdef HAVE_PROC_NET_IF_INET6
  185. extern int ifaddr_proc_ipv6 (void);
  186. #endif /* HAVE_PROC_NET_IF_INET6 */
  187. #ifdef BSDI
  188. extern int if_kvm_get_mtu (struct interface *);
  189. #endif /* BSDI */
  190. #endif /* _ZEBRA_INTERFACE_H */