ospf_lsdb.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * OSPF LSDB support.
  3. * Copyright (C) 1999, 2000 Alex Zinin, Kunihiro Ishiguro, Toshiaki Takada
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #ifndef _ZEBRA_OSPF_LSDB_H
  23. #define _ZEBRA_OSPF_LSDB_H
  24. /* OSPF LSDB structure. */
  25. struct ospf_lsdb
  26. {
  27. struct
  28. {
  29. unsigned long count;
  30. unsigned long count_self;
  31. unsigned int checksum;
  32. struct route_table *db;
  33. } type[OSPF_MAX_LSA];
  34. unsigned long total;
  35. #define MONITOR_LSDB_CHANGE 1 /* XXX */
  36. #ifdef MONITOR_LSDB_CHANGE
  37. /* Hooks for callback functions to catch every add/del event. */
  38. int (* new_lsa_hook)(struct ospf_lsa *);
  39. int (* del_lsa_hook)(struct ospf_lsa *);
  40. #endif /* MONITOR_LSDB_CHANGE */
  41. };
  42. /* Macros. */
  43. #define LSDB_LOOP(T,N,L) \
  44. if ((T) != NULL) \
  45. for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \
  46. if (((L) = (N)->info))
  47. #define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db)
  48. #define NETWORK_LSDB(A) ((A)->lsdb->type[OSPF_NETWORK_LSA].db)
  49. #define SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_SUMMARY_LSA].db)
  50. #define ASBR_SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_ASBR_SUMMARY_LSA].db)
  51. #define EXTERNAL_LSDB(O) ((O)->lsdb->type[OSPF_AS_EXTERNAL_LSA].db)
  52. #define NSSA_LSDB(A) ((A)->lsdb->type[OSPF_AS_NSSA_LSA].db)
  53. #define OPAQUE_LINK_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_LINK_LSA].db)
  54. #define OPAQUE_AREA_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_AREA_LSA].db)
  55. #define OPAQUE_AS_LSDB(O) ((O)->lsdb->type[OSPF_OPAQUE_AS_LSA].db)
  56. #define AREA_LSDB(A,T) ((A)->lsdb->type[(T)].db)
  57. #define AS_LSDB(O,T) ((O)->lsdb->type[(T)].db)
  58. /* OSPF LSDB related functions. */
  59. extern struct ospf_lsdb *ospf_lsdb_new (void);
  60. extern void ospf_lsdb_init (struct ospf_lsdb *);
  61. extern void ospf_lsdb_free (struct ospf_lsdb *);
  62. extern void ospf_lsdb_cleanup (struct ospf_lsdb *);
  63. extern void ls_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa);
  64. extern void ospf_lsdb_add (struct ospf_lsdb *, struct ospf_lsa *);
  65. extern void ospf_lsdb_delete (struct ospf_lsdb *, struct ospf_lsa *);
  66. extern void ospf_lsdb_delete_all (struct ospf_lsdb *);
  67. /* Set all stats to -1 (LSA_SPF_NOT_EXPLORED). */
  68. extern void ospf_lsdb_clean_stat (struct ospf_lsdb *lsdb);
  69. extern struct ospf_lsa *ospf_lsdb_lookup (struct ospf_lsdb *, struct ospf_lsa *);
  70. extern struct ospf_lsa *ospf_lsdb_lookup_by_id (struct ospf_lsdb *, u_char,
  71. struct in_addr, struct in_addr);
  72. extern struct ospf_lsa *ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *, u_char,
  73. struct in_addr, struct in_addr,
  74. int);
  75. extern unsigned long ospf_lsdb_count_all (struct ospf_lsdb *);
  76. extern unsigned long ospf_lsdb_count (struct ospf_lsdb *, int);
  77. extern unsigned long ospf_lsdb_count_self (struct ospf_lsdb *, int);
  78. extern unsigned int ospf_lsdb_checksum (struct ospf_lsdb *, int);
  79. extern unsigned long ospf_lsdb_isempty (struct ospf_lsdb *);
  80. #endif /* _ZEBRA_OSPF_LSDB_H */