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