]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_lsdb.h
ripd: Make sure we do not overuse higher values for ECMP count
[mirror_frr.git] / ospf6d / ospf6_lsdb.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2003 Yasuhiro Ohara
4 */
5
6 #ifndef OSPF6_LSDB_H
7 #define OSPF6_LSDB_H
8
9 #include "prefix.h"
10 #include "table.h"
11 #include "ospf6_route.h"
12
13 struct ospf6_lsdb {
14 void *data; /* data structure that holds this lsdb */
15 struct route_table *table;
16 uint32_t count;
17 uint32_t stats[OSPF6_LSTYPE_SIZE];
18 void (*hook_add)(struct ospf6_lsa *);
19 void (*hook_remove)(struct ospf6_lsa *);
20 };
21
22 /* Function Prototypes */
23 extern struct ospf6_lsdb *ospf6_lsdb_create(void *data);
24 extern void ospf6_lsdb_delete(struct ospf6_lsdb *lsdb);
25
26 extern struct ospf6_lsa *ospf6_lsdb_lookup(uint16_t type, uint32_t id,
27 uint32_t adv_router,
28 struct ospf6_lsdb *lsdb);
29 extern struct ospf6_lsa *ospf6_lsdb_lookup_next(uint16_t type, uint32_t id,
30 uint32_t adv_router,
31 struct ospf6_lsdb *lsdb);
32 extern struct ospf6_lsa *ospf6_find_inter_prefix_lsa(struct ospf6 *ospf6,
33 struct ospf6_area *area,
34 struct prefix *p);
35
36 extern void ospf6_lsdb_add(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
37 extern void ospf6_lsdb_remove(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
38
39 extern const struct route_node *ospf6_lsdb_head(struct ospf6_lsdb *lsdb,
40 int argmode, uint16_t type,
41 uint32_t adv_router,
42 struct ospf6_lsa **lsa);
43 extern struct ospf6_lsa *ospf6_lsdb_next(const struct route_node *iterend,
44 struct ospf6_lsa *lsa);
45
46 #define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
47 const struct route_node *iterend = \
48 ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \
49 lsa; \
50 lsa = ospf6_lsdb_next(iterend, lsa)
51
52 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
53 const struct route_node *iterend = \
54 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
55 lsa; \
56 lsa = ospf6_lsdb_next(iterend, lsa)
57
58 /*
59 * Since we are locking the lsa in ospf6_lsdb_head
60 * and then unlocking it in ospf6_lsa_unlock, when
61 * we cache the next pointer we need to increment
62 * the lock for the lsa so we don't accidentally free
63 * it really early.
64 */
65 #define ALL_LSDB(lsdb, lsa, lsanext) \
66 const struct route_node *iterend = \
67 ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
68 (lsa) != NULL && ospf6_lsa_lock(lsa) \
69 && ((lsanext) = ospf6_lsdb_next(iterend, (lsa)), 1); \
70 ospf6_lsa_unlock(lsa), (lsa) = (lsanext)
71
72 extern void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb);
73 extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa);
74
75 enum ospf_lsdb_show_level {
76 OSPF6_LSDB_SHOW_LEVEL_NORMAL = 0,
77 OSPF6_LSDB_SHOW_LEVEL_DETAIL,
78 OSPF6_LSDB_SHOW_LEVEL_INTERNAL,
79 OSPF6_LSDB_SHOW_LEVEL_DUMP,
80 };
81
82 extern void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
83 uint16_t *type, uint32_t *id, uint32_t *adv_router,
84 struct ospf6_lsdb *lsdb, json_object *json,
85 bool use_json);
86
87 extern uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
88 struct ospf6_lsdb *lsdb);
89 extern uint32_t ospf6_new_ls_seqnum(uint16_t type, uint32_t id,
90 uint32_t adv_router,
91 struct ospf6_lsdb *lsdb);
92 extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb);
93
94 #endif /* OSPF6_LSDB_H */