void ospf_route_table_dump (struct route_table *rt) { struct route_node *rn; struct ospf_route *or; char buf1[BUFSIZ]; char buf2[BUFSIZ]; struct listnode *pnode; struct ospf_path *path; #if 0 zlog_debug ("Type Dest Area Path Type Cost Next Adv."); zlog_debug (" Hop(s) Router(s)"); #endif /* 0 */ zlog_debug ("========== OSPF routing table =========="); for (rn = route_top (rt); rn; rn = route_next (rn)) if ((or = rn->info) != NULL) { if (or->type == OSPF_DESTINATION_NETWORK) { zlog_debug ("N %s/%d\t%s\t%s\t%d", inet_ntop (AF_INET, &rn->p.u.prefix4, buf1, BUFSIZ), rn->p.prefixlen, inet_ntop (AF_INET, &or->u.std.area_id, buf2, BUFSIZ), ospf_path_type_str[or->path_type], or->cost); for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) zlog_debug (" -> %s", inet_ntoa (path->nexthop)); } else zlog_debug ("R %s\t%s\t%s\t%d", inet_ntop (AF_INET, &rn->p.u.prefix4, buf1, BUFSIZ), inet_ntop (AF_INET, &or->u.std.area_id, buf2, BUFSIZ), ospf_path_type_str[or->path_type], or->cost); } zlog_debug ("========================================"); }
dump的结果类似
N 10.1.0.0/24 0.0.0.0 intra-area 10 -> 0.0.0.0
代表
下一跳 下一跳地址/掩码 区域 类型 度量 -> 目的IP
上面结果是
下一跳为10.1.0.0/24