blob: 312d88fe52e3a9f1d1633ede25159f8d2652acee [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
hasso508e53e2004-05-18 18:57:06 +000022#include <zebra.h>
23
24#include "log.h"
25#include "memory.h"
26#include "linklist.h"
27#include "thread.h"
28#include "vty.h"
29#include "command.h"
30#include "if.h"
31#include "prefix.h"
32#include "table.h"
33
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_proto.h"
35#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
37#include "ospf6_route.h"
38#include "ospf6_spf.h"
39#include "ospf6_top.h"
40#include "ospf6_area.h"
41#include "ospf6_interface.h"
42#include "ospf6_intra.h"
hasso049207c2004-08-04 20:02:13 +000043#include "ospf6_abr.h"
44#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000045
hasso508e53e2004-05-18 18:57:06 +000046int
47ospf6_area_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000048{
hasso508e53e2004-05-18 18:57:06 +000049 struct ospf6_area *oa = (struct ospf6_area *) va;
50 struct ospf6_area *ob = (struct ospf6_area *) vb;
hasso6452df02004-08-15 05:52:07 +000051 return (ntohl (oa->area_id) < ntohl (ob->area_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000052}
53
hasso508e53e2004-05-18 18:57:06 +000054/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000055void
hasso508e53e2004-05-18 18:57:06 +000056ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000057{
hasso508e53e2004-05-18 18:57:06 +000058 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000059 {
hasso508e53e2004-05-18 18:57:06 +000060 case OSPF6_LSTYPE_ROUTER:
61 case OSPF6_LSTYPE_NETWORK:
hasso6452df02004-08-15 05:52:07 +000062 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +000063 break;
paul718e3742002-12-13 20:15:29 +000064
hasso508e53e2004-05-18 18:57:06 +000065 case OSPF6_LSTYPE_INTRA_PREFIX:
66 ospf6_intra_prefix_lsa_add (lsa);
67 break;
68
69 case OSPF6_LSTYPE_INTER_PREFIX:
70 case OSPF6_LSTYPE_INTER_ROUTER:
hassoccb59b12004-08-25 09:10:37 +000071 ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data);
hasso508e53e2004-05-18 18:57:06 +000072 break;
73
74 default:
75 if (IS_OSPF6_DEBUG_LSA (RECV))
hasso6452df02004-08-15 05:52:07 +000076 zlog_info ("Unknown LSA in Area %s's lsdb",
77 OSPF6_AREA (lsa->lsdb->data)->name);
hasso508e53e2004-05-18 18:57:06 +000078 break;
79 }
paul718e3742002-12-13 20:15:29 +000080}
81
82void
hasso508e53e2004-05-18 18:57:06 +000083ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000084{
hasso508e53e2004-05-18 18:57:06 +000085 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000086 {
hasso508e53e2004-05-18 18:57:06 +000087 case OSPF6_LSTYPE_ROUTER:
88 case OSPF6_LSTYPE_NETWORK:
hasso6452df02004-08-15 05:52:07 +000089 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +000090 break;
paul718e3742002-12-13 20:15:29 +000091
hasso508e53e2004-05-18 18:57:06 +000092 case OSPF6_LSTYPE_INTRA_PREFIX:
93 ospf6_intra_prefix_lsa_remove (lsa);
94 break;
95
96 case OSPF6_LSTYPE_INTER_PREFIX:
97 case OSPF6_LSTYPE_INTER_ROUTER:
hassoccb59b12004-08-25 09:10:37 +000098 ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data);
hasso508e53e2004-05-18 18:57:06 +000099 break;
100
101 default:
102 if (IS_OSPF6_DEBUG_LSA (RECV))
hasso6452df02004-08-15 05:52:07 +0000103 zlog_info ("Unknown LSA in Area %s's lsdb",
104 OSPF6_AREA (lsa->lsdb->data)->name);
hasso508e53e2004-05-18 18:57:06 +0000105 break;
106 }
107}
108
109void
110ospf6_area_route_hook_add (struct ospf6_route *route)
111{
112 struct ospf6_route *copy = ospf6_route_copy (route);
113 ospf6_route_add (copy, ospf6->route_table);
114}
115
116void
117ospf6_area_route_hook_remove (struct ospf6_route *route)
118{
119 struct ospf6_route *copy;
120
121 copy = ospf6_route_lookup_identical (route, ospf6->route_table);
122 if (copy)
123 ospf6_route_remove (copy, ospf6->route_table);
paul718e3742002-12-13 20:15:29 +0000124}
125
126/* Make new area structure */
127struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000128ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000129{
hasso508e53e2004-05-18 18:57:06 +0000130 struct ospf6_area *oa;
hasso049207c2004-08-04 20:02:13 +0000131 struct ospf6_route *route;
paul718e3742002-12-13 20:15:29 +0000132
hasso508e53e2004-05-18 18:57:06 +0000133 oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
paul718e3742002-12-13 20:15:29 +0000134
hasso508e53e2004-05-18 18:57:06 +0000135 inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
136 oa->area_id = area_id;
137 oa->if_list = list_new ();
paul718e3742002-12-13 20:15:29 +0000138
hasso6452df02004-08-15 05:52:07 +0000139 oa->lsdb = ospf6_lsdb_create (oa);
hasso508e53e2004-05-18 18:57:06 +0000140 oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
141 oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
hasso6452df02004-08-15 05:52:07 +0000142 oa->lsdb_self = ospf6_lsdb_create (oa);
paul718e3742002-12-13 20:15:29 +0000143
hasso508e53e2004-05-18 18:57:06 +0000144 oa->spf_table = ospf6_route_table_create ();
145 oa->route_table = ospf6_route_table_create ();
146 oa->route_table->hook_add = ospf6_area_route_hook_add;
147 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000148
hasso6452df02004-08-15 05:52:07 +0000149 oa->range_table = ospf6_route_table_create ();
150 oa->summary_prefix = ospf6_route_table_create ();
151 oa->summary_router = ospf6_route_table_create ();
152
hasso508e53e2004-05-18 18:57:06 +0000153 /* set default options */
154 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
155 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
156 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000157
hasso508e53e2004-05-18 18:57:06 +0000158 oa->ospf6 = o;
159 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +0000160
hasso049207c2004-08-04 20:02:13 +0000161 /* import athoer area's routes as inter-area routes */
162 for (route = ospf6_route_head (o->route_table); route;
163 route = ospf6_route_next (route))
hasso6452df02004-08-15 05:52:07 +0000164 ospf6_abr_originate_summary_to_area (route, oa);
hasso049207c2004-08-04 20:02:13 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 return oa;
paul718e3742002-12-13 20:15:29 +0000167}
168
169void
hasso508e53e2004-05-18 18:57:06 +0000170ospf6_area_delete (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000171{
172 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000173 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000174
hasso6452df02004-08-15 05:52:07 +0000175 ospf6_route_table_delete (oa->range_table);
176 ospf6_route_table_delete (oa->summary_prefix);
177 ospf6_route_table_delete (oa->summary_router);
hasso049207c2004-08-04 20:02:13 +0000178
paul718e3742002-12-13 20:15:29 +0000179 /* ospf6 interface list */
hasso508e53e2004-05-18 18:57:06 +0000180 for (n = listhead (oa->if_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000181 {
hasso508e53e2004-05-18 18:57:06 +0000182 oi = (struct ospf6_interface *) getdata (n);
183 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000184 }
hasso508e53e2004-05-18 18:57:06 +0000185 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000186
hasso508e53e2004-05-18 18:57:06 +0000187 ospf6_lsdb_delete (oa->lsdb);
hasso6452df02004-08-15 05:52:07 +0000188 ospf6_lsdb_delete (oa->lsdb_self);
189
hasso508e53e2004-05-18 18:57:06 +0000190 ospf6_route_table_delete (oa->spf_table);
191 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000192
hasso508e53e2004-05-18 18:57:06 +0000193#if 0
194 ospf6_spftree_delete (oa->spf_tree);
195 ospf6_route_table_delete (oa->topology_table);
196#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000197
hasso508e53e2004-05-18 18:57:06 +0000198 THREAD_OFF (oa->thread_spf_calculation);
199 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000200
hasso508e53e2004-05-18 18:57:06 +0000201 listnode_delete (oa->ospf6->area_list, oa);
202 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000203
204 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000205 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000206}
207
208struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000209ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000210{
hasso508e53e2004-05-18 18:57:06 +0000211 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000212 listnode n;
213
hasso508e53e2004-05-18 18:57:06 +0000214 for (n = listhead (ospf6->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000215 {
hasso508e53e2004-05-18 18:57:06 +0000216 oa = (struct ospf6_area *) getdata (n);
217 if (oa->area_id == area_id)
218 return oa;
paul718e3742002-12-13 20:15:29 +0000219 }
220
221 return (struct ospf6_area *) NULL;
222}
223
hasso6452df02004-08-15 05:52:07 +0000224struct ospf6_area *
225ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
226{
227 struct ospf6_area *oa;
228 oa = ospf6_area_lookup (area_id, o);
229 if (oa == NULL)
230 oa = ospf6_area_create (area_id, o);
231 return oa;
232}
233
paul718e3742002-12-13 20:15:29 +0000234void
hasso508e53e2004-05-18 18:57:06 +0000235ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000236{
237 listnode i;
hasso508e53e2004-05-18 18:57:06 +0000238 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000239
hasso6452df02004-08-15 05:52:07 +0000240 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
paul718e3742002-12-13 20:15:29 +0000241
hasso508e53e2004-05-18 18:57:06 +0000242 for (i = listhead (oa->if_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000243 {
hasso508e53e2004-05-18 18:57:06 +0000244 oi = (struct ospf6_interface *) getdata (i);
245 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000246 }
247}
248
249void
hasso508e53e2004-05-18 18:57:06 +0000250ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000251{
hasso508e53e2004-05-18 18:57:06 +0000252 listnode i;
253 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000254
hasso6452df02004-08-15 05:52:07 +0000255 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso508e53e2004-05-18 18:57:06 +0000256
257 for (i = listhead (oa->if_list); i; nextnode (i))
258 {
259 oi = (struct ospf6_interface *) getdata (i);
260 ospf6_interface_disable (oi);
261 }
paul718e3742002-12-13 20:15:29 +0000262}
263
hasso508e53e2004-05-18 18:57:06 +0000264
265void
266ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
267{
268 listnode i;
269 struct ospf6_interface *oi;
270
hasso049207c2004-08-04 20:02:13 +0000271 vty_out (vty, " Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000272 vty_out (vty, " Number of Area scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000273 oa->lsdb->count, VNL);
hasso508e53e2004-05-18 18:57:06 +0000274
275 vty_out (vty, " Interface attached to this area:");
276 for (i = listhead (oa->if_list); i; nextnode (i))
277 {
278 oi = (struct ospf6_interface *) getdata (i);
279 vty_out (vty, " %s", oi->interface->name);
280 }
hasso049207c2004-08-04 20:02:13 +0000281 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000282}
283
284
hasso049207c2004-08-04 20:02:13 +0000285#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
286{ \
287 u_int32_t area_id = 0; \
288 if (inet_pton (AF_INET, str, &area_id) != 1) \
289 { \
290 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
291 return CMD_SUCCESS; \
292 } \
293 oa = ospf6_area_lookup (area_id, ospf6); \
294 if (oa == NULL) \
295 { \
296 vty_out (vty, "No such Area: %s%s", str, VNL); \
297 return CMD_SUCCESS; \
298 } \
hasso508e53e2004-05-18 18:57:06 +0000299}
300
hasso6452df02004-08-15 05:52:07 +0000301#define OSPF6_CMD_AREA_GET(str, oa) \
302{ \
303 u_int32_t area_id = 0; \
304 if (inet_pton (AF_INET, str, &area_id) != 1) \
305 { \
306 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
307 return CMD_SUCCESS; \
308 } \
309 oa = ospf6_area_get (area_id, ospf6); \
310}
311
312DEFUN (area_range,
313 area_range_cmd,
314 "area A.B.C.D range X:X::X:X/M",
315 "OSPF area parameters\n"
316 OSPF6_AREA_ID_STR
317 "Configured address range\n"
318 "Specify IPv6 prefix\n"
319 )
320{
321 int ret;
322 struct ospf6_area *oa;
323 struct prefix prefix;
324 struct ospf6_route *range;
325
326 OSPF6_CMD_AREA_GET (argv[0], oa);
327 argc--;
328 argv++;
329
330 ret = str2prefix (argv[0], &prefix);
331 if (ret != 1 || prefix.family != AF_INET6)
332 {
333 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
334 return CMD_SUCCESS;
335 }
336 argc--;
337 argv++;
338
339 range = ospf6_route_lookup (&prefix, oa->range_table);
340 if (range == NULL)
341 {
342 range = ospf6_route_create ();
343 range->type = OSPF6_DEST_TYPE_RANGE;
344 range->prefix = prefix;
345 }
346
347 if (argc)
348 {
349 if (! strcmp (argv[0], "not-advertise"))
350 SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
351 else if (! strcmp (argv[0], "advertise"))
352 UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
353 }
354
355 ospf6_route_add (range, oa->range_table);
356 return CMD_SUCCESS;
357}
358
359ALIAS (area_range,
360 area_range_advertise_cmd,
361 "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
362 "OSPF area parameters\n"
363 OSPF6_AREA_ID_STR
364 "Configured address range\n"
365 "Specify IPv6 prefix\n"
366 );
367
368DEFUN (no_area_range,
369 no_area_range_cmd,
370 "no area A.B.C.D range X:X::X:X/M",
371 "OSPF area parameters\n"
372 OSPF6_AREA_ID_STR
373 "Configured address range\n"
374 "Specify IPv6 prefix\n"
375 )
376{
377 int ret;
378 struct ospf6_area *oa;
379 struct prefix prefix;
380 struct ospf6_route *range;
381
382 OSPF6_CMD_AREA_GET (argv[0], oa);
383 argc--;
384 argv++;
385
386 ret = str2prefix (argv[0], &prefix);
387 if (ret != 1 || prefix.family != AF_INET6)
388 {
389 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
390 return CMD_SUCCESS;
391 }
392
393 range = ospf6_route_lookup (&prefix, oa->range_table);
394 if (range == NULL)
395 {
396 vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
397 return CMD_SUCCESS;
398 }
399
400 ospf6_route_remove (range, oa->range_table);
401 return CMD_SUCCESS;
402}
403
404void
405ospf6_area_config_write (struct vty *vty)
406{
407 listnode node;
408 struct ospf6_area *oa;
409 struct ospf6_route *range;
410 char buf[128];
411
412 for (node = listhead (ospf6->area_list); node; nextnode (node))
413 {
414 oa = OSPF6_AREA (getdata (node));
415
416 for (range = ospf6_route_head (oa->range_table); range;
417 range = ospf6_route_next (range))
418 {
419 prefix2str (&range->prefix, buf, sizeof (buf));
420 vty_out (vty, " area %s range %s%s", oa->name, buf, VNL);
421 }
422 }
423}
424
hasso508e53e2004-05-18 18:57:06 +0000425DEFUN (show_ipv6_ospf6_area_route_intra,
426 show_ipv6_ospf6_area_route_intra_cmd,
427 "show ipv6 ospf6 area A.B.C.D route intra-area",
paul718e3742002-12-13 20:15:29 +0000428 SHOW_STR
429 IP6_STR
430 OSPF6_STR
431 OSPF6_AREA_STR
432 OSPF6_AREA_ID_STR
433 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000434 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000435 )
436{
hasso508e53e2004-05-18 18:57:06 +0000437 struct ospf6_area *oa;
438 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
439 argc--;
440 argv++;
441 return ospf6_route_table_show (vty, argc, argv, oa->route_table);
paul718e3742002-12-13 20:15:29 +0000442}
443
hasso508e53e2004-05-18 18:57:06 +0000444ALIAS (show_ipv6_ospf6_area_route_intra,
445 show_ipv6_ospf6_area_route_intra_detail_cmd,
446 "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)",
paul718e3742002-12-13 20:15:29 +0000447 SHOW_STR
448 IP6_STR
449 OSPF6_STR
450 OSPF6_AREA_STR
451 OSPF6_AREA_ID_STR
452 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000453 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000454 "Specify IPv6 address\n"
hasso508e53e2004-05-18 18:57:06 +0000455 "Specify IPv6 prefix\n"
456 "Detailed information\n"
457 );
458
459DEFUN (show_ipv6_ospf6_area_route_intra_match,
460 show_ipv6_ospf6_area_route_intra_match_cmd,
461 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match",
462 SHOW_STR
463 IP6_STR
464 OSPF6_STR
465 ROUTE_STR
466 "Display Intra-Area routes\n"
467 OSPF6_AREA_STR
468 OSPF6_AREA_ID_STR
469 "Specify IPv6 prefix\n"
470 "Display routes which match the specified route\n"
471 )
472{
473 char *sargv[CMD_ARGC_MAX];
474 int i, sargc;
475 struct ospf6_area *oa;
476
477 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
478 argc--;
479 argv++;
480
481 /* copy argv to sargv and then append "match" */
482 for (i = 0; i < argc; i++)
483 sargv[i] = argv[i];
484 sargc = argc;
485 sargv[sargc++] = "match";
486 sargv[sargc] = NULL;
487
488 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
489}
490
491DEFUN (show_ipv6_ospf6_area_route_intra_match_detail,
492 show_ipv6_ospf6_area_route_intra_match_detail_cmd,
493 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail",
494 SHOW_STR
495 IP6_STR
496 OSPF6_STR
497 OSPF6_AREA_STR
498 OSPF6_AREA_ID_STR
499 ROUTE_STR
500 "Display Intra-Area routes\n"
501 "Specify IPv6 prefix\n"
502 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000503 "Detailed information\n"
504 )
hasso508e53e2004-05-18 18:57:06 +0000505{
506 char *sargv[CMD_ARGC_MAX];
507 int i, sargc;
508 struct ospf6_area *oa;
509
510 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
511 argc--;
512 argv++;
513
514 /* copy argv to sargv and then append "match" and "detail" */
515 for (i = 0; i < argc; i++)
516 sargv[i] = argv[i];
517 sargc = argc;
518 sargv[sargc++] = "match";
519 sargv[sargc++] = "detail";
520 sargv[sargc] = NULL;
521
522 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
523}
524
525DEFUN (show_ipv6_ospf6_route_intra,
526 show_ipv6_ospf6_route_intra_cmd,
527 "show ipv6 ospf6 route intra-area",
528 SHOW_STR
529 IP6_STR
530 OSPF6_STR
531 ROUTE_STR
532 "Display Intra-Area routes\n"
533 )
534{
535 listnode node;
536 struct ospf6_area *oa;
537
538 for (node = listhead (ospf6->area_list); node; nextnode (node))
539 {
540 oa = (struct ospf6_area *) getdata (node);
hasso049207c2004-08-04 20:02:13 +0000541 vty_out (vty, "Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000542 ospf6_route_table_show (vty, argc, argv, oa->route_table);
543 }
544
545 return CMD_SUCCESS;
546}
547
548ALIAS (show_ipv6_ospf6_route_intra,
549 show_ipv6_ospf6_route_intra_detail_cmd,
550 "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)",
551 SHOW_STR
552 IP6_STR
553 OSPF6_STR
554 ROUTE_STR
555 "Display Intra-Area routes\n"
556 "Specify IPv6 address\n"
557 "Specify IPv6 prefix\n"
558 "Detailed information\n"
559 "Summary of route table\n"
560 );
561
562DEFUN (show_ipv6_ospf6_route_intra_match,
563 show_ipv6_ospf6_route_intra_match_cmd,
564 "show ipv6 ospf6 route intra-area X::X/M match",
565 SHOW_STR
566 IP6_STR
567 OSPF6_STR
568 ROUTE_STR
569 "Display Intra-Area routes\n"
570 "Specify IPv6 prefix\n"
571 "Display routes which match the specified route\n"
572 )
573{
574 char *sargv[CMD_ARGC_MAX];
575 int i, sargc;
576 listnode node;
577 struct ospf6_area *oa;
578
579 /* copy argv to sargv and then append "match" */
580 for (i = 0; i < argc; i++)
581 sargv[i] = argv[i];
582 sargc = argc;
583 sargv[sargc++] = "match";
584 sargv[sargc] = NULL;
585
586 for (node = listhead (ospf6->area_list); node; nextnode (node))
587 {
588 oa = (struct ospf6_area *) getdata (node);
589 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
590 }
591
592 return CMD_SUCCESS;
593}
594
595DEFUN (show_ipv6_ospf6_route_intra_match_detail,
596 show_ipv6_ospf6_route_intra_match_detail_cmd,
597 "show ipv6 ospf6 route intra-area X::X/M match detail",
598 SHOW_STR
599 IP6_STR
600 OSPF6_STR
601 ROUTE_STR
602 "Display Intra-Area routes\n"
603 "Specify IPv6 prefix\n"
604 "Display routes which match the specified route\n"
605 "Detailed information\n"
606 )
607{
608 char *sargv[CMD_ARGC_MAX];
609 int i, sargc;
610 listnode node;
611 struct ospf6_area *oa;
612
613 /* copy argv to sargv and then append "match" and "detail" */
614 for (i = 0; i < argc; i++)
615 sargv[i] = argv[i];
616 sargc = argc;
617 sargv[sargc++] = "match";
618 sargv[sargc++] = "detail";
619 sargv[sargc] = NULL;
620
621 for (node = listhead (ospf6->area_list); node; nextnode (node))
622 {
623 oa = (struct ospf6_area *) getdata (node);
624 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
625 }
626
627 return CMD_SUCCESS;
628}
629
630DEFUN (show_ipv6_ospf6_spf_tree,
631 show_ipv6_ospf6_spf_tree_cmd,
632 "show ipv6 ospf6 spf tree",
633 SHOW_STR
634 IP6_STR
635 OSPF6_STR
636 "Shortest Path First caculation\n"
637 "Show SPF tree\n")
638{
639 listnode node;
640 struct ospf6_area *oa;
641 struct ospf6_vertex *root;
642 struct ospf6_route *route;
643 struct prefix prefix;
644
645 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
646 for (node = listhead (ospf6->area_list); node; nextnode (node))
647 {
648 oa = (struct ospf6_area *) getdata (node);
649 route = ospf6_route_lookup (&prefix, oa->spf_table);
650 if (route == NULL)
651 {
652 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000653 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000654 continue;
655 }
656 root = (struct ospf6_vertex *) route->route_option;
657 ospf6_spf_display_subtree (vty, "", 0, root);
658 }
659
660 return CMD_SUCCESS;
661}
662
663DEFUN (show_ipv6_ospf6_area_spf_tree,
664 show_ipv6_ospf6_area_spf_tree_cmd,
665 "show ipv6 ospf6 area A.B.C.D spf tree",
666 SHOW_STR
667 IP6_STR
668 OSPF6_STR
669 OSPF6_AREA_STR
670 OSPF6_AREA_ID_STR
671 "Shortest Path First caculation\n"
672 "Show SPF tree\n")
673{
674 u_int32_t area_id;
675 struct ospf6_area *oa;
676 struct ospf6_vertex *root;
677 struct ospf6_route *route;
678 struct prefix prefix;
679
680 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
681
682 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
683 {
hasso049207c2004-08-04 20:02:13 +0000684 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000685 return CMD_SUCCESS;
686 }
687 oa = ospf6_area_lookup (area_id, ospf6);
688 if (oa == NULL)
689 {
hasso049207c2004-08-04 20:02:13 +0000690 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000691 return CMD_SUCCESS;
692 }
693
694 route = ospf6_route_lookup (&prefix, oa->spf_table);
695 if (route == NULL)
696 {
697 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000698 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000699 return CMD_SUCCESS;
700 }
701 root = (struct ospf6_vertex *) route->route_option;
702 ospf6_spf_display_subtree (vty, "", 0, root);
703
704 return CMD_SUCCESS;
705}
706
707DEFUN (show_ipv6_ospf6_area_spf_table,
708 show_ipv6_ospf6_area_spf_table_cmd,
709 "show ipv6 ospf6 area A.B.C.D spf table",
710 SHOW_STR
711 IP6_STR
712 OSPF6_STR
713 OSPF6_AREA_STR
714 OSPF6_AREA_ID_STR
715 "Shortest Path First caculation\n"
716 "Show table contains SPF result\n"
717 )
718{
719 u_int32_t area_id;
720 struct ospf6_area *oa;
721
722 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
723 {
hasso049207c2004-08-04 20:02:13 +0000724 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000725 return CMD_SUCCESS;
726 }
727 oa = ospf6_area_lookup (area_id, ospf6);
728 if (oa == NULL)
729 {
hasso049207c2004-08-04 20:02:13 +0000730 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000731 return CMD_SUCCESS;
732 }
733
734 argc--;
735 argv++;
736
737 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
738 return CMD_SUCCESS;
739}
740
741ALIAS (show_ipv6_ospf6_area_spf_table,
742 show_ipv6_ospf6_area_spf_table_1_cmd,
743 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)",
744 SHOW_STR
745 IP6_STR
746 OSPF6_STR
747 OSPF6_AREA_STR
748 OSPF6_AREA_ID_STR
749 "Shortest Path First caculation\n"
750 "Show table contains SPF result\n"
751 "Specify Router-ID\n"
752 "Display multiple entry by specifying match-prefix of Router-ID\n"
753 "Display Detail\n"
754 );
755
756ALIAS (show_ipv6_ospf6_area_spf_table,
757 show_ipv6_ospf6_area_spf_table_2_cmd,
758 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)",
759 SHOW_STR
760 IP6_STR
761 OSPF6_STR
762 OSPF6_AREA_STR
763 OSPF6_AREA_ID_STR
764 "Shortest Path First caculation\n"
765 "Show table contains SPF result\n"
766 "Specify Router-ID\n"
767 "Wildcard Router-ID\n"
768 "Specify Link State ID\n"
769 "Display multiple entry by specifying match-prefix of Link State ID\n"
770 "Display Detail\n"
771 );
772
773DEFUN (show_ipv6_ospf6_area_spf_table_3,
774 show_ipv6_ospf6_area_spf_table_3_cmd,
775 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail",
776 SHOW_STR
777 IP6_STR
778 OSPF6_STR
779 OSPF6_AREA_STR
780 OSPF6_AREA_ID_STR
781 "Shortest Path First caculation\n"
782 "Show table contains SPF result\n"
783 "Specify Router-ID\n"
784 "Wildcard Router-ID\n"
785 "Display multiple entry by specifying match-prefix of Link State ID\n"
786 "Display Detail\n"
787 )
788{
789 u_int32_t area_id;
790 struct ospf6_area *oa;
791 char *sargv[CMD_ARGC_MAX];
792 int i, sargc;
793
794 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
795 {
hasso049207c2004-08-04 20:02:13 +0000796 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000797 return CMD_SUCCESS;
798 }
799 oa = ospf6_area_lookup (area_id, ospf6);
800 if (oa == NULL)
801 {
hasso049207c2004-08-04 20:02:13 +0000802 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000803 return CMD_SUCCESS;
804 }
805
806 argc--;
807 argv++;
808
809 /* copy argv to sargv and then append "detail" */
810 for (i = 0; i < argc; i++)
811 sargv[i] = argv[i];
812 sargc = argc;
813 sargv[sargc++] = "detail";
814 sargv[sargc] = NULL;
815
816 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
817 return CMD_SUCCESS;
818}
819
820DEFUN (show_ipv6_ospf6_spf_table,
821 show_ipv6_ospf6_spf_table_cmd,
822 "show ipv6 ospf6 spf table",
823 SHOW_STR
824 IP6_STR
825 OSPF6_STR
826 "Shortest Path First caculation\n"
827 "Show table contains SPF result\n"
828 )
829{
830 listnode node;
831 struct ospf6_area *oa;
832
833 for (node = listhead (ospf6->area_list); node; nextnode (node))
834 {
835 oa = (struct ospf6_area *) getdata (node);
836 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
837 }
838
839 return CMD_SUCCESS;
840}
841
842ALIAS (show_ipv6_ospf6_spf_table,
843 show_ipv6_ospf6_spf_table_1_cmd,
844 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)",
845 SHOW_STR
846 IP6_STR
847 OSPF6_STR
848 "Shortest Path First caculation\n"
849 "Show table contains SPF result\n"
850 "Specify Router-ID\n"
851 "Display multiple entry by specifying match-prefix of Router-ID\n"
852 "Display Detail\n"
853 );
854
855ALIAS (show_ipv6_ospf6_spf_table,
856 show_ipv6_ospf6_spf_table_2_cmd,
857 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)",
858 SHOW_STR
859 IP6_STR
860 OSPF6_STR
861 "Shortest Path First caculation\n"
862 "Show table contains SPF result\n"
863 "Specify Router-ID\n"
864 "Display multiple entry by specifying match-prefix of Router-ID\n"
865 "Wildcard Router-ID\n"
866 "Specify Link State ID\n"
867 "Display multiple entry by specifying match-prefix of Link State ID\n"
868 "Display Detail\n"
869 );
870
871DEFUN (show_ipv6_ospf6_spf_table_3,
872 show_ipv6_ospf6_spf_table_3_cmd,
873 "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail",
874 SHOW_STR
875 IP6_STR
876 OSPF6_STR
877 "Shortest Path First caculation\n"
878 "Show table contains SPF result\n"
879 "Specify Router-ID\n"
880 "Wildcard Router-ID\n"
881 "Display multiple entry by specifying match-prefix of Link State ID\n"
882 "Display Detail\n"
883 )
884{
885 listnode node;
886 struct ospf6_area *oa;
887 char *sargv[CMD_ARGC_MAX];
888 int i, sargc;
889
890 /* copy argv to sargv and then append "detail" */
891 for (i = 0; i < argc; i++)
892 sargv[i] = argv[i];
893 sargc = argc;
894 sargv[sargc++] = "detail";
895 sargv[sargc] = NULL;
896
897 for (node = listhead (ospf6->area_list); node; nextnode (node))
898 {
899 oa = (struct ospf6_area *) getdata (node);
900 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
901 }
902
903 return CMD_SUCCESS;
904}
905
906DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
907 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
908 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
909 SHOW_STR
910 IP6_STR
911 OSPF6_STR
912 "Shortest Path First caculation\n"
913 "Show SPF tree\n"
914 "Specify root's router-id to calculate another router's SPF tree\n")
915{
916 u_int32_t area_id;
917 struct ospf6_area *oa;
918 struct ospf6_vertex *root;
919 struct ospf6_route *route;
920 struct prefix prefix;
921 u_int32_t router_id;
922 struct ospf6_route_table *spf_table;
923 unsigned char tmp_debug_ospf6_spf = 0;
924
925 inet_pton (AF_INET, argv[0], &router_id);
926 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
927
928 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
929 {
hasso049207c2004-08-04 20:02:13 +0000930 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000931 return CMD_SUCCESS;
932 }
933 oa = ospf6_area_lookup (area_id, ospf6);
934 if (oa == NULL)
935 {
hasso049207c2004-08-04 20:02:13 +0000936 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000937 return CMD_SUCCESS;
938 }
939
940 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
941 conf_debug_ospf6_spf = 0;
942
943 spf_table = ospf6_route_table_create ();
944 ospf6_spf_calculation (router_id, spf_table, oa);
945
946 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
947
948 route = ospf6_route_lookup (&prefix, spf_table);
949 if (route == NULL)
950 {
951 ospf6_spf_table_finish (spf_table);
952 ospf6_route_table_delete (spf_table);
953 return CMD_SUCCESS;
954 }
955 root = (struct ospf6_vertex *) route->route_option;
956 ospf6_spf_display_subtree (vty, "", 0, root);
957
958 ospf6_spf_table_finish (spf_table);
959 ospf6_route_table_delete (spf_table);
960
961 return CMD_SUCCESS;
962}
paul718e3742002-12-13 20:15:29 +0000963
964void
965ospf6_area_init ()
966{
hasso508e53e2004-05-18 18:57:06 +0000967 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
968 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd);
969 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
970 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
971 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
972 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
973 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
974 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
975 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
976 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
paul718e3742002-12-13 20:15:29 +0000977
hasso508e53e2004-05-18 18:57:06 +0000978 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd);
979 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
980 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
981 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
982 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
983 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
984 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
985 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
986
987 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
988
989 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
990 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd);
991 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
992 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
993 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
994 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
995 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
996 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
997 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
998 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
999
1000 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd);
1001 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
1002 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
1003 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
1004 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
1005 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
1006 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
1007 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
1008
1009 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
hasso6452df02004-08-15 05:52:07 +00001010
1011 install_element (OSPF6_NODE, &area_range_cmd);
1012 install_element (OSPF6_NODE, &area_range_advertise_cmd);
1013 install_element (OSPF6_NODE, &no_area_range_cmd);
paul718e3742002-12-13 20:15:29 +00001014}
hasso049207c2004-08-04 20:02:13 +00001015
hasso6452df02004-08-15 05:52:07 +00001016