blob: 865a116763bfa52804c5cd68fcfa0d0f1e59c92d [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
hasso508e53e2004-05-18 18:57:06 +000054void
55ospf6_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:
64 if (IS_OSPF6_DEBUG_LSA (RECV))
65 zlog_info ("Unknown LSA in AS-scoped lsdb");
66 break;
paul718e3742002-12-13 20:15:29 +000067 }
68}
69
hasso508e53e2004-05-18 18:57:06 +000070void
71ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000072{
hasso508e53e2004-05-18 18:57:06 +000073 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000074 {
hasso508e53e2004-05-18 18:57:06 +000075 case OSPF6_LSTYPE_AS_EXTERNAL:
76 ospf6_asbr_lsa_remove (lsa);
77 break;
78
79 default:
80 if (IS_OSPF6_DEBUG_LSA (RECV))
81 zlog_info ("Unknown LSA in AS-scoped lsdb");
82 break;
paul718e3742002-12-13 20:15:29 +000083 }
84}
85
hasso049207c2004-08-04 20:02:13 +000086void
87ospf6_top_route_hook_add (struct ospf6_route *route)
88{
hasso6452df02004-08-15 05:52:07 +000089 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000090 ospf6_zebra_route_update_add (route);
91}
92
93void
94ospf6_top_route_hook_remove (struct ospf6_route *route)
95{
hasso6452df02004-08-15 05:52:07 +000096 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000097 ospf6_zebra_route_update_remove (route);
98}
99
hasso6452df02004-08-15 05:52:07 +0000100void
101ospf6_top_brouter_hook_add (struct ospf6_route *route)
102{
103 ospf6_abr_originate_summary (route);
104 ospf6_asbr_lsentry_add (route);
105}
106
107void
108ospf6_top_brouter_hook_remove (struct ospf6_route *route)
109{
110 ospf6_abr_originate_summary (route);
111 ospf6_asbr_lsentry_remove (route);
112}
113
hasso508e53e2004-05-18 18:57:06 +0000114struct ospf6 *
115ospf6_create ()
paul718e3742002-12-13 20:15:29 +0000116{
hasso508e53e2004-05-18 18:57:06 +0000117 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000118
hasso508e53e2004-05-18 18:57:06 +0000119 o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
120 memset (o, 0, sizeof (struct ospf6));
121
122 /* initialize */
123 gettimeofday (&o->starttime, (struct timezone *) NULL);
124 o->area_list = list_new ();
125 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000126 o->lsdb = ospf6_lsdb_create (o);
127 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000128 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
129 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
130
131 o->route_table = ospf6_route_table_create ();
hasso049207c2004-08-04 20:02:13 +0000132 o->route_table->hook_add = ospf6_top_route_hook_add;
133 o->route_table->hook_remove = ospf6_top_route_hook_remove;
hasso508e53e2004-05-18 18:57:06 +0000134
hasso049207c2004-08-04 20:02:13 +0000135 o->brouter_table = ospf6_route_table_create ();
hasso6452df02004-08-15 05:52:07 +0000136 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
137 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000138
hasso508e53e2004-05-18 18:57:06 +0000139 o->external_table = ospf6_route_table_create ();
140 o->external_id_table = route_table_init ();
141
142 return o;
143}
144
145void
146ospf6_delete (struct ospf6 *o)
147{
148 listnode i;
149 struct ospf6_area *oa;
150
151 for (i = listhead (o->area_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000152 {
hasso508e53e2004-05-18 18:57:06 +0000153 oa = (struct ospf6_area *) getdata (i);
154 ospf6_area_delete (oa);
155 }
156
157 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000158 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000159
160 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000161 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000162
163 ospf6_route_table_delete (o->external_table);
164 route_table_finish (o->external_id_table);
165
166 XFREE (MTYPE_OSPF6_TOP, o);
167}
168
169void
170ospf6_enable (struct ospf6 *o)
171{
172 listnode i;
173 struct ospf6_area *oa;
174
175 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
176 {
177 UNSET_FLAG (o->flag, OSPF6_DISABLED);
178 for (i = listhead (o->area_list); i; nextnode (i))
179 {
180 oa = (struct ospf6_area *) getdata (i);
181 ospf6_area_enable (oa);
182 }
paul718e3742002-12-13 20:15:29 +0000183 }
184}
185
hasso508e53e2004-05-18 18:57:06 +0000186void
187ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000188{
hasso508e53e2004-05-18 18:57:06 +0000189 listnode i;
190 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000191
hasso508e53e2004-05-18 18:57:06 +0000192 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
193 {
194 SET_FLAG (o->flag, OSPF6_DISABLED);
195 for (i = listhead (o->area_list); i; nextnode (i))
196 {
197 oa = (struct ospf6_area *) getdata (i);
198 ospf6_area_disable (oa);
199 }
paul718e3742002-12-13 20:15:29 +0000200
hasso508e53e2004-05-18 18:57:06 +0000201 ospf6_lsdb_remove_all (o->lsdb);
202 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000203 ospf6_route_remove_all (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000204 }
205}
paul718e3742002-12-13 20:15:29 +0000206
hasso508e53e2004-05-18 18:57:06 +0000207int
208ospf6_maxage_remover (struct thread *thread)
209{
210 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
211 struct ospf6_area *oa;
212 struct ospf6_interface *oi;
213 struct ospf6_neighbor *on;
214 listnode i, j, k;
215
216 o->maxage_remover = (struct thread *) NULL;
217 if (IS_OSPF6_DEBUG_LSA (TIMER))
218 zlog_info ("Maxage Remover");
219
220 for (i = listhead (o->area_list); i; nextnode (i))
221 {
222 oa = (struct ospf6_area *) getdata (i);
223 for (j = listhead (oa->if_list); j; nextnode (j))
224 {
225 oi = (struct ospf6_interface *) getdata (j);
226 for (k = listhead (oi->neighbor_list); k; nextnode (k))
227 {
228 on = (struct ospf6_neighbor *) getdata (k);
229 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
230 on->state != OSPF6_NEIGHBOR_LOADING)
231 continue;
232
233 if (IS_OSPF6_DEBUG_LSA (TIMER))
234 zlog_info ("Maxage Remover End: %s exchange or loading",
235 on->name);
236 return 0;
237 }
238 }
239 }
240
241 for (i = listhead (o->area_list); i; nextnode (i))
242 {
243 oa = (struct ospf6_area *) getdata (i);
244 for (j = listhead (oa->if_list); j; nextnode (j))
245 {
246 oi = (struct ospf6_interface *) getdata (j);
247 OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
248 }
249 OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
250 }
251 OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
252
253 if (IS_OSPF6_DEBUG_LSA (TIMER))
254 zlog_info ("Maxage Remover End");
255
paul718e3742002-12-13 20:15:29 +0000256 return 0;
257}
258
259void
hasso508e53e2004-05-18 18:57:06 +0000260ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000261{
hasso508e53e2004-05-18 18:57:06 +0000262 if (o && ! o->maxage_remover)
263 o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
264}
paul718e3742002-12-13 20:15:29 +0000265
hasso508e53e2004-05-18 18:57:06 +0000266/* start ospf6 */
267DEFUN (router_ospf6,
268 router_ospf6_cmd,
269 "router ospf6",
270 ROUTER_STR
271 OSPF6_STR)
272{
273 if (ospf6 == NULL)
274 ospf6 = ospf6_create ();
275 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
276 ospf6_enable (ospf6);
277
278 /* set current ospf point. */
279 vty->node = OSPF6_NODE;
280 vty->index = ospf6;
281
282 return CMD_SUCCESS;
283}
284
285/* stop ospf6 */
286DEFUN (no_router_ospf6,
287 no_router_ospf6_cmd,
288 "no router ospf6",
289 NO_STR
290 OSPF6_ROUTER_STR)
291{
292 if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
hasso049207c2004-08-04 20:02:13 +0000293 vty_out (vty, "OSPFv3 is not running%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000294 else
295 ospf6_disable (ospf6);
296
297 /* return to config node . */
298 vty->node = CONFIG_NODE;
299 vty->index = NULL;
300
301 return CMD_SUCCESS;
302}
303
304/* change Router_ID commands. */
305DEFUN (ospf6_router_id,
306 ospf6_router_id_cmd,
307 "router-id A.B.C.D",
308 "Configure OSPF Router-ID\n"
309 V4NOTATION_STR)
310{
311 int ret;
312 u_int32_t router_id;
313 struct ospf6 *o;
314
315 o = (struct ospf6 *) vty->index;
316
317 ret = inet_pton (AF_INET, argv[0], &router_id);
318 if (ret == 0)
319 {
hasso049207c2004-08-04 20:02:13 +0000320 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000321 return CMD_SUCCESS;
322 }
323
324 o->router_id = router_id;
325 return CMD_SUCCESS;
326}
327
328DEFUN (ospf6_interface_area,
329 ospf6_interface_area_cmd,
330 "interface IFNAME area A.B.C.D",
331 "Enable routing on an IPv6 interface\n"
332 IFNAME_STR
333 "Specify the OSPF6 area ID\n"
334 "OSPF6 area ID in IPv4 address notation\n"
335 )
336{
337 struct ospf6 *o;
hasso6452df02004-08-15 05:52:07 +0000338 struct ospf6_area *oa, *area;
hasso508e53e2004-05-18 18:57:06 +0000339 struct ospf6_interface *oi;
340 struct interface *ifp;
341 u_int32_t area_id;
hasso6452df02004-08-15 05:52:07 +0000342 listnode node;
343 struct ospf6_route *ro;
hasso508e53e2004-05-18 18:57:06 +0000344
345 o = (struct ospf6 *) vty->index;
346
347 /* find/create ospf6 interface */
348 ifp = if_get_by_name (argv[0]);
349 oi = (struct ospf6_interface *) ifp->info;
350 if (oi == NULL)
351 oi = ospf6_interface_create (ifp);
352 if (oi->area)
353 {
354 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000355 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000356 return CMD_SUCCESS;
357 }
358
359 /* parse Area-ID */
360 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
361 {
hasso049207c2004-08-04 20:02:13 +0000362 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000363 return CMD_SUCCESS;
364 }
365
366 /* find/create ospf6 area */
367 oa = ospf6_area_lookup (area_id, o);
368 if (oa == NULL)
369 oa = ospf6_area_create (area_id, o);
370
371 /* attach interface to area */
372 listnode_add (oa->if_list, oi); /* sort ?? */
373 oi->area = oa;
374
hasso6452df02004-08-15 05:52:07 +0000375 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
376
hasso508e53e2004-05-18 18:57:06 +0000377 /* start up */
378 thread_add_event (master, interface_up, oi, 0);
hasso6452df02004-08-15 05:52:07 +0000379
380 /* ABR stuff, redistribute inter-area LSAs and
381 re-originate Router-LSA (B-bit may have been changed) */
382 for (node = listhead (o->area_list); node; nextnode (node))
383 {
384 area = OSPF6_AREA (getdata (node));
385 OSPF6_ROUTER_LSA_SCHEDULE (area);
386
387 for (ro = ospf6_route_head (area->range_table); ro;
388 ro = ospf6_route_next (ro))
389 ospf6_abr_originate_summary_to_area (ro, oa);
390 }
391
392 for (ro = ospf6_route_head (o->brouter_table); ro;
393 ro = ospf6_route_next (ro))
394 ospf6_abr_originate_summary_to_area (ro, oa);
395
396 for (ro = ospf6_route_head (o->route_table); ro;
397 ro = ospf6_route_next (ro))
398 ospf6_abr_originate_summary_to_area (ro, oa);
399
hasso508e53e2004-05-18 18:57:06 +0000400 return CMD_SUCCESS;
401}
402
403DEFUN (no_ospf6_interface_area,
404 no_ospf6_interface_area_cmd,
405 "no interface IFNAME area A.B.C.D",
406 NO_STR
407 "Disable routing on an IPv6 interface\n"
408 IFNAME_STR
409 "Specify the OSPF6 area ID\n"
410 "OSPF6 area ID in IPv4 address notation\n"
411 )
412{
413 struct ospf6 *o;
414 struct ospf6_interface *oi;
hasso6452df02004-08-15 05:52:07 +0000415 struct ospf6_area *oa, *area;
hasso508e53e2004-05-18 18:57:06 +0000416 struct interface *ifp;
417 u_int32_t area_id;
hasso6452df02004-08-15 05:52:07 +0000418 listnode node;
419 struct ospf6_route *ro;
420 struct ospf6_lsa *old;
hasso508e53e2004-05-18 18:57:06 +0000421
422 o = (struct ospf6 *) vty->index;
423
424 ifp = if_lookup_by_name (argv[0]);
425 if (ifp == NULL)
426 {
hasso049207c2004-08-04 20:02:13 +0000427 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000428 return CMD_SUCCESS;
429 }
430
431 oi = (struct ospf6_interface *) ifp->info;
432 if (oi == NULL)
433 {
hasso049207c2004-08-04 20:02:13 +0000434 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000435 return CMD_SUCCESS;
436 }
437
438 /* parse Area-ID */
439 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
440 {
hasso049207c2004-08-04 20:02:13 +0000441 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000442 return CMD_SUCCESS;
443 }
444
445 if (oi->area->area_id != area_id)
446 {
447 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000448 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000449 return CMD_SUCCESS;
450 }
451
452 thread_execute (master, interface_down, oi, 0);
453
hasso6452df02004-08-15 05:52:07 +0000454 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000455 listnode_delete (oi->area->if_list, oi);
456 oi->area = (struct ospf6_area *) NULL;
457
hasso6452df02004-08-15 05:52:07 +0000458 /* Withdraw inter-area routes from this area, if necessary */
459 if (oa->if_list->count == 0)
460 {
461 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
462
463 for (ro = ospf6_route_head (oa->summary_prefix); ro;
464 ro = ospf6_route_next (ro))
465 {
466 old = ospf6_lsdb_lookup (ro->path.origin.type,
467 ro->path.origin.id,
468 oa->ospf6->router_id, oa->lsdb);
469 if (old)
470 ospf6_lsa_purge (old);
471 ospf6_route_remove (ro, oa->summary_prefix);
472 }
473 for (ro = ospf6_route_head (oa->summary_router); ro;
474 ro = ospf6_route_next (ro))
475 {
476 old = ospf6_lsdb_lookup (ro->path.origin.type,
477 ro->path.origin.id,
478 oa->ospf6->router_id, oa->lsdb);
479 if (old)
480 ospf6_lsa_purge (old);
481 ospf6_route_remove (ro, oa->summary_router);
482 }
483 }
484
485 /* Schedule Refreshment of Router-LSA for each area
486 (ABR status may change) */
487 for (node = listhead (o->area_list); node; nextnode (node))
488 {
489 area = OSPF6_AREA (getdata (node));
490 OSPF6_ROUTER_LSA_SCHEDULE (area);
491 }
492
hasso508e53e2004-05-18 18:57:06 +0000493 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000494}
495
496void
hasso508e53e2004-05-18 18:57:06 +0000497ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000498{
499 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000500 struct ospf6_area *oa;
501 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000502 struct timeval now, running;
503
504 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000505 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
506 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
hasso049207c2004-08-04 20:02:13 +0000507 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000508
509 /* running time */
510 gettimeofday (&now, (struct timezone *)NULL);
hasso508e53e2004-05-18 18:57:06 +0000511 timersub (&now, &o->starttime, &running);
512 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000513 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000514
hasso508e53e2004-05-18 18:57:06 +0000515 /* Redistribute configuration */
516 /* XXX */
paul718e3742002-12-13 20:15:29 +0000517
518 /* LSAs */
519 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000520 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000521
522 /* Areas */
523 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000524 listcount (o->area_list), VNL);
hasso508e53e2004-05-18 18:57:06 +0000525 for (n = listhead (o->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000526 {
hasso508e53e2004-05-18 18:57:06 +0000527 oa = (struct ospf6_area *) getdata (n);
528 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000529 }
530}
531
hasso508e53e2004-05-18 18:57:06 +0000532/* show top level structures */
533DEFUN (show_ipv6_ospf6,
534 show_ipv6_ospf6_cmd,
535 "show ipv6 ospf6",
536 SHOW_STR
537 IP6_STR
538 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000539{
hasso508e53e2004-05-18 18:57:06 +0000540 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000541
hasso508e53e2004-05-18 18:57:06 +0000542 ospf6_show (vty, ospf6);
543 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000544}
545
546DEFUN (show_ipv6_ospf6_route,
547 show_ipv6_ospf6_route_cmd,
548 "show ipv6 ospf6 route",
549 SHOW_STR
550 IP6_STR
551 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000552 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000553 )
554{
hasso508e53e2004-05-18 18:57:06 +0000555 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
556 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000557}
558
559ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000560 show_ipv6_ospf6_route_detail_cmd,
561 "show ipv6 ospf6 route (X::X|X::X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000562 SHOW_STR
563 IP6_STR
564 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000565 ROUTE_STR
566 "Specify IPv6 address\n"
567 "Specify IPv6 prefix\n"
568 "Detailed information\n"
569 "Summary of route table\n"
570 );
paul718e3742002-12-13 20:15:29 +0000571
hasso508e53e2004-05-18 18:57:06 +0000572DEFUN (show_ipv6_ospf6_route_match,
573 show_ipv6_ospf6_route_match_cmd,
574 "show ipv6 ospf6 route X::X/M match",
paul718e3742002-12-13 20:15:29 +0000575 SHOW_STR
576 IP6_STR
577 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000578 ROUTE_STR
579 "Specify IPv6 prefix\n"
580 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000581 )
582{
hasso508e53e2004-05-18 18:57:06 +0000583 char *sargv[CMD_ARGC_MAX];
584 int i, sargc;
585
586 /* copy argv to sargv and then append "match" */
587 for (i = 0; i < argc; i++)
588 sargv[i] = argv[i];
589 sargc = argc;
590 sargv[sargc++] = "match";
591 sargv[sargc] = NULL;
592
593 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
594 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000595}
596
hasso508e53e2004-05-18 18:57:06 +0000597DEFUN (show_ipv6_ospf6_route_match_detail,
598 show_ipv6_ospf6_route_match_detail_cmd,
599 "show ipv6 ospf6 route X::X/M match detail",
paul718e3742002-12-13 20:15:29 +0000600 SHOW_STR
601 IP6_STR
602 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000603 ROUTE_STR
604 "Specify IPv6 prefix\n"
605 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000606 "Detailed information\n"
607 )
hasso508e53e2004-05-18 18:57:06 +0000608{
609 char *sargv[CMD_ARGC_MAX];
610 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000611
hasso508e53e2004-05-18 18:57:06 +0000612 /* copy argv to sargv and then append "match" and "detail" */
613 for (i = 0; i < argc; i++)
614 sargv[i] = argv[i];
615 sargc = argc;
616 sargv[sargc++] = "match";
617 sargv[sargc++] = "detail";
618 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000619
hasso508e53e2004-05-18 18:57:06 +0000620 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
621 return CMD_SUCCESS;
622}
623
624
625/* OSPF configuration write function. */
626int
627config_write_ospf6 (struct vty *vty)
628{
629 char router_id[16];
630 listnode j, k;
631 struct ospf6_area *oa;
632 struct ospf6_interface *oi;
633
634 /* OSPFv6 configuration. */
635 if (ospf6 == NULL)
636 return CMD_SUCCESS;
637 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
638 return CMD_SUCCESS;
639
640 inet_ntop (AF_INET, &ospf6->router_id, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000641 vty_out (vty, "router ospf6%s", VNL);
642 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000643
644 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000645 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000646
647 for (j = listhead (ospf6->area_list); j; nextnode (j))
648 {
649 oa = (struct ospf6_area *) getdata (j);
650 for (k = listhead (oa->if_list); k; nextnode (k))
651 {
652 oi = (struct ospf6_interface *) getdata (k);
653 vty_out (vty, " interface %s area %s%s",
hasso049207c2004-08-04 20:02:13 +0000654 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000655 }
656 }
hasso049207c2004-08-04 20:02:13 +0000657 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000658 return 0;
659}
660
661/* OSPF6 node structure. */
662struct cmd_node ospf6_node =
663{
664 OSPF6_NODE,
665 "%s(config-ospf6)# ",
666};
667
668/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000669void
670ospf6_top_init ()
671{
hasso508e53e2004-05-18 18:57:06 +0000672 /* Install ospf6 top node. */
673 install_node (&ospf6_node, config_write_ospf6);
674
675 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
676 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
677 install_element (CONFIG_NODE, &router_ospf6_cmd);
678
paul718e3742002-12-13 20:15:29 +0000679 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000680 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
681 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
682 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000683 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000684 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
685 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
686 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
687
688 install_default (OSPF6_NODE);
689 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
690 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
691 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
692 install_element (OSPF6_NODE, &no_router_ospf6_cmd);
paul718e3742002-12-13 20:15:29 +0000693}
694
hasso508e53e2004-05-18 18:57:06 +0000695