]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 3 | * |
4 | * This file is part of GNU Zebra. | |
5 | * | |
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 | |
9 | * later version. | |
10 | * | |
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. | |
15 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
21 | #ifndef OSPF6_LSDB_H | |
22 | #define OSPF6_LSDB_H | |
23 | ||
24 | #include "prefix.h" | |
25 | #include "table.h" | |
c3c0ac83 | 26 | #include "ospf6_route.h" |
718e3744 | 27 | |
d62a17ae | 28 | struct ospf6_lsdb { |
29 | void *data; /* data structure that holds this lsdb */ | |
30 | struct route_table *table; | |
d7c0a89a | 31 | uint32_t count; |
d62a17ae | 32 | void (*hook_add)(struct ospf6_lsa *); |
33 | void (*hook_remove)(struct ospf6_lsa *); | |
718e3744 | 34 | }; |
35 | ||
718e3744 | 36 | /* Function Prototypes */ |
d62a17ae | 37 | extern struct ospf6_lsdb *ospf6_lsdb_create(void *data); |
38 | extern void ospf6_lsdb_delete(struct ospf6_lsdb *lsdb); | |
718e3744 | 39 | |
d7c0a89a QY |
40 | extern struct ospf6_lsa *ospf6_lsdb_lookup(uint16_t type, uint32_t id, |
41 | uint32_t adv_router, | |
d62a17ae | 42 | struct ospf6_lsdb *lsdb); |
d7c0a89a QY |
43 | extern struct ospf6_lsa *ospf6_lsdb_lookup_next(uint16_t type, uint32_t id, |
44 | uint32_t adv_router, | |
d62a17ae | 45 | struct ospf6_lsdb *lsdb); |
718e3744 | 46 | |
d62a17ae | 47 | extern void ospf6_lsdb_add(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb); |
48 | extern void ospf6_lsdb_remove(struct ospf6_lsa *lsa, struct ospf6_lsdb *lsdb); | |
718e3744 | 49 | |
d62a17ae | 50 | extern const struct route_node *ospf6_lsdb_head(struct ospf6_lsdb *lsdb, |
51 | int argmode, uint16_t type, | |
52 | uint32_t adv_router, | |
53 | struct ospf6_lsa **lsa); | |
54 | extern struct ospf6_lsa *ospf6_lsdb_next(const struct route_node *iterend, | |
55 | struct ospf6_lsa *lsa); | |
718e3744 | 56 | |
d62a17ae | 57 | #define ALL_LSDB_TYPED_ADVRTR(lsdb, type, adv_router, lsa) \ |
58 | const struct route_node *iterend = \ | |
59 | ospf6_lsdb_head(lsdb, 2, type, adv_router, &lsa); \ | |
60 | lsa; \ | |
954306f7 | 61 | lsa = ospf6_lsdb_next(iterend, lsa) |
508e53e2 | 62 | |
d62a17ae | 63 | #define ALL_LSDB_TYPED(lsdb, type, lsa) \ |
64 | const struct route_node *iterend = \ | |
65 | ospf6_lsdb_head(lsdb, 1, type, 0, &lsa); \ | |
66 | lsa; \ | |
954306f7 DL |
67 | lsa = ospf6_lsdb_next(iterend, lsa) |
68 | ||
2e37407f DS |
69 | /* |
70 | * Since we are locking the lsa in ospf6_lsdb_head | |
71 | * and then unlocking it in lspf6_lsa_lock, when | |
72 | * we cache the next pointer we need to increment | |
73 | * the lock for the lsa so we don't accidently free | |
74 | * it really early. | |
75 | */ | |
76 | #define ALL_LSDB(lsdb, lsa, lsanext) \ | |
d62a17ae | 77 | const struct route_node *iterend = \ |
78 | ospf6_lsdb_head(lsdb, 0, 0, 0, &lsa); \ | |
2e37407f DS |
79 | (lsa) != NULL &&ospf6_lsa_lock(lsa) \ |
80 | && ((lsanext) = ospf6_lsdb_next(iterend, (lsa)), 1); \ | |
81 | ospf6_lsa_unlock(lsa), (lsa) = (lsanext) | |
718e3744 | 82 | |
d62a17ae | 83 | extern void ospf6_lsdb_remove_all(struct ospf6_lsdb *lsdb); |
84 | extern void ospf6_lsdb_lsa_unlock(struct ospf6_lsa *lsa); | |
718e3744 | 85 | |
f58c5fbd | 86 | enum ospf_lsdb_show_level { |
d62a17ae | 87 | OSPF6_LSDB_SHOW_LEVEL_NORMAL = 0, |
88 | OSPF6_LSDB_SHOW_LEVEL_DETAIL, | |
89 | OSPF6_LSDB_SHOW_LEVEL_INTERNAL, | |
90 | OSPF6_LSDB_SHOW_LEVEL_DUMP, | |
f58c5fbd | 91 | }; |
049207c3 | 92 | |
d62a17ae | 93 | extern void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level, |
d7c0a89a | 94 | uint16_t *type, uint32_t *id, uint32_t *adv_router, |
e4bacbaa YR |
95 | struct ospf6_lsdb *lsdb, json_object *json, |
96 | bool use_json); | |
718e3744 | 97 | |
d7c0a89a QY |
98 | extern uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router, |
99 | struct ospf6_lsdb *lsdb); | |
100 | extern uint32_t ospf6_new_ls_seqnum(uint16_t type, uint32_t id, | |
101 | uint32_t adv_router, | |
102 | struct ospf6_lsdb *lsdb); | |
d62a17ae | 103 | extern int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb); |
718e3744 | 104 | |
105 | #endif /* OSPF6_LSDB_H */ |