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 | |
Vincent Bernat | fd50068 | 2012-10-24 14:45:54 +0000 | [diff] [blame] | 151 | o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH; |
| 152 | |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 153 | o->distance_table = route_table_init (); |
| 154 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 155 | return o; |
| 156 | } |
| 157 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 158 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 159 | ospf6_delete (struct ospf6 *o) |
| 160 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 161 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 162 | struct ospf6_area *oa; |
| 163 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 164 | ospf6_disable (ospf6); |
| 165 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 166 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 167 | ospf6_area_delete (oa); |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 168 | |
| 169 | |
Tom Goff | ae2254a | 2010-11-10 13:01:41 -0800 | [diff] [blame] | 170 | list_delete (o->area_list); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 171 | |
| 172 | ospf6_lsdb_delete (o->lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 173 | ospf6_lsdb_delete (o->lsdb_self); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 174 | |
| 175 | ospf6_route_table_delete (o->route_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 176 | ospf6_route_table_delete (o->brouter_table); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 177 | |
| 178 | ospf6_route_table_delete (o->external_table); |
| 179 | route_table_finish (o->external_id_table); |
| 180 | |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 181 | ospf6_distance_reset (o); |
| 182 | route_table_finish (o->distance_table); |
| 183 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 184 | XFREE (MTYPE_OSPF6_TOP, o); |
| 185 | } |
| 186 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 187 | static void |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 188 | __attribute__((unused)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 189 | ospf6_enable (struct ospf6 *o) |
| 190 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 191 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 192 | struct ospf6_area *oa; |
| 193 | |
| 194 | if (CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 195 | { |
| 196 | UNSET_FLAG (o->flag, OSPF6_DISABLED); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 197 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 198 | ospf6_area_enable (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 202 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 203 | ospf6_disable (struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 205 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 206 | struct ospf6_area *oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 208 | if (! CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 209 | { |
| 210 | SET_FLAG (o->flag, OSPF6_DISABLED); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 211 | |
| 212 | for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa)) |
| 213 | ospf6_area_disable (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 214 | |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 215 | /* XXX: This also changes persistent settings */ |
| 216 | ospf6_asbr_redistribute_reset(); |
| 217 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 218 | ospf6_lsdb_remove_all (o->lsdb); |
| 219 | ospf6_route_remove_all (o->route_table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 220 | ospf6_route_remove_all (o->brouter_table); |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 221 | |
| 222 | THREAD_OFF(o->maxage_remover); |
| 223 | THREAD_OFF(o->t_spf_calc); |
| 224 | THREAD_OFF(o->t_ase_calc); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 225 | } |
| 226 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 228 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 229 | ospf6_maxage_remover (struct thread *thread) |
| 230 | { |
| 231 | struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread); |
| 232 | struct ospf6_area *oa; |
| 233 | struct ospf6_interface *oi; |
| 234 | struct ospf6_neighbor *on; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 235 | struct listnode *i, *j, *k; |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 236 | int reschedule = 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 237 | |
| 238 | o->maxage_remover = (struct thread *) NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 239 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 240 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 241 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 242 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 243 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 244 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 245 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 246 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE && |
| 247 | on->state != OSPF6_NEIGHBOR_LOADING) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 248 | continue; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 249 | |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 250 | ospf6_maxage_remove (o); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 251 | return 0; |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 256 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 257 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 258 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 259 | { |
| 260 | if (ospf6_lsdb_maxage_remover (oi->lsdb)) |
| 261 | { |
| 262 | reschedule = 1; |
| 263 | } |
| 264 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 265 | |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 266 | if (ospf6_lsdb_maxage_remover (oa->lsdb)) |
| 267 | { |
| 268 | reschedule = 1; |
| 269 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 270 | } |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 271 | |
| 272 | if (ospf6_lsdb_maxage_remover (o->lsdb)) |
| 273 | { |
| 274 | reschedule = 1; |
| 275 | } |
| 276 | |
| 277 | if (reschedule) |
| 278 | { |
| 279 | ospf6_maxage_remove (o); |
| 280 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 281 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 286 | ospf6_maxage_remove (struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 287 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 288 | if (o && ! o->maxage_remover) |
Dinesh Dutt | 2449fcd | 2013-08-24 07:54:17 +0000 | [diff] [blame] | 289 | o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o, |
| 290 | OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 291 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 292 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 293 | /* start ospf6 */ |
| 294 | DEFUN (router_ospf6, |
| 295 | router_ospf6_cmd, |
| 296 | "router ospf6", |
| 297 | ROUTER_STR |
| 298 | OSPF6_STR) |
| 299 | { |
| 300 | if (ospf6 == NULL) |
| 301 | ospf6 = ospf6_create (); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 302 | |
| 303 | /* set current ospf point. */ |
| 304 | vty->node = OSPF6_NODE; |
| 305 | vty->index = ospf6; |
| 306 | |
| 307 | return CMD_SUCCESS; |
| 308 | } |
| 309 | |
| 310 | /* stop ospf6 */ |
| 311 | DEFUN (no_router_ospf6, |
| 312 | no_router_ospf6_cmd, |
| 313 | "no router ospf6", |
| 314 | NO_STR |
| 315 | OSPF6_ROUTER_STR) |
| 316 | { |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 317 | if (ospf6 == NULL) |
| 318 | vty_out (vty, "OSPFv3 is not configured%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 319 | else |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 320 | { |
| 321 | ospf6_delete (ospf6); |
| 322 | ospf6 = NULL; |
| 323 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 324 | |
| 325 | /* return to config node . */ |
| 326 | vty->node = CONFIG_NODE; |
| 327 | vty->index = NULL; |
| 328 | |
| 329 | return CMD_SUCCESS; |
| 330 | } |
| 331 | |
| 332 | /* change Router_ID commands. */ |
| 333 | DEFUN (ospf6_router_id, |
| 334 | ospf6_router_id_cmd, |
| 335 | "router-id A.B.C.D", |
| 336 | "Configure OSPF Router-ID\n" |
| 337 | V4NOTATION_STR) |
| 338 | { |
| 339 | int ret; |
| 340 | u_int32_t router_id; |
| 341 | struct ospf6 *o; |
| 342 | |
| 343 | o = (struct ospf6 *) vty->index; |
| 344 | |
| 345 | ret = inet_pton (AF_INET, argv[0], &router_id); |
| 346 | if (ret == 0) |
| 347 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 348 | vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 349 | return CMD_SUCCESS; |
| 350 | } |
| 351 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 352 | o->router_id_static = router_id; |
| 353 | if (o->router_id == 0) |
| 354 | o->router_id = router_id; |
| 355 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 356 | return CMD_SUCCESS; |
| 357 | } |
| 358 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 359 | DEFUN (ospf6_log_adjacency_changes, |
| 360 | ospf6_log_adjacency_changes_cmd, |
| 361 | "log-adjacency-changes", |
| 362 | "Log changes in adjacency state\n") |
| 363 | { |
| 364 | struct ospf6 *ospf6 = vty->index; |
| 365 | |
| 366 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 367 | return CMD_SUCCESS; |
| 368 | } |
| 369 | |
| 370 | DEFUN (ospf6_log_adjacency_changes_detail, |
| 371 | ospf6_log_adjacency_changes_detail_cmd, |
| 372 | "log-adjacency-changes detail", |
| 373 | "Log changes in adjacency state\n" |
| 374 | "Log all state changes\n") |
| 375 | { |
| 376 | struct ospf6 *ospf6 = vty->index; |
| 377 | |
| 378 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 379 | SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 380 | return CMD_SUCCESS; |
| 381 | } |
| 382 | |
| 383 | DEFUN (no_ospf6_log_adjacency_changes, |
| 384 | no_ospf6_log_adjacency_changes_cmd, |
| 385 | "no log-adjacency-changes", |
| 386 | NO_STR |
| 387 | "Log changes in adjacency state\n") |
| 388 | { |
| 389 | struct ospf6 *ospf6 = vty->index; |
| 390 | |
| 391 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 392 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES); |
| 393 | return CMD_SUCCESS; |
| 394 | } |
| 395 | |
| 396 | DEFUN (no_ospf6_log_adjacency_changes_detail, |
| 397 | no_ospf6_log_adjacency_changes_detail_cmd, |
| 398 | "no log-adjacency-changes detail", |
| 399 | NO_STR |
| 400 | "Log changes in adjacency state\n" |
| 401 | "Log all state changes\n") |
| 402 | { |
| 403 | struct ospf6 *ospf6 = vty->index; |
| 404 | |
| 405 | UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL); |
| 406 | return CMD_SUCCESS; |
| 407 | } |
| 408 | |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 409 | DEFUN (ospf6_distance, |
| 410 | ospf6_distance_cmd, |
| 411 | "distance <1-255>", |
| 412 | NO_STR |
| 413 | "Define an administrative distance\n" |
| 414 | "OSPF6 Administrative distance\n") |
| 415 | { |
| 416 | struct ospf6 *o; |
| 417 | |
| 418 | o = (struct ospf6 *) vty->index; |
| 419 | |
| 420 | o->distance_all = atoi (argv[0]); |
| 421 | |
| 422 | return CMD_SUCCESS; |
| 423 | } |
| 424 | |
| 425 | DEFUN (no_ospf6_distance, |
| 426 | no_ospf6_distance_cmd, |
| 427 | "no distance <1-255>", |
| 428 | NO_STR |
| 429 | "Define an administrative distance\n" |
| 430 | "OSPF6 Administrative distance\n") |
| 431 | { |
| 432 | struct ospf6 *o; |
| 433 | |
| 434 | o = (struct ospf6 *) vty->index; |
| 435 | |
| 436 | o->distance_all = 0; |
| 437 | |
| 438 | return CMD_SUCCESS; |
| 439 | } |
| 440 | |
| 441 | DEFUN (no_ospf6_distance_ospf6, |
| 442 | no_ospf6_distance_ospf6_cmd, |
| 443 | "no distance ospf6", |
| 444 | NO_STR |
| 445 | "Define an administrative distance\n" |
| 446 | "OSPF6 Administrative distance\n" |
| 447 | "OSPF6 Distance\n") |
| 448 | { |
| 449 | struct ospf6 *o; |
| 450 | |
| 451 | o = (struct ospf6 *) vty->index; |
| 452 | |
| 453 | o->distance_intra = 0; |
| 454 | o->distance_inter = 0; |
| 455 | o->distance_external = 0; |
| 456 | |
| 457 | return CMD_SUCCESS; |
| 458 | } |
| 459 | |
| 460 | DEFUN (ospf6_distance_ospf6_intra, |
| 461 | ospf6_distance_ospf6_intra_cmd, |
| 462 | "distance ospf6 intra-area <1-255>", |
| 463 | "Define an administrative distance\n" |
| 464 | "OSPF6 Administrative distance\n" |
| 465 | "Intra-area routes\n" |
| 466 | "Distance for intra-area routes\n") |
| 467 | { |
| 468 | struct ospf6 *o; |
| 469 | |
| 470 | o = (struct ospf6 *) vty->index; |
| 471 | |
| 472 | o->distance_intra = atoi (argv[0]); |
| 473 | |
| 474 | return CMD_SUCCESS; |
| 475 | } |
| 476 | |
| 477 | DEFUN (ospf6_distance_ospf6_intra_inter, |
| 478 | ospf6_distance_ospf6_intra_inter_cmd, |
| 479 | "distance ospf6 intra-area <1-255> inter-area <1-255>", |
| 480 | "Define an administrative distance\n" |
| 481 | "OSPF6 Administrative distance\n" |
| 482 | "Intra-area routes\n" |
| 483 | "Distance for intra-area routes\n" |
| 484 | "Inter-area routes\n" |
| 485 | "Distance for inter-area routes\n") |
| 486 | { |
| 487 | struct ospf6 *o; |
| 488 | |
| 489 | o = (struct ospf6 *) vty->index; |
| 490 | |
| 491 | o->distance_intra = atoi (argv[0]); |
| 492 | o->distance_inter = atoi (argv[1]); |
| 493 | |
| 494 | return CMD_SUCCESS; |
| 495 | } |
| 496 | |
| 497 | DEFUN (ospf6_distance_ospf6_intra_external, |
| 498 | ospf6_distance_ospf6_intra_external_cmd, |
| 499 | "distance ospf6 intra-area <1-255> external <1-255>", |
| 500 | "Define an administrative distance\n" |
| 501 | "OSPF6 Administrative distance\n" |
| 502 | "Intra-area routes\n" |
| 503 | "Distance for intra-area routes\n" |
| 504 | "External routes\n" |
| 505 | "Distance for external routes\n") |
| 506 | { |
| 507 | struct ospf6 *o; |
| 508 | |
| 509 | o = (struct ospf6 *) vty->index; |
| 510 | |
| 511 | o->distance_intra = atoi (argv[0]); |
| 512 | o->distance_external = atoi (argv[1]); |
| 513 | |
| 514 | return CMD_SUCCESS; |
| 515 | } |
| 516 | |
| 517 | DEFUN (ospf6_distance_ospf6_intra_inter_external, |
| 518 | ospf6_distance_ospf6_intra_inter_external_cmd, |
| 519 | "distance ospf6 intra-area <1-255> inter-area <1-255> external <1-255>", |
| 520 | "Define an administrative distance\n" |
| 521 | "OSPF6 Administrative distance\n" |
| 522 | "Intra-area routes\n" |
| 523 | "Distance for intra-area routes\n" |
| 524 | "Inter-area routes\n" |
| 525 | "Distance for inter-area routes\n" |
| 526 | "External routes\n" |
| 527 | "Distance for external routes\n") |
| 528 | { |
| 529 | struct ospf6 *o; |
| 530 | |
| 531 | o = (struct ospf6 *) vty->index; |
| 532 | |
| 533 | o->distance_intra = atoi (argv[0]); |
| 534 | o->distance_inter = atoi (argv[1]); |
| 535 | o->distance_external = atoi (argv[2]); |
| 536 | |
| 537 | return CMD_SUCCESS; |
| 538 | } |
| 539 | |
| 540 | DEFUN (ospf6_distance_ospf6_intra_external_inter, |
| 541 | ospf6_distance_ospf6_intra_external_inter_cmd, |
| 542 | "distance ospf6 intra-area <1-255> external <1-255> inter-area <1-255>", |
| 543 | "Define an administrative distance\n" |
| 544 | "OSPF6 Administrative distance\n" |
| 545 | "Intra-area routes\n" |
| 546 | "Distance for intra-area routes\n" |
| 547 | "External routes\n" |
| 548 | "Distance for external routes\n" |
| 549 | "Inter-area routes\n" |
| 550 | "Distance for inter-area routes\n") |
| 551 | { |
| 552 | struct ospf6 *o; |
| 553 | |
| 554 | o = (struct ospf6 *) vty->index; |
| 555 | |
| 556 | o->distance_intra = atoi (argv[0]); |
| 557 | o->distance_external = atoi (argv[1]); |
| 558 | o->distance_inter = atoi (argv[2]); |
| 559 | |
| 560 | return CMD_SUCCESS; |
| 561 | } |
| 562 | |
| 563 | DEFUN (ospf6_distance_ospf6_inter, |
| 564 | ospf6_distance_ospf6_inter_cmd, |
| 565 | "distance ospf6 inter-area <1-255>", |
| 566 | "Define an administrative distance\n" |
| 567 | "OSPF6 Administrative distance\n" |
| 568 | "Inter-area routes\n" |
| 569 | "Distance for inter-area routes\n") |
| 570 | { |
| 571 | struct ospf6 *o; |
| 572 | |
| 573 | o = (struct ospf6 *) vty->index; |
| 574 | |
| 575 | o->distance_inter = atoi (argv[0]); |
| 576 | |
| 577 | return CMD_SUCCESS; |
| 578 | } |
| 579 | |
| 580 | DEFUN (ospf6_distance_ospf6_inter_intra, |
| 581 | ospf6_distance_ospf6_inter_intra_cmd, |
| 582 | "distance ospf6 inter-area <1-255> intra-area <1-255>", |
| 583 | "Define an administrative distance\n" |
| 584 | "OSPF6 Administrative distance\n" |
| 585 | "Inter-area routes\n" |
| 586 | "Distance for inter-area routes\n" |
| 587 | "Intra-area routes\n" |
| 588 | "Distance for intra-area routes\n") |
| 589 | { |
| 590 | struct ospf6 *o; |
| 591 | |
| 592 | o = (struct ospf6 *) vty->index; |
| 593 | |
| 594 | o->distance_inter = atoi (argv[0]); |
| 595 | o->distance_intra = atoi (argv[1]); |
| 596 | |
| 597 | return CMD_SUCCESS; |
| 598 | } |
| 599 | |
| 600 | DEFUN (ospf6_distance_ospf6_inter_external, |
| 601 | ospf6_distance_ospf6_inter_external_cmd, |
| 602 | "distance ospf6 inter-area <1-255> external <1-255>", |
| 603 | "Define an administrative distance\n" |
| 604 | "OSPF6 Administrative distance\n" |
| 605 | "Inter-area routes\n" |
| 606 | "Distance for inter-area routes\n" |
| 607 | "External routes\n" |
| 608 | "Distance for external routes\n") |
| 609 | { |
| 610 | struct ospf6 *o; |
| 611 | |
| 612 | o = (struct ospf6 *) vty->index; |
| 613 | |
| 614 | o->distance_inter = atoi (argv[0]); |
| 615 | o->distance_external = atoi (argv[1]); |
| 616 | |
| 617 | return CMD_SUCCESS; |
| 618 | } |
| 619 | |
| 620 | DEFUN (ospf6_distance_ospf6_inter_intra_external, |
| 621 | ospf6_distance_ospf6_inter_intra_external_cmd, |
| 622 | "distance ospf6 inter-area <1-255> intra-area <1-255> external <1-255>", |
| 623 | "Define an administrative distance\n" |
| 624 | "OSPF6 Administrative distance\n" |
| 625 | "Inter-area routes\n" |
| 626 | "Distance for inter-area routes\n" |
| 627 | "Intra-area routes\n" |
| 628 | "Distance for intra-area routes\n" |
| 629 | "External routes\n" |
| 630 | "Distance for external routes\n") |
| 631 | { |
| 632 | struct ospf6 *o; |
| 633 | |
| 634 | o = (struct ospf6 *) vty->index; |
| 635 | |
| 636 | o->distance_inter = atoi (argv[0]); |
| 637 | o->distance_intra = atoi (argv[1]); |
| 638 | o->distance_external = atoi (argv[2]); |
| 639 | |
| 640 | return CMD_SUCCESS; |
| 641 | } |
| 642 | |
| 643 | DEFUN (ospf6_distance_ospf6_inter_external_intra, |
| 644 | ospf6_distance_ospf6_inter_external_intra_cmd, |
| 645 | "distance ospf6 inter-area <1-255> external <1-255> intra-area <1-255>", |
| 646 | "Define an administrative distance\n" |
| 647 | "OSPF6 Administrative distance\n" |
| 648 | "Inter-area routes\n" |
| 649 | "Distance for inter-area routes\n" |
| 650 | "External routes\n" |
| 651 | "Distance for external routes\n" |
| 652 | "Intra-area routes\n" |
| 653 | "Distance for intra-area routes\n") |
| 654 | { |
| 655 | struct ospf6 *o; |
| 656 | |
| 657 | o = (struct ospf6 *) vty->index; |
| 658 | |
| 659 | o->distance_inter = atoi (argv[0]); |
| 660 | o->distance_external = atoi (argv[1]); |
| 661 | o->distance_intra = atoi (argv[2]); |
| 662 | |
| 663 | return CMD_SUCCESS; |
| 664 | } |
| 665 | |
| 666 | DEFUN (ospf6_distance_ospf6_external, |
| 667 | ospf6_distance_ospf6_external_cmd, |
| 668 | "distance ospf6 external <1-255>", |
| 669 | "Define an administrative distance\n" |
| 670 | "OSPF6 Administrative distance\n" |
| 671 | "External routes\n" |
| 672 | "Distance for external routes\n") |
| 673 | { |
| 674 | struct ospf6 *o; |
| 675 | |
| 676 | o = (struct ospf6 *) vty->index; |
| 677 | |
| 678 | o->distance_external = atoi (argv[0]); |
| 679 | |
| 680 | return CMD_SUCCESS; |
| 681 | } |
| 682 | |
| 683 | DEFUN (ospf6_distance_ospf6_external_intra, |
| 684 | ospf6_distance_ospf6_external_intra_cmd, |
| 685 | "distance ospf6 external <1-255> intra-area <1-255>", |
| 686 | "Define an administrative distance\n" |
| 687 | "OSPF6 Administrative distance\n" |
| 688 | "External routes\n" |
| 689 | "Distance for external routes\n" |
| 690 | "Intra-area routes\n" |
| 691 | "Distance for intra-area routes\n") |
| 692 | { |
| 693 | struct ospf6 *o; |
| 694 | |
| 695 | o = (struct ospf6 *) vty->index; |
| 696 | |
| 697 | o->distance_external = atoi (argv[0]); |
| 698 | o->distance_intra = atoi (argv[1]); |
| 699 | |
| 700 | return CMD_SUCCESS; |
| 701 | } |
| 702 | |
| 703 | DEFUN (ospf6_distance_ospf6_external_inter, |
| 704 | ospf6_distance_ospf6_external_inter_cmd, |
| 705 | "distance ospf6 external <1-255> inter-area <1-255>", |
| 706 | "Define an administrative distance\n" |
| 707 | "OSPF6 Administrative distance\n" |
| 708 | "External routes\n" |
| 709 | "Distance for external routes\n" |
| 710 | "Inter-area routes\n" |
| 711 | "Distance for inter-area routes\n") |
| 712 | { |
| 713 | struct ospf6 *o; |
| 714 | |
| 715 | o = (struct ospf6 *) vty->index; |
| 716 | |
| 717 | o->distance_external = atoi (argv[0]); |
| 718 | o->distance_inter = atoi (argv[1]); |
| 719 | |
| 720 | return CMD_SUCCESS; |
| 721 | } |
| 722 | |
| 723 | DEFUN (ospf6_distance_ospf6_external_intra_inter, |
| 724 | ospf6_distance_ospf6_external_intra_inter_cmd, |
| 725 | "distance ospf6 external <1-255> intra-area <1-255> inter-area <1-255>", |
| 726 | "Define an administrative distance\n" |
| 727 | "OSPF6 Administrative distance\n" |
| 728 | "External routes\n" |
| 729 | "Distance for external routes\n" |
| 730 | "Intra-area routes\n" |
| 731 | "Distance for intra-area routes\n" |
| 732 | "Inter-area routes\n" |
| 733 | "Distance for inter-area routes\n") |
| 734 | { |
| 735 | struct ospf6 *o; |
| 736 | |
| 737 | o = (struct ospf6 *) vty->index; |
| 738 | |
| 739 | o->distance_external = atoi (argv[0]); |
| 740 | o->distance_intra = atoi (argv[1]); |
| 741 | o->distance_inter = atoi (argv[2]); |
| 742 | |
| 743 | return CMD_SUCCESS; |
| 744 | } |
| 745 | |
| 746 | DEFUN (ospf6_distance_ospf6_external_inter_intra, |
| 747 | ospf6_distance_ospf6_external_inter_intra_cmd, |
| 748 | "distance ospf6 external <1-255> inter-area <1-255> intra-area <1-255>", |
| 749 | "Define an administrative distance\n" |
| 750 | "OSPF6 Administrative distance\n" |
| 751 | "External routes\n" |
| 752 | "Distance for external routes\n" |
| 753 | "Inter-area routes\n" |
| 754 | "Distance for inter-area routes\n" |
| 755 | "Intra-area routes\n" |
| 756 | "Distance for intra-area routes\n") |
| 757 | { |
| 758 | struct ospf6 *o; |
| 759 | |
| 760 | o = (struct ospf6 *) vty->index; |
| 761 | |
| 762 | o->distance_external = atoi (argv[0]); |
| 763 | o->distance_inter = atoi (argv[1]); |
| 764 | o->distance_intra = atoi (argv[2]); |
| 765 | |
| 766 | return CMD_SUCCESS; |
| 767 | } |
| 768 | |
| 769 | DEFUN (ospf6_distance_source, |
| 770 | ospf6_distance_source_cmd, |
| 771 | "distance <1-255> X:X::X:X/M", |
| 772 | "Administrative distance\n" |
| 773 | "Distance value\n" |
| 774 | "IP source prefix\n") |
| 775 | { |
| 776 | struct ospf6 *o; |
| 777 | |
| 778 | o = (struct ospf6 *) vty->index; |
| 779 | |
| 780 | ospf6_distance_set (vty, o, argv[0], argv[1], NULL); |
| 781 | |
| 782 | return CMD_SUCCESS; |
| 783 | } |
| 784 | |
| 785 | DEFUN (no_ospf6_distance_source, |
| 786 | no_ospf6_distance_source_cmd, |
| 787 | "no distance <1-255> X:X::X:X/M", |
| 788 | NO_STR |
| 789 | "Administrative distance\n" |
| 790 | "Distance value\n" |
| 791 | "IP source prefix\n") |
| 792 | { |
| 793 | struct ospf6 *o; |
| 794 | |
| 795 | o = (struct ospf6 *) vty->index; |
| 796 | |
| 797 | /* XXX: distance arg seems to be irrelevant */ |
| 798 | ospf6_distance_unset (vty, o, argv[1], NULL); |
| 799 | |
| 800 | return CMD_SUCCESS; |
| 801 | } |
| 802 | |
| 803 | DEFUN (ospf6_distance_source_access_list, |
| 804 | ospf6_distance_source_access_list_cmd, |
| 805 | "distance <1-255> X:X::X:X/M WORD", |
| 806 | "Administrative distance\n" |
| 807 | "Distance value\n" |
| 808 | "IP source prefix\n" |
| 809 | "Access list name\n") |
| 810 | { |
| 811 | struct ospf6 *o; |
| 812 | |
| 813 | o = (struct ospf6 *) vty->index; |
| 814 | |
| 815 | ospf6_distance_set (vty, o, argv[0], argv[1], argv[2]); |
| 816 | |
| 817 | return CMD_SUCCESS; |
| 818 | } |
| 819 | |
| 820 | DEFUN (no_ospf6_distance_source_access_list, |
| 821 | no_ospf6_distance_source_access_list_cmd, |
| 822 | "no distance <1-255> X:X::X:X/M WORD", |
| 823 | NO_STR |
| 824 | "Administrative distance\n" |
| 825 | "Distance value\n" |
| 826 | "IP source prefix\n" |
| 827 | "Access list name\n") |
| 828 | { |
| 829 | struct ospf6 *o; |
| 830 | |
| 831 | o = (struct ospf6 *) vty->index; |
| 832 | |
| 833 | ospf6_distance_unset (vty, o, argv[1], argv[2]); |
| 834 | |
| 835 | return CMD_SUCCESS; |
| 836 | } |
| 837 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 838 | DEFUN (ospf6_interface_area, |
| 839 | ospf6_interface_area_cmd, |
| 840 | "interface IFNAME area A.B.C.D", |
| 841 | "Enable routing on an IPv6 interface\n" |
| 842 | IFNAME_STR |
| 843 | "Specify the OSPF6 area ID\n" |
| 844 | "OSPF6 area ID in IPv4 address notation\n" |
| 845 | ) |
| 846 | { |
| 847 | struct ospf6 *o; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 848 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 849 | struct ospf6_interface *oi; |
| 850 | struct interface *ifp; |
| 851 | u_int32_t area_id; |
| 852 | |
| 853 | o = (struct ospf6 *) vty->index; |
| 854 | |
| 855 | /* find/create ospf6 interface */ |
| 856 | ifp = if_get_by_name (argv[0]); |
| 857 | oi = (struct ospf6_interface *) ifp->info; |
| 858 | if (oi == NULL) |
| 859 | oi = ospf6_interface_create (ifp); |
| 860 | if (oi->area) |
| 861 | { |
| 862 | vty_out (vty, "%s already attached to Area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 863 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 864 | return CMD_SUCCESS; |
| 865 | } |
| 866 | |
| 867 | /* parse Area-ID */ |
| 868 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 869 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 870 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 871 | return CMD_SUCCESS; |
| 872 | } |
| 873 | |
| 874 | /* find/create ospf6 area */ |
| 875 | oa = ospf6_area_lookup (area_id, o); |
| 876 | if (oa == NULL) |
| 877 | oa = ospf6_area_create (area_id, o); |
| 878 | |
| 879 | /* attach interface to area */ |
| 880 | listnode_add (oa->if_list, oi); /* sort ?? */ |
| 881 | oi->area = oa; |
| 882 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 883 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
| 884 | |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 885 | /* ospf6 process is currently disabled, not much more to do */ |
| 886 | if (CHECK_FLAG (o->flag, OSPF6_DISABLED)) |
| 887 | return CMD_SUCCESS; |
| 888 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 889 | /* start up */ |
Christian Franke | d962872 | 2013-03-08 21:47:35 +0100 | [diff] [blame] | 890 | ospf6_interface_enable (oi); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 891 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 892 | /* If the router is ABR, originate summary routes */ |
| 893 | if (ospf6_is_router_abr (o)) |
| 894 | ospf6_abr_enable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 895 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 896 | return CMD_SUCCESS; |
| 897 | } |
| 898 | |
| 899 | DEFUN (no_ospf6_interface_area, |
| 900 | no_ospf6_interface_area_cmd, |
| 901 | "no interface IFNAME area A.B.C.D", |
| 902 | NO_STR |
| 903 | "Disable routing on an IPv6 interface\n" |
| 904 | IFNAME_STR |
| 905 | "Specify the OSPF6 area ID\n" |
| 906 | "OSPF6 area ID in IPv4 address notation\n" |
| 907 | ) |
| 908 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 909 | struct ospf6_interface *oi; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 910 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 911 | struct interface *ifp; |
| 912 | u_int32_t area_id; |
| 913 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 914 | ifp = if_lookup_by_name (argv[0]); |
| 915 | if (ifp == NULL) |
| 916 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 917 | vty_out (vty, "No such interface %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 918 | return CMD_SUCCESS; |
| 919 | } |
| 920 | |
| 921 | oi = (struct ospf6_interface *) ifp->info; |
| 922 | if (oi == NULL) |
| 923 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 924 | vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 925 | return CMD_SUCCESS; |
| 926 | } |
| 927 | |
| 928 | /* parse Area-ID */ |
| 929 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 930 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 931 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 932 | return CMD_SUCCESS; |
| 933 | } |
| 934 | |
Jon | 56abbb8 | 2009-02-11 17:30:44 -0800 | [diff] [blame] | 935 | /* Verify Area */ |
| 936 | if (oi->area == NULL) |
| 937 | { |
| 938 | vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL); |
| 939 | return CMD_SUCCESS; |
| 940 | } |
| 941 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 942 | if (oi->area->area_id != area_id) |
| 943 | { |
| 944 | vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 945 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 946 | return CMD_SUCCESS; |
| 947 | } |
| 948 | |
| 949 | thread_execute (master, interface_down, oi, 0); |
| 950 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 951 | oa = oi->area; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 952 | listnode_delete (oi->area->if_list, oi); |
| 953 | oi->area = (struct ospf6_area *) NULL; |
| 954 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 955 | /* Withdraw inter-area routes from this area, if necessary */ |
| 956 | if (oa->if_list->count == 0) |
| 957 | { |
| 958 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 959 | ospf6_abr_disable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 960 | } |
| 961 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 962 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 963 | } |
| 964 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 965 | DEFUN (ospf6_stub_router_admin, |
| 966 | ospf6_stub_router_admin_cmd, |
| 967 | "stub-router administrative", |
| 968 | "Make router a stub router\n" |
| 969 | "Advertise inability to be a transit router\n" |
| 970 | "Administratively applied, for an indefinite period\n") |
| 971 | { |
| 972 | struct listnode *node; |
| 973 | struct ospf6_area *oa; |
| 974 | |
| 975 | if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 976 | { |
| 977 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
| 978 | { |
| 979 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6); |
| 980 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R); |
| 981 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 982 | } |
| 983 | SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER); |
| 984 | } |
| 985 | |
| 986 | return CMD_SUCCESS; |
| 987 | } |
| 988 | |
| 989 | DEFUN (no_ospf6_stub_router_admin, |
| 990 | no_ospf6_stub_router_admin_cmd, |
| 991 | "no stub-router administrative", |
| 992 | NO_STR |
| 993 | "Make router a stub router\n" |
| 994 | "Advertise ability to be a transit router\n" |
| 995 | "Administratively applied, for an indefinite period\n") |
| 996 | { |
| 997 | struct listnode *node; |
| 998 | struct ospf6_area *oa; |
| 999 | |
| 1000 | if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 1001 | { |
| 1002 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
| 1003 | { |
| 1004 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); |
| 1005 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); |
| 1006 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 1007 | } |
| 1008 | UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER); |
| 1009 | } |
| 1010 | |
| 1011 | return CMD_SUCCESS; |
| 1012 | } |
| 1013 | |
| 1014 | DEFUN (ospf6_stub_router_startup, |
| 1015 | ospf6_stub_router_startup_cmd, |
| 1016 | "stub-router on-startup <5-86400>", |
| 1017 | "Make router a stub router\n" |
| 1018 | "Advertise inability to be a transit router\n" |
| 1019 | "Automatically advertise as stub-router on startup of OSPF6\n" |
| 1020 | "Time (seconds) to advertise self as stub-router\n") |
| 1021 | { |
| 1022 | return CMD_SUCCESS; |
| 1023 | } |
| 1024 | |
| 1025 | DEFUN (no_ospf6_stub_router_startup, |
| 1026 | no_ospf6_stub_router_startup_cmd, |
| 1027 | "no stub-router on-startup", |
| 1028 | NO_STR |
| 1029 | "Make router a stub router\n" |
| 1030 | "Advertise inability to be a transit router\n" |
| 1031 | "Automatically advertise as stub-router on startup of OSPF6\n" |
| 1032 | "Time (seconds) to advertise self as stub-router\n") |
| 1033 | { |
| 1034 | return CMD_SUCCESS; |
| 1035 | } |
| 1036 | |
| 1037 | DEFUN (ospf6_stub_router_shutdown, |
| 1038 | ospf6_stub_router_shutdown_cmd, |
| 1039 | "stub-router on-shutdown <5-86400>", |
| 1040 | "Make router a stub router\n" |
| 1041 | "Advertise inability to be a transit router\n" |
| 1042 | "Automatically advertise as stub-router before shutdown\n" |
| 1043 | "Time (seconds) to advertise self as stub-router\n") |
| 1044 | { |
| 1045 | return CMD_SUCCESS; |
| 1046 | } |
| 1047 | |
| 1048 | DEFUN (no_ospf6_stub_router_shutdown, |
| 1049 | no_ospf6_stub_router_shutdown_cmd, |
| 1050 | "no stub-router on-shutdown", |
| 1051 | NO_STR |
| 1052 | "Make router a stub router\n" |
| 1053 | "Advertise inability to be a transit router\n" |
| 1054 | "Automatically advertise as stub-router before shutdown\n" |
| 1055 | "Time (seconds) to advertise self as stub-router\n") |
| 1056 | { |
| 1057 | return CMD_SUCCESS; |
| 1058 | } |
| 1059 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1060 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1061 | ospf6_show (struct vty *vty, struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1063 | struct listnode *n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1064 | struct ospf6_area *oa; |
| 1065 | char router_id[16], duration[32]; |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 1066 | struct timeval now, running, result; |
| 1067 | char buf[32], rbuf[32]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1068 | |
| 1069 | /* process id, router id */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1070 | inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id)); |
| 1071 | vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1072 | router_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1073 | |
| 1074 | /* running time */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 1075 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1076 | timersub (&now, &o->starttime, &running); |
| 1077 | timerstring (&running, duration, sizeof (duration)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1078 | vty_out (vty, " Running %s%s", duration, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1079 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1080 | /* Redistribute configuration */ |
| 1081 | /* XXX */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1082 | |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 1083 | /* Show SPF parameters */ |
| 1084 | vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 1085 | " Minimum hold time between consecutive SPFs %d millsecond(s)%s" |
| 1086 | " Maximum hold time between consecutive SPFs %d millsecond(s)%s" |
| 1087 | " Hold time multiplier is currently %d%s", |
| 1088 | o->spf_delay, VNL, |
| 1089 | o->spf_holdtime, VNL, |
| 1090 | o->spf_max_holdtime, VNL, |
| 1091 | o->spf_hold_multiplier, VNL); |
| 1092 | |
| 1093 | vty_out(vty, " SPF algorithm "); |
| 1094 | if (o->ts_spf.tv_sec || o->ts_spf.tv_usec) |
| 1095 | { |
| 1096 | timersub(&now, &o->ts_spf, &result); |
| 1097 | timerstring(&result, buf, sizeof(buf)); |
| 1098 | ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf)); |
| 1099 | vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL); |
David Lamparter | ef008d2 | 2015-03-03 08:48:11 +0100 | [diff] [blame] | 1100 | vty_out (vty, " Last SPF duration %lld sec %lld usec%s", |
| 1101 | (long long)o->ts_spf_duration.tv_sec, |
| 1102 | (long long)o->ts_spf_duration.tv_usec, VNL); |
Dinesh Dutt | a0edf67 | 2013-08-26 03:40:23 +0000 | [diff] [blame] | 1103 | } |
| 1104 | else |
| 1105 | vty_out(vty, "has not been run$%s", VNL); |
| 1106 | threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf)); |
| 1107 | vty_out (vty, " SPF timer %s%s%s", |
| 1108 | (o->t_spf_calc ? "due in " : "is "), buf, VNL); |
| 1109 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 1110 | if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER)) |
| 1111 | vty_out (vty, " Router Is Stub Router%s", VNL); |
| 1112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1113 | /* LSAs */ |
| 1114 | vty_out (vty, " Number of AS scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1115 | o->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1116 | |
| 1117 | /* Areas */ |
| 1118 | vty_out (vty, " Number of areas in this router is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1119 | listcount (o->area_list), VNL); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1120 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 1121 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) |
| 1122 | { |
| 1123 | if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) |
| 1124 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 1125 | else |
| 1126 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 1127 | } |
| 1128 | |
| 1129 | vty_out (vty, "%s",VTY_NEWLINE); |
| 1130 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1131 | for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa)) |
| 1132 | ospf6_area_show (vty, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1135 | /* show top level structures */ |
| 1136 | DEFUN (show_ipv6_ospf6, |
| 1137 | show_ipv6_ospf6_cmd, |
| 1138 | "show ipv6 ospf6", |
| 1139 | SHOW_STR |
| 1140 | IP6_STR |
| 1141 | OSPF6_STR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1142 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1143 | OSPF6_CMD_CHECK_RUNNING (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1144 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1145 | ospf6_show (vty, ospf6); |
| 1146 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | DEFUN (show_ipv6_ospf6_route, |
| 1150 | show_ipv6_ospf6_route_cmd, |
| 1151 | "show ipv6 ospf6 route", |
| 1152 | SHOW_STR |
| 1153 | IP6_STR |
| 1154 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1155 | ROUTE_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1156 | ) |
| 1157 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1158 | ospf6_route_table_show (vty, argc, argv, ospf6->route_table); |
| 1159 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | ALIAS (show_ipv6_ospf6_route, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1163 | show_ipv6_ospf6_route_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1164 | "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] | 1165 | SHOW_STR |
| 1166 | IP6_STR |
| 1167 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1168 | ROUTE_STR |
| 1169 | "Specify IPv6 address\n" |
| 1170 | "Specify IPv6 prefix\n" |
| 1171 | "Detailed information\n" |
| 1172 | "Summary of route table\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1173 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1174 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1175 | DEFUN (show_ipv6_ospf6_route_match, |
| 1176 | show_ipv6_ospf6_route_match_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1177 | "show ipv6 ospf6 route X:X::X:X/M match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1178 | SHOW_STR |
| 1179 | IP6_STR |
| 1180 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1181 | ROUTE_STR |
| 1182 | "Specify IPv6 prefix\n" |
| 1183 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1184 | ) |
| 1185 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1186 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1187 | int i, sargc; |
| 1188 | |
| 1189 | /* copy argv to sargv and then append "match" */ |
| 1190 | for (i = 0; i < argc; i++) |
| 1191 | sargv[i] = argv[i]; |
| 1192 | sargc = argc; |
| 1193 | sargv[sargc++] = "match"; |
| 1194 | sargv[sargc] = NULL; |
| 1195 | |
| 1196 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 1197 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1200 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 1201 | show_ipv6_ospf6_route_match_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1202 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1203 | SHOW_STR |
| 1204 | IP6_STR |
| 1205 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1206 | ROUTE_STR |
| 1207 | "Specify IPv6 prefix\n" |
| 1208 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1209 | "Detailed information\n" |
| 1210 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1211 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1212 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1213 | int i, sargc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1215 | /* copy argv to sargv and then append "match" and "detail" */ |
| 1216 | for (i = 0; i < argc; i++) |
| 1217 | sargv[i] = argv[i]; |
| 1218 | sargc = argc; |
| 1219 | sargv[sargc++] = "match"; |
| 1220 | sargv[sargc++] = "detail"; |
| 1221 | sargv[sargc] = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1222 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1223 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 1224 | return CMD_SUCCESS; |
| 1225 | } |
| 1226 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1227 | ALIAS (show_ipv6_ospf6_route_match, |
| 1228 | show_ipv6_ospf6_route_longer_cmd, |
| 1229 | "show ipv6 ospf6 route X:X::X:X/M longer", |
| 1230 | SHOW_STR |
| 1231 | IP6_STR |
| 1232 | OSPF6_STR |
| 1233 | ROUTE_STR |
| 1234 | "Specify IPv6 prefix\n" |
| 1235 | "Display routes longer than the specified route\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1236 | ) |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1237 | |
| 1238 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 1239 | show_ipv6_ospf6_route_longer_detail_cmd, |
| 1240 | "show ipv6 ospf6 route X:X::X:X/M longer detail", |
| 1241 | SHOW_STR |
| 1242 | IP6_STR |
| 1243 | OSPF6_STR |
| 1244 | ROUTE_STR |
| 1245 | "Specify IPv6 prefix\n" |
| 1246 | "Display routes longer than the specified route\n" |
| 1247 | "Detailed information\n" |
| 1248 | ); |
| 1249 | |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1250 | ALIAS (show_ipv6_ospf6_route, |
| 1251 | show_ipv6_ospf6_route_type_cmd, |
| 1252 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", |
| 1253 | SHOW_STR |
| 1254 | IP6_STR |
| 1255 | OSPF6_STR |
| 1256 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1257 | "Display Intra-Area routes\n" |
| 1258 | "Display Inter-Area routes\n" |
| 1259 | "Display Type-1 External routes\n" |
| 1260 | "Display Type-2 External routes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1261 | ) |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1262 | |
| 1263 | DEFUN (show_ipv6_ospf6_route_type_detail, |
| 1264 | show_ipv6_ospf6_route_type_detail_cmd, |
| 1265 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", |
| 1266 | SHOW_STR |
| 1267 | IP6_STR |
| 1268 | OSPF6_STR |
| 1269 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 1270 | "Display Intra-Area routes\n" |
| 1271 | "Display Inter-Area routes\n" |
| 1272 | "Display Type-1 External routes\n" |
| 1273 | "Display Type-2 External routes\n" |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1274 | "Detailed information\n" |
| 1275 | ) |
| 1276 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1277 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1278 | int i, sargc; |
| 1279 | |
| 1280 | /* copy argv to sargv and then append "detail" */ |
| 1281 | for (i = 0; i < argc; i++) |
| 1282 | sargv[i] = argv[i]; |
| 1283 | sargc = argc; |
| 1284 | sargv[sargc++] = "detail"; |
| 1285 | sargv[sargc] = NULL; |
| 1286 | |
| 1287 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 1288 | return CMD_SUCCESS; |
| 1289 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1290 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 1291 | static void |
| 1292 | ospf6_stub_router_config_write (struct vty *vty) |
| 1293 | { |
| 1294 | if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER)) |
| 1295 | { |
| 1296 | vty_out (vty, " stub-router administrative%s", VNL); |
| 1297 | } |
| 1298 | return; |
| 1299 | } |
| 1300 | |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 1301 | static int |
| 1302 | ospf6_distance_config_write (struct vty *vty) |
| 1303 | { |
| 1304 | struct route_node *rn; |
| 1305 | struct ospf6_distance *odistance; |
| 1306 | |
| 1307 | if (ospf6->distance_all) |
| 1308 | vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE); |
| 1309 | |
| 1310 | if (ospf6->distance_intra |
| 1311 | || ospf6->distance_inter |
| 1312 | || ospf6->distance_external) |
| 1313 | { |
| 1314 | vty_out (vty, " distance ospf6"); |
| 1315 | |
| 1316 | if (ospf6->distance_intra) |
| 1317 | vty_out (vty, " intra-area %d", ospf6->distance_intra); |
| 1318 | if (ospf6->distance_inter) |
| 1319 | vty_out (vty, " inter-area %d", ospf6->distance_inter); |
| 1320 | if (ospf6->distance_external) |
| 1321 | vty_out (vty, " external %d", ospf6->distance_external); |
| 1322 | |
| 1323 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1324 | } |
| 1325 | |
| 1326 | for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn)) |
| 1327 | if ((odistance = rn->info) != NULL) |
| 1328 | { |
| 1329 | char pstr[128]; |
| 1330 | vty_out (vty, " distance %d %s %s%s", odistance->distance, |
| 1331 | prefix2str (&rn->p, pstr, sizeof(pstr)), |
| 1332 | odistance->access_list ? odistance->access_list : "", |
| 1333 | VTY_NEWLINE); |
| 1334 | } |
| 1335 | return 0; |
| 1336 | } |
| 1337 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1338 | /* OSPF configuration write function. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1339 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1340 | config_write_ospf6 (struct vty *vty) |
| 1341 | { |
| 1342 | char router_id[16]; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1343 | struct listnode *j, *k; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1344 | struct ospf6_area *oa; |
| 1345 | struct ospf6_interface *oi; |
| 1346 | |
| 1347 | /* OSPFv6 configuration. */ |
| 1348 | if (ospf6 == NULL) |
| 1349 | return CMD_SUCCESS; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1350 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 1351 | inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1352 | vty_out (vty, "router ospf6%s", VNL); |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 1353 | if (ospf6->router_id_static != 0) |
| 1354 | vty_out (vty, " router-id %s%s", router_id, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1355 | |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 1356 | /* log-adjacency-changes flag print. */ |
| 1357 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) |
| 1358 | { |
| 1359 | vty_out(vty, " log-adjacency-changes"); |
| 1360 | if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL)) |
| 1361 | vty_out(vty, " detail"); |
| 1362 | vty_out(vty, "%s", VTY_NEWLINE); |
| 1363 | } |
| 1364 | |
Vincent Bernat | fd50068 | 2012-10-24 14:45:54 +0000 | [diff] [blame] | 1365 | if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH) |
| 1366 | vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000, |
| 1367 | VNL); |
| 1368 | |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 1369 | ospf6_stub_router_config_write (vty); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1370 | ospf6_redistribute_config_write (vty); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 1371 | ospf6_area_config_write (vty); |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 1372 | ospf6_spf_config_write (vty); |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 1373 | ospf6_distance_config_write (vty); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1374 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1375 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1376 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1377 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi)) |
| 1378 | vty_out (vty, " interface %s area %s%s", |
| 1379 | oi->interface->name, oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1380 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1381 | vty_out (vty, "!%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1382 | return 0; |
| 1383 | } |
| 1384 | |
| 1385 | /* OSPF6 node structure. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1386 | static struct cmd_node ospf6_node = |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1387 | { |
| 1388 | OSPF6_NODE, |
| 1389 | "%s(config-ospf6)# ", |
hasso | 69b4a81 | 2004-08-26 18:10:36 +0000 | [diff] [blame] | 1390 | 1 /* VTYSH */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1391 | }; |
| 1392 | |
| 1393 | /* Install ospf related commands. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1394 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1395 | ospf6_top_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1397 | /* Install ospf6 top node. */ |
| 1398 | install_node (&ospf6_node, config_write_ospf6); |
| 1399 | |
| 1400 | install_element (VIEW_NODE, &show_ipv6_ospf6_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1401 | install_element (CONFIG_NODE, &router_ospf6_cmd); |
Jon | 6c19d26 | 2009-02-11 17:19:07 -0800 | [diff] [blame] | 1402 | install_element (CONFIG_NODE, &no_router_ospf6_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1403 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1404 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1405 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); |
| 1406 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); |
| 1407 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 1408 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd); |
| 1409 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 1410 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); |
| 1411 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1412 | |
| 1413 | install_default (OSPF6_NODE); |
| 1414 | install_element (OSPF6_NODE, &ospf6_router_id_cmd); |
Dinesh Dutt | 3d35ca4 | 2013-08-26 03:40:16 +0000 | [diff] [blame] | 1415 | install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd); |
| 1416 | install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd); |
| 1417 | install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd); |
| 1418 | install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1419 | install_element (OSPF6_NODE, &ospf6_interface_area_cmd); |
| 1420 | install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 1421 | install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd); |
| 1422 | install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd); |
| 1423 | /* For a later time |
| 1424 | install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd); |
| 1425 | install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd); |
| 1426 | install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd); |
| 1427 | install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd); |
| 1428 | */ |
Roman Hoog Antink | d8f7f86 | 2014-03-05 09:13:43 +0100 | [diff] [blame] | 1429 | |
| 1430 | install_element (OSPF6_NODE, &ospf6_distance_cmd); |
| 1431 | install_element (OSPF6_NODE, &no_ospf6_distance_cmd); |
| 1432 | install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd); |
| 1433 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_cmd); |
| 1434 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_cmd); |
| 1435 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_cmd); |
| 1436 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_external_cmd); |
| 1437 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_inter_cmd); |
| 1438 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_cmd); |
| 1439 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_cmd); |
| 1440 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_cmd); |
| 1441 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_external_cmd); |
| 1442 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_intra_cmd); |
| 1443 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_cmd); |
| 1444 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_cmd); |
| 1445 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_cmd); |
| 1446 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_inter_cmd); |
| 1447 | install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_intra_cmd); |
| 1448 | |
| 1449 | install_element (OSPF6_NODE, &ospf6_distance_source_cmd); |
| 1450 | install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd); |
| 1451 | install_element (OSPF6_NODE, &ospf6_distance_source_access_list_cmd); |
| 1452 | install_element (OSPF6_NODE, &no_ospf6_distance_source_access_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 1455 | |