📄 ospf6_area.c
字号:
u_int32_t area_id = 0; \ if (inet_pton (AF_INET, str, &area_id) != 1) \ { \ vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ return CMD_SUCCESS; \ } \ oa = ospf6_area_lookup (area_id, ospf6); \ if (oa == NULL) \ { \ vty_out (vty, "No such Area: %s%s", str, VNL); \ return CMD_SUCCESS; \ } \}#define OSPF6_CMD_AREA_GET(str, oa) \{ \ u_int32_t area_id = 0; \ if (inet_pton (AF_INET, str, &area_id) != 1) \ { \ vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ return CMD_SUCCESS; \ } \ oa = ospf6_area_get (area_id, ospf6); \}DEFUN (area_range, area_range_cmd, "area A.B.C.D range X:X::X:X/M", "OSPF area parameters\n" OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n" ){ int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range; OSPF6_CMD_AREA_GET (argv[0], oa); argc--; argv++; ret = str2prefix (argv[0], &prefix); if (ret != 1 || prefix.family != AF_INET6) { vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); return CMD_SUCCESS; } argc--; argv++; range = ospf6_route_lookup (&prefix, oa->range_table); if (range == NULL) { range = ospf6_route_create (); range->type = OSPF6_DEST_TYPE_RANGE; range->prefix = prefix; } if (argc) { if (! strcmp (argv[0], "not-advertise")) SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); else if (! strcmp (argv[0], "advertise")) UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); } ospf6_route_add (range, oa->range_table); return CMD_SUCCESS;}ALIAS (area_range, area_range_advertise_cmd, "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", "OSPF area parameters\n" OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n" );DEFUN (no_area_range, no_area_range_cmd, "no area A.B.C.D range X:X::X:X/M", "OSPF area parameters\n" OSPF6_AREA_ID_STR "Configured address range\n" "Specify IPv6 prefix\n" ){ int ret; struct ospf6_area *oa; struct prefix prefix; struct ospf6_route *range; OSPF6_CMD_AREA_GET (argv[0], oa); argc--; argv++; ret = str2prefix (argv[0], &prefix); if (ret != 1 || prefix.family != AF_INET6) { vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); return CMD_SUCCESS; } range = ospf6_route_lookup (&prefix, oa->range_table); if (range == NULL) { vty_out (vty, "Range %s does not exists.%s", argv[0], VNL); return CMD_SUCCESS; } ospf6_route_remove (range, oa->range_table); return CMD_SUCCESS;}voidospf6_area_config_write (struct vty *vty){ listnode node; struct ospf6_area *oa; struct ospf6_route *range; char buf[128]; for (node = listhead (ospf6->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); for (range = ospf6_route_head (oa->range_table); range; range = ospf6_route_next (range)) { prefix2str (&range->prefix, buf, sizeof (buf)); vty_out (vty, " area %s range %s%s", oa->name, buf, VNL); } }}DEFUN (show_ipv6_ospf6_spf_tree, show_ipv6_ospf6_spf_tree_cmd, "show ipv6 ospf6 spf tree", SHOW_STR IP6_STR OSPF6_STR "Shortest Path First caculation\n" "Show SPF tree\n"){ listnode node; struct ospf6_area *oa; struct ospf6_vertex *root; struct ospf6_route *route; struct prefix prefix; ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); for (node = listhead (ospf6->area_list); node; nextnode (node)) { oa = (struct ospf6_area *) getdata (node); route = ospf6_route_lookup (&prefix, oa->spf_table); if (route == NULL) { vty_out (vty, "LS entry for root not found in area %s%s", oa->name, VNL); continue; } root = (struct ospf6_vertex *) route->route_option; ospf6_spf_display_subtree (vty, "", 0, root); } return CMD_SUCCESS;}DEFUN (show_ipv6_ospf6_area_spf_tree, show_ipv6_ospf6_area_spf_tree_cmd, "show ipv6 ospf6 area A.B.C.D spf tree", SHOW_STR IP6_STR OSPF6_STR OSPF6_AREA_STR OSPF6_AREA_ID_STR "Shortest Path First caculation\n" "Show SPF tree\n"){ u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; struct ospf6_route *route; struct prefix prefix; ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); 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; } route = ospf6_route_lookup (&prefix, oa->spf_table); if (route == NULL) { vty_out (vty, "LS entry for root not found in area %s%s", oa->name, VNL); return CMD_SUCCESS; } root = (struct ospf6_vertex *) route->route_option; ospf6_spf_display_subtree (vty, "", 0, root); 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", SHOW_STR IP6_STR OSPF6_STR "Shortest Path First caculation\n" "Show SPF tree\n" "Specify root's router-id to calculate another router's SPF tree\n"){ u_int32_t area_id; struct ospf6_area *oa; struct ospf6_vertex *root; struct ospf6_route *route; struct prefix prefix; u_int32_t router_id; struct ospf6_route_table *spf_table; unsigned char tmp_debug_ospf6_spf = 0; inet_pton (AF_INET, argv[0], &router_id); ospf6_linkstate_prefix (router_id, htonl (0), &prefix); if (inet_pton (AF_INET, argv[1], &area_id) != 1) { vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL); return CMD_SUCCESS; } oa = ospf6_area_lookup (area_id, ospf6); if (oa == NULL) { vty_out (vty, "No such Area: %s%s", argv[1], VNL); return CMD_SUCCESS; } tmp_debug_ospf6_spf = conf_debug_ospf6_spf; conf_debug_ospf6_spf = 0; spf_table = ospf6_route_table_create (); ospf6_spf_calculation (router_id, spf_table, oa); conf_debug_ospf6_spf = tmp_debug_ospf6_spf; route = ospf6_route_lookup (&prefix, spf_table); if (route == NULL) { ospf6_spf_table_finish (spf_table); ospf6_route_table_delete (spf_table); return CMD_SUCCESS; } root = (struct ospf6_vertex *) route->route_option; ospf6_spf_display_subtree (vty, "", 0, root); ospf6_spf_table_finish (spf_table); ospf6_route_table_delete (spf_table); return CMD_SUCCESS;}voidospf6_area_init (){ install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd); install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_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_area_spf_tree_cmd); install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); install_element (OSPF6_NODE, &area_range_cmd); install_element (OSPF6_NODE, &area_range_advertise_cmd); install_element (OSPF6_NODE, &no_area_range_cmd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -