📄 ospf6_route.c
字号:
}voidospf6_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);}voidospf6_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); }}voidospf6_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); }}voidospf6_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 (detail) ospf6_route_show_detail (vty, route); else ospf6_route_show (vty, route); route = ospf6_route_next (route); }}intospf6_route_table_show (struct vty *vty, int argc, char **argv, struct ospf6_route_table *table){ int summary = 0; int match = 0; int detail = 0; int slash = 0; int isprefix = 0; int i, ret; struct prefix prefix; u_char type = 0; memset (&prefix, 0, sizeof (struct prefix)); for (i = 0; i < argc; i++) { if (! strcmp (argv[i], "summary")) { summary++; continue; } if (! strcmp (argv[i], "intra-area")) { type = OSPF6_PATH_TYPE_INTRA; continue; } if (! strcmp (argv[i], "inter-area")) { type = OSPF6_PATH_TYPE_INTER; continue; } if (! strcmp (argv[i], "external-1")) { 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) { isprefix++; if (strchr (argv[i], '/')) slash++; continue; } vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } /* Give summary of this route table */ if (summary) { ospf6_route_show_table_summary (vty, table); return CMD_SUCCESS; } /* Give exact prefix-match route */ if (isprefix && ! match) { /* If exact address, give best matching route */ if (! slash) ospf6_route_show_table_address (vty, &prefix, table); else ospf6_route_show_table_prefix (vty, &prefix, table); return CMD_SUCCESS; } 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); return CMD_SUCCESS;}voidospf6_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);}voidospf6_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 (ntohl (id)) vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", "Network", routername, idname, rbits, options, (unsigned long) route->path.cost, VNL); else vty_out (vty, "%-7s %-15s %-15s %-8s %-14s %lu%s", "Router", routername, idname, rbits, options, (unsigned long) route->path.cost, VNL);}voidospf6_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);}voidospf6_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 (detail) ospf6_route_show_detail (vty, route); else ospf6_linkstate_show (vty, route); route = ospf6_route_next (route); }}intospf6_linkstate_table_show (struct vty *vty, int argc, char **argv, struct ospf6_route_table *table){ int detail = 0; int is_id = 0; int is_router = 0; int i, ret; struct prefix router, id, 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++) { if (! strcmp (argv[i], "detail")) { detail++; continue; } if (! is_router) { ret = str2prefix (argv[i], &router); if (ret == 1 && router.family == AF_INET) { is_router++; continue; } vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } if (! is_id) { ret = str2prefix (argv[i], &id); if (ret == 1 && id.family == AF_INET) { is_id++; continue; } vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } vty_out (vty, "Malformed argument: %s%s", argv[i], VNL); return CMD_SUCCESS; } if (is_router) ospf6_linkstate_prefix (router.u.prefix4.s_addr, id.u.prefix4.s_addr, &prefix); if (prefix.family) ospf6_linkstate_show_table_exact (vty, &prefix, table); else ospf6_linkstate_show_table (vty, detail, table); return CMD_SUCCESS;}voidospf6_brouter_show_header (struct vty *vty){ vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area", VNL);}voidospf6_brouter_show (struct vty *vty, struct ospf6_route *route){ u_int32_t adv_router; char adv[16], rbits[16], options[16], area[16]; adv_router = ospf6_linkstate_prefix_adv_router (&route->prefix); inet_ntop (AF_INET, &adv_router, adv, sizeof (adv)); ospf6_capability_printbuf (route->path.router_bits, rbits, sizeof (rbits)); ospf6_options_printbuf (route->path.options, options, sizeof (options)); inet_ntop (AF_INET, &route->path.area_id, area, sizeof (area)); /* vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area", VNL); */ vty_out (vty, "%-15s %-8s %-14s %-10s %-15s%s", adv, rbits, options, OSPF6_PATH_TYPE_NAME (route->path.type), area, VNL);}DEFUN (debug_ospf6_route, debug_ospf6_route_cmd, "debug ospf6 route (table|intra-area|inter-area)", DEBUG_STR OSPF6_STR "Debug route table calculation\n" "Debug detail\n" "Debug intra-area route calculation\n" "Debug inter-area route calculation\n" ){ unsigned char level = 0; if (! strncmp (argv[0], "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; else if (! strncmp (argv[0], "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; else if (! strncmp (argv[0], "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; OSPF6_DEBUG_ROUTE_ON (level); return CMD_SUCCESS;}DEFUN (no_debug_ospf6_route, no_debug_ospf6_route_cmd, "no debug ospf6 route (table|intra-area|inter-area)", NO_STR DEBUG_STR OSPF6_STR "Debug route table calculation\n" "Debug intra-area route calculation\n"){ unsigned char level = 0; if (! strncmp (argv[0], "table", 5)) level = OSPF6_DEBUG_ROUTE_TABLE; else if (! strncmp (argv[0], "intra", 5)) level = OSPF6_DEBUG_ROUTE_INTRA; else if (! strncmp (argv[0], "inter", 5)) level = OSPF6_DEBUG_ROUTE_INTER; OSPF6_DEBUG_ROUTE_OFF (level); return CMD_SUCCESS;}intconfig_write_ospf6_debug_route (struct vty *vty){ if (IS_OSPF6_DEBUG_ROUTE (TABLE)) vty_out (vty, "debug ospf6 route table%s", VNL); if (IS_OSPF6_DEBUG_ROUTE (INTRA)) vty_out (vty, "debug ospf6 route intra-area%s", VNL); if (IS_OSPF6_DEBUG_ROUTE (INTER)) vty_out (vty, "debug ospf6 route inter-area%s", VNL); return 0;}voidinstall_element_ospf6_debug_route (){ install_element (ENABLE_NODE, &debug_ospf6_route_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_route_cmd); install_element (CONFIG_NODE, &debug_ospf6_route_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_route_cmd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -