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