⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ripng_zebra.c

📁 大名鼎鼎的路由器源码。程序分ZEBRA、OSPFRIP等3个包。程序框架采用一个路由协议一个进程的方式
💻 C
📖 第 1 页 / 共 2 页
字号:
       ripng_redistribute_ospf6_metric_cmd,       "redistribute ospf6 metric <0-16>",       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Metric\n"       "Metric value\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_OSPF6, atoi (argv[0]));  zclient_redistribute_set (zclient, ZEBRA_ROUTE_OSPF6);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_ospf6,       no_ripng_redistribute_ospf6_metric_cmd,       "no redistribute ospf6 metric",       NO_STR       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Metric\n");ALIAS (no_ripng_redistribute_ospf6,       no_ripng_redistribute_ospf6_metric_val_cmd,       "no redistribute ospf6 metric <0-16>",       NO_STR       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Metric\n"       "Metric value\n");DEFUN (ripng_redistribute_bgp_metric,       ripng_redistribute_bgp_metric_cmd,       "redistribute bgp metric <0-16>",       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Metric\n"       "Metric value\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_BGP, atoi (argv[0]));  zclient_redistribute_set (zclient, ZEBRA_ROUTE_BGP);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_bgp,       no_ripng_redistribute_bgp_metric_cmd,       "no redistribute bgp metric",       NO_STR       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Metric\n");ALIAS (no_ripng_redistribute_bgp,       no_ripng_redistribute_bgp_metric_val_cmd,       "no redistribute bgp metric <0-16>",       NO_STR       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Metric\n"       "Metric value\n");DEFUN (ripng_redistribute_kernel_routemap,       ripng_redistribute_kernel_routemap_cmd,       "redistribute kernel route-map WORD",       "Redistribute information from another routing protocol\n"       "Kernel routes\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_routemap_set (ZEBRA_ROUTE_KERNEL, argv[0]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_KERNEL);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_kernel,       no_ripng_redistribute_kernel_routemap_cmd,       "no redistribute kernel route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Kernel routes\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_connected_routemap,       ripng_redistribute_connected_routemap_cmd,       "redistribute connected route-map WORD",       "Redistribute information from another routing protocol\n"       "Connected\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_routemap_set (ZEBRA_ROUTE_CONNECT, argv[0]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_CONNECT);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_connected,       no_ripng_redistribute_connected_routemap_cmd,       "no redistribute connected route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Connected\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_static_routemap,       ripng_redistribute_static_routemap_cmd,       "redistribute static route-map WORD",       "Redistribute information from another routing protocol\n"       "Static routes\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_routemap_set (ZEBRA_ROUTE_STATIC, argv[0]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_STATIC);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_static,       no_ripng_redistribute_static_routemap_cmd,       "no redistribute static route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Static routes\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_ospf6_routemap,       ripng_redistribute_ospf6_routemap_cmd,       "redistribute ospf6 route-map WORD",       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_routemap_set (ZEBRA_ROUTE_OSPF6, argv[0]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_OSPF6);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_ospf6,       no_ripng_redistribute_ospf6_routemap_cmd,       "no redistribute ospf6 route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_bgp_routemap,       ripng_redistribute_bgp_routemap_cmd,       "redistribute bgp route-map WORD",       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_routemap_set (ZEBRA_ROUTE_BGP, argv[0]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_BGP);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_bgp,       no_ripng_redistribute_bgp_routemap_cmd,       "no redistribute bgp route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_kernel_metric_routemap,       ripng_redistribute_kernel_metric_routemap_cmd,       "redistribute kernel metric <0-16> route-map WORD",       "Redistribute information from another routing protocol\n"       "Kernel routes\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_KERNEL, atoi (argv[0]));  ripng_redistribute_routemap_set (ZEBRA_ROUTE_KERNEL, argv[1]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_KERNEL);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_kernel,       no_ripng_redistribute_kernel_metric_routemap_cmd,       "no redistribute kernel metric <0-16> route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Kernel routes\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_connected_metric_routemap,       ripng_redistribute_connected_metric_routemap_cmd,       "redistribute connected metric <0-16> route-map WORD",       "Redistribute information from another routing protocol\n"       "Connected\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_CONNECT, atoi (argv[0]));  ripng_redistribute_routemap_set (ZEBRA_ROUTE_CONNECT, argv[1]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_CONNECT);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_connected,       no_ripng_redistribute_connected_metric_routemap_cmd,       "no redistribute connected metric <0-16> route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Connected\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_static_metric_routemap,       ripng_redistribute_static_metric_routemap_cmd,       "redistribute static metric <0-16> route-map WORD",       "Redistribute information from another routing protocol\n"       "Static routes\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_STATIC, atoi (argv[0]));  ripng_redistribute_routemap_set (ZEBRA_ROUTE_STATIC, argv[1]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_STATIC);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_static,       no_ripng_redistribute_static_metric_routemap_cmd,       "no redistribute static metric <0-16> route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Static routes\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_ospf6_metric_routemap,       ripng_redistribute_ospf6_metric_routemap_cmd,       "redistribute ospf6 metric <0-16> route-map WORD",       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_OSPF6, atoi (argv[0]));  ripng_redistribute_routemap_set (ZEBRA_ROUTE_OSPF6, argv[1]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_OSPF6);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_ospf6,       no_ripng_redistribute_ospf6_metric_routemap_cmd,       "no redistribute ospf6 metric <0-16> route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "IPv6 Open Shortest Path First (OSPFv3)\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n");DEFUN (ripng_redistribute_bgp_metric_routemap,       ripng_redistribute_bgp_metric_routemap_cmd,       "redistribute bgp metric <0-16> route-map WORD",       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n"){  ripng_redistribute_metric_set (ZEBRA_ROUTE_BGP, atoi (argv[0]));  ripng_redistribute_routemap_set (ZEBRA_ROUTE_BGP, argv[1]);  zclient_redistribute_set (zclient, ZEBRA_ROUTE_BGP);  return CMD_SUCCESS;}ALIAS (no_ripng_redistribute_bgp,       no_ripng_redistribute_bgp_metric_routemap_cmd,       "no redistribute bgp metric <0-16> route-map WORD",       NO_STR       "Redistribute information from another routing protocol\n"       "Border Gateway Protocol (BGP)\n"       "Metric\n"       "Metric value\n"       "Route map reference\n"       "Pointer to route-map entries\n");voidripng_redistribute_write (struct vty *vty){  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 (ripng->route_map[i].metric_config)	  {	    if (ripng->route_map[i].name)	      vty_out (vty, " redistribute %s metric %d route-map %s%s",		       str[i], ripng->route_map[i].metric,		       ripng->route_map[i].name, VTY_NEWLINE);	    else	      vty_out (vty, " redistribute %s metric %d%s",		       str[i], ripng->route_map[i].metric, VTY_NEWLINE);	  }	else	  {	    if (ripng->route_map[i].name)	      vty_out (vty, " redistribute %s route-map %s%s",		       str[i], ripng->route_map[i].name, VTY_NEWLINE);	    else	      vty_out (vty, " redistribute %s%s", str[i], VTY_NEWLINE);	  }      }}/* RIPng configuration write function. */intzebra_config_write (struct vty *vty){  if (! zclient->enable)    {      vty_out (vty, "no router zebra%s", VTY_NEWLINE);      return 1;    }  else if (! zclient->redist[ZEBRA_ROUTE_RIPNG])    {      vty_out (vty, "router zebra%s", VTY_NEWLINE);      vty_out (vty, " no redistribute ripng%s", VTY_NEWLINE);      return 1;    }  return 0;}/* Zebra node structure. */struct cmd_node zebra_node ={  ZEBRA_NODE,  "%s(config-router)# ",};/* Initialize zebra structure and it's commands. */voidzebra_init (){  /* Allocate zebra structure. */  zclient = zclient_new ();  zclient_init (zclient, ZEBRA_ROUTE_RIPNG);  zclient->interface_up = ripng_interface_up;  zclient->interface_down = ripng_interface_down;  zclient->interface_add = ripng_interface_add;  zclient->interface_delete = ripng_interface_delete;  zclient->interface_address_add = ripng_interface_address_add;  zclient->interface_address_delete = ripng_interface_address_delete;  zclient->ipv6_route_add = ripng_zebra_read_ipv6;  zclient->ipv6_route_delete = ripng_zebra_read_ipv6;    /* Install zebra node. */  install_node (&zebra_node, zebra_config_write);  /* Install command element for 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, &ripng_redistribute_ripng_cmd);  install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_static_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_static_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_kernel_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_kernel_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_connected_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_connected_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_bgp_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_bgp_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_ospf6_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_ospf6_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_kernel_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_kernel_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_kernel_metric_val_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_connected_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_connected_metric_cmd);  install_element (RIPNG_NODE,		   &no_ripng_redistribute_connected_metric_val_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_static_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_static_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_static_metric_val_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_ospf6_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_ospf6_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_ospf6_metric_val_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_bgp_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_bgp_metric_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_bgp_metric_val_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_kernel_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_kernel_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_connected_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_connected_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_static_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_static_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_ospf6_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_ospf6_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_bgp_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_bgp_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_kernel_metric_routemap_cmd);  install_element (RIPNG_NODE,		   &no_ripng_redistribute_kernel_metric_routemap_cmd);  install_element (RIPNG_NODE,		   &ripng_redistribute_connected_metric_routemap_cmd);  install_element (RIPNG_NODE,		   &no_ripng_redistribute_connected_metric_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_static_metric_routemap_cmd);  install_element (RIPNG_NODE,		   &no_ripng_redistribute_static_metric_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_ospf6_metric_routemap_cmd);  install_element (RIPNG_NODE,		   &no_ripng_redistribute_ospf6_metric_routemap_cmd);  install_element (RIPNG_NODE, &ripng_redistribute_bgp_metric_routemap_cmd);  install_element (RIPNG_NODE, &no_ripng_redistribute_bgp_metric_routemap_cmd);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -