blob: 2d4d3caf29b5220d59bf2492f35e2d53da8f2396 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
paul718e3742002-12-13 20:15:29 +000033#include "ospf6_proto.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_message.h"
paul718e3742002-12-13 20:15:29 +000035#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
paul718e3742002-12-13 20:15:29 +000037#include "ospf6_route.h"
38#include "ospf6_zebra.h"
39
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_top.h"
41#include "ospf6_area.h"
42#include "ospf6_interface.h"
43#include "ospf6_neighbor.h"
paul718e3742002-12-13 20:15:29 +000044
hasso6452df02004-08-15 05:52:07 +000045#include "ospf6_flood.h"
hasso508e53e2004-05-18 18:57:06 +000046#include "ospf6_asbr.h"
hasso049207c2004-08-04 20:02:13 +000047#include "ospf6_abr.h"
hasso6452df02004-08-15 05:52:07 +000048#include "ospf6_intra.h"
hasso049207c2004-08-04 20:02:13 +000049#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000050
51/* global ospf6d variable */
52struct ospf6 *ospf6;
53
Paul Jakma6ac29a52008-08-15 13:45:30 +010054static void
hasso508e53e2004-05-18 18:57:06 +000055ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000056{
hasso508e53e2004-05-18 18:57:06 +000057 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000058 {
hasso508e53e2004-05-18 18:57:06 +000059 case OSPF6_LSTYPE_AS_EXTERNAL:
60 ospf6_asbr_lsa_add (lsa);
61 break;
62
63 default:
hasso508e53e2004-05-18 18:57:06 +000064 break;
paul718e3742002-12-13 20:15:29 +000065 }
66}
67
Paul Jakma6ac29a52008-08-15 13:45:30 +010068static void
hasso508e53e2004-05-18 18:57:06 +000069ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000070{
hasso508e53e2004-05-18 18:57:06 +000071 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000072 {
hasso508e53e2004-05-18 18:57:06 +000073 case OSPF6_LSTYPE_AS_EXTERNAL:
74 ospf6_asbr_lsa_remove (lsa);
75 break;
76
77 default:
hasso508e53e2004-05-18 18:57:06 +000078 break;
paul718e3742002-12-13 20:15:29 +000079 }
80}
81
Paul Jakma6ac29a52008-08-15 13:45:30 +010082static void
hasso049207c2004-08-04 20:02:13 +000083ospf6_top_route_hook_add (struct ospf6_route *route)
84{
hasso6452df02004-08-15 05:52:07 +000085 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000086 ospf6_zebra_route_update_add (route);
87}
88
Paul Jakma6ac29a52008-08-15 13:45:30 +010089static void
hasso049207c2004-08-04 20:02:13 +000090ospf6_top_route_hook_remove (struct ospf6_route *route)
91{
hasso6452df02004-08-15 05:52:07 +000092 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000093 ospf6_zebra_route_update_remove (route);
94}
95
Paul Jakma6ac29a52008-08-15 13:45:30 +010096static void
hasso6452df02004-08-15 05:52:07 +000097ospf6_top_brouter_hook_add (struct ospf6_route *route)
98{
hassoccb59b12004-08-25 09:10:37 +000099 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000100 ospf6_asbr_lsentry_add (route);
hassoccb59b12004-08-25 09:10:37 +0000101 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000102}
103
Paul Jakma6ac29a52008-08-15 13:45:30 +0100104static void
hasso6452df02004-08-15 05:52:07 +0000105ospf6_top_brouter_hook_remove (struct ospf6_route *route)
106{
hassoccb59b12004-08-25 09:10:37 +0000107 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000108 ospf6_asbr_lsentry_remove (route);
hassoccb59b12004-08-25 09:10:37 +0000109 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000110}
111
Paul Jakma6ac29a52008-08-15 13:45:30 +0100112static struct ospf6 *
113ospf6_create (void)
paul718e3742002-12-13 20:15:29 +0000114{
hasso508e53e2004-05-18 18:57:06 +0000115 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000116
Stephen Hemminger393deb92008-08-18 14:13:29 -0700117 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
hasso508e53e2004-05-18 18:57:06 +0000118
119 /* initialize */
120 gettimeofday (&o->starttime, (struct timezone *) NULL);
121 o->area_list = list_new ();
122 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000123 o->lsdb = ospf6_lsdb_create (o);
124 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000125 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
126 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
127
Paul Jakmacf1ce252006-05-15 10:46:07 +0000128 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
129 o->route_table->scope = o;
hasso049207c2004-08-04 20:02:13 +0000130 o->route_table->hook_add = ospf6_top_route_hook_add;
131 o->route_table->hook_remove = ospf6_top_route_hook_remove;
hasso508e53e2004-05-18 18:57:06 +0000132
Paul Jakmacf1ce252006-05-15 10:46:07 +0000133 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
134 o->brouter_table->scope = o;
hasso6452df02004-08-15 05:52:07 +0000135 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
136 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000137
Paul Jakmacf1ce252006-05-15 10:46:07 +0000138 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
139 o->external_table->scope = o;
140
hasso508e53e2004-05-18 18:57:06 +0000141 o->external_id_table = route_table_init ();
142
143 return o;
144}
145
Paul Jakma6ac29a52008-08-15 13:45:30 +0100146static void
hasso508e53e2004-05-18 18:57:06 +0000147ospf6_delete (struct ospf6 *o)
148{
paul1eb8ef22005-04-07 07:30:20 +0000149 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000150 struct ospf6_area *oa;
151
paul1eb8ef22005-04-07 07:30:20 +0000152 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
153 ospf6_area_delete (oa);
hasso508e53e2004-05-18 18:57:06 +0000154
155 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000156 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000157
158 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000159 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000160
161 ospf6_route_table_delete (o->external_table);
162 route_table_finish (o->external_id_table);
163
164 XFREE (MTYPE_OSPF6_TOP, o);
165}
166
Paul Jakma6ac29a52008-08-15 13:45:30 +0100167static void
hasso508e53e2004-05-18 18:57:06 +0000168ospf6_enable (struct ospf6 *o)
169{
paul1eb8ef22005-04-07 07:30:20 +0000170 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000171 struct ospf6_area *oa;
172
173 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
174 {
175 UNSET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000176 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
177 ospf6_area_enable (oa);
paul718e3742002-12-13 20:15:29 +0000178 }
179}
180
Paul Jakma6ac29a52008-08-15 13:45:30 +0100181static void
hasso508e53e2004-05-18 18:57:06 +0000182ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000183{
paul1eb8ef22005-04-07 07:30:20 +0000184 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000185 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000186
hasso508e53e2004-05-18 18:57:06 +0000187 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
188 {
189 SET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000190
191 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
192 ospf6_area_disable (oa);
paul718e3742002-12-13 20:15:29 +0000193
hasso508e53e2004-05-18 18:57:06 +0000194 ospf6_lsdb_remove_all (o->lsdb);
195 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000196 ospf6_route_remove_all (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000197 }
198}
paul718e3742002-12-13 20:15:29 +0000199
Paul Jakma6ac29a52008-08-15 13:45:30 +0100200static int
hasso508e53e2004-05-18 18:57:06 +0000201ospf6_maxage_remover (struct thread *thread)
202{
203 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
204 struct ospf6_area *oa;
205 struct ospf6_interface *oi;
206 struct ospf6_neighbor *on;
hasso52dc7ee2004-09-23 19:18:23 +0000207 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000208
209 o->maxage_remover = (struct thread *) NULL;
hasso508e53e2004-05-18 18:57:06 +0000210
paul1eb8ef22005-04-07 07:30:20 +0000211 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000212 {
paul1eb8ef22005-04-07 07:30:20 +0000213 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
hasso508e53e2004-05-18 18:57:06 +0000214 {
paul1eb8ef22005-04-07 07:30:20 +0000215 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
hasso508e53e2004-05-18 18:57:06 +0000216 {
hasso508e53e2004-05-18 18:57:06 +0000217 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
218 on->state != OSPF6_NEIGHBOR_LOADING)
219 continue;
220
hasso508e53e2004-05-18 18:57:06 +0000221 return 0;
222 }
223 }
224 }
225
paul1eb8ef22005-04-07 07:30:20 +0000226 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000227 {
paul1eb8ef22005-04-07 07:30:20 +0000228 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
229 OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
230
hasso508e53e2004-05-18 18:57:06 +0000231 OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
232 }
233 OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
234
paul718e3742002-12-13 20:15:29 +0000235 return 0;
236}
237
238void
hasso508e53e2004-05-18 18:57:06 +0000239ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000240{
hasso508e53e2004-05-18 18:57:06 +0000241 if (o && ! o->maxage_remover)
242 o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
243}
paul718e3742002-12-13 20:15:29 +0000244
hasso508e53e2004-05-18 18:57:06 +0000245/* start ospf6 */
246DEFUN (router_ospf6,
247 router_ospf6_cmd,
248 "router ospf6",
249 ROUTER_STR
250 OSPF6_STR)
251{
252 if (ospf6 == NULL)
253 ospf6 = ospf6_create ();
254 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
255 ospf6_enable (ospf6);
256
257 /* set current ospf point. */
258 vty->node = OSPF6_NODE;
259 vty->index = ospf6;
260
261 return CMD_SUCCESS;
262}
263
264/* stop ospf6 */
265DEFUN (no_router_ospf6,
266 no_router_ospf6_cmd,
267 "no router ospf6",
268 NO_STR
269 OSPF6_ROUTER_STR)
270{
271 if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
hasso049207c2004-08-04 20:02:13 +0000272 vty_out (vty, "OSPFv3 is not running%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000273 else
274 ospf6_disable (ospf6);
275
276 /* return to config node . */
277 vty->node = CONFIG_NODE;
278 vty->index = NULL;
279
280 return CMD_SUCCESS;
281}
282
283/* change Router_ID commands. */
284DEFUN (ospf6_router_id,
285 ospf6_router_id_cmd,
286 "router-id A.B.C.D",
287 "Configure OSPF Router-ID\n"
288 V4NOTATION_STR)
289{
290 int ret;
291 u_int32_t router_id;
292 struct ospf6 *o;
293
294 o = (struct ospf6 *) vty->index;
295
296 ret = inet_pton (AF_INET, argv[0], &router_id);
297 if (ret == 0)
298 {
hasso049207c2004-08-04 20:02:13 +0000299 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000300 return CMD_SUCCESS;
301 }
302
hassoc8a440e2004-10-11 17:02:40 +0000303 o->router_id_static = router_id;
304 if (o->router_id == 0)
305 o->router_id = router_id;
306
hasso508e53e2004-05-18 18:57:06 +0000307 return CMD_SUCCESS;
308}
309
310DEFUN (ospf6_interface_area,
311 ospf6_interface_area_cmd,
312 "interface IFNAME area A.B.C.D",
313 "Enable routing on an IPv6 interface\n"
314 IFNAME_STR
315 "Specify the OSPF6 area ID\n"
316 "OSPF6 area ID in IPv4 address notation\n"
317 )
318{
319 struct ospf6 *o;
hasso3b687352004-08-19 06:56:53 +0000320 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000321 struct ospf6_interface *oi;
322 struct interface *ifp;
323 u_int32_t area_id;
324
325 o = (struct ospf6 *) vty->index;
326
327 /* find/create ospf6 interface */
328 ifp = if_get_by_name (argv[0]);
329 oi = (struct ospf6_interface *) ifp->info;
330 if (oi == NULL)
331 oi = ospf6_interface_create (ifp);
332 if (oi->area)
333 {
334 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000335 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000336 return CMD_SUCCESS;
337 }
338
339 /* parse Area-ID */
340 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
341 {
hasso049207c2004-08-04 20:02:13 +0000342 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000343 return CMD_SUCCESS;
344 }
345
346 /* find/create ospf6 area */
347 oa = ospf6_area_lookup (area_id, o);
348 if (oa == NULL)
349 oa = ospf6_area_create (area_id, o);
350
351 /* attach interface to area */
352 listnode_add (oa->if_list, oi); /* sort ?? */
353 oi->area = oa;
354
hasso6452df02004-08-15 05:52:07 +0000355 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
356
hasso508e53e2004-05-18 18:57:06 +0000357 /* start up */
358 thread_add_event (master, interface_up, oi, 0);
hasso6452df02004-08-15 05:52:07 +0000359
hasso3b687352004-08-19 06:56:53 +0000360 /* If the router is ABR, originate summary routes */
361 if (ospf6_is_router_abr (o))
362 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000363
hasso508e53e2004-05-18 18:57:06 +0000364 return CMD_SUCCESS;
365}
366
367DEFUN (no_ospf6_interface_area,
368 no_ospf6_interface_area_cmd,
369 "no interface IFNAME area A.B.C.D",
370 NO_STR
371 "Disable routing on an IPv6 interface\n"
372 IFNAME_STR
373 "Specify the OSPF6 area ID\n"
374 "OSPF6 area ID in IPv4 address notation\n"
375 )
376{
377 struct ospf6 *o;
378 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000379 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000380 struct interface *ifp;
381 u_int32_t area_id;
382
383 o = (struct ospf6 *) vty->index;
384
385 ifp = if_lookup_by_name (argv[0]);
386 if (ifp == NULL)
387 {
hasso049207c2004-08-04 20:02:13 +0000388 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000389 return CMD_SUCCESS;
390 }
391
392 oi = (struct ospf6_interface *) ifp->info;
393 if (oi == NULL)
394 {
hasso049207c2004-08-04 20:02:13 +0000395 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000396 return CMD_SUCCESS;
397 }
398
399 /* parse Area-ID */
400 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
401 {
hasso049207c2004-08-04 20:02:13 +0000402 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000403 return CMD_SUCCESS;
404 }
405
406 if (oi->area->area_id != area_id)
407 {
408 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000409 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000410 return CMD_SUCCESS;
411 }
412
413 thread_execute (master, interface_down, oi, 0);
414
hasso6452df02004-08-15 05:52:07 +0000415 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000416 listnode_delete (oi->area->if_list, oi);
417 oi->area = (struct ospf6_area *) NULL;
418
hasso6452df02004-08-15 05:52:07 +0000419 /* Withdraw inter-area routes from this area, if necessary */
420 if (oa->if_list->count == 0)
421 {
422 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso3b687352004-08-19 06:56:53 +0000423 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000424 }
425
hasso508e53e2004-05-18 18:57:06 +0000426 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000427}
428
Paul Jakma6ac29a52008-08-15 13:45:30 +0100429static void
hasso508e53e2004-05-18 18:57:06 +0000430ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000431{
hasso52dc7ee2004-09-23 19:18:23 +0000432 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000433 struct ospf6_area *oa;
434 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000435 struct timeval now, running;
436
437 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000438 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
439 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
hasso049207c2004-08-04 20:02:13 +0000440 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000441
442 /* running time */
443 gettimeofday (&now, (struct timezone *)NULL);
hasso508e53e2004-05-18 18:57:06 +0000444 timersub (&now, &o->starttime, &running);
445 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000446 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000447
hasso508e53e2004-05-18 18:57:06 +0000448 /* Redistribute configuration */
449 /* XXX */
paul718e3742002-12-13 20:15:29 +0000450
451 /* LSAs */
452 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000453 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000454
455 /* Areas */
456 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000457 listcount (o->area_list), VNL);
paul1eb8ef22005-04-07 07:30:20 +0000458
459 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
460 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000461}
462
hasso508e53e2004-05-18 18:57:06 +0000463/* show top level structures */
464DEFUN (show_ipv6_ospf6,
465 show_ipv6_ospf6_cmd,
466 "show ipv6 ospf6",
467 SHOW_STR
468 IP6_STR
469 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000470{
hasso508e53e2004-05-18 18:57:06 +0000471 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000472
hasso508e53e2004-05-18 18:57:06 +0000473 ospf6_show (vty, ospf6);
474 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000475}
476
477DEFUN (show_ipv6_ospf6_route,
478 show_ipv6_ospf6_route_cmd,
479 "show ipv6 ospf6 route",
480 SHOW_STR
481 IP6_STR
482 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000483 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000484 )
485{
hasso508e53e2004-05-18 18:57:06 +0000486 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
487 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000488}
489
490ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000491 show_ipv6_ospf6_route_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000492 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000493 SHOW_STR
494 IP6_STR
495 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000496 ROUTE_STR
497 "Specify IPv6 address\n"
498 "Specify IPv6 prefix\n"
499 "Detailed information\n"
500 "Summary of route table\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100501 )
paul718e3742002-12-13 20:15:29 +0000502
hasso508e53e2004-05-18 18:57:06 +0000503DEFUN (show_ipv6_ospf6_route_match,
504 show_ipv6_ospf6_route_match_cmd,
hasso4846ef62004-09-03 06:04:00 +0000505 "show ipv6 ospf6 route X:X::X:X/M match",
paul718e3742002-12-13 20:15:29 +0000506 SHOW_STR
507 IP6_STR
508 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000509 ROUTE_STR
510 "Specify IPv6 prefix\n"
511 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000512 )
513{
paul0c083ee2004-10-10 12:54:58 +0000514 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000515 int i, sargc;
516
517 /* copy argv to sargv and then append "match" */
518 for (i = 0; i < argc; i++)
519 sargv[i] = argv[i];
520 sargc = argc;
521 sargv[sargc++] = "match";
522 sargv[sargc] = NULL;
523
524 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
525 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000526}
527
hasso508e53e2004-05-18 18:57:06 +0000528DEFUN (show_ipv6_ospf6_route_match_detail,
529 show_ipv6_ospf6_route_match_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000530 "show ipv6 ospf6 route X:X::X:X/M match detail",
paul718e3742002-12-13 20:15:29 +0000531 SHOW_STR
532 IP6_STR
533 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000534 ROUTE_STR
535 "Specify IPv6 prefix\n"
536 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000537 "Detailed information\n"
538 )
hasso508e53e2004-05-18 18:57:06 +0000539{
paul0c083ee2004-10-10 12:54:58 +0000540 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000541 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000542
hasso508e53e2004-05-18 18:57:06 +0000543 /* copy argv to sargv and then append "match" and "detail" */
544 for (i = 0; i < argc; i++)
545 sargv[i] = argv[i];
546 sargc = argc;
547 sargv[sargc++] = "match";
548 sargv[sargc++] = "detail";
549 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000550
hasso508e53e2004-05-18 18:57:06 +0000551 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
552 return CMD_SUCCESS;
553}
554
Paul Jakmacb4b8842006-05-15 10:39:30 +0000555ALIAS (show_ipv6_ospf6_route_match,
556 show_ipv6_ospf6_route_longer_cmd,
557 "show ipv6 ospf6 route X:X::X:X/M longer",
558 SHOW_STR
559 IP6_STR
560 OSPF6_STR
561 ROUTE_STR
562 "Specify IPv6 prefix\n"
563 "Display routes longer than the specified route\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100564 )
Paul Jakmacb4b8842006-05-15 10:39:30 +0000565
566DEFUN (show_ipv6_ospf6_route_match_detail,
567 show_ipv6_ospf6_route_longer_detail_cmd,
568 "show ipv6 ospf6 route X:X::X:X/M longer detail",
569 SHOW_STR
570 IP6_STR
571 OSPF6_STR
572 ROUTE_STR
573 "Specify IPv6 prefix\n"
574 "Display routes longer than the specified route\n"
575 "Detailed information\n"
576 );
577
hasso4846ef62004-09-03 06:04:00 +0000578ALIAS (show_ipv6_ospf6_route,
579 show_ipv6_ospf6_route_type_cmd,
580 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
581 SHOW_STR
582 IP6_STR
583 OSPF6_STR
584 ROUTE_STR
585 "Dispaly Intra-Area routes\n"
586 "Dispaly Inter-Area routes\n"
587 "Dispaly Type-1 External routes\n"
588 "Dispaly Type-2 External routes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100589 )
hasso4846ef62004-09-03 06:04:00 +0000590
591DEFUN (show_ipv6_ospf6_route_type_detail,
592 show_ipv6_ospf6_route_type_detail_cmd,
593 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
594 SHOW_STR
595 IP6_STR
596 OSPF6_STR
597 ROUTE_STR
598 "Dispaly Intra-Area routes\n"
599 "Dispaly Inter-Area routes\n"
600 "Dispaly Type-1 External routes\n"
601 "Dispaly Type-2 External routes\n"
602 "Detailed information\n"
603 )
604{
paul0c083ee2004-10-10 12:54:58 +0000605 const char *sargv[CMD_ARGC_MAX];
hasso4846ef62004-09-03 06:04:00 +0000606 int i, sargc;
607
608 /* copy argv to sargv and then append "detail" */
609 for (i = 0; i < argc; i++)
610 sargv[i] = argv[i];
611 sargc = argc;
612 sargv[sargc++] = "detail";
613 sargv[sargc] = NULL;
614
615 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
616 return CMD_SUCCESS;
617}
hasso508e53e2004-05-18 18:57:06 +0000618
619/* OSPF configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100620static int
hasso508e53e2004-05-18 18:57:06 +0000621config_write_ospf6 (struct vty *vty)
622{
623 char router_id[16];
hasso52dc7ee2004-09-23 19:18:23 +0000624 struct listnode *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000625 struct ospf6_area *oa;
626 struct ospf6_interface *oi;
627
628 /* OSPFv6 configuration. */
629 if (ospf6 == NULL)
630 return CMD_SUCCESS;
631 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
632 return CMD_SUCCESS;
633
hassoc8a440e2004-10-11 17:02:40 +0000634 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000635 vty_out (vty, "router ospf6%s", VNL);
hassoc8a440e2004-10-11 17:02:40 +0000636 if (ospf6->router_id_static != 0)
637 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000638
639 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000640 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000641
paul1eb8ef22005-04-07 07:30:20 +0000642 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
hasso508e53e2004-05-18 18:57:06 +0000643 {
paul1eb8ef22005-04-07 07:30:20 +0000644 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
645 vty_out (vty, " interface %s area %s%s",
646 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000647 }
hasso049207c2004-08-04 20:02:13 +0000648 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000649 return 0;
650}
651
652/* OSPF6 node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800653static struct cmd_node ospf6_node =
hasso508e53e2004-05-18 18:57:06 +0000654{
655 OSPF6_NODE,
656 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +0000657 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +0000658};
659
660/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000661void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100662ospf6_top_init (void)
paul718e3742002-12-13 20:15:29 +0000663{
hasso508e53e2004-05-18 18:57:06 +0000664 /* Install ospf6 top node. */
665 install_node (&ospf6_node, config_write_ospf6);
666
667 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
668 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
669 install_element (CONFIG_NODE, &router_ospf6_cmd);
Jon6c19d262009-02-11 17:19:07 -0800670 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +0000671
paul718e3742002-12-13 20:15:29 +0000672 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000673 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
674 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
675 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000676 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
677 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000678 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
679 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000680 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000681 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
682 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
683 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000684 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
685 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000686 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
687 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +0000688
689 install_default (OSPF6_NODE);
690 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
691 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
692 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
693 install_element (OSPF6_NODE, &no_router_ospf6_cmd);
paul718e3742002-12-13 20:15:29 +0000694}
695
hasso508e53e2004-05-18 18:57:06 +0000696