]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_lsdb.h
Merge pull request #12967 from pguibert6WIND/show_zebra_mpls_empty
[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
33 extern void ospf6_lsdb_add(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
34 extern void ospf6_lsdb_remove(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb);
35
36 extern const struct route_node *ospf6_lsdb_head(struct ospf6_lsdb *lsdb,
37 int argmode, uint16_t type,
38 uint32_t adv_router,
39 struct ospf6_lsa **lsa);
40 extern struct ospf6_lsa *ospf6_lsdb_next(const struct route_node *iterend,
41 struct ospf6_lsa *lsa);
42
43 #define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \
44 const struct route_node *iterend = \
45 ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \
46 lsa; \
47 lsa = ospf6_lsdb_next(iterend, lsa)
48
49 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
50 const struct route_node *iterend = \
51 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
52 lsa; \
53 lsa = ospf6_lsdb_next(iterend, lsa)
54
55 /*
56 * Since we are locking the lsa in ospf6_lsdb_head
57 * and then unlocking it in ospf6_lsa_unlock, when
58 * we cache the next pointer we need to increment
59 * the lock for the lsa so we don't accidentally free
60 * it really early.
61 */
62 #define ALL_LSDB(lsdb, lsa, lsanext) \
63 const struct route_node *iterend = \
64 ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \
65 (lsa) != NULL && ospf6_lsa_lock(lsa) \
66 && ((lsanext) = ospf6_lsdb_next(iterend, (lsa)), 1); \
67 ospf6_lsa_unlock(lsa), (lsa) = (lsanext)
68
69 extern void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb);
70 extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa);
71
72 enum ospf_lsdb_show_level {
73 OSPF6_LSDB_SHOW_LEVEL_NORMAL = 0,
74 OSPF6_LSDB_SHOW_LEVEL_DETAIL,
75 OSPF6_LSDB_SHOW_LEVEL_INTERNAL,
76 OSPF6_LSDB_SHOW_LEVEL_DUMP,
77 };
78
79 extern void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
80 uint16_t *type, uint32_t *id, uint32_t *adv_router,
81 struct ospf6_lsdb *lsdb, json_object *json,
82 bool use_json);
83
84 extern uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
85 struct ospf6_lsdb *lsdb);
86 extern uint32_t ospf6_new_ls_seqnum(uint16_t type, uint32_t id,
87 uint32_t adv_router,
88 struct ospf6_lsdb *lsdb);
89 extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb);
90
91 #endif /* OSPF6_LSDB_H */