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 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 211 | static 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; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 219 | |
| 220 | o->maxage_remover = (struct thread *) NULL; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 221 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 222 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 223 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 224 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 225 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 226 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 227 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 228 | if (on->state != OSPF6_NEIGHBOR_EXCHANGE && |
| 229 | on->state != OSPF6_NEIGHBOR_LOADING) |
| 230 | continue; |
| 231 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 232 | return 0; |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 237 | for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 238 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 239 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi)) |
| 240 | OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb); |
| 241 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 242 | OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb); |
| 243 | } |
| 244 | OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb); |
| 245 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 250 | ospf6_maxage_remove (struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 251 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 252 | if (o && ! o->maxage_remover) |
| 253 | o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0); |
| 254 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 256 | /* start ospf6 */ |
| 257 | DEFUN (router_ospf6, |
| 258 | router_ospf6_cmd, |
| 259 | "router ospf6", |
| 260 | ROUTER_STR |
| 261 | OSPF6_STR) |
| 262 | { |
| 263 | if (ospf6 == NULL) |
| 264 | ospf6 = ospf6_create (); |
| 265 | if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) |
| 266 | ospf6_enable (ospf6); |
| 267 | |
| 268 | /* set current ospf point. */ |
| 269 | vty->node = OSPF6_NODE; |
| 270 | vty->index = ospf6; |
| 271 | |
| 272 | return CMD_SUCCESS; |
| 273 | } |
| 274 | |
| 275 | /* stop ospf6 */ |
| 276 | DEFUN (no_router_ospf6, |
| 277 | no_router_ospf6_cmd, |
| 278 | "no router ospf6", |
| 279 | NO_STR |
| 280 | OSPF6_ROUTER_STR) |
| 281 | { |
| 282 | if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 283 | vty_out (vty, "OSPFv3 is not running%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 284 | else |
| 285 | ospf6_disable (ospf6); |
| 286 | |
| 287 | /* return to config node . */ |
| 288 | vty->node = CONFIG_NODE; |
| 289 | vty->index = NULL; |
| 290 | |
| 291 | return CMD_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | /* change Router_ID commands. */ |
| 295 | DEFUN (ospf6_router_id, |
| 296 | ospf6_router_id_cmd, |
| 297 | "router-id A.B.C.D", |
| 298 | "Configure OSPF Router-ID\n" |
| 299 | V4NOTATION_STR) |
| 300 | { |
| 301 | int ret; |
| 302 | u_int32_t router_id; |
| 303 | struct ospf6 *o; |
| 304 | |
| 305 | o = (struct ospf6 *) vty->index; |
| 306 | |
| 307 | ret = inet_pton (AF_INET, argv[0], &router_id); |
| 308 | if (ret == 0) |
| 309 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 310 | vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 311 | return CMD_SUCCESS; |
| 312 | } |
| 313 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 314 | o->router_id_static = router_id; |
| 315 | if (o->router_id == 0) |
| 316 | o->router_id = router_id; |
| 317 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 318 | return CMD_SUCCESS; |
| 319 | } |
| 320 | |
| 321 | DEFUN (ospf6_interface_area, |
| 322 | ospf6_interface_area_cmd, |
| 323 | "interface IFNAME area A.B.C.D", |
| 324 | "Enable routing on an IPv6 interface\n" |
| 325 | IFNAME_STR |
| 326 | "Specify the OSPF6 area ID\n" |
| 327 | "OSPF6 area ID in IPv4 address notation\n" |
| 328 | ) |
| 329 | { |
| 330 | struct ospf6 *o; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 331 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 332 | struct ospf6_interface *oi; |
| 333 | struct interface *ifp; |
| 334 | u_int32_t area_id; |
| 335 | |
| 336 | o = (struct ospf6 *) vty->index; |
| 337 | |
| 338 | /* find/create ospf6 interface */ |
| 339 | ifp = if_get_by_name (argv[0]); |
| 340 | oi = (struct ospf6_interface *) ifp->info; |
| 341 | if (oi == NULL) |
| 342 | oi = ospf6_interface_create (ifp); |
| 343 | if (oi->area) |
| 344 | { |
| 345 | vty_out (vty, "%s already attached to Area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 346 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 347 | return CMD_SUCCESS; |
| 348 | } |
| 349 | |
| 350 | /* parse Area-ID */ |
| 351 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 352 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 353 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 354 | return CMD_SUCCESS; |
| 355 | } |
| 356 | |
| 357 | /* find/create ospf6 area */ |
| 358 | oa = ospf6_area_lookup (area_id, o); |
| 359 | if (oa == NULL) |
| 360 | oa = ospf6_area_create (area_id, o); |
| 361 | |
| 362 | /* attach interface to area */ |
| 363 | listnode_add (oa->if_list, oi); /* sort ?? */ |
| 364 | oi->area = oa; |
| 365 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 366 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
| 367 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 368 | /* start up */ |
| 369 | thread_add_event (master, interface_up, oi, 0); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 370 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 371 | /* If the router is ABR, originate summary routes */ |
| 372 | if (ospf6_is_router_abr (o)) |
| 373 | ospf6_abr_enable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 374 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 375 | return CMD_SUCCESS; |
| 376 | } |
| 377 | |
| 378 | DEFUN (no_ospf6_interface_area, |
| 379 | no_ospf6_interface_area_cmd, |
| 380 | "no interface IFNAME area A.B.C.D", |
| 381 | NO_STR |
| 382 | "Disable routing on an IPv6 interface\n" |
| 383 | IFNAME_STR |
| 384 | "Specify the OSPF6 area ID\n" |
| 385 | "OSPF6 area ID in IPv4 address notation\n" |
| 386 | ) |
| 387 | { |
| 388 | struct ospf6 *o; |
| 389 | struct ospf6_interface *oi; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 390 | struct ospf6_area *oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 391 | struct interface *ifp; |
| 392 | u_int32_t area_id; |
| 393 | |
| 394 | o = (struct ospf6 *) vty->index; |
| 395 | |
| 396 | ifp = if_lookup_by_name (argv[0]); |
| 397 | if (ifp == NULL) |
| 398 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 399 | vty_out (vty, "No such interface %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 400 | return CMD_SUCCESS; |
| 401 | } |
| 402 | |
| 403 | oi = (struct ospf6_interface *) ifp->info; |
| 404 | if (oi == NULL) |
| 405 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 406 | vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 407 | return CMD_SUCCESS; |
| 408 | } |
| 409 | |
| 410 | /* parse Area-ID */ |
| 411 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 412 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 413 | vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 414 | return CMD_SUCCESS; |
| 415 | } |
| 416 | |
Jon | 56abbb8 | 2009-02-11 17:30:44 -0800 | [diff] [blame] | 417 | /* Verify Area */ |
| 418 | if (oi->area == NULL) |
| 419 | { |
| 420 | vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL); |
| 421 | return CMD_SUCCESS; |
| 422 | } |
| 423 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 424 | if (oi->area->area_id != area_id) |
| 425 | { |
| 426 | vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 427 | oi->interface->name, oi->area->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 428 | return CMD_SUCCESS; |
| 429 | } |
| 430 | |
| 431 | thread_execute (master, interface_down, oi, 0); |
| 432 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 433 | oa = oi->area; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 434 | listnode_delete (oi->area->if_list, oi); |
| 435 | oi->area = (struct ospf6_area *) NULL; |
| 436 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 437 | /* Withdraw inter-area routes from this area, if necessary */ |
| 438 | if (oa->if_list->count == 0) |
| 439 | { |
| 440 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 441 | ospf6_abr_disable_area (oa); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 442 | } |
| 443 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 444 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 447 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 448 | ospf6_show (struct vty *vty, struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 449 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 450 | struct listnode *n; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 451 | struct ospf6_area *oa; |
| 452 | char router_id[16], duration[32]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 453 | struct timeval now, running; |
| 454 | |
| 455 | /* process id, router id */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 456 | inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id)); |
| 457 | vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 458 | router_id, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 459 | |
| 460 | /* running time */ |
Takashi Sogabe | 86f72dc | 2009-06-22 13:07:02 +0900 | [diff] [blame] | 461 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 462 | timersub (&now, &o->starttime, &running); |
| 463 | timerstring (&running, duration, sizeof (duration)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 464 | vty_out (vty, " Running %s%s", duration, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 466 | /* Redistribute configuration */ |
| 467 | /* XXX */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 468 | |
| 469 | /* LSAs */ |
| 470 | vty_out (vty, " Number of AS scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 471 | o->lsdb->count, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 472 | |
| 473 | /* Areas */ |
| 474 | vty_out (vty, " Number of areas in this router is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 475 | listcount (o->area_list), VNL); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 476 | |
| 477 | for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa)) |
| 478 | ospf6_area_show (vty, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | } |
| 480 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 481 | /* show top level structures */ |
| 482 | DEFUN (show_ipv6_ospf6, |
| 483 | show_ipv6_ospf6_cmd, |
| 484 | "show ipv6 ospf6", |
| 485 | SHOW_STR |
| 486 | IP6_STR |
| 487 | OSPF6_STR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 488 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 489 | OSPF6_CMD_CHECK_RUNNING (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 490 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 491 | ospf6_show (vty, ospf6); |
| 492 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | DEFUN (show_ipv6_ospf6_route, |
| 496 | show_ipv6_ospf6_route_cmd, |
| 497 | "show ipv6 ospf6 route", |
| 498 | SHOW_STR |
| 499 | IP6_STR |
| 500 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 501 | ROUTE_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 502 | ) |
| 503 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 504 | ospf6_route_table_show (vty, argc, argv, ospf6->route_table); |
| 505 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | ALIAS (show_ipv6_ospf6_route, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 509 | show_ipv6_ospf6_route_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 510 | "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] | 511 | SHOW_STR |
| 512 | IP6_STR |
| 513 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 514 | ROUTE_STR |
| 515 | "Specify IPv6 address\n" |
| 516 | "Specify IPv6 prefix\n" |
| 517 | "Detailed information\n" |
| 518 | "Summary of route table\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 519 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 520 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 521 | DEFUN (show_ipv6_ospf6_route_match, |
| 522 | show_ipv6_ospf6_route_match_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 523 | "show ipv6 ospf6 route X:X::X:X/M match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | SHOW_STR |
| 525 | IP6_STR |
| 526 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 527 | ROUTE_STR |
| 528 | "Specify IPv6 prefix\n" |
| 529 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 530 | ) |
| 531 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 532 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 533 | int i, sargc; |
| 534 | |
| 535 | /* copy argv to sargv and then append "match" */ |
| 536 | for (i = 0; i < argc; i++) |
| 537 | sargv[i] = argv[i]; |
| 538 | sargc = argc; |
| 539 | sargv[sargc++] = "match"; |
| 540 | sargv[sargc] = NULL; |
| 541 | |
| 542 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 543 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | } |
| 545 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 546 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 547 | show_ipv6_ospf6_route_match_detail_cmd, |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 548 | "show ipv6 ospf6 route X:X::X:X/M match detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | SHOW_STR |
| 550 | IP6_STR |
| 551 | OSPF6_STR |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 552 | ROUTE_STR |
| 553 | "Specify IPv6 prefix\n" |
| 554 | "Display routes which match the specified route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 555 | "Detailed information\n" |
| 556 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 557 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 558 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 559 | int i, sargc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 560 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 561 | /* copy argv to sargv and then append "match" and "detail" */ |
| 562 | for (i = 0; i < argc; i++) |
| 563 | sargv[i] = argv[i]; |
| 564 | sargc = argc; |
| 565 | sargv[sargc++] = "match"; |
| 566 | sargv[sargc++] = "detail"; |
| 567 | sargv[sargc] = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 568 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 569 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 570 | return CMD_SUCCESS; |
| 571 | } |
| 572 | |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 573 | ALIAS (show_ipv6_ospf6_route_match, |
| 574 | show_ipv6_ospf6_route_longer_cmd, |
| 575 | "show ipv6 ospf6 route X:X::X:X/M longer", |
| 576 | SHOW_STR |
| 577 | IP6_STR |
| 578 | OSPF6_STR |
| 579 | ROUTE_STR |
| 580 | "Specify IPv6 prefix\n" |
| 581 | "Display routes longer than the specified route\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 582 | ) |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 583 | |
| 584 | DEFUN (show_ipv6_ospf6_route_match_detail, |
| 585 | show_ipv6_ospf6_route_longer_detail_cmd, |
| 586 | "show ipv6 ospf6 route X:X::X:X/M longer detail", |
| 587 | SHOW_STR |
| 588 | IP6_STR |
| 589 | OSPF6_STR |
| 590 | ROUTE_STR |
| 591 | "Specify IPv6 prefix\n" |
| 592 | "Display routes longer than the specified route\n" |
| 593 | "Detailed information\n" |
| 594 | ); |
| 595 | |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 596 | ALIAS (show_ipv6_ospf6_route, |
| 597 | show_ipv6_ospf6_route_type_cmd, |
| 598 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", |
| 599 | SHOW_STR |
| 600 | IP6_STR |
| 601 | OSPF6_STR |
| 602 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 603 | "Display Intra-Area routes\n" |
| 604 | "Display Inter-Area routes\n" |
| 605 | "Display Type-1 External routes\n" |
| 606 | "Display Type-2 External routes\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 607 | ) |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 608 | |
| 609 | DEFUN (show_ipv6_ospf6_route_type_detail, |
| 610 | show_ipv6_ospf6_route_type_detail_cmd, |
| 611 | "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", |
| 612 | SHOW_STR |
| 613 | IP6_STR |
| 614 | OSPF6_STR |
| 615 | ROUTE_STR |
Denis Ovsienko | ea40219 | 2011-08-19 16:27:16 +0400 | [diff] [blame] | 616 | "Display Intra-Area routes\n" |
| 617 | "Display Inter-Area routes\n" |
| 618 | "Display Type-1 External routes\n" |
| 619 | "Display Type-2 External routes\n" |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 620 | "Detailed information\n" |
| 621 | ) |
| 622 | { |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 623 | const char *sargv[CMD_ARGC_MAX]; |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 624 | int i, sargc; |
| 625 | |
| 626 | /* copy argv to sargv and then append "detail" */ |
| 627 | for (i = 0; i < argc; i++) |
| 628 | sargv[i] = argv[i]; |
| 629 | sargc = argc; |
| 630 | sargv[sargc++] = "detail"; |
| 631 | sargv[sargc] = NULL; |
| 632 | |
| 633 | ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); |
| 634 | return CMD_SUCCESS; |
| 635 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 636 | |
| 637 | /* OSPF configuration write function. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 638 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 639 | config_write_ospf6 (struct vty *vty) |
| 640 | { |
| 641 | char router_id[16]; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 642 | struct listnode *j, *k; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 643 | struct ospf6_area *oa; |
| 644 | struct ospf6_interface *oi; |
| 645 | |
| 646 | /* OSPFv6 configuration. */ |
| 647 | if (ospf6 == NULL) |
| 648 | return CMD_SUCCESS; |
| 649 | if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)) |
| 650 | return CMD_SUCCESS; |
| 651 | |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 652 | inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 653 | vty_out (vty, "router ospf6%s", VNL); |
hasso | c8a440e | 2004-10-11 17:02:40 +0000 | [diff] [blame] | 654 | if (ospf6->router_id_static != 0) |
| 655 | vty_out (vty, " router-id %s%s", router_id, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 656 | |
| 657 | ospf6_redistribute_config_write (vty); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 658 | ospf6_area_config_write (vty); |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame^] | 659 | ospf6_spf_config_write (vty); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 660 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 661 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 662 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 663 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi)) |
| 664 | vty_out (vty, " interface %s area %s%s", |
| 665 | oi->interface->name, oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 666 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 667 | vty_out (vty, "!%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | /* OSPF6 node structure. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 672 | static struct cmd_node ospf6_node = |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 673 | { |
| 674 | OSPF6_NODE, |
| 675 | "%s(config-ospf6)# ", |
hasso | 69b4a81 | 2004-08-26 18:10:36 +0000 | [diff] [blame] | 676 | 1 /* VTYSH */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 677 | }; |
| 678 | |
| 679 | /* Install ospf related commands. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 680 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 681 | ospf6_top_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 683 | /* Install ospf6 top node. */ |
| 684 | install_node (&ospf6_node, config_write_ospf6); |
| 685 | |
| 686 | install_element (VIEW_NODE, &show_ipv6_ospf6_cmd); |
| 687 | install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd); |
| 688 | install_element (CONFIG_NODE, &router_ospf6_cmd); |
Jon | 6c19d26 | 2009-02-11 17:19:07 -0800 | [diff] [blame] | 689 | install_element (CONFIG_NODE, &no_router_ospf6_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 690 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 692 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); |
| 693 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); |
| 694 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 695 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd); |
| 696 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 697 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); |
| 698 | install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 700 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd); |
| 701 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd); |
| 702 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd); |
Paul Jakma | cb4b884 | 2006-05-15 10:39:30 +0000 | [diff] [blame] | 703 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd); |
| 704 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd); |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 705 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd); |
| 706 | install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 707 | |
| 708 | install_default (OSPF6_NODE); |
| 709 | install_element (OSPF6_NODE, &ospf6_router_id_cmd); |
| 710 | install_element (OSPF6_NODE, &ospf6_interface_area_cmd); |
| 711 | install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 712 | } |
| 713 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 714 | |