ospf6_intra.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  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
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef OSPF6_INTRA_H
  22. #define OSPF6_INTRA_H
  23. /* Debug option */
  24. extern unsigned char conf_debug_ospf6_brouter;
  25. extern u_int32_t conf_debug_ospf6_brouter_specific_router_id;
  26. extern u_int32_t conf_debug_ospf6_brouter_specific_area_id;
  27. #define OSPF6_DEBUG_BROUTER_SUMMARY 0x01
  28. #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
  29. #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04
  30. #define OSPF6_DEBUG_BROUTER_ON() \
  31. (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
  32. #define OSPF6_DEBUG_BROUTER_OFF() \
  33. (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
  34. #define IS_OSPF6_DEBUG_BROUTER \
  35. (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)
  36. #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
  37. do { \
  38. conf_debug_ospf6_brouter_specific_router_id = (router_id); \
  39. conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
  40. } while (0)
  41. #define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
  42. do { \
  43. conf_debug_ospf6_brouter_specific_router_id = 0; \
  44. conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
  45. } while (0)
  46. #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \
  47. (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
  48. #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \
  49. (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER && \
  50. conf_debug_ospf6_brouter_specific_router_id == (router_id))
  51. #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
  52. do { \
  53. conf_debug_ospf6_brouter_specific_area_id = (area_id); \
  54. conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
  55. } while (0)
  56. #define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
  57. do { \
  58. conf_debug_ospf6_brouter_specific_area_id = 0; \
  59. conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
  60. } while (0)
  61. #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \
  62. (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
  63. #define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \
  64. (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA && \
  65. conf_debug_ospf6_brouter_specific_area_id == (area_id))
  66. /* Router-LSA */
  67. #define OSPF6_ROUTER_LSA_MIN_SIZE 4U
  68. struct ospf6_router_lsa
  69. {
  70. u_char bits;
  71. u_char options[3];
  72. /* followed by ospf6_router_lsdesc(s) */
  73. };
  74. /* Link State Description in Router-LSA */
  75. #define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
  76. struct ospf6_router_lsdesc
  77. {
  78. u_char type;
  79. u_char reserved;
  80. u_int16_t metric; /* output cost */
  81. u_int32_t interface_id;
  82. u_int32_t neighbor_interface_id;
  83. u_int32_t neighbor_router_id;
  84. };
  85. #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1
  86. #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2
  87. #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3
  88. #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4
  89. enum stub_router_mode
  90. {
  91. OSPF6_NOT_STUB_ROUTER,
  92. OSPF6_IS_STUB_ROUTER,
  93. OSPF6_IS_STUB_ROUTER_V6,
  94. };
  95. #define ROUTER_LSDESC_IS_TYPE(t,x) \
  96. ((((struct ospf6_router_lsdesc *)(x))->type == \
  97. OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0)
  98. #define ROUTER_LSDESC_GET_METRIC(x) \
  99. (ntohs (((struct ospf6_router_lsdesc *)(x))->metric))
  100. #define ROUTER_LSDESC_GET_IFID(x) \
  101. (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id))
  102. #define ROUTER_LSDESC_GET_NBR_IFID(x) \
  103. (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
  104. #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \
  105. (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)
  106. /* Network-LSA */
  107. #define OSPF6_NETWORK_LSA_MIN_SIZE 4U
  108. struct ospf6_network_lsa
  109. {
  110. u_char reserved;
  111. u_char options[3];
  112. /* followed by ospf6_netowrk_lsd(s) */
  113. };
  114. /* Link State Description in Router-LSA */
  115. #define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
  116. struct ospf6_network_lsdesc
  117. {
  118. u_int32_t router_id;
  119. };
  120. #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
  121. (((struct ospf6_network_lsdesc *)(x))->router_id)
  122. /* Link-LSA */
  123. #define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
  124. struct ospf6_link_lsa
  125. {
  126. u_char priority;
  127. u_char options[3];
  128. struct in6_addr linklocal_addr;
  129. u_int32_t prefix_num;
  130. /* followed by ospf6 prefix(es) */
  131. };
  132. /* Intra-Area-Prefix-LSA */
  133. #define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */
  134. struct ospf6_intra_prefix_lsa
  135. {
  136. u_int16_t prefix_num;
  137. u_int16_t ref_type;
  138. u_int32_t ref_id;
  139. u_int32_t ref_adv_router;
  140. /* followed by ospf6 prefix(es) */
  141. };
  142. #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
  143. do { \
  144. if (! (oa)->thread_router_lsa \
  145. && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
  146. (oa)->thread_router_lsa = \
  147. thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
  148. } while (0)
  149. #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
  150. do { \
  151. if (! (oi)->thread_network_lsa \
  152. && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  153. (oi)->thread_network_lsa = \
  154. thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
  155. } while (0)
  156. #define OSPF6_LINK_LSA_SCHEDULE(oi) \
  157. do { \
  158. if (! (oi)->thread_link_lsa \
  159. && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  160. (oi)->thread_link_lsa = \
  161. thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
  162. } while (0)
  163. #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
  164. do { \
  165. if (! (oa)->thread_intra_prefix_lsa \
  166. && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
  167. (oa)->thread_intra_prefix_lsa = \
  168. thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
  169. oa, 0); \
  170. } while (0)
  171. #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
  172. do { \
  173. if (! (oi)->thread_intra_prefix_lsa \
  174. && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
  175. (oi)->thread_intra_prefix_lsa = \
  176. thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
  177. oi, 0); \
  178. } while (0)
  179. #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
  180. do { \
  181. THREAD_OFF ((oi)->thread_network_lsa); \
  182. thread_execute (master, ospf6_network_lsa_originate, oi, 0); \
  183. } while (0)
  184. #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
  185. do { \
  186. THREAD_OFF ((oi)->thread_intra_prefix_lsa); \
  187. thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \
  188. } while (0)
  189. /* Function Prototypes */
  190. extern char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id,
  191. u_int32_t neighbor_interface_id,
  192. u_int32_t neighbor_router_id,
  193. struct ospf6_lsa *lsa);
  194. extern char *ospf6_network_lsdesc_lookup (u_int32_t router_id,
  195. struct ospf6_lsa *lsa);
  196. extern int ospf6_router_is_stub_router (struct ospf6_lsa *lsa);
  197. extern int ospf6_router_lsa_originate (struct thread *);
  198. extern int ospf6_network_lsa_originate (struct thread *);
  199. extern int ospf6_link_lsa_originate (struct thread *);
  200. extern int ospf6_intra_prefix_lsa_originate_transit (struct thread *);
  201. extern int ospf6_intra_prefix_lsa_originate_stub (struct thread *);
  202. extern void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa);
  203. extern void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa);
  204. extern void ospf6_intra_route_calculation (struct ospf6_area *oa);
  205. extern void ospf6_intra_brouter_calculation (struct ospf6_area *oa);
  206. extern void ospf6_intra_init (void);
  207. extern int config_write_ospf6_debug_brouter (struct vty *vty);
  208. extern void install_element_ospf6_debug_brouter (void);
  209. #endif /* OSPF6_LSA_H */