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 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "memory.h" |
| 26 | #include "vty.h" |
| 27 | #include "linklist.h" |
| 28 | #include "prefix.h" |
| 29 | #include "table.h" |
| 30 | #include "thread.h" |
| 31 | #include "command.h" |
| 32 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | #include "ospf6_proto.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 34 | #include "ospf6_message.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 35 | #include "ospf6_lsa.h" |
| 36 | #include "ospf6_lsdb.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | #include "ospf6_route.h" |
| 38 | #include "ospf6_zebra.h" |
| 39 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 40 | #include "ospf6_top.h" |
| 41 | #include "ospf6_area.h" |
| 42 | #include "ospf6_interface.h" |
| 43 | #include "ospf6_neighbor.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 45 | #include "ospf6_flood.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 46 | #include "ospf6_asbr.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 47 | #include "ospf6_abr.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 48 | #include "ospf6_intra.h" |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 49 | #include "ospf6_spf.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 50 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | |
| 52 | /* global ospf6d variable */ |
| 53 | struct ospf6 *ospf6; |
| 54 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 55 | static void ospf6_disable (struct ospf6 *o); |
| 56 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 57 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 58 | ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 62 | case OSPF6_LSTYPE_AS_EXTERNAL: |
| 63 | ospf6_asbr_lsa_add (lsa); |
| 64 | break; |
| 65 | |
| 66 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 67 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 71 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 72 | ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 74 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 76 | case OSPF6_LSTYPE_AS_EXTERNAL: |
| 77 | ospf6_asbr_lsa_remove (lsa); |
| 78 | break; |
| 79 | |
| 80 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 81 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 85 | static void |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 86 | ospf6_top_route_hook_add (struct ospf6_route *route) |
| 87 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 88 | ospf6_abr_originate_summary (route); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 89 | ospf6_zebra_route_update_add (route); |
| 90 | } |
| 91 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 92 | static void |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 93 | ospf6_top_route_hook_remove (struct ospf6_route *route) |
| 94 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 95 | ospf6_abr_originate_summary (route); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 96 | ospf6_zebra_route_update_remove (route); |
| 97 | } |
| 98 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 99 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 100 | ospf6_top_brouter_hook_add (struct ospf6_route *route) |
| 101 | { |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 102 | ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix)); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 103 | ospf6_asbr_lsentry_add (route); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 104 | ospf6_abr_originate_summary (route); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 107 | static void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 108 | ospf6_top_brouter_hook_remove (struct ospf6_route *route) |
| 109 | { |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 110 | ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix)); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 111 | ospf6_asbr_lsentry_remove (route); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 112 | ospf6_abr_originate_summary (route); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 115 | static struct ospf6 * |
| 116 | ospf6_create (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 118 | struct ospf6 *o; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 120 | o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 121 | |
| 122 | /* initialize */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 123 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 124 | o->area_list = list_new (); |
| 125 | o->area_list->cmp = ospf6_area_cmp; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 126 | o->lsdb = ospf6_lsdb_create (o); |
| 127 | o->lsdb_self = ospf6_lsdb_create (o); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 128 | o->lsdb->hook_add = ospf6_top_lsdb_hook_add; |
| 129 | o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove; |
| 130 | |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 131 | o->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
| 132 | o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; |
| 133 | o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT; |
| 134 | o->spf_hold_multiplier = 1; |
| 135 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 136 | o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES); |
| 137 | o->route_table->scope = o; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 138 | o->route_table->hook_add = ospf6_top_route_hook_add; |
| 139 | o->route_table->hook_remove = ospf6_top_route_hook_remove; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 140 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 141 | o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS); |
| 142 | o->brouter_table->scope = o; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 143 | o->brouter_table->hook_add = ospf6_top_brouter_hook_add; |
| 144 | o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 145 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 146 | o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES); |
| 147 | o->external_table->scope = o; |
| 148 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 149 | o->external_id_table = route_table_init (); |
| 150 | |
| 151 | return o; |
| 152 | } |
| 153 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 154 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 155 | ospf6_delete (struct ospf6 *o) |
| 156 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 157 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 158 | struct ospf6_area *oa; |
| 159 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 160 | ospf6_disable (ospf6); |
| 161 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 162 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 163 | ospf6_area_delete (oa); |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 164 | |
| 165 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 166 | list_delete (o->area_list); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 167 | |
| 168 | ospf6_lsdb_delete (o->lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 169 | ospf6_lsdb_delete (o->lsdb_self); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 170 | |
| 171 | ospf6_route_table_delete (o->route_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 172 | ospf6_route_table_delete (o->brouter_table); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 173 | |
| 174 | ospf6_route_table_delete (o->external_table); |
| 175 | route_table_finish (o->external_id_table); |
| 176 | |
| 177 | XFREE (MTYPE_OSPF6_TOP, o); |
| 178 | } |
| 179 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 180 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 181 | ospf6_enable (struct ospf6 *o) |
| 182 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 183 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 184 | struct ospf6_area *oa; |
| 185 | |
| 186 | if (CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 187 | { |
| 188 | UNSET_FLAG (o->flag, OSPF6_DISABLED); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 189 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 190 | ospf6_area_enable (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 194 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 195 | ospf6_disable (struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 197 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 198 | struct ospf6_area *oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 199 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 200 | if (! CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 201 | { |
| 202 | SET_FLAG (o->flag, OSPF6_DISABLED); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 203 | |
| 204 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 205 | ospf6_area_disable (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 206 | |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 207 | /* XXX: This also changes persistent settings */ |
| 208 | ospf6_asbr_redistribute_reset(); |
| 209 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 210 | ospf6_lsdb_remove_all (o->lsdb); |
| 211 | ospf6_route_remove_all (o->route_table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 212 | ospf6_route_remove_all (o->brouter_table); |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 213 | |
| 214 | THREAD_OFF(o->maxage_remover); |
| 215 | THREAD_OFF(o->t_spf_calc); |
| 216 | THREAD_OFF(o->t_ase_calc); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 217 | } |
| 218 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 219 | |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 220 | int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 221 | ospf6_maxage_remover (struct thread *thread) |
| 222 | { |
| 223 | struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread); |
| 224 | struct ospf6_area *oa; |
| 225 | struct ospf6_interface *oi; |
| 226 | struct ospf6_neighbor *on; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 227 | struct listnode *i, *j, *k; |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 228 | int reschedule = 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 229 | |
| 230 | o->maxage_remover = (struct thread *) NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 231 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 232 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 233 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 234 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 235 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 236 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 237 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 238 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE && |
| 239 | on->state != OSPF6_NEIGHBOR_LOADING) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 240 | continue; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 241 | |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 242 | ospf6_maxage_remove (o); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 248 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 249 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 250 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 251 | { |
| 252 | if (ospf6_lsdb_maxage_remover (oi->lsdb)) |
| 253 | { |
| 254 | reschedule = 1; |
| 255 | } |
| 256 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 257 | |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 258 | if (ospf6_lsdb_maxage_remover (oa->lsdb)) |
| 259 | { |
| 260 | reschedule = 1; |
| 261 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 262 | } |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 263 | |
| 264 | if (ospf6_lsdb_maxage_remover (o->lsdb)) |
| 265 | { |
| 266 | reschedule = 1; |
| 267 | } |
| 268 | |
| 269 | if (reschedule) |
| 270 | { |
| 271 | ospf6_maxage_remove (o); |
| 272 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 273 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 278 | ospf6_maxage_remove (struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 280 | if (o && ! o->maxage_remover) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 281 | o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o, |
| 282 | OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 283 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 284 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 285 | /* start ospf6 */ |
| 286 | DEFUN (router_ospf6, |
| 287 | router_ospf6_cmd, |
| 288 | "router ospf6", |
| 289 | ROUTER_STR |
| 290 | OSPF6_STR) |
| 291 | { |
| 292 | if (ospf6 == NULL) |
| 293 | ospf6 = ospf6_create (); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 294 | |
| 295 | /* set current ospf point. */ |
| 296 | vty->node = OSPF6_NODE; |
| 297 | vty->index = ospf6; |
| 298 | |
| 299 | return CMD_SUCCESS; |
| 300 | } |
| 301 | |
| 302 | /* stop ospf6 */ |
| 303 | DEFUN (no_router_ospf6, |
| 304 | no_router_ospf6_cmd, |
| 305 | "no router ospf6", |
| 306 | NO_STR |
| 307 | OSPF6_ROUTER_STR) |
| 308 | { |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 309 | if (ospf6 == NULL) |
| 310 | vty_out (vty, "OSPFv3 is not configured%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 311 | else |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 312 | { |
| 313 | ospf6_delete (ospf6); |
| 314 | ospf6 = NULL; |
| 315 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 316 | |
| 317 | /* return to config node . */ |
| 318 | vty->node = CONFIG_NODE; |
| 319 | vty->index = NULL; |
| 320 | |
| 321 | return CMD_SUCCESS; |
| 322 | } |
| 323 | |
| 324 | /* change Router_ID commands. */ |
| 325 | DEFUN (ospf6_router_id, |
| 326 | ospf6_router_id_cmd, |
| 327 | "router-id A.B.C.D", |
| 328 | "Configure OSPF Router-ID\n" |
| 329 | V4NOTATION_STR) |
| 330 | { |
| 331 | int ret; |
| 332 | u_int32_t router_id; |
| 333 | struct ospf6 *o; |
| 334 | |
| 335 | o = (struct ospf6 *) vty->index; |
| 336 | |
| 337 | ret = inet_pton (AF_INET, argv[0], &router_id); |
| 338 | if (ret == 0) |
| 339 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 340 | vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 341 | return CMD_SUCCESS; |
| 342 | } |
| 343 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 344 | o->router_id_static = router_id; |
| 345 | if (o->router_id == 0) |
| 346 | o->router_id = router_id; |
| 347 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 348 | return CMD_SUCCESS; |
| 349 | } |
| 350 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 351 | DEFUN (ospf6_log_adjacency_changes, |
| 352 | ospf6_log_adjacency_changes_cmd, |
| 353 | "log-adjacency-changes", |
| 354 | "Log changes in adjacency state\n") |
| 355 | { |
| 356 | struct ospf6 *ospf6 = vty->index; |
| 357 | |
| 358 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 359 | return CMD_SUCCESS; |
| 360 | } |
| 361 | |
| 362 | DEFUN (ospf6_log_adjacency_changes_detail, |
| 363 | ospf6_log_adjacency_changes_detail_cmd, |
| 364 | "log-adjacency-changes detail", |
| 365 | "Log changes in adjacency state\n" |
| 366 | "Log all state changes\n") |
| 367 | { |
| 368 | struct ospf6 *ospf6 = vty->index; |
| 369 | |
| 370 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 371 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 372 | return CMD_SUCCESS; |
| 373 | } |
| 374 | |
| 375 | DEFUN (no_ospf6_log_adjacency_changes, |
| 376 | no_ospf6_log_adjacency_changes_cmd, |
| 377 | "no log-adjacency-changes", |
| 378 | NO_STR |
| 379 | "Log changes in adjacency state\n") |
| 380 | { |
| 381 | struct ospf6 *ospf6 = vty->index; |
| 382 | |
| 383 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 384 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 385 | return CMD_SUCCESS; |
| 386 | } |
| 387 | |
| 388 | DEFUN (no_ospf6_log_adjacency_changes_detail, |
| 389 | no_ospf6_log_adjacency_changes_detail_cmd, |
| 390 | "no log-adjacency-changes detail", |
| 391 | NO_STR |
| 392 | "Log changes in adjacency state\n" |
| 393 | "Log all state changes\n") |
| 394 | { |
| 395 | struct ospf6 *ospf6 = vty->index; |
| 396 | |
| 397 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 398 | return CMD_SUCCESS; |
| 399 | } |
| 400 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 401 | DEFUN (ospf6_interface_area, |
| 402 | ospf6_interface_area_cmd, |
| 403 | "interface IFNAME area A.B.C.D", |
| 404 | "Enable routing on an IPv6 interface\n" |
| 405 | IFNAME_STR |
| 406 | "Specify the OSPF6 area ID\n" |
| 407 | "OSPF6 area ID in IPv4 address notation\n" |
| 408 | ) |
| 409 | { |
| 410 | struct ospf6 *o; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 411 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 412 | struct ospf6_interface *oi; |
| 413 | struct interface *ifp; |
| 414 | u_int32_t area_id; |
| 415 | |
| 416 | o = (struct ospf6 *) vty->index; |
| 417 | |
| 418 | /* find/create ospf6 interface */ |
| 419 | ifp = if_get_by_name (argv[0]); |
| 420 | oi = (struct ospf6_interface *) ifp->info; |
| 421 | if (oi == NULL) |
| 422 | oi = ospf6_interface_create (ifp); |
| 423 | if (oi->area) |
| 424 | { |
| 425 | vty_out (vty, "%s already attached to Area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 426 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 427 | return CMD_SUCCESS; |
| 428 | } |
| 429 | |
| 430 | /* parse Area-ID */ |
| 431 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 432 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 433 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 434 | return CMD_SUCCESS; |
| 435 | } |
| 436 | |
| 437 | /* find/create ospf6 area */ |
| 438 | oa = ospf6_area_lookup (area_id, o); |
| 439 | if (oa == NULL) |
| 440 | oa = ospf6_area_create (area_id, o); |
| 441 | |
| 442 | /* attach interface to area */ |
| 443 | listnode_add (oa->if_list, oi); /* sort ?? */ |
| 444 | oi->area = oa; |
| 445 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 446 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
| 447 | |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 448 | /* ospf6 process is currently disabled, not much more to do */ |
| 449 | if (CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 450 | return CMD_SUCCESS; |
| 451 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 452 | /* start up */ |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 453 | ospf6_interface_enable (oi); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 454 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 455 | /* If the router is ABR, originate summary routes */ |
| 456 | if (ospf6_is_router_abr (o)) |
| 457 | ospf6_abr_enable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 458 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 459 | return CMD_SUCCESS; |
| 460 | } |
| 461 | |
| 462 | DEFUN (no_ospf6_interface_area, |
| 463 | no_ospf6_interface_area_cmd, |
| 464 | "no interface IFNAME area A.B.C.D", |
| 465 | NO_STR |
| 466 | "Disable routing on an IPv6 interface\n" |
| 467 | IFNAME_STR |
| 468 | "Specify the OSPF6 area ID\n" |
| 469 | "OSPF6 area ID in IPv4 address notation\n" |
| 470 | ) |
| 471 | { |
| 472 | struct ospf6 *o; |
| 473 | struct ospf6_interface *oi; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 474 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 475 | struct interface *ifp; |
| 476 | u_int32_t area_id; |
| 477 | |
| 478 | o = (struct ospf6 *) vty->index; |
| 479 | |
| 480 | ifp = if_lookup_by_name (argv[0]); |
| 481 | if (ifp == NULL) |
| 482 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 483 | vty_out (vty, "No such interface %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 484 | return CMD_SUCCESS; |
| 485 | } |
| 486 | |
| 487 | oi = (struct ospf6_interface *) ifp->info; |
| 488 | if (oi == NULL) |
| 489 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 490 | vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 491 | return CMD_SUCCESS; |
| 492 | } |
| 493 | |
| 494 | /* parse Area-ID */ |
| 495 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 496 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 497 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 498 | return CMD_SUCCESS; |
| 499 | } |
| 500 | |
Jon | 56abbb8 | 2009-02-11 17:30:44 -0800 | [diff] [blame] | 501 | /* Verify Area */ |
| 502 | if (oi->area == NULL) |
| 503 | { |
| 504 | vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL); |
| 505 | return CMD_SUCCESS; |
| 506 | } |
| 507 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 508 | if (oi->area->area_id != area_id) |
| 509 | { |
| 510 | vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 511 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 512 | return CMD_SUCCESS; |
| 513 | } |
| 514 | |
| 515 | thread_execute (master, interface_down, oi, 0); |
| 516 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 517 | oa = oi->area; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 518 | listnode_delete (oi->area->if_list, oi); |
| 519 | oi->area = (struct ospf6_area *) NULL; |
| 520 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 521 | /* Withdraw inter-area routes from this area, if necessary */ |
| 522 | if (oa->if_list->count == 0) |
| 523 | { |
| 524 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 525 | ospf6_abr_disable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 526 | } |
| 527 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 528 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | } |
| 530 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 531 | DEFUN (ospf6_stub_router_admin, |
| 532 | ospf6_stub_router_admin_cmd, |
| 533 | "stub-router administrative", |
| 534 | "Make router a stub router\n" |
| 535 | "Advertise inability to be a transit router\n" |
| 536 | "Administratively applied, for an indefinite period\n") |
| 537 | { |
| 538 | struct listnode *node; |
| 539 | struct ospf6_area *oa; |
| 540 | |
| 541 | if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 542 | { |
| 543 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
| 544 | { |
| 545 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6); |
| 546 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R); |
| 547 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 548 | } |
| 549 | SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER); |
| 550 | } |
| 551 | |
| 552 | return CMD_SUCCESS; |
| 553 | } |
| 554 | |
| 555 | DEFUN (no_ospf6_stub_router_admin, |
| 556 | no_ospf6_stub_router_admin_cmd, |
| 557 | "no stub-router administrative", |
| 558 | NO_STR |
| 559 | "Make router a stub router\n" |
| 560 | "Advertise ability to be a transit router\n" |
| 561 | "Administratively applied, for an indefinite period\n") |
| 562 | { |
| 563 | struct listnode *node; |
| 564 | struct ospf6_area *oa; |
| 565 | |
| 566 | if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 567 | { |
| 568 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
| 569 | { |
| 570 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); |
| 571 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); |
| 572 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 573 | } |
| 574 | UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER); |
| 575 | } |
| 576 | |
| 577 | return CMD_SUCCESS; |
| 578 | } |
| 579 | |
| 580 | DEFUN (ospf6_stub_router_startup, |
| 581 | ospf6_stub_router_startup_cmd, |
| 582 | "stub-router on-startup <5-86400>", |
| 583 | "Make router a stub router\n" |
| 584 | "Advertise inability to be a transit router\n" |
| 585 | "Automatically advertise as stub-router on startup of OSPF6\n" |
| 586 | "Time (seconds) to advertise self as stub-router\n") |
| 587 | { |
| 588 | return CMD_SUCCESS; |
| 589 | } |
| 590 | |
| 591 | DEFUN (no_ospf6_stub_router_startup, |
| 592 | no_ospf6_stub_router_startup_cmd, |
| 593 | "no stub-router on-startup", |
| 594 | NO_STR |
| 595 | "Make router a stub router\n" |
| 596 | "Advertise inability to be a transit router\n" |
| 597 | "Automatically advertise as stub-router on startup of OSPF6\n" |
| 598 | "Time (seconds) to advertise self as stub-router\n") |
| 599 | { |
| 600 | return CMD_SUCCESS; |
| 601 | } |
| 602 | |
| 603 | DEFUN (ospf6_stub_router_shutdown, |
| 604 | ospf6_stub_router_shutdown_cmd, |
| 605 | "stub-router on-shutdown <5-86400>", |
| 606 | "Make router a stub router\n" |
| 607 | "Advertise inability to be a transit router\n" |
| 608 | "Automatically advertise as stub-router before shutdown\n" |
| 609 | "Time (seconds) to advertise self as stub-router\n") |
| 610 | { |
| 611 | return CMD_SUCCESS; |
| 612 | } |
| 613 | |
| 614 | DEFUN (no_ospf6_stub_router_shutdown, |
| 615 | no_ospf6_stub_router_shutdown_cmd, |
| 616 | "no stub-router on-shutdown", |
| 617 | NO_STR |
| 618 | "Make router a stub router\n" |
| 619 | "Advertise inability to be a transit router\n" |
| 620 | "Automatically advertise as stub-router before shutdown\n" |
| 621 | "Time (seconds) to advertise self as stub-router\n") |
| 622 | { |
| 623 | return CMD_SUCCESS; |
| 624 | } |
| 625 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 626 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 627 | ospf6_show (struct vty *vty, struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 628 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 629 | struct listnode *n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 630 | struct ospf6_area *oa; |
| 631 | char router_id[16], duration[32]; |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 632 | struct timeval now, running, result; |
| 633 | char buf[32], rbuf[32]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 634 | |
| 635 | /* process id, router id */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 636 | inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id)); |
| 637 | vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 638 | router_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | |
| 640 | /* running time */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 641 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 642 | timersub (&now, &o->starttime, &running); |
| 643 | timerstring (&running, duration, sizeof (duration)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 644 | vty_out (vty, " Running %s%s", duration, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 645 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 646 | /* Redistribute configuration */ |
| 647 | /* XXX */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 648 | |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 649 | /* Show SPF parameters */ |
| 650 | vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 651 | " Minimum hold time between consecutive SPFs %d millsecond(s)%s" |
| 652 | " Maximum hold time between consecutive SPFs %d millsecond(s)%s" |
| 653 | " Hold time multiplier is currently %d%s", |
| 654 | o->spf_delay, VNL, |
| 655 | o->spf_holdtime, VNL, |
| 656 | o->spf_max_holdtime, VNL, |
| 657 | o->spf_hold_multiplier, VNL); |
| 658 | |
| 659 | vty_out(vty, " SPF algorithm "); |
| 660 | if (o->ts_spf.tv_sec || o->ts_spf.tv_usec) |
| 661 | { |
| 662 | timersub(&now, &o->ts_spf, &result); |
| 663 | timerstring(&result, buf, sizeof(buf)); |
| 664 | ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf)); |
| 665 | vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL); |
| 666 | vty_out (vty, " Last SPF duration %ld sec %ld usec%s", |
| 667 | o->ts_spf_duration.tv_sec, o->ts_spf_duration.tv_usec, VNL); |
| 668 | } |
| 669 | else |
| 670 | vty_out(vty, "has not been run$%s", VNL); |
| 671 | threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf)); |
| 672 | vty_out (vty, " SPF timer %s%s%s", |
| 673 | (o->t_spf_calc ? "due in " : "is "), buf, VNL); |
| 674 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 675 | if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER)) |
| 676 | vty_out (vty, " Router Is Stub Router%s", VNL); |
| 677 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 678 | /* LSAs */ |
| 679 | vty_out (vty, " Number of AS scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 680 | o->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 681 | |
| 682 | /* Areas */ |
| 683 | vty_out (vty, " Number of areas in this router is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 684 | listcount (o->area_list), VNL); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 685 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 686 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) |
| 687 | { |
| 688 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) |
| 689 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 690 | else |
| 691 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 692 | } |
| 693 | |
| 694 | vty_out (vty, "%s",VTY_NEWLINE); |
| 695 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 696 | for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa)) |
| 697 | ospf6_area_show (vty, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 698 | } |
| 699 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 700 | /* show top level structures */ |
| 701 | DEFUN (show_ipv6_ospf6, |
| 702 | show_ipv6_ospf6_cmd, |
| 703 | "show ipv6 ospf6", |
| 704 | SHOW_STR |
| 705 | IP6_STR |
| 706 | OSPF6_STR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 707 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 708 | OSPF6_CMD_CHECK_RUNNING (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 710 | ospf6_show (vty, ospf6); |
| 711 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | DEFUN (show_ipv6_ospf6_route, |
| 715 | show_ipv6_ospf6_route_cmd, |
| 716 | "show ipv6 ospf6 route", |
| 717 | SHOW_STR |
| 718 | IP6_STR |
| 719 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 720 | ROUTE_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | ) |
| 722 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 723 | ospf6_route_table_show (vty, argc, argv, ospf6->route_table); |
| 724 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | ALIAS (show_ipv6_ospf6_route, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 728 | show_ipv6_ospf6_route_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 729 | "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 730 | SHOW_STR |
| 731 | IP6_STR |
| 732 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 733 | ROUTE_STR |
| 734 | "Specify IPv6 address\n" |
| 735 | "Specify IPv6 prefix\n" |
| 736 | "Detailed information\n" |
| 737 | "Summary of route table\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 738 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 739 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 740 | DEFUN (show_ipv6_ospf6_route_match, |
| 741 | show_ipv6_ospf6_route_match_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 742 | "show ipv6 ospf6 route X:X::X:X/M match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 743 | SHOW_STR |
| 744 | IP6_STR |
| 745 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 746 | ROUTE_STR |
| 747 | "Specify IPv6 prefix\n" |
| 748 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 749 | ) |
| 750 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 751 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 752 | int i, sargc; |
| 753 | |
| 754 | /* copy argv to sargv and then append "match" */ |
| 755 | for (i = 0; i < argc; i++) |
| 756 | sargv[i] = argv[i]; |
| 757 | sargc = argc; |
| 758 | sargv[sargc++] = "match"; |
| 759 | sargv[sargc] = NULL; |
| 760 | |
| 761 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 762 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 763 | } |
| 764 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 765 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 766 | show_ipv6_ospf6_route_match_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 767 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 768 | SHOW_STR |
| 769 | IP6_STR |
| 770 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 771 | ROUTE_STR |
| 772 | "Specify IPv6 prefix\n" |
| 773 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 774 | "Detailed information\n" |
| 775 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 776 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 777 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 778 | int i, sargc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 779 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 780 | /* copy argv to sargv and then append "match" and "detail" */ |
| 781 | for (i = 0; i < argc; i++) |
| 782 | sargv[i] = argv[i]; |
| 783 | sargc = argc; |
| 784 | sargv[sargc++] = "match"; |
| 785 | sargv[sargc++] = "detail"; |
| 786 | sargv[sargc] = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 788 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 789 | return CMD_SUCCESS; |
| 790 | } |
| 791 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 792 | ALIAS (show_ipv6_ospf6_route_match, |
| 793 | show_ipv6_ospf6_route_longer_cmd, |
| 794 | "show ipv6 ospf6 route X:X::X:X/M longer", |
| 795 | SHOW_STR |
| 796 | IP6_STR |
| 797 | OSPF6_STR |
| 798 | ROUTE_STR |
| 799 | "Specify IPv6 prefix\n" |
| 800 | "Display routes longer than the specified route\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 801 | ) |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 802 | |
| 803 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 804 | show_ipv6_ospf6_route_longer_detail_cmd, |
| 805 | "show ipv6 ospf6 route X:X::X:X/M longer detail", |
| 806 | SHOW_STR |
| 807 | IP6_STR |
| 808 | OSPF6_STR |
| 809 | ROUTE_STR |
| 810 | "Specify IPv6 prefix\n" |
| 811 | "Display routes longer than the specified route\n" |
| 812 | "Detailed information\n" |
| 813 | ); |
| 814 | |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 815 | ALIAS (show_ipv6_ospf6_route, |
| 816 | show_ipv6_ospf6_route_type_cmd, |
| 817 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", |
| 818 | SHOW_STR |
| 819 | IP6_STR |
| 820 | OSPF6_STR |
| 821 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 822 | "Display Intra-Area routes\n" |
| 823 | "Display Inter-Area routes\n" |
| 824 | "Display Type-1 External routes\n" |
| 825 | "Display Type-2 External routes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 826 | ) |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 827 | |
| 828 | DEFUN (show_ipv6_ospf6_route_type_detail, |
| 829 | show_ipv6_ospf6_route_type_detail_cmd, |
| 830 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", |
| 831 | SHOW_STR |
| 832 | IP6_STR |
| 833 | OSPF6_STR |
| 834 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 835 | "Display Intra-Area routes\n" |
| 836 | "Display Inter-Area routes\n" |
| 837 | "Display Type-1 External routes\n" |
| 838 | "Display Type-2 External routes\n" |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 839 | "Detailed information\n" |
| 840 | ) |
| 841 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 842 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 843 | int i, sargc; |
| 844 | |
| 845 | /* copy argv to sargv and then append "detail" */ |
| 846 | for (i = 0; i < argc; i++) |
| 847 | sargv[i] = argv[i]; |
| 848 | sargc = argc; |
| 849 | sargv[sargc++] = "detail"; |
| 850 | sargv[sargc] = NULL; |
| 851 | |
| 852 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 853 | return CMD_SUCCESS; |
| 854 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 855 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 856 | static void |
| 857 | ospf6_stub_router_config_write (struct vty *vty) |
| 858 | { |
| 859 | if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 860 | { |
| 861 | vty_out (vty, " stub-router administrative%s", VNL); |
| 862 | } |
| 863 | return; |
| 864 | } |
| 865 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 866 | /* OSPF configuration write function. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 867 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 868 | config_write_ospf6 (struct vty *vty) |
| 869 | { |
| 870 | char router_id[16]; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 871 | struct listnode *j, *k; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 872 | struct ospf6_area *oa; |
| 873 | struct ospf6_interface *oi; |
| 874 | |
| 875 | /* OSPFv6 configuration. */ |
| 876 | if (ospf6 == NULL) |
| 877 | return CMD_SUCCESS; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 878 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 879 | inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 880 | vty_out (vty, "router ospf6%s", VNL); |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 881 | if (ospf6->router_id_static != 0) |
| 882 | vty_out (vty, " router-id %s%s", router_id, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 883 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 884 | /* log-adjacency-changes flag print. */ |
| 885 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) |
| 886 | { |
| 887 | vty_out(vty, " log-adjacency-changes"); |
| 888 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) |
| 889 | vty_out(vty, " detail"); |
| 890 | vty_out(vty, "%s", VTY_NEWLINE); |
| 891 | } |
| 892 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 893 | ospf6_stub_router_config_write (vty); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 894 | ospf6_redistribute_config_write (vty); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 895 | ospf6_area_config_write (vty); |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 896 | ospf6_spf_config_write (vty); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 897 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 898 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 899 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 900 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi)) |
| 901 | vty_out (vty, " interface %s area %s%s", |
| 902 | oi->interface->name, oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 903 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 904 | vty_out (vty, "!%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 905 | return 0; |
| 906 | } |
| 907 | |
| 908 | /* OSPF6 node structure. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 909 | static struct cmd_node ospf6_node = |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 910 | { |
| 911 | OSPF6_NODE, |
| 912 | "%s(config-ospf6)# ", |
hasso | 69b4a81 | 2004-08-26 18:10:36 +0000 | [diff] [blame] | 913 | 1 /* VTYSH */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 914 | }; |
| 915 | |
| 916 | /* Install ospf related commands. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 918 | ospf6_top_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 919 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 920 | /* Install ospf6 top node. */ |
| 921 | install_node (&ospf6_node, config_write_ospf6); |
| 922 | |
| 923 | install_element (VIEW_NODE, &show_ipv6_ospf6_cmd); |
| 924 | install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd); |
| 925 | install_element (CONFIG_NODE, &router_ospf6_cmd); |
Jon | 6c19d26 | 2009-02-11 17:19:07 -0800 | [diff] [blame] | 926 | install_element (CONFIG_NODE, &no_router_ospf6_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 927 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 928 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 929 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); |
| 930 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); |
| 931 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 932 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd); |
| 933 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 934 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); |
| 935 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 937 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd); |
| 938 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd); |
| 939 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 940 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd); |
| 941 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 942 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd); |
| 943 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 944 | |
| 945 | install_default (OSPF6_NODE); |
| 946 | install_element (OSPF6_NODE, &ospf6_router_id_cmd); |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 947 | install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd); |
| 948 | install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd); |
| 949 | install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd); |
| 950 | install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 951 | install_element (OSPF6_NODE, &ospf6_interface_area_cmd); |
| 952 | install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 953 | install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd); |
| 954 | install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd); |
| 955 | /* For a later time |
| 956 | install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd); |
| 957 | install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd); |
| 958 | install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd); |
| 959 | install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd); |
| 960 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 961 | } |
| 962 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 963 | |