ospf6_intra.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. struct ospf6_router_lsa
  68. {
  69. u_char bits;
  70. u_char options[3];
  71. /* followed by ospf6_router_lsdesc(s) */
  72. };
  73. /* Link State Description in Router-LSA */
  74. struct ospf6_router_lsdesc
  75. {
  76. u_char type;
  77. u_char reserved;
  78. u_int16_t metric; /* output cost */
  79. u_int32_t interface_id;
  80. u_int32_t neighbor_interface_id;
  81. u_int32_t neighbor_router_id;
  82. };
  83. #define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1
  84. #define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2
  85. #define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3
  86. #define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4
  87. #define ROUTER_LSDESC_IS_TYPE(t,x) \
  88. ((((struct ospf6_router_lsdesc *)(x))->type == \
  89. OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0)
  90. #define ROUTER_LSDESC_GET_METRIC(x) \
  91. (ntohs (((struct ospf6_router_lsdesc *)(x))->metric))
  92. #define ROUTER_LSDESC_GET_IFID(x) \
  93. (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id))
  94. #define ROUTER_LSDESC_GET_NBR_IFID(x) \
  95. (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
  96. #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \
  97. (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)
  98. /* Network-LSA */
  99. struct ospf6_network_lsa
  100. {
  101. u_char reserved;
  102. u_char options[3];
  103. /* followed by ospf6_netowrk_lsd(s) */
  104. };
  105. /* Link State Description in Router-LSA */
  106. struct ospf6_network_lsdesc
  107. {
  108. u_int32_t router_id;
  109. };
  110. #define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
  111. (((struct ospf6_network_lsdesc *)(x))->router_id)
  112. /* Link-LSA */
  113. struct ospf6_link_lsa
  114. {
  115. u_char priority;
  116. u_char options[3];
  117. struct in6_addr linklocal_addr;
  118. u_int32_t prefix_num;
  119. /* followed by ospf6 prefix(es) */
  120. };
  121. /* Intra-Area-Prefix-LSA */
  122. struct ospf6_intra_prefix_lsa
  123. {
  124. u_int16_t prefix_num;
  125. u_int16_t ref_type;
  126. u_int32_t ref_id;
  127. u_int32_t ref_adv_router;
  128. /* followed by ospf6 prefix(es) */
  129. };
  130. #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
  131. do { \
  132. if (! (oa)->thread_router_lsa) \
  133. (oa)->thread_router_lsa = \
  134. thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
  135. } while (0)
  136. #define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
  137. do { \
  138. if (! (oi)->thread_network_lsa) \
  139. (oi)->thread_network_lsa = \
  140. thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
  141. } while (0)
  142. #define OSPF6_LINK_LSA_SCHEDULE(oi) \
  143. do { \
  144. if (! (oi)->thread_link_lsa) \
  145. (oi)->thread_link_lsa = \
  146. thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
  147. } while (0)
  148. #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
  149. do { \
  150. if (! (oa)->thread_intra_prefix_lsa) \
  151. (oa)->thread_intra_prefix_lsa = \
  152. thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
  153. oa, 0); \
  154. } while (0)
  155. #define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
  156. do { \
  157. if (! (oi)->thread_intra_prefix_lsa) \
  158. (oi)->thread_intra_prefix_lsa = \
  159. thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
  160. oi, 0); \
  161. } while (0)
  162. #define OSPF6_NETWORK_LSA_EXECUTE(oi) \
  163. do { \
  164. THREAD_OFF ((oi)->thread_network_lsa); \
  165. thread_execute (master, ospf6_network_lsa_originate, oi, 0); \
  166. } while (0)
  167. #define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
  168. do { \
  169. THREAD_OFF ((oi)->thread_intra_prefix_lsa); \
  170. thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \
  171. } while (0)
  172. /* Function Prototypes */
  173. extern char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id,
  174. u_int32_t neighbor_interface_id,
  175. u_int32_t neighbor_router_id,
  176. struct ospf6_lsa *lsa);
  177. extern char *ospf6_network_lsdesc_lookup (u_int32_t router_id,
  178. struct ospf6_lsa *lsa);
  179. extern int ospf6_router_lsa_originate (struct thread *);
  180. extern int ospf6_network_lsa_originate (struct thread *);
  181. extern int ospf6_link_lsa_originate (struct thread *);
  182. extern int ospf6_intra_prefix_lsa_originate_transit (struct thread *);
  183. extern int ospf6_intra_prefix_lsa_originate_stub (struct thread *);
  184. extern void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa);
  185. extern void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa);
  186. extern void ospf6_intra_route_calculation (struct ospf6_area *oa);
  187. extern void ospf6_intra_brouter_calculation (struct ospf6_area *oa);
  188. extern void ospf6_intra_init (void);
  189. extern int config_write_ospf6_debug_brouter (struct vty *vty);
  190. extern void install_element_ospf6_debug_brouter (void);
  191. #endif /* OSPF6_LSA_H */