blob: 57103160ef6a2d1bbd4b9aad64796e437164470f [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;
hasso3b687352004-08-19 06:56:53 +0000338 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000339 struct ospf6_interface *oi;
340 struct interface *ifp;
341 u_int32_t area_id;
342
343 o = (struct ospf6 *) vty->index;
344
345 /* find/create ospf6 interface */
346 ifp = if_get_by_name (argv[0]);
347 oi = (struct ospf6_interface *) ifp->info;
348 if (oi == NULL)
349 oi = ospf6_interface_create (ifp);
350 if (oi->area)
351 {
352 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000353 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000354 return CMD_SUCCESS;
355 }
356
357 /* parse Area-ID */
358 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
359 {
hasso049207c2004-08-04 20:02:13 +0000360 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000361 return CMD_SUCCESS;
362 }
363
364 /* find/create ospf6 area */
365 oa = ospf6_area_lookup (area_id, o);
366 if (oa == NULL)
367 oa = ospf6_area_create (area_id, o);
368
369 /* attach interface to area */
370 listnode_add (oa->if_list, oi); /* sort ?? */
371 oi->area = oa;
372
hasso6452df02004-08-15 05:52:07 +0000373 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
374
hasso508e53e2004-05-18 18:57:06 +0000375 /* start up */
376 thread_add_event (master, interface_up, oi, 0);
hasso6452df02004-08-15 05:52:07 +0000377
hasso3b687352004-08-19 06:56:53 +0000378 /* If the router is ABR, originate summary routes */
379 if (ospf6_is_router_abr (o))
380 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000381
hasso508e53e2004-05-18 18:57:06 +0000382 return CMD_SUCCESS;
383}
384
385DEFUN (no_ospf6_interface_area,
386 no_ospf6_interface_area_cmd,
387 "no interface IFNAME area A.B.C.D",
388 NO_STR
389 "Disable routing on an IPv6 interface\n"
390 IFNAME_STR
391 "Specify the OSPF6 area ID\n"
392 "OSPF6 area ID in IPv4 address notation\n"
393 )
394{
395 struct ospf6 *o;
396 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000397 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000398 struct interface *ifp;
399 u_int32_t area_id;
400
401 o = (struct ospf6 *) vty->index;
402
403 ifp = if_lookup_by_name (argv[0]);
404 if (ifp == NULL)
405 {
hasso049207c2004-08-04 20:02:13 +0000406 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000407 return CMD_SUCCESS;
408 }
409
410 oi = (struct ospf6_interface *) ifp->info;
411 if (oi == NULL)
412 {
hasso049207c2004-08-04 20:02:13 +0000413 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000414 return CMD_SUCCESS;
415 }
416
417 /* parse Area-ID */
418 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
419 {
hasso049207c2004-08-04 20:02:13 +0000420 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000421 return CMD_SUCCESS;
422 }
423
424 if (oi->area->area_id != area_id)
425 {
426 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000427 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000428 return CMD_SUCCESS;
429 }
430
431 thread_execute (master, interface_down, oi, 0);
432
hasso6452df02004-08-15 05:52:07 +0000433 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000434 listnode_delete (oi->area->if_list, oi);
435 oi->area = (struct ospf6_area *) NULL;
436
hasso6452df02004-08-15 05:52:07 +0000437 /* 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);
hasso3b687352004-08-19 06:56:53 +0000441 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000442 }
443
hasso508e53e2004-05-18 18:57:06 +0000444 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000445}
446
447void
hasso508e53e2004-05-18 18:57:06 +0000448ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000449{
450 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000451 struct ospf6_area *oa;
452 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000453 struct timeval now, running;
454
455 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000456 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",
hasso049207c2004-08-04 20:02:13 +0000458 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000459
460 /* running time */
461 gettimeofday (&now, (struct timezone *)NULL);
hasso508e53e2004-05-18 18:57:06 +0000462 timersub (&now, &o->starttime, &running);
463 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000464 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000465
hasso508e53e2004-05-18 18:57:06 +0000466 /* Redistribute configuration */
467 /* XXX */
paul718e3742002-12-13 20:15:29 +0000468
469 /* LSAs */
470 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000471 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000472
473 /* Areas */
474 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000475 listcount (o->area_list), VNL);
hasso508e53e2004-05-18 18:57:06 +0000476 for (n = listhead (o->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000477 {
hasso508e53e2004-05-18 18:57:06 +0000478 oa = (struct ospf6_area *) getdata (n);
479 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000480 }
481}
482
hasso508e53e2004-05-18 18:57:06 +0000483/* show top level structures */
484DEFUN (show_ipv6_ospf6,
485 show_ipv6_ospf6_cmd,
486 "show ipv6 ospf6",
487 SHOW_STR
488 IP6_STR
489 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000490{
hasso508e53e2004-05-18 18:57:06 +0000491 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000492
hasso508e53e2004-05-18 18:57:06 +0000493 ospf6_show (vty, ospf6);
494 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000495}
496
497DEFUN (show_ipv6_ospf6_route,
498 show_ipv6_ospf6_route_cmd,
499 "show ipv6 ospf6 route",
500 SHOW_STR
501 IP6_STR
502 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000503 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000504 )
505{
hasso508e53e2004-05-18 18:57:06 +0000506 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
507 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000508}
509
510ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000511 show_ipv6_ospf6_route_detail_cmd,
512 "show ipv6 ospf6 route (X::X|X::X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000513 SHOW_STR
514 IP6_STR
515 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000516 ROUTE_STR
517 "Specify IPv6 address\n"
518 "Specify IPv6 prefix\n"
519 "Detailed information\n"
520 "Summary of route table\n"
521 );
paul718e3742002-12-13 20:15:29 +0000522
hasso508e53e2004-05-18 18:57:06 +0000523DEFUN (show_ipv6_ospf6_route_match,
524 show_ipv6_ospf6_route_match_cmd,
525 "show ipv6 ospf6 route X::X/M match",
paul718e3742002-12-13 20:15:29 +0000526 SHOW_STR
527 IP6_STR
528 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000529 ROUTE_STR
530 "Specify IPv6 prefix\n"
531 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000532 )
533{
hasso508e53e2004-05-18 18:57:06 +0000534 char *sargv[CMD_ARGC_MAX];
535 int i, sargc;
536
537 /* copy argv to sargv and then append "match" */
538 for (i = 0; i < argc; i++)
539 sargv[i] = argv[i];
540 sargc = argc;
541 sargv[sargc++] = "match";
542 sargv[sargc] = NULL;
543
544 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
545 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000546}
547
hasso508e53e2004-05-18 18:57:06 +0000548DEFUN (show_ipv6_ospf6_route_match_detail,
549 show_ipv6_ospf6_route_match_detail_cmd,
550 "show ipv6 ospf6 route X::X/M match detail",
paul718e3742002-12-13 20:15:29 +0000551 SHOW_STR
552 IP6_STR
553 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000554 ROUTE_STR
555 "Specify IPv6 prefix\n"
556 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000557 "Detailed information\n"
558 )
hasso508e53e2004-05-18 18:57:06 +0000559{
560 char *sargv[CMD_ARGC_MAX];
561 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000562
hasso508e53e2004-05-18 18:57:06 +0000563 /* copy argv to sargv and then append "match" and "detail" */
564 for (i = 0; i < argc; i++)
565 sargv[i] = argv[i];
566 sargc = argc;
567 sargv[sargc++] = "match";
568 sargv[sargc++] = "detail";
569 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000570
hasso508e53e2004-05-18 18:57:06 +0000571 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
572 return CMD_SUCCESS;
573}
574
575
576/* OSPF configuration write function. */
577int
578config_write_ospf6 (struct vty *vty)
579{
580 char router_id[16];
581 listnode j, k;
582 struct ospf6_area *oa;
583 struct ospf6_interface *oi;
584
585 /* OSPFv6 configuration. */
586 if (ospf6 == NULL)
587 return CMD_SUCCESS;
588 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
589 return CMD_SUCCESS;
590
591 inet_ntop (AF_INET, &ospf6->router_id, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000592 vty_out (vty, "router ospf6%s", VNL);
593 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000594
595 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000596 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000597
598 for (j = listhead (ospf6->area_list); j; nextnode (j))
599 {
600 oa = (struct ospf6_area *) getdata (j);
601 for (k = listhead (oa->if_list); k; nextnode (k))
602 {
603 oi = (struct ospf6_interface *) getdata (k);
604 vty_out (vty, " interface %s area %s%s",
hasso049207c2004-08-04 20:02:13 +0000605 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000606 }
607 }
hasso049207c2004-08-04 20:02:13 +0000608 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000609 return 0;
610}
611
612/* OSPF6 node structure. */
613struct cmd_node ospf6_node =
614{
615 OSPF6_NODE,
616 "%s(config-ospf6)# ",
617};
618
619/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000620void
621ospf6_top_init ()
622{
hasso508e53e2004-05-18 18:57:06 +0000623 /* Install ospf6 top node. */
624 install_node (&ospf6_node, config_write_ospf6);
625
626 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
627 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
628 install_element (CONFIG_NODE, &router_ospf6_cmd);
629
paul718e3742002-12-13 20:15:29 +0000630 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000631 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
632 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
633 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000634 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000635 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
636 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
637 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
638
639 install_default (OSPF6_NODE);
640 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
641 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
642 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
643 install_element (OSPF6_NODE, &no_router_ospf6_cmd);
paul718e3742002-12-13 20:15:29 +0000644}
645
hasso508e53e2004-05-18 18:57:06 +0000646