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