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