📄 ripngd.c
字号:
ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; ripng_event (RIPNG_UPDATE_EVENT, 0); return CMD_SUCCESS;}/* RIPng timeout timer setup. */DEFUN (ripng_timeout_timer, ripng_timeout_timer_cmd, "timeout-timer SECOND", "Set RIPng timeout timer in seconds\n" "Seconds\n"){ unsigned long timeout; char *endptr = NULL; timeout = strtoul (argv[0], &endptr, 10); if (timeout == ULONG_MAX || *endptr != '\0') { vty_out (vty, "timeout timer value error%s", VTY_NEWLINE); return CMD_WARNING; } ripng->timeout_time = timeout; return CMD_SUCCESS;}DEFUN (no_ripng_timeout_timer, no_ripng_timeout_timer_cmd, "no timeout-timer SECOND", NO_STR "Unset RIPng timeout timer in seconds\n" "Seconds\n"){ ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; return CMD_SUCCESS;}/* RIPng garbage timer setup. */DEFUN (ripng_garbage_timer, ripng_garbage_timer_cmd, "garbage-timer SECOND", "Set RIPng garbage timer in seconds\n" "Seconds\n"){ unsigned long garbage; char *endptr = NULL; garbage = strtoul (argv[0], &endptr, 10); if (garbage == ULONG_MAX || *endptr != '\0') { vty_out (vty, "garbage timer value error%s", VTY_NEWLINE); return CMD_WARNING; } ripng->garbage_time = garbage; return CMD_SUCCESS;}DEFUN (no_ripng_garbage_timer, no_ripng_garbage_timer_cmd, "no garbage-timer SECOND", NO_STR "Unset RIPng garbage timer in seconds\n" "Seconds\n"){ ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; return CMD_SUCCESS;}#endif /* 0 */DEFUN (ripng_timers, ripng_timers_cmd, "timers basic <0-65535> <0-65535> <0-65535>", "RIPng timers setup\n" "Basic timer\n" "Routing table update timer value in second. Default is 30.\n" "Routing information timeout timer. Default is 180.\n" "Garbage collection timer. Default is 120.\n"){ unsigned long update; unsigned long timeout; unsigned long garbage; char *endptr = NULL; update = strtoul (argv[0], &endptr, 10); if (update == ULONG_MAX || *endptr != '\0') { vty_out (vty, "update timer value error%s", VTY_NEWLINE); return CMD_WARNING; } timeout = strtoul (argv[1], &endptr, 10); if (timeout == ULONG_MAX || *endptr != '\0') { vty_out (vty, "timeout timer value error%s", VTY_NEWLINE); return CMD_WARNING; } garbage = strtoul (argv[2], &endptr, 10); if (garbage == ULONG_MAX || *endptr != '\0') { vty_out (vty, "garbage timer value error%s", VTY_NEWLINE); return CMD_WARNING; } /* Set each timer value. */ ripng->update_time = update; ripng->timeout_time = timeout; ripng->garbage_time = garbage; /* Reset update timer thread. */ ripng_event (RIPNG_UPDATE_EVENT, 0); return CMD_SUCCESS;}DEFUN (no_ripng_timers, no_ripng_timers_cmd, "no timers basic", NO_STR "RIPng timers setup\n" "Basic timer\n"){ /* Set each timer value to the default. */ ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT; ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT; ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT; /* Reset update timer thread. */ ripng_event (RIPNG_UPDATE_EVENT, 0); return CMD_SUCCESS;}DEFUN (show_ipv6_protocols, show_ipv6_protocols_cmd, "show ipv6 protocols", SHOW_STR IP_STR "Routing protocol information"){ if (! ripng) return CMD_SUCCESS; vty_out (vty, "Routing Protocol is \"ripng\"%s", VTY_NEWLINE); vty_out (vty, "Sending updates every %ld seconds, next due in %d seconds%s", ripng->update_time, 0, VTY_NEWLINE); vty_out (vty, "Timerout after %ld seconds, garbage correct %ld%s", ripng->timeout_time, ripng->garbage_time, VTY_NEWLINE); vty_out (vty, "Outgoing update filter list for all interfaces is not set"); vty_out (vty, "Incoming update filter list for all interfaces is not set"); return CMD_SUCCESS;}/* Please be carefull to use this command. */DEFUN (ripng_default_information_originate, ripng_default_information_originate_cmd, "default-information originate", "Default route information\n" "Distribute default route\n"){ struct prefix_ipv6 p; ripng->default_information = 1; str2prefix_ipv6 ("::/0", &p); ripng_redistribute_add (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); return CMD_SUCCESS;}DEFUN (no_ripng_default_information_originate, no_ripng_default_information_originate_cmd, "no default-information originate", NO_STR "Default route information\n" "Distribute default route\n"){ struct prefix_ipv6 p; ripng->default_information = 0; str2prefix_ipv6 ("::/0", &p); ripng_redistribute_delete (ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); return CMD_SUCCESS;}/* RIPng configuration write function. */intripng_config_write (struct vty *vty){ int ripng_network_write (struct vty *); void ripng_redistribute_write (struct vty *); int write = 0; struct route_node *rp; if (ripng) { /* RIPng router. */ vty_out (vty, "router ripng%s", VTY_NEWLINE); if (ripng->default_information) vty_out (vty, " default-information originate%s", VTY_NEWLINE); ripng_network_write (vty); /* RIPng default metric configuration */ if (ripng->default_metric != RIPNG_DEFAULT_METRIC_DEFAULT) vty_out (vty, " default-metric %d%s", ripng->default_metric, VTY_NEWLINE); ripng_redistribute_write (vty); /* RIPng aggregate routes. */ for (rp = route_top (ripng->aggregate); rp; rp = route_next (rp)) if (rp->info != NULL) vty_out (vty, " aggregate-address %s/%d%s", inet6_ntop (&rp->p.u.prefix6), rp->p.prefixlen, VTY_NEWLINE); /* RIPng static routes. */ for (rp = route_top (ripng->route); rp; rp = route_next (rp)) if (rp->info != NULL) vty_out (vty, " route %s/%d%s", inet6_ntop (&rp->p.u.prefix6), rp->p.prefixlen, VTY_NEWLINE); /* RIPng timers configuration. */ if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT || ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT || ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) { vty_out (vty, " timers basic %ld %ld %ld%s", ripng->update_time, ripng->timeout_time, ripng->garbage_time, VTY_NEWLINE); }#if 0 if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT) vty_out (vty, " update-timer %d%s", ripng->update_time, VTY_NEWLINE); if (ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT) vty_out (vty, " timeout-timer %d%s", ripng->timeout_time, VTY_NEWLINE); if (ripng->garbage_time != RIPNG_GARBAGE_TIMER_DEFAULT) vty_out (vty, " garbage-timer %d%s", ripng->garbage_time, VTY_NEWLINE);#endif /* 0 */ write += config_write_distribute (vty); write += config_write_if_rmap (vty); write++; } return write;}/* RIPng node structure. */struct cmd_node cmd_ripng_node ={ RIPNG_NODE, "%s(config-router)# ", 1,};voidripng_distribute_update (struct distribute *dist){ struct interface *ifp; struct ripng_interface *ri; struct access_list *alist; struct prefix_list *plist; if (! dist->ifname) return; ifp = if_lookup_by_name (dist->ifname); if (ifp == NULL) return; ri = ifp->info; if (dist->list[DISTRIBUTE_IN]) { alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_IN]); if (alist) ri->list[RIPNG_FILTER_IN] = alist; else ri->list[RIPNG_FILTER_IN] = NULL; } else ri->list[RIPNG_FILTER_IN] = NULL; if (dist->list[DISTRIBUTE_OUT]) { alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_OUT]); if (alist) ri->list[RIPNG_FILTER_OUT] = alist; else ri->list[RIPNG_FILTER_OUT] = NULL; } else ri->list[RIPNG_FILTER_OUT] = NULL; if (dist->prefix[DISTRIBUTE_IN]) { plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_IN]); if (plist) ri->prefix[RIPNG_FILTER_IN] = plist; else ri->prefix[RIPNG_FILTER_IN] = NULL; } else ri->prefix[RIPNG_FILTER_IN] = NULL; if (dist->prefix[DISTRIBUTE_OUT]) { plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_OUT]); if (plist) ri->prefix[RIPNG_FILTER_OUT] = plist; else ri->prefix[RIPNG_FILTER_OUT] = NULL; } else ri->prefix[RIPNG_FILTER_OUT] = NULL;}voidripng_distribute_update_interface (struct interface *ifp){ struct distribute *dist; dist = distribute_lookup (ifp->name); if (dist) ripng_distribute_update (dist);}/* Update all interface's distribute list. */voidripng_distribute_update_all (){ struct interface *ifp; listnode node; for (node = listhead (iflist); node; nextnode (node)) { ifp = getdata (node); ripng_distribute_update_interface (ifp); }}voidripng_if_rmap_update (struct if_rmap *if_rmap){ struct interface *ifp; struct ripng_interface *ri; struct route_map *rmap; ifp = if_lookup_by_name (if_rmap->ifname); if (ifp == NULL) return; ri = ifp->info; if (if_rmap->routemap[IF_RMAP_IN]) { rmap = route_map_lookup_by_name (if_rmap->routemap[IF_RMAP_IN]); if (rmap) ri->routemap[IF_RMAP_IN] = rmap; else ri->routemap[IF_RMAP_IN] = NULL; } else ri->routemap[RIPNG_FILTER_IN] = NULL; if (if_rmap->routemap[IF_RMAP_OUT]) { rmap = route_map_lookup_by_name (if_rmap->routemap[IF_RMAP_OUT]); if (rmap) ri->routemap[IF_RMAP_OUT] = rmap; else ri->routemap[IF_RMAP_OUT] = NULL; } else ri->routemap[RIPNG_FILTER_OUT] = NULL;}voidripng_if_rmap_update_interface (struct interface *ifp){ struct if_rmap *if_rmap; if_rmap = if_rmap_lookup (ifp->name); if (if_rmap) ripng_if_rmap_update (if_rmap);}voidripng_routemap_update_redistribute (void){ int i; if (ripng) { for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { if (ripng->route_map[i].name) ripng->route_map[i].map = route_map_lookup_by_name (ripng->route_map[i].name); } }}voidripng_routemap_update (){ struct interface *ifp; listnode node; for (node = listhead (iflist); node; nextnode (node)) { ifp = getdata (node); ripng_if_rmap_update_interface (ifp); } ripng_routemap_update_redistribute ();}/* Initialize ripng structure and set commands. */voidripng_init (){ /* Randomize. */ srand (time (NULL)); /* Install RIPNG_NODE. */ install_node (&cmd_ripng_node, ripng_config_write); /* Install ripng commands. */ install_element (VIEW_NODE, &show_ipv6_ripng_cmd); install_element (ENABLE_NODE, &show_ipv6_ripng_cmd); install_element (CONFIG_NODE, &router_ripng_cmd); install_default (RIPNG_NODE); install_element (RIPNG_NODE, &ripng_route_cmd); install_element (RIPNG_NODE, &no_ripng_route_cmd); install_element (RIPNG_NODE, &ripng_aggregate_address_cmd); install_element (RIPNG_NODE, &no_ripng_aggregate_address_cmd); install_element (RIPNG_NODE, &ripng_default_metric_cmd); install_element (RIPNG_NODE, &no_ripng_default_metric_cmd); install_element (RIPNG_NODE, &no_ripng_default_metric_val_cmd); install_element (RIPNG_NODE, &ripng_timers_cmd); install_element (RIPNG_NODE, &no_ripng_timers_cmd);#if 0 install_element (RIPNG_NODE, &ripng_update_timer_cmd); install_element (RIPNG_NODE, &no_ripng_update_timer_cmd); install_element (RIPNG_NODE, &ripng_timeout_timer_cmd); install_element (RIPNG_NODE, &no_ripng_timeout_timer_cmd); install_element (RIPNG_NODE, &ripng_garbage_timer_cmd); install_element (RIPNG_NODE, &no_ripng_garbage_timer_cmd);#endif /* 0 */ install_element (RIPNG_NODE, &ripng_default_information_originate_cmd); install_element (RIPNG_NODE, &no_ripng_default_information_originate_cmd); ripng_if_init (); ripng_debug_init (); /* Access list install. */ access_list_init (); access_list_add_hook (ripng_distribute_update_all); access_list_delete_hook (ripng_distribute_update_all); /* Prefix list initialize.*/ prefix_list_init (); prefix_list_add_hook (ripng_distribute_update_all); prefix_list_delete_hook (ripng_distribute_update_all); /* Distribute list install. */ distribute_list_init (RIPNG_NODE); distribute_list_add_hook (ripng_distribute_update); distribute_list_delete_hook (ripng_distribute_update); /* Route-map for interface. */ ripng_route_map_init (); rout
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -