ospf6_intra.h 8.2 KB

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