📄 rip_zebra.c
字号:
"no redistribute (kernel|connected|static|ospf|bgp)", NO_STR "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n"){ int i; for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP); rip_routemap_unset (redist_type[i].type,NULL); rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}DEFUN (rip_redistribute_type_routemap, rip_redistribute_type_routemap_cmd, "redistribute (kernel|connected|static|ospf|bgp) route-map WORD", "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n" "Route map reference\n" "Pointer to route-map entries\n"){ int i; for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { rip_routemap_set (redist_type[i].type, argv[1]); zclient_redistribute_set (zclient, redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}DEFUN (no_rip_redistribute_type_routemap, no_rip_redistribute_type_routemap_cmd, "no redistribute (kernel|connected|static|ospf|bgp) route-map WORD", NO_STR "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n" "Route map reference\n" "Pointer to route-map entries\n"){ int i; for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { if (rip_routemap_unset (redist_type[i].type,argv[1])) return CMD_WARNING; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}DEFUN (rip_redistribute_type_metric, rip_redistribute_type_metric_cmd, "redistribute (kernel|connected|static|ospf|bgp) metric <0-16>", "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n" "Metric\n" "Metric value\n"){ int i; int metric; metric = atoi (argv[1]); for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { rip_redistribute_metric_set (redist_type[i].type, metric); zclient_redistribute_set (zclient, redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}DEFUN (no_rip_redistribute_type_metric, no_rip_redistribute_type_metric_cmd, "no redistribute (kernel|connected|static|ospf|bgp) metric <0-16>", NO_STR "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n" "Metric\n" "Metric value\n"){ int i; for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) return CMD_WARNING; rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}DEFUN (no_rip_redistribute_type_metric_routemap, no_rip_redistribute_type_metric_routemap_cmd, "no redistribute (kernel|connected|static|ospf|bgp) metric <0-16> route-map WORD", NO_STR "Redistribute information from another routing protocol\n" "Kernel routes\n" "Connected\n" "Static routes\n" "Open Shortest Path First (OSPF)\n" "Border Gateway Protocol (BGP)\n" "Metric\n" "Metric value\n" "Route map reference\n" "Pointer to route-map entries\n"){ int i; for (i = 0; redist_type[i].str; i++) { if (strncmp(redist_type[i].str, argv[0], redist_type[i].str_min_len) == 0) { if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) return CMD_WARNING; if (rip_routemap_unset (redist_type[i].type, argv[2])) { rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1])); return CMD_WARNING; } rip_redistribute_unset (redist_type[i].type); return CMD_SUCCESS; } } vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING;}/* Default information originate. */DEFUN (rip_default_information_originate, rip_default_information_originate_cmd, "default-information originate", "Control distribution of default route\n" "Distribute a default route\n"){ struct prefix_ipv4 p; if (! rip->default_information) { memset (&p, 0, sizeof (struct prefix_ipv4)); p.family = AF_INET; rip->default_information = 1; rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0, NULL); } return CMD_SUCCESS;}DEFUN (no_rip_default_information_originate, no_rip_default_information_originate_cmd, "no default-information originate", NO_STR "Control distribution of default route\n" "Distribute a default route\n"){ struct prefix_ipv4 p; if (rip->default_information) { memset (&p, 0, sizeof (struct prefix_ipv4)); p.family = AF_INET; rip->default_information = 0; rip_redistribute_delete (ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0); } return CMD_SUCCESS;}/* RIP configuration write function. */intconfig_write_zebra (struct vty *vty){ if (! zclient->enable) { vty_out (vty, "no router zebra%s", VTY_NEWLINE); return 1; } else if (! zclient->redist[ZEBRA_ROUTE_RIP]) { vty_out (vty, "router zebra%s", VTY_NEWLINE); vty_out (vty, " no redistribute rip%s", VTY_NEWLINE); return 1; } return 0;}intconfig_write_rip_redistribute (struct vty *vty, int config_mode){ int i; char *str[] = { "system", "kernel", "connected", "static", "rip", "ripng", "ospf", "ospf6", "bgp"}; for (i = 0; i < ZEBRA_ROUTE_MAX; i++) if (i != zclient->redist_default && zclient->redist[i]) { if (config_mode) { if (rip->route_map[i].metric_config) { if (rip->route_map[i].name) vty_out (vty, " redistribute %s metric %d route-map %s%s", str[i], rip->route_map[i].metric, rip->route_map[i].name, VTY_NEWLINE); else vty_out (vty, " redistribute %s metric %d%s", str[i], rip->route_map[i].metric, VTY_NEWLINE); } else { if (rip->route_map[i].name) vty_out (vty, " redistribute %s route-map %s%s", str[i], rip->route_map[i].name, VTY_NEWLINE); else vty_out (vty, " redistribute %s%s", str[i], VTY_NEWLINE); } } else vty_out (vty, " %s", str[i]); } return 0;}/* Zebra node structure. */struct cmd_node zebra_node ={ ZEBRA_NODE, "%s(config-router)# ",};voidrip_zclient_init (){ /* Set default value to the zebra client structure. */ zclient = zclient_new (); zclient_init (zclient, ZEBRA_ROUTE_RIP); zclient->interface_add = rip_interface_add; zclient->interface_delete = rip_interface_delete; zclient->interface_address_add = rip_interface_address_add; zclient->interface_address_delete = rip_interface_address_delete; zclient->ipv4_route_add = rip_zebra_read_ipv4; zclient->ipv4_route_delete = rip_zebra_read_ipv4; zclient->interface_up = rip_interface_up; zclient->interface_down = rip_interface_down; /* Install zebra node. */ install_node (&zebra_node, config_write_zebra); /* Install command elements to zebra node. */ install_element (CONFIG_NODE, &router_zebra_cmd); install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd); install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd); /* Install command elements to rip node. */ install_element (RIP_NODE, &rip_redistribute_type_cmd); install_element (RIP_NODE, &rip_redistribute_type_routemap_cmd); install_element (RIP_NODE, &rip_redistribute_type_metric_cmd); install_element (RIP_NODE, &no_rip_redistribute_type_cmd); install_element (RIP_NODE, &no_rip_redistribute_type_routemap_cmd); install_element (RIP_NODE, &no_rip_redistribute_type_metric_cmd); install_element (RIP_NODE, &no_rip_redistribute_type_metric_routemap_cmd); install_element (RIP_NODE, &rip_default_information_originate_cmd); install_element (RIP_NODE, &no_rip_default_information_originate_cmd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -