blob: 94dfcb648fbe9dc1a399f69ca1b631df8e043cf9 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
22#ifndef OSPF6_LSDB_H
23#define OSPF6_LSDB_H
24
25#include "prefix.h"
26#include "table.h"
27
paul718e3742002-12-13 20:15:29 +000028struct ospf6_lsdb
29{
30 struct route_table *table;
31 u_int32_t count;
hasso508e53e2004-05-18 18:57:06 +000032 void (*hook_add) (struct ospf6_lsa *);
33 void (*hook_remove) (struct ospf6_lsa *);
paul718e3742002-12-13 20:15:29 +000034};
35
hasso508e53e2004-05-18 18:57:06 +000036#define LSDB_FOREACH_LSA(vty, func, lsdb) \
37 do { \
38 struct ospf6_lsa *lsa; \
39 for (lsa = ospf6_lsdb_head (lsdb); lsa; \
40 lsa = ospf6_lsdb_next (lsa)) \
41 { \
42 (*(func)) (vty, lsa); \
43 } \
44 } while (0)
45#define LSDB_FOREACH_LSA_T(vty, func, lsdb, type) \
46 do { \
47 struct ospf6_lsa *lsa; \
48 for (lsa = ospf6_lsdb_type_head (type, lsdb); lsa; \
49 lsa = ospf6_lsdb_type_next (type, lsa)) \
50 { \
51 (*(func)) (vty, lsa); \
52 } \
53 } while (0)
54#define LSDB_FOREACH_LSA_I(vty, func, lsdb, id) \
55 do { \
56 struct ospf6_lsa *lsa; \
57 for (lsa = ospf6_lsdb_head (lsdb); lsa; \
58 lsa = ospf6_lsdb_next (lsa)) \
59 { \
60 if (lsa->header->id != id) \
61 continue; \
62 (*(func)) (vty, lsa); \
63 } \
64 } while (0)
65#define LSDB_FOREACH_LSA_R(vty, func, lsdb, router) \
66 do { \
67 struct ospf6_lsa *lsa; \
68 for (lsa = ospf6_lsdb_head (lsdb); lsa; \
69 lsa = ospf6_lsdb_next (lsa)) \
70 { \
71 if (lsa->header->adv_router != router) \
72 continue; \
73 (*(func)) (vty, lsa); \
74 } \
75 } while (0)
76#define LSDB_FOREACH_LSA_TI(vty, func, lsdb, type, id) \
77 do { \
78 struct ospf6_lsa *lsa; \
79 for (lsa = ospf6_lsdb_type_head (type, lsdb); lsa; \
80 lsa = ospf6_lsdb_type_next (type, lsa)) \
81 { \
82 if (lsa->header->id != id) \
83 continue; \
84 (*(func)) (vty, lsa); \
85 } \
86 } while (0)
87#define LSDB_FOREACH_LSA_TR(vty, func, lsdb, type, router) \
88 do { \
89 struct ospf6_lsa *lsa; \
90 for (lsa = ospf6_lsdb_type_router_head (type, router, lsdb); lsa; \
91 lsa = ospf6_lsdb_type_router_next (type, router, lsa)) \
92 { \
93 (*(func)) (vty, lsa); \
94 } \
95 } while (0)
96#define LSDB_FOREACH_LSA_IR(vty, func, lsdb, id, router) \
97 do { \
98 struct ospf6_lsa *lsa; \
99 for (lsa = ospf6_lsdb_head (lsdb); lsa; \
100 lsa = ospf6_lsdb_next (lsa)) \
101 { \
102 if (lsa->header->adv_router != router) \
103 continue; \
104 if (lsa->header->id != id) \
105 continue; \
106 (*(func)) (vty, lsa); \
107 } \
108 } while (0)
109#define LSDB_FOREACH_LSA_TIR(vty, func, lsdb, type, id, router) \
110 do { \
111 struct ospf6_lsa *lsa; \
112 lsa = ospf6_lsdb_lookup (type, id, router, lsdb); \
113 if (lsa) \
114 (*(func)) (vty, lsa); \
115 } while (0)
paul718e3742002-12-13 20:15:29 +0000116
hasso508e53e2004-05-18 18:57:06 +0000117#define OSPF6_LSDB_MAXAGE_REMOVER(lsdb) \
118 do { \
119 struct ospf6_lsa *lsa; \
120 for (lsa = ospf6_lsdb_head (lsdb); lsa; lsa = ospf6_lsdb_next (lsa)) \
121 { \
122 if (! OSPF6_LSA_IS_MAXAGE (lsa)) \
123 continue; \
124 if (lsa->refcnt != 0) \
125 continue; \
126 if (IS_OSPF6_DEBUG_LSA (TIMER)) \
127 zlog_info (" remove maxage %s", lsa->name); \
128 ospf6_lsdb_remove (lsa, lsdb); \
129 } \
130 } while (0)
paul718e3742002-12-13 20:15:29 +0000131
132/* Function Prototypes */
hasso508e53e2004-05-18 18:57:06 +0000133struct ospf6_lsdb *ospf6_lsdb_create ();
paul718e3742002-12-13 20:15:29 +0000134void ospf6_lsdb_delete (struct ospf6_lsdb *lsdb);
135
hasso508e53e2004-05-18 18:57:06 +0000136struct ospf6_lsa *ospf6_lsdb_lookup (u_int16_t type, u_int32_t id,
137 u_int32_t adv_router,
138 struct ospf6_lsdb *lsdb);
paul718e3742002-12-13 20:15:29 +0000139
140void ospf6_lsdb_add (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
141void ospf6_lsdb_remove (struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
hasso508e53e2004-05-18 18:57:06 +0000142
143struct ospf6_lsa *ospf6_lsdb_head (struct ospf6_lsdb *lsdb);
144struct ospf6_lsa *ospf6_lsdb_next (struct ospf6_lsa *lsa);
145
146struct ospf6_lsa *ospf6_lsdb_type_router_head (u_int16_t type,
147 u_int32_t adv_router,
148 struct ospf6_lsdb *lsdb);
149struct ospf6_lsa *ospf6_lsdb_type_router_next (u_int16_t type,
150 u_int32_t adv_router,
151 struct ospf6_lsa *lsa);
152
153struct ospf6_lsa *ospf6_lsdb_type_head (u_int16_t type,
154 struct ospf6_lsdb *lsdb);
155struct ospf6_lsa *ospf6_lsdb_type_next (u_int16_t type,
156 struct ospf6_lsa *lsa);
157
paul718e3742002-12-13 20:15:29 +0000158void ospf6_lsdb_remove_all (struct ospf6_lsdb *lsdb);
159
hasso508e53e2004-05-18 18:57:06 +0000160int ospf6_lsdb_show (struct vty *vty, int argc, char **argv,
161 struct ospf6_lsdb *lsdb);
paul718e3742002-12-13 20:15:29 +0000162
hasso508e53e2004-05-18 18:57:06 +0000163#if 0
paul718e3742002-12-13 20:15:29 +0000164void ospf6_lsdb_init ();
hasso508e53e2004-05-18 18:57:06 +0000165void ospf6_lsdb_remove_maxage (struct ospf6_lsdb *lsdb);
166#endif
paul718e3742002-12-13 20:15:29 +0000167
168#endif /* OSPF6_LSDB_H */
169
hasso508e53e2004-05-18 18:57:06 +0000170