]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_spf.h
Merge pull request #5498 from mjstapp/sharp_with_labels
[mirror_frr.git] / ospf6d / ospf6_spf.h
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 "typesafe.h"
25 #include "ospf6_top.h"
26
27 /* Debug option */
28 extern unsigned char conf_debug_ospf6_spf;
29 #define OSPF6_DEBUG_SPF_PROCESS 0x01
30 #define OSPF6_DEBUG_SPF_TIME 0x02
31 #define OSPF6_DEBUG_SPF_DATABASE 0x04
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)
36
37 PREDECL_SKIPLIST_NONUNIQ(vertex_pqueue)
38 /* Transit Vertex */
39 struct ospf6_vertex {
40 /* type of this vertex */
41 uint8_t type;
42
43 /* Vertex Identifier */
44 struct prefix vertex_id;
45
46 struct vertex_pqueue_item pqi;
47
48 /* Identifier String */
49 char name[128];
50
51 /* Associated Area */
52 struct ospf6_area *area;
53
54 /* Associated LSA */
55 struct ospf6_lsa *lsa;
56
57 /* Distance from Root (i.e. Cost) */
58 uint32_t cost;
59
60 /* Router hops to this node */
61 uint8_t hops;
62
63 /* capability bits */
64 uint8_t capability;
65
66 /* Optional capabilities */
67 uint8_t options[3];
68
69 /* For tree display */
70 struct ospf6_vertex *parent;
71 struct list *child_list;
72
73 /* nexthops to this node */
74 struct list *nh_list;
75 uint32_t link_id;
76 };
77
78 #define OSPF6_VERTEX_TYPE_ROUTER 0x01
79 #define OSPF6_VERTEX_TYPE_NETWORK 0x02
80 #define VERTEX_IS_TYPE(t, v) ((v)->type == OSPF6_VERTEX_TYPE_##t ? 1 : 0)
81
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
92 static inline void ospf6_set_spf_reason(struct ospf6 *ospf, unsigned int reason)
93 {
94 ospf->spf_reason |= reason;
95 }
96
97 static inline void ospf6_reset_spf_reason(struct ospf6 *ospf)
98 {
99 ospf->spf_reason = 0;
100 }
101
102 static inline unsigned int ospf6_lsadd_to_spf_reason(struct ospf6_lsa *lsa)
103 {
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);
120 }
121
122 static inline unsigned int ospf6_lsremove_to_spf_reason(struct ospf6_lsa *lsa)
123 {
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);
140 }
141
142 extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table);
143 extern void ospf6_spf_calculation(uint32_t router_id,
144 struct ospf6_route_table *result_table,
145 struct ospf6_area *oa);
146 extern void ospf6_spf_schedule(struct ospf6 *ospf, unsigned int reason);
147
148 extern void ospf6_spf_display_subtree(struct vty *vty, const char *prefix,
149 int rest, struct ospf6_vertex *v);
150
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);
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);
160
161 #endif /* OSPF6_SPF_H */