diff options
Diffstat (limited to 'ospf6d')
-rw-r--r-- | ospf6d/ChangeLog | 11 | ||||
-rw-r--r-- | ospf6d/ospf6_abr.c | 5 | ||||
-rw-r--r-- | ospf6d/ospf6_area.c | 440 | ||||
-rw-r--r-- | ospf6d/ospf6_neighbor.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_route.c | 485 | ||||
-rw-r--r-- | ospf6d/ospf6_route.h | 8 | ||||
-rw-r--r-- | ospf6d/ospf6_top.c | 50 | ||||
-rw-r--r-- | ospf6d/ospf6d.c | 90 | ||||
-rw-r--r-- | ospf6d/ospf6d.h | 2 |
9 files changed, 429 insertions, 664 deletions
diff --git a/ospf6d/ChangeLog b/ospf6d/ChangeLog index 7e61215e..cdfd207a 100644 --- a/ospf6d/ChangeLog +++ b/ospf6d/ChangeLog @@ -1,3 +1,14 @@ +2004-09-03 Yasuhiro Ohara <yasu@sfc.wide.ad.jp> + + * ospf6_area.c, ospf6_route.c, ospf6_top.c, ospf6d.c: + "show intra-route" function and "show SPF result" function is + changed. + * ospf6_neighbor.c: Changed to update stub intra-prefix origination + when it is not DR. + * ospf6_route.h: resolv conflict between best flag and + active-summary flag. + * ospf6d.h: version 0.9.7m + 2004-09-02 Yasuhiro Ohara <yasu@sfc.wide.ad.jp> * ospf6_asbr.c: E-bit check in examining AS-External-LSA diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 58015ff3..81992b26 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -87,7 +87,10 @@ ospf6_abr_enable_area (struct ospf6_area *area) { for (ro = ospf6_route_head (oa->range_table); ro; ro = ospf6_route_next (ro)) - ospf6_abr_originate_summary_to_area (ro, area); + { + if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) + ospf6_abr_originate_summary_to_area (ro, area); + } } } diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 78d70a2b..de28cb9b 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -428,211 +428,6 @@ ospf6_area_config_write (struct vty *vty) } } -DEFUN (show_ipv6_ospf6_area_route_intra, - show_ipv6_ospf6_area_route_intra_cmd, - "show ipv6 ospf6 area A.B.C.D route intra-area", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - ROUTE_STR - "Display Intra-Area routes\n" - ) -{ - struct ospf6_area *oa; - OSPF6_CMD_AREA_LOOKUP (argv[0], oa); - argc--; - argv++; - return ospf6_route_table_show (vty, argc, argv, oa->route_table); -} - -ALIAS (show_ipv6_ospf6_area_route_intra, - show_ipv6_ospf6_area_route_intra_detail_cmd, - "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Specify IPv6 address\n" - "Specify IPv6 prefix\n" - "Detailed information\n" - ); - -DEFUN (show_ipv6_ospf6_area_route_intra_match, - show_ipv6_ospf6_area_route_intra_match_cmd, - "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Specify IPv6 prefix\n" - "Display routes which match the specified route\n" - ) -{ - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - struct ospf6_area *oa; - - OSPF6_CMD_AREA_LOOKUP (argv[0], oa); - argc--; - argv++; - - /* copy argv to sargv and then append "match" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc] = NULL; - - return ospf6_route_table_show (vty, sargc, sargv, oa->route_table); -} - -DEFUN (show_ipv6_ospf6_area_route_intra_match_detail, - show_ipv6_ospf6_area_route_intra_match_detail_cmd, - "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Specify IPv6 prefix\n" - "Display routes which match the specified route\n" - "Detailed information\n" - ) -{ - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - struct ospf6_area *oa; - - OSPF6_CMD_AREA_LOOKUP (argv[0], oa); - argc--; - argv++; - - /* copy argv to sargv and then append "match" and "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - - return ospf6_route_table_show (vty, sargc, sargv, oa->route_table); -} - -DEFUN (show_ipv6_ospf6_route_intra, - show_ipv6_ospf6_route_intra_cmd, - "show ipv6 ospf6 route intra-area", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - ) -{ - listnode node; - struct ospf6_area *oa; - - for (node = listhead (ospf6->area_list); node; nextnode (node)) - { - oa = (struct ospf6_area *) getdata (node); - vty_out (vty, "Area %s%s", oa->name, VNL); - ospf6_route_table_show (vty, argc, argv, oa->route_table); - } - - return CMD_SUCCESS; -} - -ALIAS (show_ipv6_ospf6_route_intra, - show_ipv6_ospf6_route_intra_detail_cmd, - "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Specify IPv6 address\n" - "Specify IPv6 prefix\n" - "Detailed information\n" - "Summary of route table\n" - ); - -DEFUN (show_ipv6_ospf6_route_intra_match, - show_ipv6_ospf6_route_intra_match_cmd, - "show ipv6 ospf6 route intra-area X::X/M match", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Specify IPv6 prefix\n" - "Display routes which match the specified route\n" - ) -{ - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - listnode node; - struct ospf6_area *oa; - - /* copy argv to sargv and then append "match" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc] = NULL; - - for (node = listhead (ospf6->area_list); node; nextnode (node)) - { - oa = (struct ospf6_area *) getdata (node); - ospf6_route_table_show (vty, sargc, sargv, oa->route_table); - } - - return CMD_SUCCESS; -} - -DEFUN (show_ipv6_ospf6_route_intra_match_detail, - show_ipv6_ospf6_route_intra_match_detail_cmd, - "show ipv6 ospf6 route intra-area X::X/M match detail", - SHOW_STR - IP6_STR - OSPF6_STR - ROUTE_STR - "Display Intra-Area routes\n" - "Specify IPv6 prefix\n" - "Display routes which match the specified route\n" - "Detailed information\n" - ) -{ - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - listnode node; - struct ospf6_area *oa; - - /* copy argv to sargv and then append "match" and "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "match"; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - - for (node = listhead (ospf6->area_list); node; nextnode (node)) - { - oa = (struct ospf6_area *) getdata (node); - ospf6_route_table_show (vty, sargc, sargv, oa->route_table); - } - - return CMD_SUCCESS; -} - DEFUN (show_ipv6_ospf6_spf_tree, show_ipv6_ospf6_spf_tree_cmd, "show ipv6 ospf6 spf tree", @@ -710,205 +505,6 @@ DEFUN (show_ipv6_ospf6_area_spf_tree, return CMD_SUCCESS; } -DEFUN (show_ipv6_ospf6_area_spf_table, - show_ipv6_ospf6_area_spf_table_cmd, - "show ipv6 ospf6 area A.B.C.D spf table", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - ) -{ - u_int32_t area_id; - struct ospf6_area *oa; - - if (inet_pton (AF_INET, argv[0], &area_id) != 1) - { - vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); - return CMD_SUCCESS; - } - oa = ospf6_area_lookup (area_id, ospf6); - if (oa == NULL) - { - vty_out (vty, "No such Area: %s%s", argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table); - return CMD_SUCCESS; -} - -ALIAS (show_ipv6_ospf6_area_spf_table, - show_ipv6_ospf6_area_spf_table_1_cmd, - "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Display multiple entry by specifying match-prefix of Router-ID\n" - "Display Detail\n" - ); - -ALIAS (show_ipv6_ospf6_area_spf_table, - show_ipv6_ospf6_area_spf_table_2_cmd, - "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Wildcard Router-ID\n" - "Specify Link State ID\n" - "Display multiple entry by specifying match-prefix of Link State ID\n" - "Display Detail\n" - ); - -DEFUN (show_ipv6_ospf6_area_spf_table_3, - show_ipv6_ospf6_area_spf_table_3_cmd, - "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail", - SHOW_STR - IP6_STR - OSPF6_STR - OSPF6_AREA_STR - OSPF6_AREA_ID_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Wildcard Router-ID\n" - "Display multiple entry by specifying match-prefix of Link State ID\n" - "Display Detail\n" - ) -{ - u_int32_t area_id; - struct ospf6_area *oa; - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - - if (inet_pton (AF_INET, argv[0], &area_id) != 1) - { - vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); - return CMD_SUCCESS; - } - oa = ospf6_area_lookup (area_id, ospf6); - if (oa == NULL) - { - vty_out (vty, "No such Area: %s%s", argv[0], VNL); - return CMD_SUCCESS; - } - - argc--; - argv++; - - /* copy argv to sargv and then append "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - - ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table); - return CMD_SUCCESS; -} - -DEFUN (show_ipv6_ospf6_spf_table, - show_ipv6_ospf6_spf_table_cmd, - "show ipv6 ospf6 spf table", - SHOW_STR - IP6_STR - OSPF6_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - ) -{ - listnode node; - struct ospf6_area *oa; - - for (node = listhead (ospf6->area_list); node; nextnode (node)) - { - oa = (struct ospf6_area *) getdata (node); - ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table); - } - - return CMD_SUCCESS; -} - -ALIAS (show_ipv6_ospf6_spf_table, - show_ipv6_ospf6_spf_table_1_cmd, - "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Display multiple entry by specifying match-prefix of Router-ID\n" - "Display Detail\n" - ); - -ALIAS (show_ipv6_ospf6_spf_table, - show_ipv6_ospf6_spf_table_2_cmd, - "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)", - SHOW_STR - IP6_STR - OSPF6_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Display multiple entry by specifying match-prefix of Router-ID\n" - "Wildcard Router-ID\n" - "Specify Link State ID\n" - "Display multiple entry by specifying match-prefix of Link State ID\n" - "Display Detail\n" - ); - -DEFUN (show_ipv6_ospf6_spf_table_3, - show_ipv6_ospf6_spf_table_3_cmd, - "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail", - SHOW_STR - IP6_STR - OSPF6_STR - "Shortest Path First caculation\n" - "Show table contains SPF result\n" - "Specify Router-ID\n" - "Wildcard Router-ID\n" - "Display multiple entry by specifying match-prefix of Link State ID\n" - "Display Detail\n" - ) -{ - listnode node; - struct ospf6_area *oa; - char *sargv[CMD_ARGC_MAX]; - int i, sargc; - - /* copy argv to sargv and then append "detail" */ - for (i = 0; i < argc; i++) - sargv[i] = argv[i]; - sargc = argc; - sargv[sargc++] = "detail"; - sargv[sargc] = NULL; - - for (node = listhead (ospf6->area_list); node; nextnode (node)) - { - oa = (struct ospf6_area *) getdata (node); - ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table); - } - - return CMD_SUCCESS; -} - DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, show_ipv6_ospf6_simulate_spf_tree_root_cmd, "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D", @@ -971,47 +567,11 @@ void ospf6_area_init () { install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd); - - install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd); - install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd); - - install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd); - install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); install_element (OSPF6_NODE, &area_range_cmd); diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 402ca622..ad4261fc 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -173,8 +173,8 @@ ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on) { OSPF6_NETWORK_LSA_SCHEDULE (on->ospf6_if); OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (on->ospf6_if); - OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area); } + OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (on->ospf6_if->area); } #ifdef XXX diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 3ca21a31..b054c7b4 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -51,25 +51,29 @@ void ospf6_linkstate_prefix2str (struct prefix *prefix, char *buf, int size) { u_int32_t adv_router, id; - char adv_router_str[16]; + char adv_router_str[16], id_str[16]; memcpy (&adv_router, &prefix->u.prefix6.s6_addr[0], 4); memcpy (&id, &prefix->u.prefix6.s6_addr[4], 4); inet_ntop (AF_INET, &adv_router, adv_router_str, sizeof (adv_router_str)); - snprintf (buf, size, "%s(%lu)", adv_router_str, (u_long) ntohl (id)); + inet_ntop (AF_INET, &id, id_str, sizeof (id_str)); + if (ntohl (id)) + snprintf (buf, size, "%s Net-ID: %s", adv_router_str, id_str); + else + snprintf (buf, size, "%s", adv_router_str); } /* Global strings for logging */ char *ospf6_dest_type_str[OSPF6_DEST_TYPE_MAX] = -{ "Unknown", "Router", "Network", "Discard", "Linkstate", }; +{ "Unknown", "Router", "Network", "Discard", "Linkstate", "AddressRange", }; char *ospf6_dest_type_substr[OSPF6_DEST_TYPE_MAX] = -{ "?", "R", "N", "D", "L", }; +{ "?", "R", "N", "D", "L", "A", }; char *ospf6_path_type_str[OSPF6_PATH_TYPE_MAX] = { "Unknown", "Intra-Area", "Inter-Area", "External-1", "External-2", }; char *ospf6_path_type_substr[OSPF6_PATH_TYPE_MAX] = -{ "??", "Ia", "Ie", "E1", "E2", }; +{ "??", "IA", "IE", "E1", "E2", }; struct ospf6_route * @@ -763,8 +767,7 @@ ospf6_route_show_table_summary (struct vty *vty, int i, pathtype[OSPF6_PATH_TYPE_MAX]; int number = 0; int nhinval = 0, ecmp = 0; - int multipath = 0, destination = 0; - int desttype = 0, desttype_mismatch = 0; + int alternative = 0, destination = 0; for (i = 0; i < OSPF6_PATH_TYPE_MAX; i++) pathtype[i] = 0; @@ -772,48 +775,131 @@ ospf6_route_show_table_summary (struct vty *vty, for (route = ospf6_route_head (table); route; route = ospf6_route_next (route)) { - if (desttype == 0) - desttype = route->type; - else if (desttype != route->type) - desttype_mismatch++; - if (prev == NULL || ! ospf6_route_is_same (prev, route)) destination++; else - multipath++; - + alternative++; if (! ospf6_nexthop_is_set (&route->nexthop[0])) nhinval++; else if (ospf6_nexthop_is_set (&route->nexthop[1])) ecmp++; - - if (prev == NULL || ! ospf6_route_is_same (prev, route)) - pathtype[route->path.type]++; - + pathtype[route->path.type]++; number++; + prev = route; } assert (number == table->count); - vty_out (vty, "Number of Destination: %d (%d routes)%s", - destination, number, VNL); - if (multipath) - vty_out (vty, " Number of Multi-path: %d%s", multipath, VNL); - if (desttype_mismatch) - vty_out (vty, " Number of Different Dest-type: %d%s", - desttype_mismatch, VNL); - if (ecmp) - vty_out (vty, " Number of Equal Cost Multi Path: %d%s", - ecmp, VNL); - if (ecmp) - vty_out (vty, " Number of Invalid Nexthop: %d%s", - nhinval, VNL); - for (i = 0; i < OSPF6_PATH_TYPE_MAX; i++) + vty_out (vty, "Number of OSPFv3 routes: %d%s", number, VNL); + vty_out (vty, "Number of Destination: %d%s", destination, VNL); + vty_out (vty, "Number of Alternative routes: %d%s", alternative, VNL); + vty_out (vty, "Number of Equal Cost Multi Path: %d%s", ecmp, VNL); + for (i = OSPF6_PATH_TYPE_INTRA; i <= OSPF6_PATH_TYPE_EXTERNAL2; i++) + { + vty_out (vty, "Number of %s routes: %d%s", + OSPF6_PATH_TYPE_NAME (i), pathtype[i], VNL); + } +} + +void +ospf6_route_show_table_prefix (struct vty *vty, + struct prefix *prefix, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + route = ospf6_route_lookup (prefix, table); + if (route == NULL) + return; + + ospf6_route_lock (route); + while (route && ospf6_route_is_prefix (prefix, route)) + { + /* Specifying a prefix will always display details */ + ospf6_route_show_detail (vty, route); + route = ospf6_route_next (route); + } + if (route) + ospf6_route_unlock (route); +} + +void +ospf6_route_show_table_address (struct vty *vty, + struct prefix *prefix, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + route = ospf6_route_lookup_bestmatch (prefix, table); + if (route == NULL) + return; + + prefix = &route->prefix; + ospf6_route_lock (route); + while (route && ospf6_route_is_prefix (prefix, route)) + { + /* Specifying a prefix will always display details */ + ospf6_route_show_detail (vty, route); + route = ospf6_route_next (route); + } + if (route) + ospf6_route_unlock (route); +} + +void +ospf6_route_show_table_match (struct vty *vty, int detail, + struct prefix *prefix, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + assert (prefix->family); + + route = ospf6_route_match_head (prefix, table); + while (route) + { + if (detail) + ospf6_route_show_detail (vty, route); + else + ospf6_route_show (vty, route); + route = ospf6_route_match_next (prefix, route); + } +} + +void +ospf6_route_show_table_type (struct vty *vty, int detail, u_char type, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + route = ospf6_route_head (table); + while (route) + { + if (route->path.type == type) + { + if (detail) + ospf6_route_show_detail (vty, route); + else + ospf6_route_show (vty, route); + } + route = ospf6_route_next (route); + } +} + +void +ospf6_route_show_table (struct vty *vty, int detail, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + route = ospf6_route_head (table); + while (route) { - if (pathtype[i]) - vty_out (vty, " Number of %s routes: %d%s", - OSPF6_PATH_TYPE_NAME (i), pathtype[i], VNL); + if (detail) + ospf6_route_show_detail (vty, route); + else + ospf6_route_show (vty, route); + route = ospf6_route_next (route); } } @@ -821,269 +907,240 @@ int ospf6_route_table_show (struct vty *vty, int argc, char **argv, struct ospf6_route_table *table) { - unsigned char flag = 0; -#define MATCH 0x01 -#define DETAIL 0x02 -#define PREFIX 0x04 -#define SUMMARY 0x08 + int summary = 0; + int match = 0; + int detail = 0; + int slash = 0; + int isprefix = 0; int i, ret; - struct prefix prefix, *p; - struct ospf6_route *route; + struct prefix prefix; + u_char type = 0; memset (&prefix, 0, sizeof (struct prefix)); for (i = 0; i < argc; i++) { - /* set "detail" */ if (! strcmp (argv[i], "summary")) { - SET_FLAG (flag, SUMMARY); + summary++; continue; } - /* set "detail" */ - if (! strcmp (argv[i], "detail")) + if (! strcmp (argv[i], "intra-area")) { - SET_FLAG (flag, DETAIL); + type = OSPF6_PATH_TYPE_INTRA; continue; } - /* set "match" */ - if (! strcmp (argv[i], "match")) + if (! strcmp (argv[i], "inter-area")) { - SET_FLAG (flag, MATCH); + type = OSPF6_PATH_TYPE_INTER; continue; } - if (prefix.family) + if (! strcmp (argv[i], "external-1")) { - vty_out (vty, "Invalid argument: %s%s", argv[i], VNL); - return CMD_SUCCESS; + type = OSPF6_PATH_TYPE_EXTERNAL1; + continue; + } + + if (! strcmp (argv[i], "external-2")) + { + type = OSPF6_PATH_TYPE_EXTERNAL2; + continue; + } + + if (! strcmp (argv[i], "detail")) + { + detail++; + continue; + } + + if (! strcmp (argv[i], "match")) + { + match++; + continue; } ret = str2prefix (argv[i], &prefix); - if (ret != 1 || prefix.family != AF_INET6) + if (ret == 1 && prefix.family == AF_INET6) { - vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); - return CMD_SUCCESS; + isprefix++; + if (strchr (argv[i], '/')) + slash++; + continue; } - if (strchr (argv[i], '/')) - SET_FLAG (flag, PREFIX); + vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + return CMD_SUCCESS; } /* Give summary of this route table */ - if (CHECK_FLAG (flag, SUMMARY)) + if (summary) { ospf6_route_show_table_summary (vty, table); return CMD_SUCCESS; } /* Give exact prefix-match route */ - if (prefix.family && ! CHECK_FLAG (flag, MATCH)) + if (isprefix && ! match) { /* If exact address, give best matching route */ - if (! CHECK_FLAG (flag, PREFIX)) - route = ospf6_route_lookup_bestmatch (&prefix, table); + if (! slash) + ospf6_route_show_table_address (vty, &prefix, table); else - route = ospf6_route_lookup (&prefix, table); + ospf6_route_show_table_prefix (vty, &prefix, table); - if (route) - { - ospf6_route_lock (route); - p = &route->prefix; - } + return CMD_SUCCESS; + } - while (route && ospf6_route_is_prefix (p, route)) - { - /* Seaching an entry will always display details */ - if (route) - ospf6_route_show_detail (vty, route); + if (match) + ospf6_route_show_table_match (vty, detail, &prefix, table); + else if (type) + ospf6_route_show_table_type (vty, detail, type, table); + else + ospf6_route_show_table (vty, detail, table); - route = ospf6_route_next (route); - } + return CMD_SUCCESS; +} - return CMD_SUCCESS; - } +void +ospf6_linkstate_show_header (struct vty *vty) +{ + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %s%s", + "Type", "Router-ID", "Net-ID", "Rtr-Bits", "Options", "Cost", VNL); +} + +void +ospf6_linkstate_show (struct vty *vty, struct ospf6_route *route) +{ + u_int32_t router, id; + char routername[16], idname[16], rbits[16], options[16]; + + router = ospf6_linkstate_prefix_adv_router (&route->prefix); + inet_ntop (AF_INET, &router, routername, sizeof (routername)); + id = ospf6_linkstate_prefix_id (&route->prefix); + inet_ntop (AF_INET, &id, idname, sizeof (idname)); + + ospf6_capability_printbuf (route->path.router_bits, rbits, sizeof (rbits)); + ospf6_options_printbuf (route->path.options, options, sizeof (options)); - if (prefix.family == 0) - route = ospf6_route_head (table); + if (ntohl (id)) + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", + "Network", routername, idname, rbits, options, + (unsigned long) route->path.cost, VNL); else - route = ospf6_route_match_head (&prefix, table); + vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", + "Router", routername, idname, rbits, options, + (unsigned long) route->path.cost, VNL); +} + + +void +ospf6_linkstate_show_table_exact (struct vty *vty, + struct prefix *prefix, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + route = ospf6_route_lookup (prefix, table); + if (route == NULL) + return; + + ospf6_route_lock (route); + while (route && ospf6_route_is_prefix (prefix, route)) + { + /* Specifying a prefix will always display details */ + ospf6_route_show_detail (vty, route); + route = ospf6_route_next (route); + } + if (route) + ospf6_route_unlock (route); +} + +void +ospf6_linkstate_show_table (struct vty *vty, int detail, + struct ospf6_route_table *table) +{ + struct ospf6_route *route; + + if (! detail) + ospf6_linkstate_show_header (vty); + route = ospf6_route_head (table); while (route) { - if (CHECK_FLAG (flag, DETAIL)) + if (detail) ospf6_route_show_detail (vty, route); else - ospf6_route_show (vty, route); - - if (prefix.family == 0) - route = ospf6_route_next (route); - else - route = ospf6_route_match_next (&prefix, route); + ospf6_linkstate_show (vty, route); + route = ospf6_route_next (route); } - - return CMD_SUCCESS; } - int -ospf6_lsentry_table_show (struct vty *vty, int argc, char **argv, - struct ospf6_route_table *table) +ospf6_linkstate_table_show (struct vty *vty, int argc, char **argv, + struct ospf6_route_table *table) { - unsigned char flag = 0; -#define MATCH 0x01 -#define DETAIL 0x02 + int detail = 0; + int is_id = 0; + int is_router = 0; int i, ret; - struct prefix adv_router, id, prefix; - struct ospf6_route *route; + struct prefix router, id, prefix; - memset (&adv_router, 0, sizeof (struct prefix)); + memset (&router, 0, sizeof (struct prefix)); memset (&id, 0, sizeof (struct prefix)); + memset (&prefix, 0, sizeof (struct prefix)); for (i = 0; i < argc; i++) { - /* set "detail" */ if (! strcmp (argv[i], "detail")) { - SET_FLAG (flag, DETAIL); + detail++; continue; } - /* set "match" */ - if (! strcmp (argv[i], "match")) + if (! is_router) { - SET_FLAG (flag, MATCH); - continue; - } - - if (adv_router.family && id.family) - { - vty_out (vty, "Invalid argument: %s%s", argv[i], VNL); - return CMD_SUCCESS; - } - - if (adv_router.family == 0) - { - ret = str2prefix (argv[i], &adv_router); - if (ret != 1) - { - if (! strcmp (argv[i], "*")) - { - adv_router.family = AF_INET; - adv_router.prefixlen = 0; - ret = 1; - } - } - if (ret != 1) + ret = str2prefix (argv[i], &router); + if (ret == 1 && router.family == AF_INET) { - vty_out (vty, "Invalid Router-ID: %s%s", argv[i], VNL); - return CMD_SUCCESS; + is_router++; + continue; } + vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); + return CMD_SUCCESS; } - else if (id.family == 0) - { - unsigned long val; - char *endptr; + if (! is_id) + { ret = str2prefix (argv[i], &id); - if (ret != 1) - { - val = strtoul (argv[i], &endptr, 0); - if (val != ULONG_MAX && *endptr == '\0') - { - id.u.prefix4.s_addr = val; - ret = 1; - } - } - - if (ret != 1) + if (ret == 1 && id.family == AF_INET) { - vty_out (vty, "Invalid Link state ID: %s%s", argv[i], - VNL); - return CMD_WARNING; + is_id++; + continue; } - } - } - - /* Encode to linkstate prefix */ - if (adv_router.family) - { - if (adv_router.prefixlen == 0 && - id.family && id.prefixlen != IPV4_MAX_BITLEN) - { - vty_out (vty, "Specifying Link State ID by prefix is not allowed%s" - "when specifying Router-ID as wildcard%s", - VNL, VNL); - return CMD_SUCCESS; - } - else if (adv_router.prefixlen != 0 && - adv_router.prefixlen != IPV4_MAX_BITLEN && id.family) - { - vty_out (vty, "Specifying Link State ID is not allowed%s" - "when specifying Router-ID by prefix%s", - VNL, VNL); + vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } - if (adv_router.prefixlen == 0) - ospf6_linkstate_prefix (0, id.u.prefix4.s_addr, &prefix); - else if (adv_router.prefixlen != IPV4_MAX_BITLEN) - { - ospf6_linkstate_prefix (adv_router.u.prefix4.s_addr, 0, &prefix); - prefix.prefixlen = adv_router.prefixlen; - SET_FLAG (flag, MATCH); - } - else - { - ospf6_linkstate_prefix (adv_router.u.prefix4.s_addr, - id.u.prefix4.s_addr, &prefix); - prefix.prefixlen = adv_router.prefixlen + id.prefixlen; - if (prefix.prefixlen != 64) - SET_FLAG (flag, MATCH); - } - } - - /* give exact match entry */ - if (adv_router.family && adv_router.prefixlen == IPV4_MAX_BITLEN && - id.family && id.prefixlen == IPV4_MAX_BITLEN) - { - route = ospf6_route_lookup (&prefix, table); - if (route) - ospf6_route_show_detail (vty, route); + vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } - if (CHECK_FLAG (flag, MATCH)) - route = ospf6_route_match_head (&prefix, table); - else - route = ospf6_route_head (table); + if (is_router) + ospf6_linkstate_prefix (router.u.prefix4.s_addr, + id.u.prefix4.s_addr, &prefix); - while (route) - { - if (! adv_router.family || - (CHECK_FLAG (flag, MATCH) && - prefix_match (&prefix, &route->prefix)) || - (adv_router.prefixlen == 0 && id.family && - ospf6_linkstate_prefix_id (&prefix) == - ospf6_linkstate_prefix_id (&route->prefix))) - { - if (CHECK_FLAG (flag, DETAIL)) - ospf6_route_show_detail (vty, route); - else - ospf6_route_show (vty, route); - } - - if (CHECK_FLAG (flag, MATCH)) - route = ospf6_route_match_next (&prefix, route); - else - route = ospf6_route_next (route); - } + if (prefix.family) + ospf6_linkstate_show_table_exact (vty, &prefix, table); + else + ospf6_linkstate_show_table (vty, detail, table); return CMD_SUCCESS; } + void ospf6_brouter_show_header (struct vty *vty) { diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h index 3d3e1014..5835794e 100644 --- a/ospf6d/ospf6_route.h +++ b/ospf6d/ospf6_route.h @@ -156,8 +156,8 @@ struct ospf6_route #define OSPF6_ROUTE_ADD 0x02 #define OSPF6_ROUTE_REMOVE 0x04 #define OSPF6_ROUTE_BEST 0x08 -#define OSPF6_ROUTE_ACTIVE_SUMMARY 0x08 -#define OSPF6_ROUTE_DO_NOT_ADVERTISE 0x10 +#define OSPF6_ROUTE_ACTIVE_SUMMARY 0x10 +#define OSPF6_ROUTE_DO_NOT_ADVERTISE 0x20 struct ospf6_route_table { @@ -267,8 +267,8 @@ void ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route); int ospf6_route_table_show (struct vty *, int, char **, struct ospf6_route_table *); -int ospf6_lsentry_table_show (struct vty *, int, char **, - struct ospf6_route_table *); +int ospf6_linkstate_table_show (struct vty *vty, int argc, char **argv, + struct ospf6_route_table *table); void ospf6_brouter_show_header (struct vty *vty); void ospf6_brouter_show (struct vty *vty, struct ospf6_route *route); diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 5ab208b4..cc4356cb 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -499,7 +499,7 @@ DEFUN (show_ipv6_ospf6_route, ALIAS (show_ipv6_ospf6_route, show_ipv6_ospf6_route_detail_cmd, - "show ipv6 ospf6 route (X::X|X::X/M|detail|summary)", + "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)", SHOW_STR IP6_STR OSPF6_STR @@ -512,7 +512,7 @@ ALIAS (show_ipv6_ospf6_route, DEFUN (show_ipv6_ospf6_route_match, show_ipv6_ospf6_route_match_cmd, - "show ipv6 ospf6 route X::X/M match", + "show ipv6 ospf6 route X:X::X:X/M match", SHOW_STR IP6_STR OSPF6_STR @@ -537,7 +537,7 @@ DEFUN (show_ipv6_ospf6_route_match, DEFUN (show_ipv6_ospf6_route_match_detail, show_ipv6_ospf6_route_match_detail_cmd, - "show ipv6 ospf6 route X::X/M match detail", + "show ipv6 ospf6 route X:X::X:X/M match detail", SHOW_STR IP6_STR OSPF6_STR @@ -562,6 +562,46 @@ DEFUN (show_ipv6_ospf6_route_match_detail, return CMD_SUCCESS; } +ALIAS (show_ipv6_ospf6_route, + show_ipv6_ospf6_route_type_cmd, + "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)", + SHOW_STR + IP6_STR + OSPF6_STR + ROUTE_STR + "Dispaly Intra-Area routes\n" + "Dispaly Inter-Area routes\n" + "Dispaly Type-1 External routes\n" + "Dispaly Type-2 External routes\n" + ); + +DEFUN (show_ipv6_ospf6_route_type_detail, + show_ipv6_ospf6_route_type_detail_cmd, + "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail", + SHOW_STR + IP6_STR + OSPF6_STR + ROUTE_STR + "Dispaly Intra-Area routes\n" + "Dispaly Inter-Area routes\n" + "Dispaly Type-1 External routes\n" + "Dispaly Type-2 External routes\n" + "Detailed information\n" + ) +{ + char *sargv[CMD_ARGC_MAX]; + int i, sargc; + + /* copy argv to sargv and then append "detail" */ + for (i = 0; i < argc; i++) + sargv[i] = argv[i]; + sargc = argc; + sargv[sargc++] = "detail"; + sargv[sargc] = NULL; + + ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table); + return CMD_SUCCESS; +} /* OSPF configuration write function. */ int @@ -622,10 +662,14 @@ ospf6_top_init () install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd); install_default (OSPF6_NODE); install_element (OSPF6_NODE, &ospf6_router_id_cmd); diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index b954172d..4a722e41 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -1714,6 +1714,87 @@ ALIAS (show_ipv6_ospf6_border_routers, "Display Detail\n" ); +DEFUN (show_ipv6_ospf6_linkstate, + show_ipv6_ospf6_linkstate_cmd, + "show ipv6 ospf6 linkstate", + SHOW_STR + IP6_STR + OSPF6_STR + "Display linkstate routing table\n" + ) +{ + listnode node; + struct ospf6_area *oa; + + for (node = listhead (ospf6->area_list); node; nextnode (node)) + { + oa = OSPF6_AREA (getdata (node)); + + vty_out (vty, "%s SPF Result in Area %s%s%s", + VNL, oa->name, VNL, VNL); + ospf6_linkstate_table_show (vty, argc, argv, oa->spf_table); + } + + vty_out (vty, "%s", VNL); + return CMD_SUCCESS; +} + +ALIAS (show_ipv6_ospf6_linkstate, + show_ipv6_ospf6_linkstate_router_cmd, + "show ipv6 ospf6 linkstate router A.B.C.D", + SHOW_STR + IP6_STR + OSPF6_STR + "Display linkstate routing table\n" + "Display Router Entry\n" + "Specify Router ID as IPv4 address notation\n" + ); + +ALIAS (show_ipv6_ospf6_linkstate, + show_ipv6_ospf6_linkstate_network_cmd, + "show ipv6 ospf6 linkstate network A.B.C.D A.B.C.D", + SHOW_STR + IP6_STR + OSPF6_STR + "Display linkstate routing table\n" + "Display Network Entry\n" + "Specify Router ID as IPv4 address notation\n" + "Specify Link state ID as IPv4 address notation\n" + ); + +DEFUN (show_ipv6_ospf6_linkstate_detail, + show_ipv6_ospf6_linkstate_detail_cmd, + "show ipv6 ospf6 linkstate detail", + SHOW_STR + IP6_STR + OSPF6_STR + "Display linkstate routing table\n" + ) +{ + char *sargv[CMD_ARGC_MAX]; + int i, sargc; + listnode node; + struct ospf6_area *oa; + + /* copy argv to sargv and then append "detail" */ + for (i = 0; i < argc; i++) + sargv[i] = argv[i]; + sargc = argc; + sargv[sargc++] = "detail"; + sargv[sargc] = NULL; + + for (node = listhead (ospf6->area_list); node; nextnode (node)) + { + oa = OSPF6_AREA (getdata (node)); + + vty_out (vty, "%s SPF Result in Area %s%s%s", + VNL, oa->name, VNL, VNL); + ospf6_linkstate_table_show (vty, sargc, sargv, oa->spf_table); + } + + vty_out (vty, "%s", VNL); + return CMD_SUCCESS; +} /* Install ospf related commands. */ void @@ -1752,6 +1833,15 @@ ospf6_init () install_element (ENABLE_NODE, &show_ipv6_ospf6_border_routers_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_border_routers_detail_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_router_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_network_cmd); + install_element (VIEW_NODE, &show_ipv6_ospf6_linkstate_detail_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_linkstate_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_linkstate_router_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_linkstate_network_cmd); + install_element (ENABLE_NODE, &show_ipv6_ospf6_linkstate_detail_cmd); + #define INSTALL(n,c) \ install_element (n ## _NODE, &show_ipv6_ospf6_ ## c); diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h index 3df9ea69..fefdfcc7 100644 --- a/ospf6d/ospf6d.h +++ b/ospf6d/ospf6d.h @@ -22,7 +22,7 @@ #ifndef OSPF6D_H #define OSPF6D_H -#define OSPF6_DAEMON_VERSION "0.9.7l" +#define OSPF6_DAEMON_VERSION "0.9.7m" /* global variables */ extern int errno; |