blob: 34344b3b499ee3a087f2657b3f649d0bd41d4382 [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;
33 struct route_table *db;
34 } type[OSPF_MAX_LSA];
35 unsigned long total;
36#define MONITOR_LSDB_CHANGE 1 /* XXX */
37#ifdef MONITOR_LSDB_CHANGE
38 /* Hooks for callback functions to catch every add/del event. */
39 int (* new_lsa_hook)(struct ospf_lsa *);
40 int (* del_lsa_hook)(struct ospf_lsa *);
41#endif /* MONITOR_LSDB_CHANGE */
42};
43
44/* Macros. */
45#define LSDB_LOOP(T,N,L) \
46 for ((N) = route_top ((T)); ((N)); ((N)) = route_next ((N))) \
47 if (((L) = (N)->info))
48
49#define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db)
50#define NETWORK_LSDB(A) ((A)->lsdb->type[OSPF_NETWORK_LSA].db)
51#define SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_SUMMARY_LSA].db)
52#define ASBR_SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_ASBR_SUMMARY_LSA].db)
53#define EXTERNAL_LSDB(O) ((O)->lsdb->type[OSPF_AS_EXTERNAL_LSA].db)
54#define NSSA_LSDB(A) ((A)->lsdb->type[OSPF_AS_NSSA_LSA].db)
55#define OPAQUE_LINK_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_LINK_LSA].db)
56#define OPAQUE_AREA_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_AREA_LSA].db)
57#define OPAQUE_AS_LSDB(O) ((O)->lsdb->type[OSPF_OPAQUE_AS_LSA].db)
58
59#define AREA_LSDB(A,T) ((A)->lsdb->type[(T)].db)
60#define AS_LSDB(O,T) ((O)->lsdb->type[(T)].db)
61
62/* OSPF LSDB related functions. */
63struct ospf_lsdb *ospf_lsdb_new ();
64void ospf_lsdb_init (struct ospf_lsdb *);
65void ospf_lsdb_free (struct ospf_lsdb *);
66void ospf_lsdb_cleanup (struct ospf_lsdb *);
67void ospf_lsdb_add (struct ospf_lsdb *, struct ospf_lsa *);
68void ospf_lsdb_delete (struct ospf_lsdb *, struct ospf_lsa *);
69void ospf_lsdb_delete_all (struct ospf_lsdb *);
70struct ospf_lsa *ospf_lsdb_lookup (struct ospf_lsdb *, struct ospf_lsa *);
71struct ospf_lsa *ospf_lsdb_lookup_by_id (struct ospf_lsdb *, u_char,
72 struct in_addr, struct in_addr);
73struct ospf_lsa *ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *, u_char,
74 struct in_addr, struct in_addr,
75 int);
76unsigned long ospf_lsdb_count_all (struct ospf_lsdb *);
77unsigned long ospf_lsdb_count (struct ospf_lsdb *, int);
78unsigned long ospf_lsdb_count_self (struct ospf_lsdb *, int);
79unsigned long ospf_lsdb_isempty (struct ospf_lsdb *);
80struct ospf_lsa *foreach_lsa (struct route_table *, void *, int,
81 int (*callback) (struct ospf_lsa *, void *, int));
82
83#endif /* _ZEBRA_OSPF_LSDB_H */