blob: 51ae45bf5b62670370035b47ef88adb36ebe5b4f [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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
23#ifndef _ZEBRA_OSPF_LSDB_H
24#define _ZEBRA_OSPF_LSDB_H
25
26/* OSPF LSDB structure. */
27struct ospf_lsdb
28{
29 struct
30 {
31 unsigned long count;
32 unsigned long count_self;
hassofe71a972004-12-22 16:16:02 +000033 unsigned int checksum;
paul718e3742002-12-13 20:15:29 +000034 struct route_table *db;
35 } type[OSPF_MAX_LSA];
36 unsigned long total;
37#define MONITOR_LSDB_CHANGE 1 /* XXX */
38#ifdef MONITOR_LSDB_CHANGE
39 /* Hooks for callback functions to catch every add/del event. */
40 int (* new_lsa_hook)(struct ospf_lsa *);
41 int (* del_lsa_hook)(struct ospf_lsa *);
42#endif /* MONITOR_LSDB_CHANGE */
43};
44
45/* Macros. */
hassofe71a972004-12-22 16:16:02 +000046#define LSDB_LOOP(T,N,L) \
47 if ((T) != NULL) \
48 for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \
paul718e3742002-12-13 20:15:29 +000049 if (((L) = (N)->info))
50
51#define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db)
52#define NETWORK_LSDB(A) ((A)->lsdb->type[OSPF_NETWORK_LSA].db)
53#define SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_SUMMARY_LSA].db)
54#define ASBR_SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_ASBR_SUMMARY_LSA].db)
55#define EXTERNAL_LSDB(O) ((O)->lsdb->type[OSPF_AS_EXTERNAL_LSA].db)
56#define NSSA_LSDB(A) ((A)->lsdb->type[OSPF_AS_NSSA_LSA].db)
57#define OPAQUE_LINK_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_LINK_LSA].db)
58#define OPAQUE_AREA_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_AREA_LSA].db)
59#define OPAQUE_AS_LSDB(O) ((O)->lsdb->type[OSPF_OPAQUE_AS_LSA].db)
60
61#define AREA_LSDB(A,T) ((A)->lsdb->type[(T)].db)
62#define AS_LSDB(O,T) ((O)->lsdb->type[(T)].db)
63
64/* OSPF LSDB related functions. */
paul4dadc292005-05-06 21:37:42 +000065extern struct ospf_lsdb *ospf_lsdb_new (void);
66extern void ospf_lsdb_init (struct ospf_lsdb *);
67extern void ospf_lsdb_free (struct ospf_lsdb *);
68extern void ospf_lsdb_cleanup (struct ospf_lsdb *);
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -080069extern void ls_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa);
paul4dadc292005-05-06 21:37:42 +000070extern void ospf_lsdb_add (struct ospf_lsdb *, struct ospf_lsa *);
71extern void ospf_lsdb_delete (struct ospf_lsdb *, struct ospf_lsa *);
72extern void ospf_lsdb_delete_all (struct ospf_lsdb *);
hasso462f20d2005-02-23 11:29:02 +000073/* Set all stats to -1 (LSA_SPF_NOT_EXPLORED). */
paul4dadc292005-05-06 21:37:42 +000074extern void ospf_lsdb_clean_stat (struct ospf_lsdb *lsdb);
75extern struct ospf_lsa *ospf_lsdb_lookup (struct ospf_lsdb *, struct ospf_lsa *);
76extern struct ospf_lsa *ospf_lsdb_lookup_by_id (struct ospf_lsdb *, u_char,
paul718e3742002-12-13 20:15:29 +000077 struct in_addr, struct in_addr);
paul4dadc292005-05-06 21:37:42 +000078extern struct ospf_lsa *ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *, u_char,
paul718e3742002-12-13 20:15:29 +000079 struct in_addr, struct in_addr,
80 int);
paul4dadc292005-05-06 21:37:42 +000081extern unsigned long ospf_lsdb_count_all (struct ospf_lsdb *);
82extern unsigned long ospf_lsdb_count (struct ospf_lsdb *, int);
83extern unsigned long ospf_lsdb_count_self (struct ospf_lsdb *, int);
84extern unsigned int ospf_lsdb_checksum (struct ospf_lsdb *, int);
85extern unsigned long ospf_lsdb_isempty (struct ospf_lsdb *);
paul718e3742002-12-13 20:15:29 +000086
87#endif /* _ZEBRA_OSPF_LSDB_H */