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