blob: df856b4cf2b69eb63d77dd8582cdc0ec65ebcba0 [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
Tom Goffae2254a2010-11-10 13:01:41 -080054static void ospf6_disable (struct ospf6 *o);
55
Paul Jakma6ac29a52008-08-15 13:45:30 +010056static void
hasso508e53e2004-05-18 18:57:06 +000057ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000058{
hasso508e53e2004-05-18 18:57:06 +000059 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000060 {
hasso508e53e2004-05-18 18:57:06 +000061 case OSPF6_LSTYPE_AS_EXTERNAL:
62 ospf6_asbr_lsa_add (lsa);
63 break;
64
65 default:
hasso508e53e2004-05-18 18:57:06 +000066 break;
paul718e3742002-12-13 20:15:29 +000067 }
68}
69
Paul Jakma6ac29a52008-08-15 13:45:30 +010070static void
hasso508e53e2004-05-18 18:57:06 +000071ospf6_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:
hasso508e53e2004-05-18 18:57:06 +000080 break;
paul718e3742002-12-13 20:15:29 +000081 }
82}
83
Paul Jakma6ac29a52008-08-15 13:45:30 +010084static void
hasso049207c2004-08-04 20:02:13 +000085ospf6_top_route_hook_add (struct ospf6_route *route)
86{
hasso6452df02004-08-15 05:52:07 +000087 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000088 ospf6_zebra_route_update_add (route);
89}
90
Paul Jakma6ac29a52008-08-15 13:45:30 +010091static void
hasso049207c2004-08-04 20:02:13 +000092ospf6_top_route_hook_remove (struct ospf6_route *route)
93{
hasso6452df02004-08-15 05:52:07 +000094 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000095 ospf6_zebra_route_update_remove (route);
96}
97
Paul Jakma6ac29a52008-08-15 13:45:30 +010098static void
hasso6452df02004-08-15 05:52:07 +000099ospf6_top_brouter_hook_add (struct ospf6_route *route)
100{
hassoccb59b12004-08-25 09:10:37 +0000101 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000102 ospf6_asbr_lsentry_add (route);
hassoccb59b12004-08-25 09:10:37 +0000103 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000104}
105
Paul Jakma6ac29a52008-08-15 13:45:30 +0100106static void
hasso6452df02004-08-15 05:52:07 +0000107ospf6_top_brouter_hook_remove (struct ospf6_route *route)
108{
hassoccb59b12004-08-25 09:10:37 +0000109 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000110 ospf6_asbr_lsentry_remove (route);
hassoccb59b12004-08-25 09:10:37 +0000111 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000112}
113
Paul Jakma6ac29a52008-08-15 13:45:30 +0100114static struct ospf6 *
115ospf6_create (void)
paul718e3742002-12-13 20:15:29 +0000116{
hasso508e53e2004-05-18 18:57:06 +0000117 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000118
Stephen Hemminger393deb92008-08-18 14:13:29 -0700119 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
hasso508e53e2004-05-18 18:57:06 +0000120
121 /* initialize */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900122 quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
hasso508e53e2004-05-18 18:57:06 +0000123 o->area_list = list_new ();
124 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000125 o->lsdb = ospf6_lsdb_create (o);
126 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000127 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
128 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
129
Paul Jakmacf1ce252006-05-15 10:46:07 +0000130 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
131 o->route_table->scope = o;
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
Paul Jakmacf1ce252006-05-15 10:46:07 +0000135 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
136 o->brouter_table->scope = o;
hasso6452df02004-08-15 05:52:07 +0000137 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
138 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000139
Paul Jakmacf1ce252006-05-15 10:46:07 +0000140 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
141 o->external_table->scope = o;
142
hasso508e53e2004-05-18 18:57:06 +0000143 o->external_id_table = route_table_init ();
144
145 return o;
146}
147
Tom Goffae2254a2010-11-10 13:01:41 -0800148void
hasso508e53e2004-05-18 18:57:06 +0000149ospf6_delete (struct ospf6 *o)
150{
paul1eb8ef22005-04-07 07:30:20 +0000151 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000152 struct ospf6_area *oa;
153
Tom Goffae2254a2010-11-10 13:01:41 -0800154 ospf6_disable (ospf6);
155
paul1eb8ef22005-04-07 07:30:20 +0000156 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
157 ospf6_area_delete (oa);
Tom Goffae2254a2010-11-10 13:01:41 -0800158 list_delete (o->area_list);
hasso508e53e2004-05-18 18:57:06 +0000159
160 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000161 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000162
163 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000164 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000165
166 ospf6_route_table_delete (o->external_table);
167 route_table_finish (o->external_id_table);
168
169 XFREE (MTYPE_OSPF6_TOP, o);
170}
171
Paul Jakma6ac29a52008-08-15 13:45:30 +0100172static void
hasso508e53e2004-05-18 18:57:06 +0000173ospf6_enable (struct ospf6 *o)
174{
paul1eb8ef22005-04-07 07:30:20 +0000175 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000176 struct ospf6_area *oa;
177
178 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
179 {
180 UNSET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000181 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
182 ospf6_area_enable (oa);
paul718e3742002-12-13 20:15:29 +0000183 }
184}
185
Paul Jakma6ac29a52008-08-15 13:45:30 +0100186static void
hasso508e53e2004-05-18 18:57:06 +0000187ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000188{
paul1eb8ef22005-04-07 07:30:20 +0000189 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000190 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);
paul1eb8ef22005-04-07 07:30:20 +0000195
196 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
197 ospf6_area_disable (oa);
paul718e3742002-12-13 20:15:29 +0000198
hasso508e53e2004-05-18 18:57:06 +0000199 ospf6_lsdb_remove_all (o->lsdb);
200 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000201 ospf6_route_remove_all (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000202 }
203}
paul718e3742002-12-13 20:15:29 +0000204
Paul Jakma6ac29a52008-08-15 13:45:30 +0100205static int
hasso508e53e2004-05-18 18:57:06 +0000206ospf6_maxage_remover (struct thread *thread)
207{
208 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
209 struct ospf6_area *oa;
210 struct ospf6_interface *oi;
211 struct ospf6_neighbor *on;
hasso52dc7ee2004-09-23 19:18:23 +0000212 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000213
214 o->maxage_remover = (struct thread *) NULL;
hasso508e53e2004-05-18 18:57:06 +0000215
paul1eb8ef22005-04-07 07:30:20 +0000216 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000217 {
paul1eb8ef22005-04-07 07:30:20 +0000218 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
hasso508e53e2004-05-18 18:57:06 +0000219 {
paul1eb8ef22005-04-07 07:30:20 +0000220 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
hasso508e53e2004-05-18 18:57:06 +0000221 {
hasso508e53e2004-05-18 18:57:06 +0000222 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
223 on->state != OSPF6_NEIGHBOR_LOADING)
224 continue;
225
hasso508e53e2004-05-18 18:57:06 +0000226 return 0;
227 }
228 }
229 }
230
paul1eb8ef22005-04-07 07:30:20 +0000231 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000232 {
paul1eb8ef22005-04-07 07:30:20 +0000233 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
234 OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
235
hasso508e53e2004-05-18 18:57:06 +0000236 OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
237 }
238 OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
239
paul718e3742002-12-13 20:15:29 +0000240 return 0;
241}
242
243void
hasso508e53e2004-05-18 18:57:06 +0000244ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000245{
hasso508e53e2004-05-18 18:57:06 +0000246 if (o && ! o->maxage_remover)
247 o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
248}
paul718e3742002-12-13 20:15:29 +0000249
hasso508e53e2004-05-18 18:57:06 +0000250/* start ospf6 */
251DEFUN (router_ospf6,
252 router_ospf6_cmd,
253 "router ospf6",
254 ROUTER_STR
255 OSPF6_STR)
256{
257 if (ospf6 == NULL)
258 ospf6 = ospf6_create ();
259 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
260 ospf6_enable (ospf6);
261
262 /* set current ospf point. */
263 vty->node = OSPF6_NODE;
264 vty->index = ospf6;
265
266 return CMD_SUCCESS;
267}
268
269/* stop ospf6 */
270DEFUN (no_router_ospf6,
271 no_router_ospf6_cmd,
272 "no router ospf6",
273 NO_STR
274 OSPF6_ROUTER_STR)
275{
276 if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
hasso049207c2004-08-04 20:02:13 +0000277 vty_out (vty, "OSPFv3 is not running%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000278 else
279 ospf6_disable (ospf6);
280
281 /* return to config node . */
282 vty->node = CONFIG_NODE;
283 vty->index = NULL;
284
285 return CMD_SUCCESS;
286}
287
288/* change Router_ID commands. */
289DEFUN (ospf6_router_id,
290 ospf6_router_id_cmd,
291 "router-id A.B.C.D",
292 "Configure OSPF Router-ID\n"
293 V4NOTATION_STR)
294{
295 int ret;
296 u_int32_t router_id;
297 struct ospf6 *o;
298
299 o = (struct ospf6 *) vty->index;
300
301 ret = inet_pton (AF_INET, argv[0], &router_id);
302 if (ret == 0)
303 {
hasso049207c2004-08-04 20:02:13 +0000304 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000305 return CMD_SUCCESS;
306 }
307
hassoc8a440e2004-10-11 17:02:40 +0000308 o->router_id_static = router_id;
309 if (o->router_id == 0)
310 o->router_id = router_id;
311
hasso508e53e2004-05-18 18:57:06 +0000312 return CMD_SUCCESS;
313}
314
315DEFUN (ospf6_interface_area,
316 ospf6_interface_area_cmd,
317 "interface IFNAME area A.B.C.D",
318 "Enable routing on an IPv6 interface\n"
319 IFNAME_STR
320 "Specify the OSPF6 area ID\n"
321 "OSPF6 area ID in IPv4 address notation\n"
322 )
323{
324 struct ospf6 *o;
hasso3b687352004-08-19 06:56:53 +0000325 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000326 struct ospf6_interface *oi;
327 struct interface *ifp;
328 u_int32_t area_id;
329
330 o = (struct ospf6 *) vty->index;
331
332 /* find/create ospf6 interface */
333 ifp = if_get_by_name (argv[0]);
334 oi = (struct ospf6_interface *) ifp->info;
335 if (oi == NULL)
336 oi = ospf6_interface_create (ifp);
337 if (oi->area)
338 {
339 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000340 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000341 return CMD_SUCCESS;
342 }
343
344 /* parse Area-ID */
345 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
346 {
hasso049207c2004-08-04 20:02:13 +0000347 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000348 return CMD_SUCCESS;
349 }
350
351 /* find/create ospf6 area */
352 oa = ospf6_area_lookup (area_id, o);
353 if (oa == NULL)
354 oa = ospf6_area_create (area_id, o);
355
356 /* attach interface to area */
357 listnode_add (oa->if_list, oi); /* sort ?? */
358 oi->area = oa;
359
hasso6452df02004-08-15 05:52:07 +0000360 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
361
hasso508e53e2004-05-18 18:57:06 +0000362 /* start up */
363 thread_add_event (master, interface_up, oi, 0);
hasso6452df02004-08-15 05:52:07 +0000364
hasso3b687352004-08-19 06:56:53 +0000365 /* If the router is ABR, originate summary routes */
366 if (ospf6_is_router_abr (o))
367 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000368
hasso508e53e2004-05-18 18:57:06 +0000369 return CMD_SUCCESS;
370}
371
372DEFUN (no_ospf6_interface_area,
373 no_ospf6_interface_area_cmd,
374 "no interface IFNAME area A.B.C.D",
375 NO_STR
376 "Disable routing on an IPv6 interface\n"
377 IFNAME_STR
378 "Specify the OSPF6 area ID\n"
379 "OSPF6 area ID in IPv4 address notation\n"
380 )
381{
382 struct ospf6 *o;
383 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000384 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000385 struct interface *ifp;
386 u_int32_t area_id;
387
388 o = (struct ospf6 *) vty->index;
389
390 ifp = if_lookup_by_name (argv[0]);
391 if (ifp == NULL)
392 {
hasso049207c2004-08-04 20:02:13 +0000393 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000394 return CMD_SUCCESS;
395 }
396
397 oi = (struct ospf6_interface *) ifp->info;
398 if (oi == NULL)
399 {
hasso049207c2004-08-04 20:02:13 +0000400 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000401 return CMD_SUCCESS;
402 }
403
404 /* parse Area-ID */
405 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
406 {
hasso049207c2004-08-04 20:02:13 +0000407 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000408 return CMD_SUCCESS;
409 }
410
Jon56abbb82009-02-11 17:30:44 -0800411 /* Verify Area */
412 if (oi->area == NULL)
413 {
414 vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
415 return CMD_SUCCESS;
416 }
417
hasso508e53e2004-05-18 18:57:06 +0000418 if (oi->area->area_id != area_id)
419 {
420 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000421 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000422 return CMD_SUCCESS;
423 }
424
425 thread_execute (master, interface_down, oi, 0);
426
hasso6452df02004-08-15 05:52:07 +0000427 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000428 listnode_delete (oi->area->if_list, oi);
429 oi->area = (struct ospf6_area *) NULL;
430
hasso6452df02004-08-15 05:52:07 +0000431 /* Withdraw inter-area routes from this area, if necessary */
432 if (oa->if_list->count == 0)
433 {
434 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso3b687352004-08-19 06:56:53 +0000435 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000436 }
437
hasso508e53e2004-05-18 18:57:06 +0000438 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000439}
440
Paul Jakma6ac29a52008-08-15 13:45:30 +0100441static void
hasso508e53e2004-05-18 18:57:06 +0000442ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000443{
hasso52dc7ee2004-09-23 19:18:23 +0000444 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000445 struct ospf6_area *oa;
446 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000447 struct timeval now, running;
448
449 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000450 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
451 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
hasso049207c2004-08-04 20:02:13 +0000452 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000453
454 /* running time */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900455 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000456 timersub (&now, &o->starttime, &running);
457 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000458 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000459
hasso508e53e2004-05-18 18:57:06 +0000460 /* Redistribute configuration */
461 /* XXX */
paul718e3742002-12-13 20:15:29 +0000462
463 /* LSAs */
464 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000465 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000466
467 /* Areas */
468 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000469 listcount (o->area_list), VNL);
paul1eb8ef22005-04-07 07:30:20 +0000470
471 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
472 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000473}
474
hasso508e53e2004-05-18 18:57:06 +0000475/* show top level structures */
476DEFUN (show_ipv6_ospf6,
477 show_ipv6_ospf6_cmd,
478 "show ipv6 ospf6",
479 SHOW_STR
480 IP6_STR
481 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000482{
hasso508e53e2004-05-18 18:57:06 +0000483 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000484
hasso508e53e2004-05-18 18:57:06 +0000485 ospf6_show (vty, ospf6);
486 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000487}
488
489DEFUN (show_ipv6_ospf6_route,
490 show_ipv6_ospf6_route_cmd,
491 "show ipv6 ospf6 route",
492 SHOW_STR
493 IP6_STR
494 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000495 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000496 )
497{
hasso508e53e2004-05-18 18:57:06 +0000498 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
499 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000500}
501
502ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000503 show_ipv6_ospf6_route_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000504 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000505 SHOW_STR
506 IP6_STR
507 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000508 ROUTE_STR
509 "Specify IPv6 address\n"
510 "Specify IPv6 prefix\n"
511 "Detailed information\n"
512 "Summary of route table\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100513 )
paul718e3742002-12-13 20:15:29 +0000514
hasso508e53e2004-05-18 18:57:06 +0000515DEFUN (show_ipv6_ospf6_route_match,
516 show_ipv6_ospf6_route_match_cmd,
hasso4846ef62004-09-03 06:04:00 +0000517 "show ipv6 ospf6 route X:X::X:X/M match",
paul718e3742002-12-13 20:15:29 +0000518 SHOW_STR
519 IP6_STR
520 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000521 ROUTE_STR
522 "Specify IPv6 prefix\n"
523 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000524 )
525{
paul0c083ee2004-10-10 12:54:58 +0000526 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000527 int i, sargc;
528
529 /* copy argv to sargv and then append "match" */
530 for (i = 0; i < argc; i++)
531 sargv[i] = argv[i];
532 sargc = argc;
533 sargv[sargc++] = "match";
534 sargv[sargc] = NULL;
535
536 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
537 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000538}
539
hasso508e53e2004-05-18 18:57:06 +0000540DEFUN (show_ipv6_ospf6_route_match_detail,
541 show_ipv6_ospf6_route_match_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000542 "show ipv6 ospf6 route X:X::X:X/M match detail",
paul718e3742002-12-13 20:15:29 +0000543 SHOW_STR
544 IP6_STR
545 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000546 ROUTE_STR
547 "Specify IPv6 prefix\n"
548 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000549 "Detailed information\n"
550 )
hasso508e53e2004-05-18 18:57:06 +0000551{
paul0c083ee2004-10-10 12:54:58 +0000552 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000553 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000554
hasso508e53e2004-05-18 18:57:06 +0000555 /* copy argv to sargv and then append "match" and "detail" */
556 for (i = 0; i < argc; i++)
557 sargv[i] = argv[i];
558 sargc = argc;
559 sargv[sargc++] = "match";
560 sargv[sargc++] = "detail";
561 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000562
hasso508e53e2004-05-18 18:57:06 +0000563 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
564 return CMD_SUCCESS;
565}
566
Paul Jakmacb4b8842006-05-15 10:39:30 +0000567ALIAS (show_ipv6_ospf6_route_match,
568 show_ipv6_ospf6_route_longer_cmd,
569 "show ipv6 ospf6 route X:X::X:X/M longer",
570 SHOW_STR
571 IP6_STR
572 OSPF6_STR
573 ROUTE_STR
574 "Specify IPv6 prefix\n"
575 "Display routes longer than the specified route\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100576 )
Paul Jakmacb4b8842006-05-15 10:39:30 +0000577
578DEFUN (show_ipv6_ospf6_route_match_detail,
579 show_ipv6_ospf6_route_longer_detail_cmd,
580 "show ipv6 ospf6 route X:X::X:X/M longer detail",
581 SHOW_STR
582 IP6_STR
583 OSPF6_STR
584 ROUTE_STR
585 "Specify IPv6 prefix\n"
586 "Display routes longer than the specified route\n"
587 "Detailed information\n"
588 );
589
hasso4846ef62004-09-03 06:04:00 +0000590ALIAS (show_ipv6_ospf6_route,
591 show_ipv6_ospf6_route_type_cmd,
592 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
593 SHOW_STR
594 IP6_STR
595 OSPF6_STR
596 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400597 "Display Intra-Area routes\n"
598 "Display Inter-Area routes\n"
599 "Display Type-1 External routes\n"
600 "Display Type-2 External routes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100601 )
hasso4846ef62004-09-03 06:04:00 +0000602
603DEFUN (show_ipv6_ospf6_route_type_detail,
604 show_ipv6_ospf6_route_type_detail_cmd,
605 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
606 SHOW_STR
607 IP6_STR
608 OSPF6_STR
609 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +0400610 "Display Intra-Area routes\n"
611 "Display Inter-Area routes\n"
612 "Display Type-1 External routes\n"
613 "Display Type-2 External routes\n"
hasso4846ef62004-09-03 06:04:00 +0000614 "Detailed information\n"
615 )
616{
paul0c083ee2004-10-10 12:54:58 +0000617 const char *sargv[CMD_ARGC_MAX];
hasso4846ef62004-09-03 06:04:00 +0000618 int i, sargc;
619
620 /* copy argv to sargv and then append "detail" */
621 for (i = 0; i < argc; i++)
622 sargv[i] = argv[i];
623 sargc = argc;
624 sargv[sargc++] = "detail";
625 sargv[sargc] = NULL;
626
627 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
628 return CMD_SUCCESS;
629}
hasso508e53e2004-05-18 18:57:06 +0000630
631/* OSPF configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100632static int
hasso508e53e2004-05-18 18:57:06 +0000633config_write_ospf6 (struct vty *vty)
634{
635 char router_id[16];
hasso52dc7ee2004-09-23 19:18:23 +0000636 struct listnode *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000637 struct ospf6_area *oa;
638 struct ospf6_interface *oi;
639
640 /* OSPFv6 configuration. */
641 if (ospf6 == NULL)
642 return CMD_SUCCESS;
643 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
644 return CMD_SUCCESS;
645
hassoc8a440e2004-10-11 17:02:40 +0000646 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000647 vty_out (vty, "router ospf6%s", VNL);
hassoc8a440e2004-10-11 17:02:40 +0000648 if (ospf6->router_id_static != 0)
649 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000650
651 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000652 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000653
paul1eb8ef22005-04-07 07:30:20 +0000654 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
hasso508e53e2004-05-18 18:57:06 +0000655 {
paul1eb8ef22005-04-07 07:30:20 +0000656 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
657 vty_out (vty, " interface %s area %s%s",
658 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000659 }
hasso049207c2004-08-04 20:02:13 +0000660 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000661 return 0;
662}
663
664/* OSPF6 node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800665static struct cmd_node ospf6_node =
hasso508e53e2004-05-18 18:57:06 +0000666{
667 OSPF6_NODE,
668 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +0000669 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +0000670};
671
672/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000673void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100674ospf6_top_init (void)
paul718e3742002-12-13 20:15:29 +0000675{
hasso508e53e2004-05-18 18:57:06 +0000676 /* Install ospf6 top node. */
677 install_node (&ospf6_node, config_write_ospf6);
678
679 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
680 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
681 install_element (CONFIG_NODE, &router_ospf6_cmd);
Jon6c19d262009-02-11 17:19:07 -0800682 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +0000683
paul718e3742002-12-13 20:15:29 +0000684 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000685 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
686 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
687 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000688 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
689 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000690 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
691 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000692 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000693 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
694 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
695 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000696 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
697 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000698 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
699 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +0000700
701 install_default (OSPF6_NODE);
702 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
703 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
704 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
paul718e3742002-12-13 20:15:29 +0000705}
706
hasso508e53e2004-05-18 18:57:06 +0000707