ospf6_spf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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_SPF_H
  22. #define OSPF6_SPF_H
  23. #include "ospf6_top.h"
  24. /* Debug option */
  25. extern unsigned char conf_debug_ospf6_spf;
  26. #define OSPF6_DEBUG_SPF_PROCESS 0x01
  27. #define OSPF6_DEBUG_SPF_TIME 0x02
  28. #define OSPF6_DEBUG_SPF_DATABASE 0x04
  29. #define OSPF6_DEBUG_SPF_ON(level) \
  30. (conf_debug_ospf6_spf |= (level))
  31. #define OSPF6_DEBUG_SPF_OFF(level) \
  32. (conf_debug_ospf6_spf &= ~(level))
  33. #define IS_OSPF6_DEBUG_SPF(level) \
  34. (conf_debug_ospf6_spf & OSPF6_DEBUG_SPF_ ## level)
  35. /* Transit Vertex */
  36. struct ospf6_vertex
  37. {
  38. /* type of this vertex */
  39. u_int8_t type;
  40. /* Vertex Identifier */
  41. struct prefix vertex_id;
  42. /* Identifier String */
  43. char name[128];
  44. /* Associated Area */
  45. struct ospf6_area *area;
  46. /* Associated LSA */
  47. struct ospf6_lsa *lsa;
  48. /* Distance from Root (i.e. Cost) */
  49. u_int32_t cost;
  50. /* Router hops to this node */
  51. u_char hops;
  52. /* nexthops to this node */
  53. struct ospf6_nexthop nexthop[OSPF6_MULTI_PATH_LIMIT];
  54. /* capability bits */
  55. u_char capability;
  56. /* Optional capabilities */
  57. u_char options[3];
  58. /* For tree display */
  59. struct ospf6_vertex *parent;
  60. struct list *child_list;
  61. };
  62. #define OSPF6_VERTEX_TYPE_ROUTER 0x01
  63. #define OSPF6_VERTEX_TYPE_NETWORK 0x02
  64. #define VERTEX_IS_TYPE(t, v) \
  65. ((v)->type == OSPF6_VERTEX_TYPE_ ## t ? 1 : 0)
  66. /* What triggered the SPF? */
  67. #define OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED (1 << 0)
  68. #define OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED (1 << 1)
  69. #define OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED (1 << 2)
  70. #define OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED (1 << 3)
  71. #define OSPF6_SPF_FLAGS_LINK_LSA_ADDED (1 << 4)
  72. #define OSPF6_SPF_FLAGS_LINK_LSA_REMOVED (1 << 5)
  73. #define OSPF6_SPF_FLAGS_ROUTER_LSA_ORIGINATED (1 << 6)
  74. #define OSPF6_SPF_FLAGS_NETWORK_LSA_ORIGINATED (1 << 7)
  75. static inline void
  76. ospf6_set_spf_reason (struct ospf6* ospf, unsigned int reason)
  77. {
  78. ospf->spf_reason |= reason;
  79. }
  80. static inline void
  81. ospf6_reset_spf_reason (struct ospf6 *ospf)
  82. {
  83. ospf->spf_reason = 0;
  84. }
  85. static inline unsigned int
  86. ospf6_lsadd_to_spf_reason (struct ospf6_lsa *lsa)
  87. {
  88. unsigned int reason = 0;
  89. switch (ntohs (lsa->header->type))
  90. {
  91. case OSPF6_LSTYPE_ROUTER:
  92. reason = OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED;
  93. break;
  94. case OSPF6_LSTYPE_NETWORK:
  95. reason = OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED;
  96. break;
  97. case OSPF6_LSTYPE_LINK:
  98. reason = OSPF6_SPF_FLAGS_LINK_LSA_ADDED;
  99. break;
  100. default:
  101. break;
  102. }
  103. return (reason);
  104. }
  105. static inline unsigned int
  106. ospf6_lsremove_to_spf_reason (struct ospf6_lsa *lsa)
  107. {
  108. unsigned int reason = 0;
  109. switch (ntohs (lsa->header->type))
  110. {
  111. case OSPF6_LSTYPE_ROUTER:
  112. reason = OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED;
  113. break;
  114. case OSPF6_LSTYPE_NETWORK:
  115. reason = OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED;
  116. break;
  117. case OSPF6_LSTYPE_LINK:
  118. reason = OSPF6_SPF_FLAGS_LINK_LSA_REMOVED;
  119. break;
  120. default:
  121. break;
  122. }
  123. return (reason);
  124. }
  125. extern void ospf6_spf_table_finish (struct ospf6_route_table *result_table);
  126. extern void ospf6_spf_calculation (u_int32_t router_id,
  127. struct ospf6_route_table *result_table,
  128. struct ospf6_area *oa);
  129. extern void ospf6_spf_schedule (struct ospf6 *ospf, unsigned int reason);
  130. extern void ospf6_spf_display_subtree (struct vty *vty, const char *prefix,
  131. int rest, struct ospf6_vertex *v);
  132. extern void ospf6_spf_config_write (struct vty *vty);
  133. extern int config_write_ospf6_debug_spf (struct vty *vty);
  134. extern void install_element_ospf6_debug_spf (void);
  135. extern void ospf6_spf_init (void);
  136. extern void ospf6_spf_reason_string (unsigned int reason, char *buf, int size);
  137. #endif /* OSPF6_SPF_H */