📄 rip_interface.c
字号:
rip_neighbor_add (&p); return CMD_SUCCESS;}/* RIP neighbor configuration unset. */DEFUN (no_rip_neighbor, no_rip_neighbor_cmd, "no neighbor A.B.C.D", NO_STR "Specify a neighbor router\n" "Neighbor address\n"){ int ret; struct prefix_ipv4 p; ret = str2prefix_ipv4 (argv[0], &p); if (ret <= 0) { vty_out (vty, "Please specify address by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; } rip_neighbor_delete (&p); return CMD_SUCCESS;}DEFUN (ip_rip_receive_version, ip_rip_receive_version_cmd, "ip rip receive version (1|2)", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" "Version control\n" "RIP version 1\n" "RIP version 2\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1. */ if (atoi (argv[0]) == 1) { ri->ri_receive = RI_RIP_VERSION_1; return CMD_SUCCESS; } if (atoi (argv[0]) == 2) { ri->ri_receive = RI_RIP_VERSION_2; return CMD_SUCCESS; } return CMD_WARNING;}DEFUN (ip_rip_receive_version_1, ip_rip_receive_version_1_cmd, "ip rip receive version 1 2", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" "Version control\n" "RIP version 1\n" "RIP version 2\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1 and 2. */ ri->ri_receive = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS;}DEFUN (ip_rip_receive_version_2, ip_rip_receive_version_2_cmd, "ip rip receive version 2 1", IP_STR "Routing Information Protocol\n" "Advertisement reception\n" "Version control\n" "RIP version 2\n" "RIP version 1\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1 and 2. */ ri->ri_receive = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS;}DEFUN (no_ip_rip_receive_version, no_ip_rip_receive_version_cmd, "no ip rip receive version", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement reception\n" "Version control\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; ri->ri_receive = RI_RIP_UNSPEC; return CMD_SUCCESS;}ALIAS (no_ip_rip_receive_version, no_ip_rip_receive_version_num_cmd, "no ip rip receive version (1|2)", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement reception\n" "Version control\n" "Version 1\n" "Version 2\n");DEFUN (ip_rip_send_version, ip_rip_send_version_cmd, "ip rip send version (1|2)", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" "Version control\n" "RIP version 1\n" "RIP version 2\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1. */ if (atoi (argv[0]) == 1) { ri->ri_send = RI_RIP_VERSION_1; return CMD_SUCCESS; } if (atoi (argv[0]) == 2) { ri->ri_send = RI_RIP_VERSION_2; return CMD_SUCCESS; } return CMD_WARNING;}DEFUN (ip_rip_send_version_1, ip_rip_send_version_1_cmd, "ip rip send version 1 2", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" "Version control\n" "RIP version 1\n" "RIP version 2\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1 and 2. */ ri->ri_send = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS;}DEFUN (ip_rip_send_version_2, ip_rip_send_version_2_cmd, "ip rip send version 2 1", IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" "Version control\n" "RIP version 2\n" "RIP version 1\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* Version 1 and 2. */ ri->ri_send = RI_RIP_VERSION_1_AND_2; return CMD_SUCCESS;}DEFUN (no_ip_rip_send_version, no_ip_rip_send_version_cmd, "no ip rip send version", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" "Version control\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; ri->ri_send = RI_RIP_UNSPEC; return CMD_SUCCESS;}ALIAS (no_ip_rip_send_version, no_ip_rip_send_version_num_cmd, "no ip rip send version (1|2)", NO_STR IP_STR "Routing Information Protocol\n" "Advertisement transmission\n" "Version control\n" "Version 1\n" "Version 2\n");DEFUN (ip_rip_authentication_mode, ip_rip_authentication_mode_cmd, "ip rip authentication mode (md5|text)", IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication mode\n" "Keyed message digest\n" "Clear text authentication\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; if (strncmp ("md5", argv[0], strlen (argv[0])) == 0) ri->auth_type = RIP_AUTH_MD5; else if (strncmp ("text", argv[0], strlen (argv[0])) == 0) ri->auth_type = RIP_AUTH_SIMPLE_PASSWORD; else { vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS;}DEFUN (no_ip_rip_authentication_mode, no_ip_rip_authentication_mode_cmd, "no ip rip authentication mode", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication mode\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; /* ri->auth_type = RIP_NO_AUTH; */ ri->auth_type = RIP_AUTH_SIMPLE_PASSWORD; return CMD_SUCCESS;}ALIAS (no_ip_rip_authentication_mode, no_ip_rip_authentication_mode_type_cmd, "no ip rip authentication mode (md5|text)", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication mode\n" "Keyed message digest\n" "Clear text authentication\n");DEFUN (ip_rip_authentication_string, ip_rip_authentication_string_cmd, "ip rip authentication string LINE", IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication string\n" "Authentication string\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; if (strlen (argv[0]) > 16) { vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s", VTY_NEWLINE); return CMD_WARNING; } if (ri->key_chain) { vty_out (vty, "%% key-chain configuration exists%s", VTY_NEWLINE); return CMD_WARNING; } if (ri->auth_str) free (ri->auth_str); ri->auth_str = strdup (argv[0]); return CMD_SUCCESS;}DEFUN (no_ip_rip_authentication_string, no_ip_rip_authentication_string_cmd, "no ip rip authentication string", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication string\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *)vty->index; ri = ifp->info; if (ri->auth_str) free (ri->auth_str); ri->auth_str = NULL; return CMD_SUCCESS;}ALIAS (no_ip_rip_authentication_string, no_ip_rip_authentication_string2_cmd, "no ip rip authentication string LINE", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication string\n" "Authentication string\n");DEFUN (ip_rip_authentication_key_chain, ip_rip_authentication_key_chain_cmd, "ip rip authentication key-chain LINE", IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication key-chain\n" "name of key-chain\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *) vty->index; ri = ifp->info; if (ri->auth_str) { vty_out (vty, "%% authentication string configuration exists%s", VTY_NEWLINE); return CMD_WARNING; } if (ri->key_chain) free (ri->key_chain); ri->key_chain = strdup (argv[0]); return CMD_SUCCESS;}DEFUN (no_ip_rip_authentication_key_chain, no_ip_rip_authentication_key_chain_cmd, "no ip rip authentication key-chain", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication key-chain\n"){ struct interface *ifp; struct rip_interface *ri; ifp = (struct interface *) vty->index; ri = ifp->info; if (ri->key_chain) free (ri->key_chain); ri->key_chain = NULL; return CMD_SUCCESS;}ALIAS (no_ip_rip_authentication_key_chain, no_ip_rip_authentication_key_chain2_cmd, "no ip rip authentication key-chain LINE", NO_STR IP_STR "Routing Information Protocol\n" "Authentication control\n" "Authentication key-chain\n" "name of key-chain\n");DEFUN (rip_split_horizon, rip_split_horizon_cmd, "ip split-horizon", IP_STR "Perform split horizon\n"){ struct interface *ifp; struct rip_interface *ri; ifp = vty->index; ri = ifp->info; ri->split_horizon = 1; return CMD_SUCCESS;}DEFUN (no_rip_split_horizon, no_rip_split_horizon_cmd, "no ip split-horizon", NO_STR IP_STR "Perform split horizon\n"){ struct interface *ifp; struct rip_interface *ri; ifp = vty->index; ri = ifp->info; ri->split_horizon = 0; return CMD_SUCCESS;}DEFUN (rip_passive_interface, rip_passive_interface_cmd, "passive-interface IFNAME", "Suppress routing updates on an interface\n" "Interface name\n"){ return rip_passive_interface_set (vty, argv[0]);}DEFUN (no_rip_passive_interface, no_rip_passive_interface_cmd, "no passive-interface IFNAME", NO_STR "Suppress routing updates on an interface\n" "Interface name\n"){ return rip_passive_interface_unset (vty, argv[0]);}/* Write rip configuration of each interface. */intrip_interface_config_write (struct vty *vty){ listnode node; struct interface *ifp; for (node = listhead (iflist); node; nextnode (node)) { struct rip_interface *ri; ifp = getdata (node); ri = ifp->info; vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); if (ifp->desc) vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE); /* Split horizon. */ if (ri->split_horizon != ri->split_horizon_default) { if (ri->split_horizon) vty_out (vty, " ip split-horizon%s", VTY_NEWLINE); else vty_out (vty, " no ip split-horizon%s", VTY_NEWLINE); } /* RIP version setting. */ if (ri->ri_send != RI_RIP_UNSPEC) vty_out (vty, " ip rip send version %s%s", lookup (ri_version_msg, ri->ri_send), VTY_NEWLINE); if (ri->ri_receive != RI_RIP_UNSPEC) vty_out (vty, " ip rip receive version %s%s", lookup (ri_version_msg, ri->ri_receive), VTY_NEWLINE); /* RIP authentication. */#if 0 /* RIP_AUTH_SIMPLE_PASSWORD becomes default mode. */ if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD) vty_out (vty, " ip rip authentication mode text%s", VTY_NEWLINE);#endif /* 0 */ if (ri->auth_type == RIP_AUTH_MD5) vty_out (vty, " ip rip authentication mode md5%s", VTY_NEWLINE); if (ri->auth_str) vty_out (vty, " ip rip authentication string %s%s", ri->auth_str, VTY_NEWLINE); if (ri->key_chain) vty_out (vty, " ip rip authentication key-chain %s%s", ri->key_chain, VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); } return 0;}intconfig_write_rip_network (struct vty *vty, int config_mode){ int i; char *ifname; struct route_node *node; /* Network type RIP enable interface statement. */ for (node = route_top (rip_enable_network); node; node = route_next (node)) if (node->info) vty_out (vty, "%s%s/%d%s", config_mode ? " network " : " ", inet_ntoa (node->p.u.prefix4), node->p.prefixlen, VTY_NEWLINE); /* Interface name RIP enable statement. */ for (i = 0; i < vector_max (rip_enable_interface); i++) if ((ifname = vector_slot (rip_enable_interface, i)) != NULL) vty_out (vty, "%s%s%s", config_mode ? " network " : " ", ifname, VTY_NEWLINE); /* RIP neighbors listing. */ for (node = route_top (rip->neighbor); node; node = route_next (node)) if (node->info) vty_out (vty, "%s%s%s", config_mode ? " neighbor " : " ", inet_ntoa (node->p.u.prefix4), VTY_NEWLINE); /* RIP passive interface listing. */ if (config_mode) for (i = 0; i < vector_max (Vrip_passive_interface); i++) if ((ifname = vector_slot (Vrip_passive_interface, i)) != NULL) vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE); return 0;}struct cmd_node interface_node ={ INTERFACE_NODE, "%s(config-if)# ", 1,};/* Called when interface structure allocated. */intrip_interface_new_hook (struct interface *ifp){ ifp->info = rip_interface_new (); return 0;}/* Called when interface structure deleted. */intrip_interface_delete_hook (struct interface *ifp){ XFREE (MTYPE_RIP_INTERFACE, ifp->info); return 0;}/* Allocate and initialize interface vector. */voidrip_if_init (){ /* Default initial size of interface vector. */ if_init(); if_add_hook (IF_NEW_HOOK, rip_interface_new_hook); if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook); /* RIP network init. */ rip_enable_interface = vector_init (1); rip_enable_network = route_table_init (); /* RIP passive interface. */ Vrip_passive_interface = vector_init (1); /* Install interface node. */ install_node (&interface_node, rip_interface_config_write); /* Install commands. */ install_element (CONFIG_NODE, &interface_cmd); install_default (INTERFACE_NODE); install_element (INTERFACE_NODE, &interface_desc_cmd); install_element (INTERFACE_NODE, &no_interface_desc_cmd); install_element (RIP_NODE, &rip_network_cmd); install_element (RIP_NODE, &no_rip_network_cmd); install_element (RIP_NODE, &rip_neighbor_cmd); install_element (RIP_NODE, &no_rip_neighbor_cmd); install_element (RIP_NODE, &rip_passive_interface_cmd); install_element (RIP_NODE, &no_rip_passive_interface_cmd); install_element (INTERFACE_NODE, &ip_rip_send_version_cmd); install_element (INTERFACE_NODE, &ip_rip_send_version_1_cmd); install_element (INTERFACE_NODE, &ip_rip_send_version_2_cmd); install_element (INTERFACE_NODE, &no_ip_rip_send_version_cmd); install_element (INTERFACE_NODE, &no_ip_rip_send_version_num_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_1_cmd); install_element (INTERFACE_NODE, &ip_rip_receive_version_2_cmd); install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd); install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain2_cmd); install_element (INTERFACE_NODE, &ip_rip_authentication_string_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_string_cmd); install_element (INTERFACE_NODE, &no_ip_rip_authentication_string2_cmd); install_element (INTERFACE_NODE, &rip_split_horizon_cmd); install_element (INTERFACE_NODE, &no_rip_split_horizon_cmd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -