paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
| 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. |
| 20 | */ |
| 21 | |
| 22 | #ifndef OSPF6_SPF_H |
| 23 | #define OSPF6_SPF_H |
| 24 | |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 25 | #include "ospf6_top.h" |
| 26 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 27 | /* Debug option */ |
| 28 | extern unsigned char conf_debug_ospf6_spf; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 29 | #define OSPF6_DEBUG_SPF_PROCESS 0x01 |
| 30 | #define OSPF6_DEBUG_SPF_TIME 0x02 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 31 | #define OSPF6_DEBUG_SPF_DATABASE 0x04 |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 32 | #define OSPF6_DEBUG_SPF_ON(level) \ |
| 33 | (conf_debug_ospf6_spf |= (level)) |
| 34 | #define OSPF6_DEBUG_SPF_OFF(level) \ |
| 35 | (conf_debug_ospf6_spf &= ~(level)) |
| 36 | #define IS_OSPF6_DEBUG_SPF(level) \ |
| 37 | (conf_debug_ospf6_spf & OSPF6_DEBUG_SPF_ ## level) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | |
| 39 | /* Transit Vertex */ |
| 40 | struct ospf6_vertex |
| 41 | { |
| 42 | /* type of this vertex */ |
| 43 | u_int8_t type; |
| 44 | |
| 45 | /* Vertex Identifier */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 46 | struct prefix vertex_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 47 | |
| 48 | /* Identifier String */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 49 | char name[128]; |
| 50 | |
| 51 | /* Associated Area */ |
| 52 | struct ospf6_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | |
| 54 | /* Associated LSA */ |
| 55 | struct ospf6_lsa *lsa; |
| 56 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 57 | /* Distance from Root (i.e. Cost) */ |
| 58 | u_int32_t cost; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | /* Router hops to this node */ |
| 61 | u_char hops; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | |
| 63 | /* nexthops to this node */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 64 | struct ospf6_nexthop nexthop[OSPF6_MULTI_PATH_LIMIT]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 65 | |
| 66 | /* capability bits */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 67 | u_char capability; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | |
| 69 | /* Optional capabilities */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 70 | u_char options[3]; |
| 71 | |
| 72 | /* For tree display */ |
| 73 | struct ospf6_vertex *parent; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 74 | struct list *child_list; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | #define OSPF6_VERTEX_TYPE_ROUTER 0x01 |
| 78 | #define OSPF6_VERTEX_TYPE_NETWORK 0x02 |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 79 | #define VERTEX_IS_TYPE(t, v) \ |
| 80 | ((v)->type == OSPF6_VERTEX_TYPE_ ## t ? 1 : 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 81 | |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame^] | 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 |
| 93 | ospf6_set_spf_reason (struct ospf6* ospf, unsigned int reason) |
| 94 | { |
| 95 | ospf->spf_reason |= reason; |
| 96 | } |
| 97 | |
| 98 | static inline void |
| 99 | ospf6_reset_spf_reason (struct ospf6 *ospf) |
| 100 | { |
| 101 | ospf->spf_reason = 0; |
| 102 | } |
| 103 | |
| 104 | static inline unsigned int |
| 105 | ospf6_lsadd_to_spf_reason (struct ospf6_lsa *lsa) |
| 106 | { |
| 107 | unsigned int reason = 0; |
| 108 | |
| 109 | switch (ntohs (lsa->header->type)) |
| 110 | { |
| 111 | case OSPF6_LSTYPE_ROUTER: |
| 112 | reason = OSPF6_SPF_FLAGS_ROUTER_LSA_ADDED; |
| 113 | break; |
| 114 | case OSPF6_LSTYPE_NETWORK: |
| 115 | reason = OSPF6_SPF_FLAGS_NETWORK_LSA_ADDED; |
| 116 | break; |
| 117 | case OSPF6_LSTYPE_LINK: |
| 118 | reason = OSPF6_SPF_FLAGS_LINK_LSA_ADDED; |
| 119 | break; |
| 120 | default: |
| 121 | break; |
| 122 | } |
| 123 | return (reason); |
| 124 | } |
| 125 | |
| 126 | static inline unsigned int |
| 127 | ospf6_lsremove_to_spf_reason (struct ospf6_lsa *lsa) |
| 128 | { |
| 129 | unsigned int reason = 0; |
| 130 | |
| 131 | switch (ntohs (lsa->header->type)) |
| 132 | { |
| 133 | case OSPF6_LSTYPE_ROUTER: |
| 134 | reason = OSPF6_SPF_FLAGS_ROUTER_LSA_REMOVED; |
| 135 | break; |
| 136 | case OSPF6_LSTYPE_NETWORK: |
| 137 | reason = OSPF6_SPF_FLAGS_NETWORK_LSA_REMOVED; |
| 138 | break; |
| 139 | case OSPF6_LSTYPE_LINK: |
| 140 | reason = OSPF6_SPF_FLAGS_LINK_LSA_REMOVED; |
| 141 | break; |
| 142 | default: |
| 143 | break; |
| 144 | } |
| 145 | return (reason); |
| 146 | } |
| 147 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 148 | extern void ospf6_spf_table_finish (struct ospf6_route_table *result_table); |
| 149 | extern void ospf6_spf_calculation (u_int32_t router_id, |
| 150 | struct ospf6_route_table *result_table, |
| 151 | struct ospf6_area *oa); |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame^] | 152 | extern void ospf6_spf_schedule (struct ospf6 *ospf, unsigned int reason); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 153 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 154 | extern void ospf6_spf_display_subtree (struct vty *vty, const char *prefix, |
| 155 | int rest, struct ospf6_vertex *v); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 157 | extern void ospf6_spf_config_write (struct vty *vty); |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 158 | extern int config_write_ospf6_debug_spf (struct vty *vty); |
| 159 | extern void install_element_ospf6_debug_spf (void); |
| 160 | extern void ospf6_spf_init (void); |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame^] | 161 | extern void ospf6_spf_reason_string (unsigned int reason, char *buf, int size); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 162 | |
| 163 | #endif /* OSPF6_SPF_H */ |
| 164 | |