1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2003 Yasuhiro Ohara
11 #include "ospf6_route.h"
14 void *data
; /* data structure that holds this lsdb */
15 struct route_table
*table
;
17 uint32_t stats
[OSPF6_LSTYPE_SIZE
];
18 void (*hook_add
)(struct ospf6_lsa
*);
19 void (*hook_remove
)(struct ospf6_lsa
*);
22 /* Function Prototypes */
23 extern struct ospf6_lsdb
*ospf6_lsdb_create(void *data
);
24 extern void ospf6_lsdb_delete(struct ospf6_lsdb
*lsdb
);
26 extern struct ospf6_lsa
*ospf6_lsdb_lookup(uint16_t type
, uint32_t id
,
28 struct ospf6_lsdb
*lsdb
);
29 extern struct ospf6_lsa
*ospf6_lsdb_lookup_next(uint16_t type
, uint32_t id
,
31 struct ospf6_lsdb
*lsdb
);
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
);
36 extern const struct route_node
*ospf6_lsdb_head(struct ospf6_lsdb
*lsdb
,
37 int argmode
, uint16_t type
,
39 struct ospf6_lsa
**lsa
);
40 extern struct ospf6_lsa
*ospf6_lsdb_next(const struct route_node
*iterend
,
41 struct ospf6_lsa
*lsa
);
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); \
47 lsa = ospf6_lsdb_next(iterend, lsa)
49 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
50 const struct route_node *iterend = \
51 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
53 lsa = ospf6_lsdb_next(iterend, lsa)
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
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)
69 extern void ospf6_lsdb_remove_all(struct ospf6_lsdb
*lsdb
);
70 extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa
*lsa
);
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
,
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
,
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
,
88 struct ospf6_lsdb
*lsdb
);
89 extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb
*lsdb
);
91 #endif /* OSPF6_LSDB_H */