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
);
32 extern struct ospf6_lsa
*ospf6_find_inter_prefix_lsa(struct ospf6
*ospf6
,
33 struct ospf6_area
*area
,
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
);
39 extern const struct route_node
*ospf6_lsdb_head(struct ospf6_lsdb
*lsdb
,
40 int argmode
, uint16_t type
,
42 struct ospf6_lsa
**lsa
);
43 extern struct ospf6_lsa
*ospf6_lsdb_next(const struct route_node
*iterend
,
44 struct ospf6_lsa
*lsa
);
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); \
50 lsa = ospf6_lsdb_next(iterend, lsa)
52 #define ALL_LSDB_TYPED(lsdb, type, lsa) \
53 const struct route_node *iterend = \
54 ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \
56 lsa = ospf6_lsdb_next(iterend, lsa)
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
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)
72 extern void ospf6_lsdb_remove_all(struct ospf6_lsdb
*lsdb
);
73 extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa
*lsa
);
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
,
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
,
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
,
91 struct ospf6_lsdb
*lsdb
);
92 extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb
*lsdb
);
94 #endif /* OSPF6_LSDB_H */