]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2003 Yasuhiro Ohara | |
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 | * | |
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 | |
19 | */ | |
20 | ||
21 | #ifndef OSPF6_SPF_H | |
22 | #define OSPF6_SPF_H | |
23 | ||
24 | #include "ospf6_top.h" | |
25 | ||
26 | /* Debug option */ | |
27 | extern unsigned char conf_debug_ospf6_spf; | |
28 | #define OSPF6_DEBUG_SPF_PROCESS 0x01 | |
29 | #define OSPF6_DEBUG_SPF_TIME 0x02 | |
30 | #define OSPF6_DEBUG_SPF_DATABASE 0x04 | |
31 | #define OSPF6_DEBUG_SPF_ON(level) (conf_debug_ospf6_spf |= (level)) | |
32 | #define OSPF6_DEBUG_SPF_OFF(level) (conf_debug_ospf6_spf &= ~(level)) | |
33 | #define IS_OSPF6_DEBUG_SPF(level) \ | |
34 | (conf_debug_ospf6_spf & OSPF6_DEBUG_SPF_##level) | |
35 | ||
36 | /* Transit Vertex */ | |
37 | struct ospf6_vertex { | |
38 | /* type of this vertex */ | |
39 | uint8_t type; | |
40 | ||
41 | /* Vertex Identifier */ | |
42 | struct prefix vertex_id; | |
43 | ||
44 | /* Identifier String */ | |
45 | char name[128]; | |
46 | ||
47 | /* Associated Area */ | |
48 | struct ospf6_area *area; | |
49 | ||
50 | /* Associated LSA */ | |
51 | struct ospf6_lsa *lsa; | |
52 | ||
53 | /* Distance from Root (i.e. Cost) */ | |
54 | uint32_t cost; | |
55 | ||
56 | /* Router hops to this node */ | |
57 | uint8_t hops; | |
58 | ||
59 | /* capability bits */ | |
60 | uint8_t capability; | |
61 | ||
62 | /* Optional capabilities */ | |
63 | uint8_t options[3]; | |
64 | ||
65 | /* For tree display */ | |
66 | struct ospf6_vertex *parent; | |
67 | struct list *child_list; | |
68 | ||
69 | /* nexthops to this node */ | |
70 | struct list *nh_list; | |
71 | uint32_t link_id; | |
72 | }; | |
73 | ||
74 | #define OSPF6_VERTEX_TYPE_ROUTER 0x01 | |
75 | #define OSPF6_VERTEX_TYPE_NETWORK 0x02 | |
76 | #define VERTEX_IS_TYPE(t, v) ((v)->type == OSPF6_VERTEX_TYPE_##t ? 1 : 0) | |
77 | ||
78 | /* What triggered the SPF? */ | |
79 | #define OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED (1 << 0) | |
80 | #define OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED (1 << 1) | |
81 | #define OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED (1 << 2) | |
82 | #define OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED (1 << 3) | |
83 | #define OSPF6_SPF_FLAGS_LINK_LSA_ADDED (1 << 4) | |
84 | #define OSPF6_SPF_FLAGS_LINK_LSA_REMOVED (1 << 5) | |
85 | #define OSPF6_SPF_FLAGS_ROUTER_LSA_ORIGINATED (1 << 6) | |
86 | #define OSPF6_SPF_FLAGS_NETWORK_LSA_ORIGINATED (1 << 7) | |
87 | ||
88 | static inline void ospf6_set_spf_reason(struct ospf6 *ospf, unsigned int reason) | |
89 | { | |
90 | ospf->spf_reason |= reason; | |
91 | } | |
92 | ||
93 | static inline void ospf6_reset_spf_reason(struct ospf6 *ospf) | |
94 | { | |
95 | ospf->spf_reason = 0; | |
96 | } | |
97 | ||
98 | static inline unsigned int ospf6_lsadd_to_spf_reason(struct ospf6_lsa *lsa) | |
99 | { | |
100 | unsigned int reason = 0; | |
101 | ||
102 | switch (ntohs(lsa->header->type)) { | |
103 | case OSPF6_LSTYPE_ROUTER: | |
104 | reason = OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED; | |
105 | break; | |
106 | case OSPF6_LSTYPE_NETWORK: | |
107 | reason = OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED; | |
108 | break; | |
109 | case OSPF6_LSTYPE_LINK: | |
110 | reason = OSPF6_SPF_FLAGS_LINK_LSA_ADDED; | |
111 | break; | |
112 | default: | |
113 | break; | |
114 | } | |
115 | return (reason); | |
116 | } | |
117 | ||
118 | static inline unsigned int ospf6_lsremove_to_spf_reason(struct ospf6_lsa *lsa) | |
119 | { | |
120 | unsigned int reason = 0; | |
121 | ||
122 | switch (ntohs(lsa->header->type)) { | |
123 | case OSPF6_LSTYPE_ROUTER: | |
124 | reason = OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED; | |
125 | break; | |
126 | case OSPF6_LSTYPE_NETWORK: | |
127 | reason = OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED; | |
128 | break; | |
129 | case OSPF6_LSTYPE_LINK: | |
130 | reason = OSPF6_SPF_FLAGS_LINK_LSA_REMOVED; | |
131 | break; | |
132 | default: | |
133 | break; | |
134 | } | |
135 | return (reason); | |
136 | } | |
137 | ||
138 | extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table); | |
139 | extern void ospf6_spf_calculation(uint32_t router_id, | |
140 | struct ospf6_route_table *result_table, | |
141 | struct ospf6_area *oa); | |
142 | extern void ospf6_spf_schedule(struct ospf6 *ospf, unsigned int reason); | |
143 | ||
144 | extern void ospf6_spf_display_subtree(struct vty *vty, const char *prefix, | |
145 | int rest, struct ospf6_vertex *v); | |
146 | ||
147 | extern void ospf6_spf_config_write(struct vty *vty); | |
148 | extern int config_write_ospf6_debug_spf(struct vty *vty); | |
149 | extern void install_element_ospf6_debug_spf(void); | |
150 | extern void ospf6_spf_init(void); | |
151 | extern void ospf6_spf_reason_string(unsigned int reason, char *buf, int size); | |
152 | extern struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area, | |
153 | struct ospf6_lsdb *lsdb, | |
154 | uint32_t adv_router); | |
155 | extern void ospf6_remove_temp_router_lsa(struct ospf6_area *area); | |
156 | ||
157 | #endif /* OSPF6_SPF_H */ |