blob: 38f94d7b96fe5743d48779662548ba477326d2c6 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#include "log.h"
25#include "memory.h"
26#include "vty.h"
27#include "linklist.h"
28#include "prefix.h"
29#include "table.h"
30#include "thread.h"
31#include "command.h"
32
paul718e3742002-12-13 20:15:29 +000033#include "ospf6_proto.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_message.h"
paul718e3742002-12-13 20:15:29 +000035#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
paul718e3742002-12-13 20:15:29 +000037#include "ospf6_route.h"
38#include "ospf6_zebra.h"
39
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_top.h"
41#include "ospf6_area.h"
42#include "ospf6_interface.h"
43#include "ospf6_neighbor.h"
paul718e3742002-12-13 20:15:29 +000044
hasso6452df02004-08-15 05:52:07 +000045#include "ospf6_flood.h"
hasso508e53e2004-05-18 18:57:06 +000046#include "ospf6_asbr.h"
hasso049207c2004-08-04 20:02:13 +000047#include "ospf6_abr.h"
hasso6452df02004-08-15 05:52:07 +000048#include "ospf6_intra.h"
hasso049207c2004-08-04 20:02:13 +000049#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000050
51/* global ospf6d variable */
52struct ospf6 *ospf6;
53
Paul Jakma6ac29a52008-08-15 13:45:30 +010054static void
hasso508e53e2004-05-18 18:57:06 +000055ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000056{
hasso508e53e2004-05-18 18:57:06 +000057 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000058 {
hasso508e53e2004-05-18 18:57:06 +000059 case OSPF6_LSTYPE_AS_EXTERNAL:
60 ospf6_asbr_lsa_add (lsa);
61 break;
62
63 default:
hasso508e53e2004-05-18 18:57:06 +000064 break;
paul718e3742002-12-13 20:15:29 +000065 }
66}
67
Paul Jakma6ac29a52008-08-15 13:45:30 +010068static void
hasso508e53e2004-05-18 18:57:06 +000069ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000070{
hasso508e53e2004-05-18 18:57:06 +000071 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000072 {
hasso508e53e2004-05-18 18:57:06 +000073 case OSPF6_LSTYPE_AS_EXTERNAL:
74 ospf6_asbr_lsa_remove (lsa);
75 break;
76
77 default:
hasso508e53e2004-05-18 18:57:06 +000078 break;
paul718e3742002-12-13 20:15:29 +000079 }
80}
81
Paul Jakma6ac29a52008-08-15 13:45:30 +010082static void
hasso049207c2004-08-04 20:02:13 +000083ospf6_top_route_hook_add (struct ospf6_route *route)
84{
hasso6452df02004-08-15 05:52:07 +000085 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000086 ospf6_zebra_route_update_add (route);
87}
88
Paul Jakma6ac29a52008-08-15 13:45:30 +010089static void
hasso049207c2004-08-04 20:02:13 +000090ospf6_top_route_hook_remove (struct ospf6_route *route)
91{
hasso6452df02004-08-15 05:52:07 +000092 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000093 ospf6_zebra_route_update_remove (route);
94}
95
Paul Jakma6ac29a52008-08-15 13:45:30 +010096static void
hasso6452df02004-08-15 05:52:07 +000097ospf6_top_brouter_hook_add (struct ospf6_route *route)
98{
hassoccb59b12004-08-25 09:10:37 +000099 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000100 ospf6_asbr_lsentry_add (route);
hassoccb59b12004-08-25 09:10:37 +0000101 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000102}
103
Paul Jakma6ac29a52008-08-15 13:45:30 +0100104static void
hasso6452df02004-08-15 05:52:07 +0000105ospf6_top_brouter_hook_remove (struct ospf6_route *route)
106{
hassoccb59b12004-08-25 09:10:37 +0000107 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000108 ospf6_asbr_lsentry_remove (route);
hassoccb59b12004-08-25 09:10:37 +0000109 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000110}
111
Paul Jakma6ac29a52008-08-15 13:45:30 +0100112static struct ospf6 *
113ospf6_create (void)
paul718e3742002-12-13 20:15:29 +0000114{
hasso508e53e2004-05-18 18:57:06 +0000115 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000116
Stephen Hemminger393deb92008-08-18 14:13:29 -0700117 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
hasso508e53e2004-05-18 18:57:06 +0000118
119 /* initialize */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900120 quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
hasso508e53e2004-05-18 18:57:06 +0000121 o->area_list = list_new ();
122 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000123 o->lsdb = ospf6_lsdb_create (o);
124 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000125 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
126 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
127
Paul Jakmacf1ce252006-05-15 10:46:07 +0000128 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
129 o->route_table->scope = o;
hasso049207c2004-08-04 20:02:13 +0000130 o->route_table->hook_add = ospf6_top_route_hook_add;
131 o->route_table->hook_remove = ospf6_top_route_hook_remove;
hasso508e53e2004-05-18 18:57:06 +0000132
Paul Jakmacf1ce252006-05-15 10:46:07 +0000133 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
134 o->brouter_table->scope = o;
hasso6452df02004-08-15 05:52:07 +0000135 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
136 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000137
Paul Jakmacf1ce252006-05-15 10:46:07 +0000138 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
139 o->external_table->scope = o;
140
hasso508e53e2004-05-18 18:57:06 +0000141 o->external_id_table = route_table_init ();
142
143 return o;
144}
145
Stephen Hemmingere5802162009-12-10 16:18:41 +0300146#if 0
Paul Jakma6ac29a52008-08-15 13:45:30 +0100147static void
hasso508e53e2004-05-18 18:57:06 +0000148ospf6_delete (struct ospf6 *o)
149{
paul1eb8ef22005-04-07 07:30:20 +0000150 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000151 struct ospf6_area *oa;
152
paul1eb8ef22005-04-07 07:30:20 +0000153 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
154 ospf6_area_delete (oa);
hasso508e53e2004-05-18 18:57:06 +0000155
156 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000157 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000158
159 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000160 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000161
162 ospf6_route_table_delete (o->external_table);
163 route_table_finish (o->external_id_table);
164
165 XFREE (MTYPE_OSPF6_TOP, o);
166}
Stephen Hemmingere5802162009-12-10 16:18:41 +0300167#endif
hasso508e53e2004-05-18 18:57:06 +0000168
Paul Jakma6ac29a52008-08-15 13:45:30 +0100169static void
hasso508e53e2004-05-18 18:57:06 +0000170ospf6_enable (struct ospf6 *o)
171{
paul1eb8ef22005-04-07 07:30:20 +0000172 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000173 struct ospf6_area *oa;
174
175 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
176 {
177 UNSET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000178 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
179 ospf6_area_enable (oa);
paul718e3742002-12-13 20:15:29 +0000180 }
181}
182
Paul Jakma6ac29a52008-08-15 13:45:30 +0100183static void
hasso508e53e2004-05-18 18:57:06 +0000184ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000185{
paul1eb8ef22005-04-07 07:30:20 +0000186 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000187 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000188
hasso508e53e2004-05-18 18:57:06 +0000189 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
190 {
191 SET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000192
193 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
194 ospf6_area_disable (oa);
paul718e3742002-12-13 20:15:29 +0000195
hasso508e53e2004-05-18 18:57:06 +0000196 ospf6_lsdb_remove_all (o->lsdb);
197 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000198 ospf6_route_remove_all (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000199 }
200}
paul718e3742002-12-13 20:15:29 +0000201
Paul Jakma6ac29a52008-08-15 13:45:30 +0100202static int
hasso508e53e2004-05-18 18:57:06 +0000203ospf6_maxage_remover (struct thread *thread)
204{
205 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
206 struct ospf6_area *oa;
207 struct ospf6_interface *oi;
208 struct ospf6_neighbor *on;
hasso52dc7ee2004-09-23 19:18:23 +0000209 struct listnode *i, *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000210
211 o->maxage_remover = (struct thread *) NULL;
hasso508e53e2004-05-18 18:57:06 +0000212
paul1eb8ef22005-04-07 07:30:20 +0000213 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000214 {
paul1eb8ef22005-04-07 07:30:20 +0000215 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
hasso508e53e2004-05-18 18:57:06 +0000216 {
paul1eb8ef22005-04-07 07:30:20 +0000217 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
hasso508e53e2004-05-18 18:57:06 +0000218 {
hasso508e53e2004-05-18 18:57:06 +0000219 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
220 on->state != OSPF6_NEIGHBOR_LOADING)
221 continue;
222
hasso508e53e2004-05-18 18:57:06 +0000223 return 0;
224 }
225 }
226 }
227
paul1eb8ef22005-04-07 07:30:20 +0000228 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000229 {
paul1eb8ef22005-04-07 07:30:20 +0000230 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
231 OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
232
hasso508e53e2004-05-18 18:57:06 +0000233 OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
234 }
235 OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
236
paul718e3742002-12-13 20:15:29 +0000237 return 0;
238}
239
240void
hasso508e53e2004-05-18 18:57:06 +0000241ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000242{
hasso508e53e2004-05-18 18:57:06 +0000243 if (o && ! o->maxage_remover)
244 o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);
245}
paul718e3742002-12-13 20:15:29 +0000246
hasso508e53e2004-05-18 18:57:06 +0000247/* start ospf6 */
248DEFUN (router_ospf6,
249 router_ospf6_cmd,
250 "router ospf6",
251 ROUTER_STR
252 OSPF6_STR)
253{
254 if (ospf6 == NULL)
255 ospf6 = ospf6_create ();
256 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
257 ospf6_enable (ospf6);
258
259 /* set current ospf point. */
260 vty->node = OSPF6_NODE;
261 vty->index = ospf6;
262
263 return CMD_SUCCESS;
264}
265
266/* stop ospf6 */
267DEFUN (no_router_ospf6,
268 no_router_ospf6_cmd,
269 "no router ospf6",
270 NO_STR
271 OSPF6_ROUTER_STR)
272{
273 if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
hasso049207c2004-08-04 20:02:13 +0000274 vty_out (vty, "OSPFv3 is not running%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000275 else
276 ospf6_disable (ospf6);
277
278 /* return to config node . */
279 vty->node = CONFIG_NODE;
280 vty->index = NULL;
281
282 return CMD_SUCCESS;
283}
284
285/* change Router_ID commands. */
286DEFUN (ospf6_router_id,
287 ospf6_router_id_cmd,
288 "router-id A.B.C.D",
289 "Configure OSPF Router-ID\n"
290 V4NOTATION_STR)
291{
292 int ret;
293 u_int32_t router_id;
294 struct ospf6 *o;
295
296 o = (struct ospf6 *) vty->index;
297
298 ret = inet_pton (AF_INET, argv[0], &router_id);
299 if (ret == 0)
300 {
hasso049207c2004-08-04 20:02:13 +0000301 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000302 return CMD_SUCCESS;
303 }
304
hassoc8a440e2004-10-11 17:02:40 +0000305 o->router_id_static = router_id;
306 if (o->router_id == 0)
307 o->router_id = router_id;
308
hasso508e53e2004-05-18 18:57:06 +0000309 return CMD_SUCCESS;
310}
311
312DEFUN (ospf6_interface_area,
313 ospf6_interface_area_cmd,
314 "interface IFNAME area A.B.C.D",
315 "Enable routing on an IPv6 interface\n"
316 IFNAME_STR
317 "Specify the OSPF6 area ID\n"
318 "OSPF6 area ID in IPv4 address notation\n"
319 )
320{
321 struct ospf6 *o;
hasso3b687352004-08-19 06:56:53 +0000322 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000323 struct ospf6_interface *oi;
324 struct interface *ifp;
325 u_int32_t area_id;
326
327 o = (struct ospf6 *) vty->index;
328
329 /* find/create ospf6 interface */
330 ifp = if_get_by_name (argv[0]);
331 oi = (struct ospf6_interface *) ifp->info;
332 if (oi == NULL)
333 oi = ospf6_interface_create (ifp);
334 if (oi->area)
335 {
336 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000337 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000338 return CMD_SUCCESS;
339 }
340
341 /* parse Area-ID */
342 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
343 {
hasso049207c2004-08-04 20:02:13 +0000344 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000345 return CMD_SUCCESS;
346 }
347
348 /* find/create ospf6 area */
349 oa = ospf6_area_lookup (area_id, o);
350 if (oa == NULL)
351 oa = ospf6_area_create (area_id, o);
352
353 /* attach interface to area */
354 listnode_add (oa->if_list, oi); /* sort ?? */
355 oi->area = oa;
356
hasso6452df02004-08-15 05:52:07 +0000357 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
358
hasso508e53e2004-05-18 18:57:06 +0000359 /* start up */
360 thread_add_event (master, interface_up, oi, 0);
hasso6452df02004-08-15 05:52:07 +0000361
hasso3b687352004-08-19 06:56:53 +0000362 /* If the router is ABR, originate summary routes */
363 if (ospf6_is_router_abr (o))
364 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000365
hasso508e53e2004-05-18 18:57:06 +0000366 return CMD_SUCCESS;
367}
368
369DEFUN (no_ospf6_interface_area,
370 no_ospf6_interface_area_cmd,
371 "no interface IFNAME area A.B.C.D",
372 NO_STR
373 "Disable routing on an IPv6 interface\n"
374 IFNAME_STR
375 "Specify the OSPF6 area ID\n"
376 "OSPF6 area ID in IPv4 address notation\n"
377 )
378{
379 struct ospf6 *o;
380 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000381 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000382 struct interface *ifp;
383 u_int32_t area_id;
384
385 o = (struct ospf6 *) vty->index;
386
387 ifp = if_lookup_by_name (argv[0]);
388 if (ifp == NULL)
389 {
hasso049207c2004-08-04 20:02:13 +0000390 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000391 return CMD_SUCCESS;
392 }
393
394 oi = (struct ospf6_interface *) ifp->info;
395 if (oi == NULL)
396 {
hasso049207c2004-08-04 20:02:13 +0000397 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000398 return CMD_SUCCESS;
399 }
400
401 /* parse Area-ID */
402 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
403 {
hasso049207c2004-08-04 20:02:13 +0000404 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000405 return CMD_SUCCESS;
406 }
407
Jon56abbb82009-02-11 17:30:44 -0800408 /* Verify Area */
409 if (oi->area == NULL)
410 {
411 vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
412 return CMD_SUCCESS;
413 }
414
hasso508e53e2004-05-18 18:57:06 +0000415 if (oi->area->area_id != area_id)
416 {
417 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000418 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000419 return CMD_SUCCESS;
420 }
421
422 thread_execute (master, interface_down, oi, 0);
423
hasso6452df02004-08-15 05:52:07 +0000424 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000425 listnode_delete (oi->area->if_list, oi);
426 oi->area = (struct ospf6_area *) NULL;
427
hasso6452df02004-08-15 05:52:07 +0000428 /* Withdraw inter-area routes from this area, if necessary */
429 if (oa->if_list->count == 0)
430 {
431 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso3b687352004-08-19 06:56:53 +0000432 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000433 }
434
hasso508e53e2004-05-18 18:57:06 +0000435 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000436}
437
Paul Jakma6ac29a52008-08-15 13:45:30 +0100438static void
hasso508e53e2004-05-18 18:57:06 +0000439ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000440{
hasso52dc7ee2004-09-23 19:18:23 +0000441 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +0000442 struct ospf6_area *oa;
443 char router_id[16], duration[32];
paul718e3742002-12-13 20:15:29 +0000444 struct timeval now, running;
445
446 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +0000447 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
448 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
hasso049207c2004-08-04 20:02:13 +0000449 router_id, VNL);
paul718e3742002-12-13 20:15:29 +0000450
451 /* running time */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900452 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +0000453 timersub (&now, &o->starttime, &running);
454 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +0000455 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +0000456
hasso508e53e2004-05-18 18:57:06 +0000457 /* Redistribute configuration */
458 /* XXX */
paul718e3742002-12-13 20:15:29 +0000459
460 /* LSAs */
461 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000462 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +0000463
464 /* Areas */
465 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +0000466 listcount (o->area_list), VNL);
paul1eb8ef22005-04-07 07:30:20 +0000467
468 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
469 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +0000470}
471
hasso508e53e2004-05-18 18:57:06 +0000472/* show top level structures */
473DEFUN (show_ipv6_ospf6,
474 show_ipv6_ospf6_cmd,
475 "show ipv6 ospf6",
476 SHOW_STR
477 IP6_STR
478 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +0000479{
hasso508e53e2004-05-18 18:57:06 +0000480 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +0000481
hasso508e53e2004-05-18 18:57:06 +0000482 ospf6_show (vty, ospf6);
483 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000484}
485
486DEFUN (show_ipv6_ospf6_route,
487 show_ipv6_ospf6_route_cmd,
488 "show ipv6 ospf6 route",
489 SHOW_STR
490 IP6_STR
491 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000492 ROUTE_STR
paul718e3742002-12-13 20:15:29 +0000493 )
494{
hasso508e53e2004-05-18 18:57:06 +0000495 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
496 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000497}
498
499ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +0000500 show_ipv6_ospf6_route_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000501 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +0000502 SHOW_STR
503 IP6_STR
504 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000505 ROUTE_STR
506 "Specify IPv6 address\n"
507 "Specify IPv6 prefix\n"
508 "Detailed information\n"
509 "Summary of route table\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100510 )
paul718e3742002-12-13 20:15:29 +0000511
hasso508e53e2004-05-18 18:57:06 +0000512DEFUN (show_ipv6_ospf6_route_match,
513 show_ipv6_ospf6_route_match_cmd,
hasso4846ef62004-09-03 06:04:00 +0000514 "show ipv6 ospf6 route X:X::X:X/M match",
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 prefix\n"
520 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000521 )
522{
paul0c083ee2004-10-10 12:54:58 +0000523 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000524 int i, sargc;
525
526 /* copy argv to sargv and then append "match" */
527 for (i = 0; i < argc; i++)
528 sargv[i] = argv[i];
529 sargc = argc;
530 sargv[sargc++] = "match";
531 sargv[sargc] = NULL;
532
533 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
534 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000535}
536
hasso508e53e2004-05-18 18:57:06 +0000537DEFUN (show_ipv6_ospf6_route_match_detail,
538 show_ipv6_ospf6_route_match_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +0000539 "show ipv6 ospf6 route X:X::X:X/M match detail",
paul718e3742002-12-13 20:15:29 +0000540 SHOW_STR
541 IP6_STR
542 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +0000543 ROUTE_STR
544 "Specify IPv6 prefix\n"
545 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000546 "Detailed information\n"
547 )
hasso508e53e2004-05-18 18:57:06 +0000548{
paul0c083ee2004-10-10 12:54:58 +0000549 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +0000550 int i, sargc;
paul718e3742002-12-13 20:15:29 +0000551
hasso508e53e2004-05-18 18:57:06 +0000552 /* copy argv to sargv and then append "match" and "detail" */
553 for (i = 0; i < argc; i++)
554 sargv[i] = argv[i];
555 sargc = argc;
556 sargv[sargc++] = "match";
557 sargv[sargc++] = "detail";
558 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +0000559
hasso508e53e2004-05-18 18:57:06 +0000560 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
561 return CMD_SUCCESS;
562}
563
Paul Jakmacb4b8842006-05-15 10:39:30 +0000564ALIAS (show_ipv6_ospf6_route_match,
565 show_ipv6_ospf6_route_longer_cmd,
566 "show ipv6 ospf6 route X:X::X:X/M longer",
567 SHOW_STR
568 IP6_STR
569 OSPF6_STR
570 ROUTE_STR
571 "Specify IPv6 prefix\n"
572 "Display routes longer than the specified route\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100573 )
Paul Jakmacb4b8842006-05-15 10:39:30 +0000574
575DEFUN (show_ipv6_ospf6_route_match_detail,
576 show_ipv6_ospf6_route_longer_detail_cmd,
577 "show ipv6 ospf6 route X:X::X:X/M longer detail",
578 SHOW_STR
579 IP6_STR
580 OSPF6_STR
581 ROUTE_STR
582 "Specify IPv6 prefix\n"
583 "Display routes longer than the specified route\n"
584 "Detailed information\n"
585 );
586
hasso4846ef62004-09-03 06:04:00 +0000587ALIAS (show_ipv6_ospf6_route,
588 show_ipv6_ospf6_route_type_cmd,
589 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
590 SHOW_STR
591 IP6_STR
592 OSPF6_STR
593 ROUTE_STR
Denis Ovsienko9fa6be72011-08-19 16:27:16 +0400594 "Display Intra-Area routes\n"
595 "Display Inter-Area routes\n"
596 "Display Type-1 External routes\n"
597 "Display Type-2 External routes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100598 )
hasso4846ef62004-09-03 06:04:00 +0000599
600DEFUN (show_ipv6_ospf6_route_type_detail,
601 show_ipv6_ospf6_route_type_detail_cmd,
602 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
603 SHOW_STR
604 IP6_STR
605 OSPF6_STR
606 ROUTE_STR
Denis Ovsienko9fa6be72011-08-19 16:27:16 +0400607 "Display Intra-Area routes\n"
608 "Display Inter-Area routes\n"
609 "Display Type-1 External routes\n"
610 "Display Type-2 External routes\n"
hasso4846ef62004-09-03 06:04:00 +0000611 "Detailed information\n"
612 )
613{
paul0c083ee2004-10-10 12:54:58 +0000614 const char *sargv[CMD_ARGC_MAX];
hasso4846ef62004-09-03 06:04:00 +0000615 int i, sargc;
616
617 /* copy argv to sargv and then append "detail" */
618 for (i = 0; i < argc; i++)
619 sargv[i] = argv[i];
620 sargc = argc;
621 sargv[sargc++] = "detail";
622 sargv[sargc] = NULL;
623
624 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
625 return CMD_SUCCESS;
626}
hasso508e53e2004-05-18 18:57:06 +0000627
628/* OSPF configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100629static int
hasso508e53e2004-05-18 18:57:06 +0000630config_write_ospf6 (struct vty *vty)
631{
632 char router_id[16];
hasso52dc7ee2004-09-23 19:18:23 +0000633 struct listnode *j, *k;
hasso508e53e2004-05-18 18:57:06 +0000634 struct ospf6_area *oa;
635 struct ospf6_interface *oi;
636
637 /* OSPFv6 configuration. */
638 if (ospf6 == NULL)
639 return CMD_SUCCESS;
640 if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))
641 return CMD_SUCCESS;
642
hassoc8a440e2004-10-11 17:02:40 +0000643 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +0000644 vty_out (vty, "router ospf6%s", VNL);
hassoc8a440e2004-10-11 17:02:40 +0000645 if (ospf6->router_id_static != 0)
646 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +0000647
648 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +0000649 ospf6_area_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +0000650
paul1eb8ef22005-04-07 07:30:20 +0000651 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
hasso508e53e2004-05-18 18:57:06 +0000652 {
paul1eb8ef22005-04-07 07:30:20 +0000653 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
654 vty_out (vty, " interface %s area %s%s",
655 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000656 }
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. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800662static struct cmd_node ospf6_node =
hasso508e53e2004-05-18 18:57:06 +0000663{
664 OSPF6_NODE,
665 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +0000666 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +0000667};
668
669/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +0000670void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100671ospf6_top_init (void)
paul718e3742002-12-13 20:15:29 +0000672{
hasso508e53e2004-05-18 18:57:06 +0000673 /* Install ospf6 top node. */
674 install_node (&ospf6_node, config_write_ospf6);
675
676 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
677 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
678 install_element (CONFIG_NODE, &router_ospf6_cmd);
Jon6c19d262009-02-11 17:19:07 -0800679 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +0000680
paul718e3742002-12-13 20:15:29 +0000681 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000682 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
683 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
684 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000685 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
686 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000687 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
688 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
paul718e3742002-12-13 20:15:29 +0000689 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +0000690 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
691 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
692 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000693 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
694 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +0000695 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
696 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +0000697
698 install_default (OSPF6_NODE);
699 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
700 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
701 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
paul718e3742002-12-13 20:15:29 +0000702}
703
hasso508e53e2004-05-18 18:57:06 +0000704