2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "ospf6_route.h"
29 void *data
; /* data structure that holds this lsdb */
30 struct route_table
*table
;
32 uint32_t stats
[OSPF6_LSTYPE_SIZE
];
33 void (*hook_add
)(struct ospf6_lsa
*);
34 void (*hook_remove
)(struct ospf6_lsa
*);
37 /* Function Prototypes */
38 extern struct ospf6_lsdb
*ospf6_lsdb_create(void *data
);
39 extern void ospf6_lsdb_delete(struct ospf6_lsdb
*lsdb
);
41 extern struct ospf6_lsa
*ospf6_lsdb_lookup(uint16_t type
, uint32_t id
,
43 struct ospf6_lsdb
*lsdb
);
44 extern struct ospf6_lsa
*ospf6_lsdb_lookup_next(uint16_t type
, uint32_t id
,
46 struct ospf6_lsdb
*lsdb
);
48 extern void ospf6_lsdb_add(struct ospf6_lsa
*lsa
, struct ospf6_lsdb
*lsdb
);
49 extern void ospf6_lsdb_remove(struct ospf6_lsa
*lsa
, struct ospf6_lsdb
*lsdb
);
51 extern const struct route_node
*ospf6_lsdb_head(struct ospf6_lsdb
*lsdb
,
52 int argmode
, uint16_t type
,
54 struct ospf6_lsa
**lsa
);
55 extern struct ospf6_lsa
*ospf6_lsdb_next(const struct route_node
*iterend
,
56 struct ospf6_lsa
*lsa
);
58 #define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
59 const struct route_node *iterend = \
60 ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \
62 lsa = ospf6_lsdb_next(iterend, lsa)
64 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
65 const struct route_node *iterend = \
66 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
68 lsa = ospf6_lsdb_next(iterend, lsa)
71 * Since we are locking the lsa in ospf6_lsdb_head
72 * and then unlocking it in ospf6_lsa_unlock, when
73 * we cache the next pointer we need to increment
74 * the lock for the lsa so we don't accidently free
77 #define ALL_LSDB(lsdb, lsa, lsanext) \
78 const struct route_node *iterend = \
79 ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
80 (lsa) != NULL && ospf6_lsa_lock(lsa) \
81 && ((lsanext) = ospf6_lsdb_next(iterend, (lsa)), 1); \
82 ospf6_lsa_unlock(lsa), (lsa) = (lsanext)
84 extern void ospf6_lsdb_remove_all(struct ospf6_lsdb
*lsdb
);
85 extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa
*lsa
);
87 enum ospf_lsdb_show_level
{
88 OSPF6_LSDB_SHOW_LEVEL_NORMAL
= 0,
89 OSPF6_LSDB_SHOW_LEVEL_DETAIL
,
90 OSPF6_LSDB_SHOW_LEVEL_INTERNAL
,
91 OSPF6_LSDB_SHOW_LEVEL_DUMP
,
94 extern void ospf6_lsdb_show(struct vty
*vty
, enum ospf_lsdb_show_level level
,
95 uint16_t *type
, uint32_t *id
, uint32_t *adv_router
,
96 struct ospf6_lsdb
*lsdb
, json_object
*json
,
99 extern uint32_t ospf6_new_ls_id(uint16_t type
, uint32_t adv_router
,
100 struct ospf6_lsdb
*lsdb
);
101 extern uint32_t ospf6_new_ls_seqnum(uint16_t type
, uint32_t id
,
103 struct ospf6_lsdb
*lsdb
);
104 extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb
*lsdb
);
106 #endif /* OSPF6_LSDB_H */