]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_lsdb.h
*: auto-convert to SPDX License IDs
[mirror_frr.git] / ospfd / ospf_lsdb.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OSPF LSDB support.
4 * Copyright (C) 1999, 2000 Alex Zinin, Kunihiro Ishiguro, Toshiaki Takada
5 */
6
7 #ifndef _ZEBRA_OSPF_LSDB_H
8 #define _ZEBRA_OSPF_LSDB_H
9
10 /* OSPF LSDB structure. */
11 struct ospf_lsdb {
12 struct {
13 unsigned long count;
14 unsigned long count_self;
15 unsigned int checksum;
16 struct route_table *db;
17 } type[OSPF_MAX_LSA];
18 unsigned long total;
19 #define MONITOR_LSDB_CHANGE 1 /* XXX */
20 #ifdef MONITOR_LSDB_CHANGE
21 /* Hooks for callback functions to catch every add/del event. */
22 int (*new_lsa_hook)(struct ospf_lsa *);
23 int (*del_lsa_hook)(struct ospf_lsa *);
24 #endif /* MONITOR_LSDB_CHANGE */
25 };
26
27 /* Macros. */
28 #define LSDB_LOOP(T, N, L) \
29 if ((T) != NULL) \
30 for ((N) = route_top((T)); ((N)); ((N)) = route_next((N))) \
31 if (((L) = (N)->info))
32
33 #define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db)
34 #define NETWORK_LSDB(A) ((A)->lsdb->type[OSPF_NETWORK_LSA].db)
35 #define SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_SUMMARY_LSA].db)
36 #define ASBR_SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_ASBR_SUMMARY_LSA].db)
37 #define EXTERNAL_LSDB(O) ((O)->lsdb->type[OSPF_AS_EXTERNAL_LSA].db)
38 #define NSSA_LSDB(A) ((A)->lsdb->type[OSPF_AS_NSSA_LSA].db)
39 #define OPAQUE_LINK_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_LINK_LSA].db)
40 #define OPAQUE_AREA_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_AREA_LSA].db)
41 #define OPAQUE_AS_LSDB(O) ((O)->lsdb->type[OSPF_OPAQUE_AS_LSA].db)
42
43 #define AREA_LSDB(A,T) ((A)->lsdb->type[(T)].db)
44 #define AS_LSDB(O,T) ((O)->lsdb->type[(T)].db)
45
46 /* OSPF LSDB related functions. */
47 extern struct ospf_lsdb *ospf_lsdb_new(void);
48 extern void ospf_lsdb_init(struct ospf_lsdb *);
49 extern void ospf_lsdb_free(struct ospf_lsdb *);
50 extern void ospf_lsdb_cleanup(struct ospf_lsdb *);
51 extern void ls_prefix_set(struct prefix_ls *lp, struct ospf_lsa *lsa);
52 extern void ospf_lsdb_add(struct ospf_lsdb *, struct ospf_lsa *);
53 extern void ospf_lsdb_delete(struct ospf_lsdb *, struct ospf_lsa *);
54 extern void ospf_lsdb_delete_all(struct ospf_lsdb *);
55 extern struct ospf_lsa *ospf_lsdb_lookup(struct ospf_lsdb *, struct ospf_lsa *);
56 extern struct ospf_lsa *ospf_lsdb_lookup_by_id(struct ospf_lsdb *, uint8_t,
57 struct in_addr, struct in_addr);
58 extern struct ospf_lsa *ospf_lsdb_lookup_by_id_next(struct ospf_lsdb *, uint8_t,
59 struct in_addr,
60 struct in_addr, int);
61 extern unsigned long ospf_lsdb_count_all(struct ospf_lsdb *);
62 extern unsigned long ospf_lsdb_count(struct ospf_lsdb *, int);
63 extern unsigned long ospf_lsdb_count_self(struct ospf_lsdb *, int);
64 extern unsigned int ospf_lsdb_checksum(struct ospf_lsdb *, int);
65 extern unsigned long ospf_lsdb_isempty(struct ospf_lsdb *);
66
67 #endif /* _ZEBRA_OSPF_LSDB_H */