ospf6_lsdb.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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_LSDB_H
  22. #define OSPF6_LSDB_H
  23. #include "prefix.h"
  24. #include "table.h"
  25. struct ospf6_lsdb
  26. {
  27. struct route_table *table;
  28. u_int32_t count;
  29. void (*hook_add) (struct ospf6_lsa *);
  30. void (*hook_remove) (struct ospf6_lsa *);
  31. };
  32. #define LSDB_FOREACH_LSA(vty, func, lsdb) \
  33. do { \
  34. struct ospf6_lsa *lsa; \
  35. for (lsa = ospf6_lsdb_head (lsdb); lsa; \
  36. lsa = ospf6_lsdb_next (lsa)) \
  37. { \
  38. (*(func)) (vty, lsa); \
  39. } \
  40. } while (0)
  41. #define LSDB_FOREACH_LSA_T(vty, func, lsdb, type) \
  42. do { \
  43. struct ospf6_lsa *lsa; \
  44. for (lsa = ospf6_lsdb_type_head (type, lsdb); lsa; \
  45. lsa = ospf6_lsdb_type_next (type, lsa)) \
  46. { \
  47. (*(func)) (vty, lsa); \
  48. } \
  49. } while (0)
  50. #define LSDB_FOREACH_LSA_I(vty, func, lsdb, id) \
  51. do { \
  52. struct ospf6_lsa *lsa; \
  53. for (lsa = ospf6_lsdb_head (lsdb); lsa; \
  54. lsa = ospf6_lsdb_next (lsa)) \
  55. { \
  56. if (lsa->header->id != id) \
  57. continue; \
  58. (*(func)) (vty, lsa); \
  59. } \
  60. } while (0)
  61. #define LSDB_FOREACH_LSA_R(vty, func, lsdb, router) \
  62. do { \
  63. struct ospf6_lsa *lsa; \
  64. for (lsa = ospf6_lsdb_head (lsdb); lsa; \
  65. lsa = ospf6_lsdb_next (lsa)) \
  66. { \
  67. if (lsa->header->adv_router != router) \
  68. continue; \
  69. (*(func)) (vty, lsa); \
  70. } \
  71. } while (0)
  72. #define LSDB_FOREACH_LSA_TI(vty, func, lsdb, type, id) \
  73. do { \
  74. struct ospf6_lsa *lsa; \
  75. for (lsa = ospf6_lsdb_type_head (type, lsdb); lsa; \
  76. lsa = ospf6_lsdb_type_next (type, lsa)) \
  77. { \
  78. if (lsa->header->id != id) \
  79. continue; \
  80. (*(func)) (vty, lsa); \
  81. } \
  82. } while (0)
  83. #define LSDB_FOREACH_LSA_TR(vty, func, lsdb, type, router) \
  84. do { \
  85. struct ospf6_lsa *lsa; \
  86. for (lsa = ospf6_lsdb_type_router_head (type, router, lsdb); lsa; \
  87. lsa = ospf6_lsdb_type_router_next (type, router, lsa)) \
  88. { \
  89. (*(func)) (vty, lsa); \
  90. } \
  91. } while (0)
  92. #define LSDB_FOREACH_LSA_IR(vty, func, lsdb, id, router) \
  93. do { \
  94. struct ospf6_lsa *lsa; \
  95. for (lsa = ospf6_lsdb_head (lsdb); lsa; \
  96. lsa = ospf6_lsdb_next (lsa)) \
  97. { \
  98. if (lsa->header->adv_router != router) \
  99. continue; \
  100. if (lsa->header->id != id) \
  101. continue; \
  102. (*(func)) (vty, lsa); \
  103. } \
  104. } while (0)
  105. #define LSDB_FOREACH_LSA_TIR(vty, func, lsdb, type, id, router) \
  106. do { \
  107. struct ospf6_lsa *lsa; \
  108. lsa = ospf6_lsdb_lookup (type, id, router, lsdb); \
  109. if (lsa) \
  110. (*(func)) (vty, lsa); \
  111. } while (0)
  112. #define OSPF6_LSDB_MAXAGE_REMOVER(lsdb) \
  113. do { \
  114. struct ospf6_lsa *lsa; \
  115. for (lsa = ospf6_lsdb_head (lsdb); lsa; lsa = ospf6_lsdb_next (lsa)) \
  116. { \
  117. if (! OSPF6_LSA_IS_MAXAGE (lsa)) \
  118. continue; \
  119. if (lsa->onretrans != 0) \
  120. continue; \
  121. if (IS_OSPF6_DEBUG_LSA (TIMER)) \
  122. zlog_info (" remove maxage %s", lsa->name); \
  123. ospf6_lsdb_remove (lsa, lsdb); \
  124. } \
  125. } while (0)
  126. /* Function Prototypes */
  127. struct ospf6_lsdb *ospf6_lsdb_create ();
  128. void ospf6_lsdb_delete (struct ospf6_lsdb *lsdb);
  129. struct ospf6_lsa *ospf6_lsdb_lookup (u_int16_t type, u_int32_t id,
  130. u_int32_t adv_router,
  131. struct ospf6_lsdb *lsdb);
  132. void ospf6_lsdb_add (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
  133. void ospf6_lsdb_remove (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
  134. struct ospf6_lsa *ospf6_lsdb_head (struct ospf6_lsdb *lsdb);
  135. struct ospf6_lsa *ospf6_lsdb_next (struct ospf6_lsa *lsa);
  136. struct ospf6_lsa *ospf6_lsdb_type_router_head (u_int16_t type,
  137. u_int32_t adv_router,
  138. struct ospf6_lsdb *lsdb);
  139. struct ospf6_lsa *ospf6_lsdb_type_router_next (u_int16_t type,
  140. u_int32_t adv_router,
  141. struct ospf6_lsa *lsa);
  142. struct ospf6_lsa *ospf6_lsdb_type_head (u_int16_t type,
  143. struct ospf6_lsdb *lsdb);
  144. struct ospf6_lsa *ospf6_lsdb_type_next (u_int16_t type,
  145. struct ospf6_lsa *lsa);
  146. void ospf6_lsdb_remove_all (struct ospf6_lsdb *lsdb);
  147. int ospf6_lsdb_show (struct vty *vty, int argc, char **argv,
  148. struct ospf6_lsdb *lsdb);
  149. #if 0
  150. void ospf6_lsdb_init ();
  151. void ospf6_lsdb_remove_maxage (struct ospf6_lsdb *lsdb);
  152. #endif
  153. #endif /* OSPF6_LSDB_H */