]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * OSPF LSDB support. | |
3 | * Copyright (C) 1999, 2000 Alex Zinin, Kunihiro Ishiguro, Toshiaki Takada | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #ifndef _ZEBRA_OSPF_LSDB_H | |
23 | #define _ZEBRA_OSPF_LSDB_H | |
24 | ||
25 | /* OSPF LSDB structure. */ | |
d62a17ae | 26 | struct ospf_lsdb { |
27 | struct { | |
28 | unsigned long count; | |
29 | unsigned long count_self; | |
30 | unsigned int checksum; | |
31 | struct route_table *db; | |
32 | } type[OSPF_MAX_LSA]; | |
33 | unsigned long total; | |
718e3744 | 34 | #define MONITOR_LSDB_CHANGE 1 /* XXX */ |
35 | #ifdef MONITOR_LSDB_CHANGE | |
d62a17ae | 36 | /* Hooks for callback functions to catch every add/del event. */ |
37 | int (*new_lsa_hook)(struct ospf_lsa *); | |
38 | int (*del_lsa_hook)(struct ospf_lsa *); | |
718e3744 | 39 | #endif /* MONITOR_LSDB_CHANGE */ |
40 | }; | |
41 | ||
42 | /* Macros. */ | |
d62a17ae | 43 | #define LSDB_LOOP(T, N, L) \ |
44 | if ((T) != NULL) \ | |
45 | for ((N) = route_top((T)); ((N)); ((N)) = route_next((N))) \ | |
46 | if (((L) = (N)->info)) | |
718e3744 | 47 | |
48 | #define ROUTER_LSDB(A) ((A)->lsdb->type[OSPF_ROUTER_LSA].db) | |
49 | #define NETWORK_LSDB(A) ((A)->lsdb->type[OSPF_NETWORK_LSA].db) | |
50 | #define SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_SUMMARY_LSA].db) | |
51 | #define ASBR_SUMMARY_LSDB(A) ((A)->lsdb->type[OSPF_ASBR_SUMMARY_LSA].db) | |
52 | #define EXTERNAL_LSDB(O) ((O)->lsdb->type[OSPF_AS_EXTERNAL_LSA].db) | |
53 | #define NSSA_LSDB(A) ((A)->lsdb->type[OSPF_AS_NSSA_LSA].db) | |
54 | #define OPAQUE_LINK_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_LINK_LSA].db) | |
55 | #define OPAQUE_AREA_LSDB(A) ((A)->lsdb->type[OSPF_OPAQUE_AREA_LSA].db) | |
56 | #define OPAQUE_AS_LSDB(O) ((O)->lsdb->type[OSPF_OPAQUE_AS_LSA].db) | |
57 | ||
58 | #define AREA_LSDB(A,T) ((A)->lsdb->type[(T)].db) | |
59 | #define AS_LSDB(O,T) ((O)->lsdb->type[(T)].db) | |
60 | ||
61 | /* OSPF LSDB related functions. */ | |
d62a17ae | 62 | extern struct ospf_lsdb *ospf_lsdb_new(void); |
63 | extern void ospf_lsdb_init(struct ospf_lsdb *); | |
64 | extern void ospf_lsdb_free(struct ospf_lsdb *); | |
65 | extern void ospf_lsdb_cleanup(struct ospf_lsdb *); | |
66 | extern void ls_prefix_set(struct prefix_ls *lp, struct ospf_lsa *lsa); | |
67 | extern void ospf_lsdb_add(struct ospf_lsdb *, struct ospf_lsa *); | |
68 | extern void ospf_lsdb_delete(struct ospf_lsdb *, struct ospf_lsa *); | |
69 | extern void ospf_lsdb_delete_all(struct ospf_lsdb *); | |
d62a17ae | 70 | extern struct ospf_lsa *ospf_lsdb_lookup(struct ospf_lsdb *, struct ospf_lsa *); |
d7c0a89a | 71 | extern struct ospf_lsa *ospf_lsdb_lookup_by_id(struct ospf_lsdb *, uint8_t, |
d62a17ae | 72 | struct in_addr, struct in_addr); |
d7c0a89a | 73 | extern struct ospf_lsa *ospf_lsdb_lookup_by_id_next(struct ospf_lsdb *, uint8_t, |
d62a17ae | 74 | struct in_addr, |
75 | struct in_addr, int); | |
76 | extern unsigned long ospf_lsdb_count_all(struct ospf_lsdb *); | |
77 | extern unsigned long ospf_lsdb_count(struct ospf_lsdb *, int); | |
78 | extern unsigned long ospf_lsdb_count_self(struct ospf_lsdb *, int); | |
79 | extern unsigned int ospf_lsdb_checksum(struct ospf_lsdb *, int); | |
80 | extern unsigned long ospf_lsdb_isempty(struct ospf_lsdb *); | |
718e3744 | 81 | |
82 | #endif /* _ZEBRA_OSPF_LSDB_H */ |