blob: 23ad09f0975ae925033277a0eea10a7b944e377f [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{
hassoccb59b12004-08-25 09:10:37 +0000103 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000104 ospf6_asbr_lsentry_add (route);
hassoccb59b12004-08-25 09:10:37 +0000105 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000106}
107
108void
109ospf6_top_brouter_hook_remove (struct ospf6_route *route)
110{
hassoccb59b12004-08-25 09:10:37 +0000111 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000112 ospf6_asbr_lsentry_remove (route);
hassoccb59b12004-08-25 09:10:37 +0000113 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000114}
115
hasso508e53e2004-05-18 18:57:06 +0000116struct ospf6 *
117ospf6_create ()
paul718e3742002-12-13 20:15:29 +0000118{
hasso508e53e2004-05-18 18:57:06 +0000119 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000120
hasso508e53e2004-05-18 18:57:06 +0000121 o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
122 memset (o, 0, sizeof (struct ospf6));
123
124 /* initialize */
125 gettimeofday (&o->starttime, (struct timezone *) NULL);
126 o->area_list = list_new ();
127 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000128 o->lsdb = ospf6_lsdb_create (o);
129 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000130 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
131 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
132
133 o->route_table = ospf6_route_table_create ();
hasso049207c2004-08-04 20:02:13 +0000134 o->route_table->hook_add = ospf6_top_route_hook_add;
135 o->route_table->hook_remove = ospf6_top_route_hook_remove;
hasso508e53e2004-05-18 18:57:06 +0000136
hasso049207c2004-08-04 20:02:13 +0000137 o->brouter_table = ospf6_route_table_create ();
hasso6452df02004-08-15 05:52:07 +0000138 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
139 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000140
hasso508e53e2004-05-18 18:57:06 +0000141 o->external_table = ospf6_route_table_create ();
142 o->external_id_table = route_table_init ();
143
144 return o;
145}
146
147void
148ospf6_delete (struct ospf6 *o)
149{
150 listnode i;
151 struct ospf6_area *oa;
152
153 for (i = listhead (o->area_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000154 {
hasso508e53e2004-05-18 18:57:06 +0000155 oa = (struct ospf6_area *) getdata (i);
156 ospf6_area_delete (oa);
157 }
158
159 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000160 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000161
162 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000163 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000164
165 ospf6_route_table_delete (o->external_table);
166 route_table_finish (o->external_id_table);
167
168 XFREE (MTYPE_OSPF6_TOP, o);
169}
170
171void
172ospf6_enable (struct ospf6 *o)
173{
174 listnode i;
175 struct ospf6_area *oa;
176
177 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
178 {
179 UNSET_FLAG (o->flag, OSPF6_DISABLED);
180 for (i = listhead (o->area_list); i; nextnode (i))
181 {
182 oa = (struct ospf6_area *) getdata (i);
183 ospf6_area_enable (oa);
184 }
paul718e3742002-12-13 20:15:29 +0000185 }
186}
187
hasso508e53e2004-05-18 18:57:06 +0000188void
189ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000190{
hasso508e53e2004-05-18 18:57:06 +0000191 listnode i;
192 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000193
hasso508e53e2004-05-18 18:57:06 +0000194 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
195 {
196 SET_FLAG (o->flag, OSPF6_DISABLED);
197 for (i = listhead (o->area_list); i; nextnode (i))
198 {
199 oa = (struct ospf6_area *) getdata (i);
200 ospf6_area_disable (oa);
201 }
paul718e3742002-12-13 20:15:29 +0000202
hasso508e53e2004-05-18 18:57:06 +0000203 ospf6_lsdb_remove_all (o->lsdb);
204 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000205 ospf6_route_remove_all (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000206 }
207}
paul718e3742002-12-13 20:15:29 +0000208
hasso508e53e2004-05-18 18:57:06 +0000209int
210ospf6_maxage_remover (struct thread *thread)
211{
212 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
213 struct ospf6_area *oa;
214 struct ospf6_interface *oi;
215 struct ospf6_neighbor *on;
216 listnode i, j, k;
217
218 o->maxage_remover = (struct thread *) NULL;
219 if (IS_OSPF6_DEBUG_LSA (TIMER))
220 zlog_info ("Maxage Remover");
221
222 for (i = listhead (o->area_list); i; nextnode (i))
223 {
224 oa = (struct ospf6_area *) getdata (i);
225 for (j = listhead (oa->if_list); j; nextnode (j))
226 {
227 oi = (struct ospf6_interface *) getdata (j);
228 for (k = listhead (oi->neighbor_list); k; nextnode (k))
229 {
230 on = (struct ospf6_neighbor *) getdata (k);
231 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
232 on->state != OSPF6_NEIGHBOR_LOADING)
233 continue;
234
235 if (IS_OSPF6_DEBUG_LSA (TIMER))
236 zlog_info ("Maxage Remover End: %s exchange or loading",
237 on->name);
238 return 0;
239 }
240 }
241 }
242
243 for (i = listhead (o->area_list); i; nextnode (i))
244 {
245 oa = (struct ospf6_area *) getdata (i);
246 for (j = listhead (oa->if_list); j; nextnode (j))
247 {
248 oi = (struct ospf6_interface *) getdata (j);
249 OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
250 }
251 OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
252 }
253 OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
254
255 if (IS_OSPF6_DEBUG_LSA (TIMER))
256 zlog_info ("Maxage Remover End");
257
paul718e3742002-12-13 20:15:29 +0000258 return 0;
259}
260
261void
hasso508e53e2004-05-18 18:57:06 +0000262ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000263{
hasso508e53e2004-05-18 18:57:06 +0000264 if (o && ! o->maxage_remover)
265 o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
266}
paul718e3742002-12-13 20:15:29 +0000267
hasso508e53e2004-05-18 18:57:06 +0000268/* start ospf6 */
269DEFUN (router_ospf6,
270 router_ospf6_cmd,
271 "router ospf6",
272 ROUTER_STR
273 OSPF6_STR)
274{
275 if (ospf6 == NULL)
276 ospf6 = ospf6_create ();
277 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
278 ospf6_enable (ospf6);
279
280 /* set current ospf point. */
281 vty->node = OSPF6_NODE;
282 vty->index = ospf6;
283
284 return CMD_SUCCESS;
285}
286
287/* stop ospf6 */
288DEFUN (no_router_ospf6,
289 no_router_ospf6_cmd,
290 "no router ospf6",
291 NO_STR
292 OSPF6_ROUTER_STR)
293{
294 if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
hasso049207c2004-08-04 20:02:13 +0000295 vty_out (vty, "OSPFv3 is not running%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000296 else
297 ospf6_disable (ospf6);
298
299 /* return to config node . */
300 vty->node = CONFIG_NODE;
301 vty->index = NULL;
302
303 return CMD_SUCCESS;
304}
305
306/* change Router_ID commands. */
307DEFUN (ospf6_router_id,
308 ospf6_router_id_cmd,
309 "router-id A.B.C.D",
310 "Configure OSPF Router-ID\n"
311 V4NOTATION_STR)
312{
313 int ret;
314 u_int32_t router_id;
315 struct ospf6 *o;
316
317 o = (struct ospf6 *) vty->index;
318
319 ret = inet_pton (AF_INET, argv[0], &router_id);
320 if (ret == 0)
321 {
hasso049207c2004-08-04 20:02:13 +0000322 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000323 return CMD_SUCCESS;
324 }
325
326 o->router_id = router_id;
327 return CMD_SUCCESS;
328}
329
330DEFUN (ospf6_interface_area,
331 ospf6_interface_area_cmd,
332 "interface IFNAME area A.B.C.D",
333 "Enable routing on an IPv6 interface\n"
334 IFNAME_STR
335 "Specify the OSPF6 area ID\n"
336 "OSPF6 area ID in IPv4 address notation\n"
337 )
338{
339 struct ospf6 *o;
hasso3b687352004-08-19 06:56:53 +0000340 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000341 struct ospf6_interface *oi;
342 struct interface *ifp;
343 u_int32_t area_id;
344
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
hasso3b687352004-08-19 06:56:53 +0000380 /* If the router is ABR, originate summary routes */
381 if (ospf6_is_router_abr (o))
382 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000383
hasso508e53e2004-05-18 18:57:06 +0000384 return CMD_SUCCESS;
385}
386
387DEFUN (no_ospf6_interface_area,
388 no_ospf6_interface_area_cmd,
389 "no interface IFNAME area A.B.C.D",
390 NO_STR
391 "Disable routing on an IPv6 interface\n"
392 IFNAME_STR
393 "Specify the OSPF6 area ID\n"
394 "OSPF6 area ID in IPv4 address notation\n"
395 )
396{
397 struct ospf6 *o;
398 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000399 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000400 struct interface *ifp;
401 u_int32_t area_id;
402
403 o = (struct ospf6 *) vty->index;
404
405 ifp = if_lookup_by_name (argv[0]);
406 if (ifp == NULL)
407 {
hasso049207c2004-08-04 20:02:13 +0000408 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000409 return CMD_SUCCESS;
410 }
411
412 oi = (struct ospf6_interface *) ifp->info;
413 if (oi == NULL)
414 {
hasso049207c2004-08-04 20:02:13 +0000415 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000416 return CMD_SUCCESS;
417 }
418
419 /* parse Area-ID */
420 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
421 {
hasso049207c2004-08-04 20:02:13 +0000422 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000423 return CMD_SUCCESS;
424 }
425
426 if (oi->area->area_id != area_id)
427 {
428 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000429 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000430 return CMD_SUCCESS;
431 }
432
433 thread_execute (master, interface_down, oi, 0);
434
hasso6452df02004-08-15 05:52:07 +0000435 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000436 listnode_delete (oi->area->if_list, oi);
437 oi->area = (struct ospf6_area *) NULL;
438
hasso6452df02004-08-15 05:52:07 +0000439 /* Withdraw inter-area routes from this area, if necessary */
440 if (oa->if_list->count == 0)
441 {
442 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso3b687352004-08-19 06:56:53 +0000443 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000444 }
445
hasso508e53e2004-05-18 18:57:06 +0000446 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000447}
448
449void
hasso508e53e2004-05-18 18:57:06 +0000450ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000451{
452 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000453 struct ospf6_area *oa;
454 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000455 struct timeval now, running;
456
457 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000458 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
459 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
hasso049207c2004-08-04 20:02:13 +0000460 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000461
462 /* running time */
463 gettimeofday (&now, (struct timezone *)NULL);
hasso508e53e2004-05-18 18:57:06 +0000464 timersub (&now, &o->starttime, &running);
465 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000466 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000467
hasso508e53e2004-05-18 18:57:06 +0000468 /* Redistribute configuration */
469 /* XXX */
paul718e3742002-12-13 20:15:29 +0000470
471 /* LSAs */
472 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000473 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000474
475 /* Areas */
476 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000477 listcount (o->area_list), VNL);
hasso508e53e2004-05-18 18:57:06 +0000478 for (n = listhead (o->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000479 {
hasso508e53e2004-05-18 18:57:06 +0000480 oa = (struct ospf6_area *) getdata (n);
481 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000482 }
483}
484
hasso508e53e2004-05-18 18:57:06 +0000485/* show top level structures */
486DEFUN (show_ipv6_ospf6,
487 show_ipv6_ospf6_cmd,
488 "show ipv6 ospf6",
489 SHOW_STR
490 IP6_STR
491 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000492{
hasso508e53e2004-05-18 18:57:06 +0000493 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000494
hasso508e53e2004-05-18 18:57:06 +0000495 ospf6_show (vty, ospf6);
496 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000497}
498
499DEFUN (show_ipv6_ospf6_route,
500 show_ipv6_ospf6_route_cmd,
501 "show ipv6 ospf6 route",
502 SHOW_STR
503 IP6_STR
504 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000505 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000506 )
507{
hasso508e53e2004-05-18 18:57:06 +0000508 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
509 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000510}
511
512ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000513 show_ipv6_ospf6_route_detail_cmd,
514 "show ipv6 ospf6 route (X::X|X::X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000515 SHOW_STR
516 IP6_STR
517 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000518 ROUTE_STR
519 "Specify IPv6 address\n"
520 "Specify IPv6 prefix\n"
521 "Detailed information\n"
522 "Summary of route table\n"
523 );
paul718e3742002-12-13 20:15:29 +0000524
hasso508e53e2004-05-18 18:57:06 +0000525DEFUN (show_ipv6_ospf6_route_match,
526 show_ipv6_ospf6_route_match_cmd,
527 "show ipv6 ospf6 route X::X/M match",
paul718e3742002-12-13 20:15:29 +0000528 SHOW_STR
529 IP6_STR
530 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000531 ROUTE_STR
532 "Specify IPv6 prefix\n"
533 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000534 )
535{
hasso508e53e2004-05-18 18:57:06 +0000536 char *sargv[CMD_ARGC_MAX];
537 int i, sargc;
538
539 /* copy argv to sargv and then append "match" */
540 for (i = 0; i < argc; i++)
541 sargv[i] = argv[i];
542 sargc = argc;
543 sargv[sargc++] = "match";
544 sargv[sargc] = NULL;
545
546 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
547 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000548}
549
hasso508e53e2004-05-18 18:57:06 +0000550DEFUN (show_ipv6_ospf6_route_match_detail,
551 show_ipv6_ospf6_route_match_detail_cmd,
552 "show ipv6 ospf6 route X::X/M match detail",
paul718e3742002-12-13 20:15:29 +0000553 SHOW_STR
554 IP6_STR
555 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000556 ROUTE_STR
557 "Specify IPv6 prefix\n"
558 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000559 "Detailed information\n"
560 )
hasso508e53e2004-05-18 18:57:06 +0000561{
562 char *sargv[CMD_ARGC_MAX];
563 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000564
hasso508e53e2004-05-18 18:57:06 +0000565 /* copy argv to sargv and then append "match" and "detail" */
566 for (i = 0; i < argc; i++)
567 sargv[i] = argv[i];
568 sargc = argc;
569 sargv[sargc++] = "match";
570 sargv[sargc++] = "detail";
571 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000572
hasso508e53e2004-05-18 18:57:06 +0000573 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
574 return CMD_SUCCESS;
575}
576
577
578/* OSPF configuration write function. */
579int
580config_write_ospf6 (struct vty *vty)
581{
582 char router_id[16];
583 listnode j, k;
584 struct ospf6_area *oa;
585 struct ospf6_interface *oi;
586
587 /* OSPFv6 configuration. */
588 if (ospf6 == NULL)
589 return CMD_SUCCESS;
590 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
591 return CMD_SUCCESS;
592
593 inet_ntop (AF_INET, &ospf6->router_id, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000594 vty_out (vty, "router ospf6%s", VNL);
595 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000596
597 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000598 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000599
600 for (j = listhead (ospf6->area_list); j; nextnode (j))
601 {
602 oa = (struct ospf6_area *) getdata (j);
603 for (k = listhead (oa->if_list); k; nextnode (k))
604 {
605 oi = (struct ospf6_interface *) getdata (k);
606 vty_out (vty, " interface %s area %s%s",
hasso049207c2004-08-04 20:02:13 +0000607 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000608 }
609 }
hasso049207c2004-08-04 20:02:13 +0000610 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000611 return 0;
612}
613
614/* OSPF6 node structure. */
615struct cmd_node ospf6_node =
616{
617 OSPF6_NODE,
618 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +0000619 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +0000620};
621
622/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000623void
624ospf6_top_init ()
625{
hasso508e53e2004-05-18 18:57:06 +0000626 /* Install ospf6 top node. */
627 install_node (&ospf6_node, config_write_ospf6);
628
629 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
630 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
631 install_element (CONFIG_NODE, &router_ospf6_cmd);
632
paul718e3742002-12-13 20:15:29 +0000633 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000634 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
635 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
636 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000637 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000638 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
639 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
640 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
641
642 install_default (OSPF6_NODE);
643 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
644 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
645 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
646 install_element (OSPF6_NODE, &no_router_ospf6_cmd);
paul718e3742002-12-13 20:15:29 +0000647}
648
hasso508e53e2004-05-18 18:57:06 +0000649