2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #include "ospf6_proto.h"
36 #include "ospf6_lsa.h"
37 #include "ospf6_lsdb.h"
38 #include "ospf6_route.h"
39 #include "ospf6_spf.h"
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_intra.h"
44 #include "ospf6_abr.h"
45 #include "ospf6_asbr.h"
49 ospf6_area_cmp (void *va
, void *vb
)
51 struct ospf6_area
*oa
= (struct ospf6_area
*) va
;
52 struct ospf6_area
*ob
= (struct ospf6_area
*) vb
;
53 return (ntohl (oa
->area_id
) < ntohl (ob
->area_id
) ? -1 : 1);
56 /* schedule routing table recalculation */
58 ospf6_area_lsdb_hook_add (struct ospf6_lsa
*lsa
)
60 switch (ntohs (lsa
->header
->type
))
62 case OSPF6_LSTYPE_ROUTER
:
63 case OSPF6_LSTYPE_NETWORK
:
64 if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa
->header
->type
))
66 zlog_debug ("Examin %s", lsa
->name
);
67 zlog_debug ("Schedule SPF Calculation for %s",
68 OSPF6_AREA (lsa
->lsdb
->data
)->name
);
70 ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa
->lsdb
->data
)->ospf6
),
71 ospf6_lsadd_to_spf_reason(lsa
));
74 case OSPF6_LSTYPE_INTRA_PREFIX
:
75 ospf6_intra_prefix_lsa_add (lsa
);
78 case OSPF6_LSTYPE_INTER_PREFIX
:
79 case OSPF6_LSTYPE_INTER_ROUTER
:
80 ospf6_abr_examin_summary (lsa
, (struct ospf6_area
*) lsa
->lsdb
->data
);
89 ospf6_area_lsdb_hook_remove (struct ospf6_lsa
*lsa
)
91 switch (ntohs (lsa
->header
->type
))
93 case OSPF6_LSTYPE_ROUTER
:
94 case OSPF6_LSTYPE_NETWORK
:
95 if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa
->header
->type
))
97 zlog_debug ("LSA disappearing: %s", lsa
->name
);
98 zlog_debug ("Schedule SPF Calculation for %s",
99 OSPF6_AREA (lsa
->lsdb
->data
)->name
);
101 ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa
->lsdb
->data
)->ospf6
),
102 ospf6_lsremove_to_spf_reason(lsa
));
105 case OSPF6_LSTYPE_INTRA_PREFIX
:
106 ospf6_intra_prefix_lsa_remove (lsa
);
109 case OSPF6_LSTYPE_INTER_PREFIX
:
110 case OSPF6_LSTYPE_INTER_ROUTER
:
111 ospf6_abr_examin_summary (lsa
, (struct ospf6_area
*) lsa
->lsdb
->data
);
120 ospf6_area_route_hook_add (struct ospf6_route
*route
)
122 struct ospf6_route
*copy
= ospf6_route_copy (route
);
123 ospf6_route_add (copy
, ospf6
->route_table
);
127 ospf6_area_route_hook_remove (struct ospf6_route
*route
)
129 struct ospf6_route
*copy
;
131 copy
= ospf6_route_lookup_identical (route
, ospf6
->route_table
);
133 ospf6_route_remove (copy
, ospf6
->route_table
);
137 ospf6_area_stub_update (struct ospf6_area
*area
)
140 if (IS_AREA_STUB (area
))
142 if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER
))
143 zlog_debug ("Stubbing out area for if %s\n", area
->name
);
144 OSPF6_OPT_CLEAR (area
->options
, OSPF6_OPT_E
);
146 else if (IS_AREA_ENABLED (area
))
148 if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER
))
149 zlog_debug ("Normal area for if %s\n", area
->name
);
150 OSPF6_OPT_SET (area
->options
, OSPF6_OPT_E
);
151 ospf6_asbr_send_externals_to_area (area
);
154 OSPF6_ROUTER_LSA_SCHEDULE(area
);
158 ospf6_area_stub_set (struct ospf6
*ospf6
, struct ospf6_area
*area
)
160 if (!IS_AREA_STUB(area
))
162 SET_FLAG (area
->flag
, OSPF6_AREA_STUB
);
163 ospf6_area_stub_update (area
);
170 ospf6_area_stub_unset (struct ospf6
*ospf6
, struct ospf6_area
*area
)
172 if (IS_AREA_STUB (area
))
174 UNSET_FLAG (area
->flag
, OSPF6_AREA_STUB
);
175 ospf6_area_stub_update (area
);
180 ospf6_area_no_summary_set (struct ospf6
*ospf6
, struct ospf6_area
*area
)
184 if (!area
->no_summary
)
186 area
->no_summary
= 1;
187 ospf6_abr_range_reset_cost (ospf6
);
188 ospf6_abr_prefix_resummarize (ospf6
);
194 ospf6_area_no_summary_unset (struct ospf6
*ospf6
, struct ospf6_area
*area
)
198 if (area
->no_summary
)
200 area
->no_summary
= 0;
201 ospf6_abr_range_reset_cost (ospf6
);
202 ospf6_abr_prefix_resummarize (ospf6
);
208 * Make new area structure.
210 * @param area_id - ospf6 area ID
211 * @param o - ospf6 instance
212 * @param df - display format for area ID
215 ospf6_area_create (u_int32_t area_id
, struct ospf6
*o
, int df
)
217 struct ospf6_area
*oa
;
219 oa
= XCALLOC (MTYPE_OSPF6_AREA
, sizeof (struct ospf6_area
));
223 case OSPF6_AREA_FMT_DECIMAL
:
224 snprintf (oa
->name
, sizeof (oa
->name
), "%u", ntohl (area_id
));
227 case OSPF6_AREA_FMT_DOTTEDQUAD
:
228 inet_ntop (AF_INET
, &area_id
, oa
->name
, sizeof (oa
->name
));
232 oa
->area_id
= area_id
;
233 oa
->if_list
= list_new ();
235 oa
->lsdb
= ospf6_lsdb_create (oa
);
236 oa
->lsdb
->hook_add
= ospf6_area_lsdb_hook_add
;
237 oa
->lsdb
->hook_remove
= ospf6_area_lsdb_hook_remove
;
238 oa
->lsdb_self
= ospf6_lsdb_create (oa
);
240 oa
->spf_table
= OSPF6_ROUTE_TABLE_CREATE (AREA
, SPF_RESULTS
);
241 oa
->spf_table
->scope
= oa
;
242 oa
->route_table
= OSPF6_ROUTE_TABLE_CREATE (AREA
, ROUTES
);
243 oa
->route_table
->scope
= oa
;
244 oa
->route_table
->hook_add
= ospf6_area_route_hook_add
;
245 oa
->route_table
->hook_remove
= ospf6_area_route_hook_remove
;
247 oa
->range_table
= OSPF6_ROUTE_TABLE_CREATE (AREA
, PREFIX_RANGES
);
248 oa
->range_table
->scope
= oa
;
249 bf_init(oa
->range_table
->idspace
, 32);
250 oa
->summary_prefix
= OSPF6_ROUTE_TABLE_CREATE (AREA
, SUMMARY_PREFIXES
);
251 oa
->summary_prefix
->scope
= oa
;
252 oa
->summary_router
= OSPF6_ROUTE_TABLE_CREATE (AREA
, SUMMARY_ROUTERS
);
253 oa
->summary_router
->scope
= oa
;
255 /* set default options */
256 if (CHECK_FLAG (o
->flag
, OSPF6_STUB_ROUTER
))
258 OSPF6_OPT_CLEAR (oa
->options
, OSPF6_OPT_V6
);
259 OSPF6_OPT_CLEAR (oa
->options
, OSPF6_OPT_R
);
263 OSPF6_OPT_SET (oa
->options
, OSPF6_OPT_V6
);
264 OSPF6_OPT_SET (oa
->options
, OSPF6_OPT_R
);
267 OSPF6_OPT_SET (oa
->options
, OSPF6_OPT_E
);
269 SET_FLAG (oa
->flag
, OSPF6_AREA_ACTIVE
);
270 SET_FLAG (oa
->flag
, OSPF6_AREA_ENABLE
);
273 listnode_add_sort (o
->area_list
, oa
);
275 if (area_id
== OSPF_AREA_BACKBONE
)
284 ospf6_area_delete (struct ospf6_area
*oa
)
287 struct ospf6_interface
*oi
;
289 /* The ospf6_interface structs store configuration
290 * information which should not be lost/reset when
292 * So just detach the interface from the area and
294 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, n
, oi
))
297 list_delete (oa
->if_list
);
299 ospf6_lsdb_delete (oa
->lsdb
);
300 ospf6_lsdb_delete (oa
->lsdb_self
);
302 ospf6_spf_table_finish (oa
->spf_table
);
303 ospf6_route_table_delete (oa
->spf_table
);
304 ospf6_route_table_delete (oa
->route_table
);
306 ospf6_route_table_delete (oa
->range_table
);
307 ospf6_route_table_delete (oa
->summary_prefix
);
308 ospf6_route_table_delete (oa
->summary_router
);
310 listnode_delete (oa
->ospf6
->area_list
, oa
);
314 XFREE (MTYPE_OSPF6_AREA
, oa
);
318 ospf6_area_lookup (u_int32_t area_id
, struct ospf6
*ospf6
)
320 struct ospf6_area
*oa
;
323 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, n
, oa
))
324 if (oa
->area_id
== area_id
)
327 return (struct ospf6_area
*) NULL
;
331 ospf6_area_enable (struct ospf6_area
*oa
)
333 struct listnode
*node
, *nnode
;
334 struct ospf6_interface
*oi
;
336 SET_FLAG (oa
->flag
, OSPF6_AREA_ENABLE
);
338 for (ALL_LIST_ELEMENTS (oa
->if_list
, node
, nnode
, oi
))
339 ospf6_interface_enable (oi
);
340 ospf6_abr_enable_area (oa
);
344 ospf6_area_disable (struct ospf6_area
*oa
)
346 struct listnode
*node
, *nnode
;
347 struct ospf6_interface
*oi
;
349 UNSET_FLAG (oa
->flag
, OSPF6_AREA_ENABLE
);
351 for (ALL_LIST_ELEMENTS (oa
->if_list
, node
, nnode
, oi
))
352 ospf6_interface_disable (oi
);
354 ospf6_abr_disable_area (oa
);
355 ospf6_lsdb_remove_all (oa
->lsdb
);
356 ospf6_lsdb_remove_all (oa
->lsdb_self
);
358 ospf6_spf_table_finish(oa
->spf_table
);
359 ospf6_route_remove_all(oa
->route_table
);
361 THREAD_OFF (oa
->thread_router_lsa
);
362 THREAD_OFF (oa
->thread_intra_prefix_lsa
);
367 ospf6_area_show (struct vty
*vty
, struct ospf6_area
*oa
)
370 struct ospf6_interface
*oi
;
371 unsigned long result
;
373 if (!IS_AREA_STUB (oa
))
374 vty_out (vty
, " Area %s\n", oa
->name
);
379 vty_out (vty
, " Area %s[Stub, No Summary]\n", oa
->name
);
383 vty_out (vty
, " Area %s[Stub]\n", oa
->name
);
386 vty_out (vty
, " Number of Area scoped LSAs is %u\n",
389 vty_out (vty
, " Interface attached to this area:");
390 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, i
, oi
))
391 vty_out (vty
, " %s", oi
->interface
->name
);
394 if (oa
->ts_spf
.tv_sec
|| oa
->ts_spf
.tv_usec
)
396 result
= monotime_since(&oa
->ts_spf
, NULL
);
397 if (result
/TIMER_SECOND_MICRO
> 0)
399 vty_out (vty
, "SPF last executed %ld.%lds ago\n",
400 result
/TIMER_SECOND_MICRO
,
401 result
% TIMER_SECOND_MICRO
);
405 vty_out (vty
, "SPF last executed %ldus ago\n",
410 vty_out (vty
, "SPF has not been run\n");
414 #define OSPF6_CMD_AREA_GET(str, oa) \
417 u_int32_t area_id = htonl (strtoul (str, &ep, 10)); \
418 if (*ep && inet_pton (AF_INET, str, &area_id) != 1) \
420 vty_out (vty, "Malformed Area-ID: %s\n", str); \
421 return CMD_SUCCESS; \
423 int format = !*ep ? OSPF6_AREA_FMT_DECIMAL : \
424 OSPF6_AREA_FMT_DOTTEDQUAD; \
425 oa = ospf6_area_lookup (area_id, ospf6); \
427 oa = ospf6_area_create (area_id, ospf6, format); \
432 "area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]",
433 "OSPF6 area parameters\n"
434 "OSPF6 area ID in IP address format\n"
435 "OSPF6 area ID as a decimal value\n"
436 "Configured address range\n"
437 "Specify IPv6 prefix\n"
440 "User specified metric for this range\n"
441 "Advertised metric for this range\n")
444 int idx_ipv6_prefixlen
= 3;
447 struct ospf6_area
*oa
;
448 struct prefix prefix
;
449 struct ospf6_route
*range
;
450 u_int32_t cost
= OSPF_AREA_RANGE_COST_UNSPEC
;
452 OSPF6_CMD_AREA_GET (argv
[idx_ipv4
]->arg
, oa
);
454 ret
= str2prefix (argv
[idx_ipv6_prefixlen
]->arg
, &prefix
);
455 if (ret
!= 1 || prefix
.family
!= AF_INET6
)
457 vty_out (vty
, "Malformed argument: %s\n", argv
[idx_ipv6_prefixlen
]->arg
);
461 range
= ospf6_route_lookup (&prefix
, oa
->range_table
);
464 range
= ospf6_route_create ();
465 range
->type
= OSPF6_DEST_TYPE_RANGE
;
466 range
->prefix
= prefix
;
467 range
->path
.area_id
= oa
->area_id
;
468 range
->path
.cost
= OSPF_AREA_RANGE_COST_UNSPEC
;
473 if (strmatch (argv
[idx_type
]->text
, "not-advertise"))
475 SET_FLAG (range
->flag
, OSPF6_ROUTE_DO_NOT_ADVERTISE
);
477 else if (strmatch (argv
[idx_type
]->text
, "advertise"))
479 UNSET_FLAG (range
->flag
, OSPF6_ROUTE_DO_NOT_ADVERTISE
);
483 cost
= strtoul(argv
[5]->arg
, NULL
, 10);
484 UNSET_FLAG (range
->flag
, OSPF6_ROUTE_DO_NOT_ADVERTISE
);
488 range
->path
.u
.cost_config
= cost
;
490 zlog_debug ("%s: for prefix %s, flag = %x\n", __func__
, argv
[idx_ipv6_prefixlen
]->arg
, range
->flag
);
491 if (range
->rnode
== NULL
)
493 ospf6_route_add (range
, oa
->range_table
);
496 if (ospf6_is_router_abr (ospf6
))
498 /* Redo summaries if required */
499 ospf6_abr_prefix_resummarize (ospf6
);
505 DEFUN (no_area_range
,
507 "no area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]",
509 "OSPF6 area parameters\n"
510 "OSPF6 area ID in IP address format\n"
511 "OSPF6 area ID as a decimal value\n"
512 "Configured address range\n"
513 "Specify IPv6 prefix\n"
516 "User specified metric for this range\n"
517 "Advertised metric for this range\n")
522 struct ospf6_area
*oa
;
523 struct prefix prefix
;
524 struct ospf6_route
*range
, *route
;
526 OSPF6_CMD_AREA_GET (argv
[idx_ipv4
]->arg
, oa
);
528 ret
= str2prefix (argv
[idx_ipv6
]->arg
, &prefix
);
529 if (ret
!= 1 || prefix
.family
!= AF_INET6
)
531 vty_out (vty
, "Malformed argument: %s\n", argv
[idx_ipv6
]->arg
);
535 range
= ospf6_route_lookup (&prefix
, oa
->range_table
);
538 vty_out (vty
, "Range %s does not exists.\n", argv
[idx_ipv6
]->arg
);
542 if (ospf6_is_router_abr(oa
->ospf6
))
544 /* Blow away the aggregated LSA and route */
545 SET_FLAG (range
->flag
, OSPF6_ROUTE_REMOVE
);
547 /* Redo summaries if required */
548 for (route
= ospf6_route_head (ospf6
->route_table
); route
;
549 route
= ospf6_route_next (route
))
550 ospf6_abr_originate_summary(route
);
552 /* purge the old aggregated summary LSA */
553 ospf6_abr_originate_summary(range
);
555 ospf6_route_remove (range
, oa
->range_table
);
561 ospf6_area_config_write (struct vty
*vty
)
563 struct listnode
*node
;
564 struct ospf6_area
*oa
;
565 struct ospf6_route
*range
;
566 char buf
[PREFIX2STR_BUFFER
];
568 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
570 for (range
= ospf6_route_head (oa
->range_table
); range
;
571 range
= ospf6_route_next (range
))
573 prefix2str (&range
->prefix
, buf
, sizeof (buf
));
574 vty_out (vty
, " area %s range %s", oa
->name
, buf
);
576 if (CHECK_FLAG (range
->flag
, OSPF6_ROUTE_DO_NOT_ADVERTISE
))
578 vty_out (vty
, " not-advertise");
582 // "advertise" is the default so we do not display it
583 if (range
->path
.u
.cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
584 vty_out (vty
, " cost %d", range
->path
.u
.cost_config
);
589 if (IS_AREA_STUB (oa
))
592 vty_out (vty
, " area %s stub no-summary\n", oa
->name
);
594 vty_out (vty
, " area %s stub\n", oa
->name
);
596 if (PREFIX_NAME_IN (oa
))
597 vty_out (vty
, " area %s filter-list prefix %s in\n",
598 oa
->name
, PREFIX_NAME_IN (oa
));
599 if (PREFIX_NAME_OUT (oa
))
600 vty_out (vty
, " area %s filter-list prefix %s out\n",
601 oa
->name
, PREFIX_NAME_OUT (oa
));
602 if (IMPORT_NAME (oa
))
603 vty_out (vty
, " area %s import-list %s\n",
604 oa
->name
, IMPORT_NAME (oa
));
605 if (EXPORT_NAME (oa
))
606 vty_out (vty
, " area %s export-list %s\n",
607 oa
->name
, EXPORT_NAME (oa
));
611 DEFUN (area_filter_list
,
612 area_filter_list_cmd
,
613 "area A.B.C.D filter-list prefix WORD <in|out>",
614 "OSPF6 area parameters\n"
615 "OSPF6 area ID in IP address format\n"
616 "Filter networks between OSPF6 areas\n"
617 "Filter prefixes between OSPF6 areas\n"
618 "Name of an IPv6 prefix-list\n"
619 "Filter networks sent to this area\n"
620 "Filter networks sent from this area\n")
622 char *inout
= argv
[argc
- 1]->text
;
623 char *areaid
= argv
[1]->arg
;
624 char *plistname
= argv
[4]->arg
;
626 struct ospf6_area
*area
;
627 struct prefix_list
*plist
;
629 OSPF6_CMD_AREA_GET (areaid
, area
);
631 plist
= prefix_list_lookup (AFI_IP6
, plistname
);
632 if (strmatch (inout
, "in"))
634 PREFIX_LIST_IN (area
) = plist
;
635 if (PREFIX_NAME_IN (area
))
636 free (PREFIX_NAME_IN (area
));
638 PREFIX_NAME_IN (area
) = strdup (plistname
);
639 ospf6_abr_reimport (area
);
643 PREFIX_LIST_OUT (area
) = plist
;
644 if (PREFIX_NAME_OUT (area
))
645 free (PREFIX_NAME_OUT (area
));
647 PREFIX_NAME_OUT (area
) = strdup (plistname
);
648 ospf6_abr_enable_area (area
);
654 DEFUN (no_area_filter_list
,
655 no_area_filter_list_cmd
,
656 "no area A.B.C.D filter-list prefix WORD <in|out>",
658 "OSPF6 area parameters\n"
659 "OSPF6 area ID in IP address format\n"
660 "Filter networks between OSPF6 areas\n"
661 "Filter prefixes between OSPF6 areas\n"
662 "Name of an IPv6 prefix-list\n"
663 "Filter networks sent to this area\n"
664 "Filter networks sent from this area\n")
666 char *inout
= argv
[argc
- 1]->text
;
667 char *areaid
= argv
[2]->arg
;
668 char *plistname
= argv
[5]->arg
;
670 struct ospf6_area
*area
;
672 OSPF6_CMD_AREA_GET (areaid
, area
);
674 if (strmatch (inout
, "in"))
676 if (PREFIX_NAME_IN (area
))
677 if (!strmatch (PREFIX_NAME_IN (area
), plistname
))
680 PREFIX_LIST_IN (area
) = NULL
;
681 if (PREFIX_NAME_IN (area
))
682 free (PREFIX_NAME_IN (area
));
684 PREFIX_NAME_IN (area
) = NULL
;
685 ospf6_abr_reimport (area
);
689 if (PREFIX_NAME_OUT (area
))
690 if (!strmatch (PREFIX_NAME_OUT (area
), plistname
))
693 PREFIX_LIST_OUT (area
) = NULL
;
694 if (PREFIX_NAME_OUT (area
))
695 free (PREFIX_NAME_OUT (area
));
697 PREFIX_NAME_OUT (area
) = NULL
;
698 ospf6_abr_enable_area (area
);
704 DEFUN (area_import_list
,
705 area_import_list_cmd
,
706 "area A.B.C.D import-list NAME",
707 "OSPF6 area parameters\n"
708 "OSPF6 area ID in IP address format\n"
709 "Set the filter for networks from other areas announced to the specified one\n"
710 "Name of the acess-list\n")
714 struct ospf6_area
*area
;
715 struct access_list
*list
;
717 OSPF6_CMD_AREA_GET(argv
[idx_ipv4
]->arg
, area
);
719 list
= access_list_lookup (AFI_IP6
, argv
[idx_name
]->arg
);
721 IMPORT_LIST (area
) = list
;
723 if (IMPORT_NAME (area
))
724 free (IMPORT_NAME (area
));
726 IMPORT_NAME (area
) = strdup (argv
[idx_name
]->arg
);
727 ospf6_abr_reimport (area
);
732 DEFUN (no_area_import_list
,
733 no_area_import_list_cmd
,
734 "no area A.B.C.D import-list NAME",
736 "OSPF6 area parameters\n"
737 "OSPF6 area ID in IP address format\n"
738 "Unset the filter for networks announced to other areas\n"
739 "Name of the access-list\n")
742 struct ospf6_area
*area
;
744 OSPF6_CMD_AREA_GET(argv
[idx_ipv4
]->arg
, area
);
746 IMPORT_LIST (area
) = 0;
748 if (IMPORT_NAME (area
))
749 free (IMPORT_NAME (area
));
751 IMPORT_NAME (area
) = NULL
;
752 ospf6_abr_reimport (area
);
757 DEFUN (area_export_list
,
758 area_export_list_cmd
,
759 "area A.B.C.D export-list NAME",
760 "OSPF6 area parameters\n"
761 "OSPF6 area ID in IP address format\n"
762 "Set the filter for networks announced to other areas\n"
763 "Name of the acess-list\n")
767 struct ospf6_area
*area
;
768 struct access_list
*list
;
770 OSPF6_CMD_AREA_GET(argv
[idx_ipv4
]->arg
, area
);
772 list
= access_list_lookup (AFI_IP6
, argv
[idx_name
]->arg
);
774 EXPORT_LIST (area
) = list
;
776 if (EXPORT_NAME (area
))
777 free (EXPORT_NAME (area
));
779 EXPORT_NAME (area
) = strdup (argv
[idx_name
]->arg
);
780 ospf6_abr_enable_area (area
);
785 DEFUN (no_area_export_list
,
786 no_area_export_list_cmd
,
787 "no area A.B.C.D export-list NAME",
789 "OSPF6 area parameters\n"
790 "OSPF6 area ID in IP address format\n"
791 "Unset the filter for networks announced to other areas\n"
792 "Name of the access-list\n")
795 struct ospf6_area
*area
;
797 OSPF6_CMD_AREA_GET(argv
[idx_ipv4
]->arg
, area
);
799 EXPORT_LIST (area
) = 0;
801 if (EXPORT_NAME (area
))
802 free (EXPORT_NAME (area
));
804 EXPORT_NAME (area
) = NULL
;
805 ospf6_abr_enable_area (area
);
810 DEFUN (show_ipv6_ospf6_spf_tree
,
811 show_ipv6_ospf6_spf_tree_cmd
,
812 "show ipv6 ospf6 spf tree",
816 "Shortest Path First caculation\n"
819 struct listnode
*node
;
820 struct ospf6_area
*oa
;
821 struct ospf6_vertex
*root
;
822 struct ospf6_route
*route
;
823 struct prefix prefix
;
825 OSPF6_CMD_CHECK_RUNNING ();
827 ospf6_linkstate_prefix (ospf6
->router_id
, htonl (0), &prefix
);
829 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
831 route
= ospf6_route_lookup (&prefix
, oa
->spf_table
);
834 vty_out (vty
, "LS entry for root not found in area %s\n",
838 root
= (struct ospf6_vertex
*) route
->route_option
;
839 ospf6_spf_display_subtree (vty
, "", 0, root
);
845 DEFUN (show_ipv6_ospf6_area_spf_tree
,
846 show_ipv6_ospf6_area_spf_tree_cmd
,
847 "show ipv6 ospf6 area A.B.C.D spf tree",
853 "Shortest Path First caculation\n"
858 struct ospf6_area
*oa
;
859 struct ospf6_vertex
*root
;
860 struct ospf6_route
*route
;
861 struct prefix prefix
;
863 OSPF6_CMD_CHECK_RUNNING ();
865 ospf6_linkstate_prefix (ospf6
->router_id
, htonl (0), &prefix
);
867 if (inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1)
869 vty_out (vty
, "Malformed Area-ID: %s\n", argv
[idx_ipv4
]->arg
);
872 oa
= ospf6_area_lookup (area_id
, ospf6
);
875 vty_out (vty
, "No such Area: %s\n", argv
[idx_ipv4
]->arg
);
879 route
= ospf6_route_lookup (&prefix
, oa
->spf_table
);
882 vty_out (vty
, "LS entry for root not found in area %s\n",
886 root
= (struct ospf6_vertex
*) route
->route_option
;
887 ospf6_spf_display_subtree (vty
, "", 0, root
);
892 DEFUN (show_ipv6_ospf6_simulate_spf_tree_root
,
893 show_ipv6_ospf6_simulate_spf_tree_root_cmd
,
894 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
898 "Shortest Path First calculation\n"
900 "Specify root's router-id to calculate another router's SPF tree\n"
901 "OSPF6 area parameters\n"
907 struct ospf6_area
*oa
;
908 struct ospf6_vertex
*root
;
909 struct ospf6_route
*route
;
910 struct prefix prefix
;
912 struct ospf6_route_table
*spf_table
;
913 unsigned char tmp_debug_ospf6_spf
= 0;
915 OSPF6_CMD_CHECK_RUNNING ();
917 inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
);
918 ospf6_linkstate_prefix (router_id
, htonl (0), &prefix
);
920 if (inet_pton (AF_INET
, argv
[idx_ipv4_2
]->arg
, &area_id
) != 1)
922 vty_out (vty
, "Malformed Area-ID: %s\n", argv
[idx_ipv4_2
]->arg
);
925 oa
= ospf6_area_lookup (area_id
, ospf6
);
928 vty_out (vty
, "No such Area: %s\n", argv
[idx_ipv4_2
]->arg
);
932 tmp_debug_ospf6_spf
= conf_debug_ospf6_spf
;
933 conf_debug_ospf6_spf
= 0;
935 spf_table
= OSPF6_ROUTE_TABLE_CREATE (NONE
, SPF_RESULTS
);
936 ospf6_spf_calculation (router_id
, spf_table
, oa
);
938 conf_debug_ospf6_spf
= tmp_debug_ospf6_spf
;
940 route
= ospf6_route_lookup (&prefix
, spf_table
);
943 ospf6_spf_table_finish (spf_table
);
944 ospf6_route_table_delete (spf_table
);
947 root
= (struct ospf6_vertex
*) route
->route_option
;
948 ospf6_spf_display_subtree (vty
, "", 0, root
);
950 ospf6_spf_table_finish (spf_table
);
951 ospf6_route_table_delete (spf_table
);
956 DEFUN (ospf6_area_stub
,
958 "area <A.B.C.D|(0-4294967295)> stub",
959 "OSPF6 area parameters\n"
960 "OSPF6 area ID in IP address format\n"
961 "OSPF6 area ID as a decimal value\n"
962 "Configure OSPF6 area as stub\n")
964 int idx_ipv4_number
= 1;
965 struct ospf6_area
*area
;
967 OSPF6_CMD_AREA_GET(argv
[idx_ipv4_number
]->arg
, area
);
969 if (!ospf6_area_stub_set (ospf6
, area
))
971 vty_out (vty
,"First deconfigure all virtual link through this area\n");
972 return CMD_WARNING_CONFIG_FAILED
;
975 ospf6_area_no_summary_unset (ospf6
, area
);
980 DEFUN (ospf6_area_stub_no_summary
,
981 ospf6_area_stub_no_summary_cmd
,
982 "area <A.B.C.D|(0-4294967295)> stub no-summary",
983 "OSPF6 stub parameters\n"
984 "OSPF6 area ID in IP address format\n"
985 "OSPF6 area ID as a decimal value\n"
986 "Configure OSPF6 area as stub\n"
987 "Do not inject inter-area routes into stub\n")
989 int idx_ipv4_number
= 1;
990 struct ospf6_area
*area
;
992 OSPF6_CMD_AREA_GET(argv
[idx_ipv4_number
]->arg
, area
);
994 if (!ospf6_area_stub_set (ospf6
, area
))
996 vty_out (vty
,"First deconfigure all virtual link through this area\n");
997 return CMD_WARNING_CONFIG_FAILED
;
1000 ospf6_area_no_summary_set (ospf6
, area
);
1005 DEFUN (no_ospf6_area_stub
,
1006 no_ospf6_area_stub_cmd
,
1007 "no area <A.B.C.D|(0-4294967295)> stub",
1009 "OSPF6 area parameters\n"
1010 "OSPF6 area ID in IP address format\n"
1011 "OSPF6 area ID as a decimal value\n"
1012 "Configure OSPF6 area as stub\n")
1014 int idx_ipv4_number
= 2;
1015 struct ospf6_area
*area
;
1017 OSPF6_CMD_AREA_GET(argv
[idx_ipv4_number
]->arg
, area
);
1019 ospf6_area_stub_unset (ospf6
, area
);
1020 ospf6_area_no_summary_unset (ospf6
, area
);
1025 DEFUN (no_ospf6_area_stub_no_summary
,
1026 no_ospf6_area_stub_no_summary_cmd
,
1027 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1029 "OSPF6 area parameters\n"
1030 "OSPF6 area ID in IP address format\n"
1031 "OSPF6 area ID as a decimal value\n"
1032 "Configure OSPF6 area as stub\n"
1033 "Do not inject inter-area routes into area\n")
1035 int idx_ipv4_number
= 2;
1036 struct ospf6_area
*area
;
1038 OSPF6_CMD_AREA_GET(argv
[idx_ipv4_number
]->arg
, area
);
1040 ospf6_area_stub_unset (ospf6
, area
);
1041 ospf6_area_no_summary_unset (ospf6
, area
);
1047 ospf6_area_init (void)
1049 install_element (VIEW_NODE
, &show_ipv6_ospf6_spf_tree_cmd
);
1050 install_element (VIEW_NODE
, &show_ipv6_ospf6_area_spf_tree_cmd
);
1051 install_element (VIEW_NODE
, &show_ipv6_ospf6_simulate_spf_tree_root_cmd
);
1053 install_element (OSPF6_NODE
, &area_range_cmd
);
1054 install_element (OSPF6_NODE
, &no_area_range_cmd
);
1055 install_element (OSPF6_NODE
, &ospf6_area_stub_no_summary_cmd
);
1056 install_element (OSPF6_NODE
, &ospf6_area_stub_cmd
);
1057 install_element (OSPF6_NODE
, &no_ospf6_area_stub_no_summary_cmd
);
1058 install_element (OSPF6_NODE
, &no_ospf6_area_stub_cmd
);
1061 install_element (OSPF6_NODE
, &area_import_list_cmd
);
1062 install_element (OSPF6_NODE
, &no_area_import_list_cmd
);
1063 install_element (OSPF6_NODE
, &area_export_list_cmd
);
1064 install_element (OSPF6_NODE
, &no_area_export_list_cmd
);
1066 install_element (OSPF6_NODE
, &area_filter_list_cmd
);
1067 install_element (OSPF6_NODE
, &no_area_filter_list_cmd
);