]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_spf.h
debianpkg: Add missing XSBC-Original-Maintainer field (fixes merge error)
[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 *
16 * You should have received a copy of the GNU General Public License
ac4d0be5 17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
718e3744 20 */
21
22#ifndef OSPF6_SPF_H
23#define OSPF6_SPF_H
24
3810e06e
DD
25#include "ospf6_top.h"
26
508e53e2 27/* Debug option */
28extern 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
ac4d0be5 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
37/* Transit Vertex */
ac4d0be5 38struct ospf6_vertex {
39 /* type of this vertex */
40 u_int8_t type;
718e3744 41
ac4d0be5 42 /* Vertex Identifier */
43 struct prefix vertex_id;
718e3744 44
ac4d0be5 45 /* Identifier String */
46 char name[128];
508e53e2 47
ac4d0be5 48 /* Associated Area */
49 struct ospf6_area *area;
718e3744 50
ac4d0be5 51 /* Associated LSA */
52 struct ospf6_lsa *lsa;
718e3744 53
ac4d0be5 54 /* Distance from Root (i.e. Cost) */
55 u_int32_t cost;
718e3744 56
ac4d0be5 57 /* Router hops to this node */
58 u_char hops;
718e3744 59
ac4d0be5 60 /* capability bits */
61 u_char capability;
718e3744 62
ac4d0be5 63 /* Optional capabilities */
64 u_char options[3];
508e53e2 65
ac4d0be5 66 /* For tree display */
67 struct ospf6_vertex *parent;
68 struct list *child_list;
c3c0ac83 69
ac4d0be5 70 /* nexthops to this node */
71 struct list *nh_list;
718e3744 72};
73
74#define OSPF6_VERTEX_TYPE_ROUTER 0x01
75#define OSPF6_VERTEX_TYPE_NETWORK 0x02
ac4d0be5 76#define VERTEX_IS_TYPE(t, v) ((v)->type == OSPF6_VERTEX_TYPE_##t ? 1 : 0)
718e3744 77
a0edf674
DD
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
ac4d0be5 88static inline void ospf6_set_spf_reason(struct ospf6 *ospf, unsigned int reason)
a0edf674 89{
ac4d0be5 90 ospf->spf_reason |= reason;
a0edf674
DD
91}
92
ac4d0be5 93static inline void ospf6_reset_spf_reason(struct ospf6 *ospf)
a0edf674 94{
ac4d0be5 95 ospf->spf_reason = 0;
a0edf674
DD
96}
97
ac4d0be5 98static inline unsigned int ospf6_lsadd_to_spf_reason(struct ospf6_lsa *lsa)
a0edf674 99{
ac4d0be5 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);
a0edf674
DD
116}
117
ac4d0be5 118static inline unsigned int ospf6_lsremove_to_spf_reason(struct ospf6_lsa *lsa)
a0edf674 119{
ac4d0be5 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);
a0edf674
DD
136}
137
ac4d0be5 138extern void ospf6_spf_table_finish(struct ospf6_route_table *result_table);
139extern void ospf6_spf_calculation(u_int32_t router_id,
140 struct ospf6_route_table *result_table,
141 struct ospf6_area *oa);
142extern void ospf6_spf_schedule(struct ospf6 *ospf, unsigned int reason);
6ac29a51 143
ac4d0be5 144extern void ospf6_spf_display_subtree(struct vty *vty, const char *prefix,
145 int rest, struct ospf6_vertex *v);
6ac29a51 146
ac4d0be5 147extern void ospf6_spf_config_write(struct vty *vty);
148extern int config_write_ospf6_debug_spf(struct vty *vty);
149extern void install_element_ospf6_debug_spf(void);
150extern void ospf6_spf_init(void);
151extern void ospf6_spf_reason_string(unsigned int reason, char *buf, int size);
718e3744 152
153#endif /* OSPF6_SPF_H */