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

📄 bgp_vty.c

📁 大名鼎鼎的路由器源码。程序分ZEBRA、OSPFRIP等3个包。程序框架采用一个路由协议一个进程的方式
💻 C
📖 第 1 页 / 共 5 页
字号:
{  u_int16_t flags = PEER_FLAG_MED_UNCHANGED;  if (strncmp (argv[1], "as-path", 1) == 0)    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);  else if (strncmp (argv[1], "next-hop", 1) == 0)    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),			       bgp_node_safi (vty), flags);}ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged5_cmd,       NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Nexthop attribute\n"       "Med attribute\n");ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged6_cmd,       NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Med attribute\n"       "Nexthop attribute\n");ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged7_cmd,       NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Nexthop attribute\n"       "Med attribute\n"       "As-path attribute\n");ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged8_cmd,       NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Nexthop attribute\n"       "As-path attribute\n"       "Med attribute\n");ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged9_cmd,       NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Med attribute\n"       "Nexthop attribute\n"       "As-path attribute\n");ALIAS (neighbor_attr_unchanged,       neighbor_attr_unchanged10_cmd,       NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Med attribute\n"       "As-path attribute\n"       "Nexthop attribute\n");DEFUN (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged",       NO_STR	        NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"){  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),				 bgp_node_safi (vty),				 (PEER_FLAG_AS_PATH_UNCHANGED |				  PEER_FLAG_NEXTHOP_UNCHANGED |				  PEER_FLAG_MED_UNCHANGED));}DEFUN (no_neighbor_attr_unchanged1,       no_neighbor_attr_unchanged1_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Nexthop attribute\n"       "Med attribute\n"){  u_int16_t flags = 0;  if (strncmp (argv[1], "as-path", 1) == 0)    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);  else if (strncmp (argv[1], "next-hop", 1) == 0)    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);  else if (strncmp (argv[1], "med", 1) == 0)    SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),				 bgp_node_safi (vty), flags);}DEFUN (no_neighbor_attr_unchanged2,       no_neighbor_attr_unchanged2_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Nexthop attribute\n"       "Med attribute\n"){  u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;  if (strncmp (argv[1], "next-hop", 1) == 0)    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);  else if (strncmp (argv[1], "med", 1) == 0)    SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),				 bgp_node_safi (vty), flags);}DEFUN (no_neighbor_attr_unchanged3,       no_neighbor_attr_unchanged3_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Nexthop attribute\n"       "As-path attribute\n"       "Med attribute\n"){  u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;  if (strncmp (argv[1], "as-path", 1) == 0)    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);  else if (strncmp (argv[1], "med", 1) == 0)    SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),				 bgp_node_safi (vty), flags);}DEFUN (no_neighbor_attr_unchanged4,       no_neighbor_attr_unchanged4_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Med attribute\n"       "As-path attribute\n"       "Nexthop attribute\n"){  u_int16_t flags = PEER_FLAG_MED_UNCHANGED;  if (strncmp (argv[1], "as-path", 1) == 0)    SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);  else if (strncmp (argv[1], "next-hop", 1) == 0)    SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);  return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),				 bgp_node_safi (vty), flags);}ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged5_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Nexthop attribute\n"       "Med attribute\n");ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged6_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "As-path attribute\n"       "Med attribute\n"       "Nexthop attribute\n");ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged7_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Nexthop attribute\n"       "Med attribute\n"       "As-path attribute\n");ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged8_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Nexthop attribute\n"       "As-path attribute\n"       "Med attribute\n");ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged9_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Med attribute\n"       "Nexthop attribute\n"       "As-path attribute\n");ALIAS (no_neighbor_attr_unchanged,       no_neighbor_attr_unchanged10_cmd,       NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "BGP attribute is propagated unchanged to this neighbor\n"       "Med attribute\n"       "As-path attribute\n"       "Nexthop attribute\n");/* For old version Zebra compatibility.  */DEFUN (neighbor_transparent_as,       neighbor_transparent_as_cmd,       NEIGHBOR_CMD "transparent-as",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR       "Do not append my AS number even peer is EBGP peer\n"){  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),			       bgp_node_safi (vty),			       PEER_FLAG_AS_PATH_UNCHANGED);}DEFUN (neighbor_transparent_nexthop,       neighbor_transparent_nexthop_cmd,       NEIGHBOR_CMD "transparent-nexthop",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR       "Do not change nexthop even peer is EBGP peer\n"){  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),			       bgp_node_safi (vty),			       PEER_FLAG_NEXTHOP_UNCHANGED);}/* EBGP multihop configuration. */intpeer_ebgp_multihop_set_vty (struct vty *vty, char *ip_str, char *ttl_str){  struct peer *peer;  int ttl;  peer = peer_and_group_lookup_vty (vty, ip_str);  if (! peer)    return CMD_WARNING;  if (! ttl_str)    ttl = TTL_MAX;  else    VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);  peer_ebgp_multihop_set (peer, ttl);  return CMD_SUCCESS;}intpeer_ebgp_multihop_unset_vty (struct vty *vty, char *ip_str) {  struct peer *peer;  peer = peer_and_group_lookup_vty (vty, ip_str);  if (! peer)    return CMD_WARNING;  peer_ebgp_multihop_unset (peer);  return CMD_SUCCESS;}/* neighbor ebgp-multihop. */DEFUN (neighbor_ebgp_multihop,       neighbor_ebgp_multihop_cmd,       NEIGHBOR_CMD2 "ebgp-multihop",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Allow EBGP neighbors not on directly connected networks\n"){  return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);}DEFUN (neighbor_ebgp_multihop_ttl,       neighbor_ebgp_multihop_ttl_cmd,       NEIGHBOR_CMD2 "ebgp-multihop <1-255>",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Allow EBGP neighbors not on directly connected networks\n"       "maximum hop count\n"){  return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);}DEFUN (no_neighbor_ebgp_multihop,       no_neighbor_ebgp_multihop_cmd,       NO_NEIGHBOR_CMD2 "ebgp-multihop",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Allow EBGP neighbors not on directly connected networks\n"){  return peer_ebgp_multihop_unset_vty (vty, argv[0]);}ALIAS (no_neighbor_ebgp_multihop,       no_neighbor_ebgp_multihop_ttl_cmd,       NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Allow EBGP neighbors not on directly connected networks\n"       "maximum hop count\n");/* Enforce multihop.  */DEFUN (neighbor_enforce_multihop,       neighbor_enforce_multihop_cmd,       NEIGHBOR_CMD2 "enforce-multihop",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Enforce EBGP neighbors perform multihop\n"){  return peer_flag_set_vty (vty, argv[0], PEER_FLAG_ENFORCE_MULTIHOP);}DEFUN (no_neighbor_enforce_multihop,       no_neighbor_enforce_multihop_cmd,       NO_NEIGHBOR_CMD2 "enforce-multihop",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Enforce EBGP neighbors perform multihop\n"){  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_ENFORCE_MULTIHOP);}DEFUN (neighbor_description,       neighbor_description_cmd,       NEIGHBOR_CMD2 "description .LINE",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Neighbor specific description\n"       "Up to 80 characters describing this neighbor\n"){  struct peer *peer;  struct buffer *b;  char *str;  int i;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  if (argc == 1)    return CMD_SUCCESS;  /* Make string from buffer.  This function should be provided by     buffer.c. */  b = buffer_new (1024);  for (i = 1; i < argc; i++)    {      buffer_putstr (b, (u_char *)argv[i]);      buffer_putc (b, ' ');    }  buffer_putc (b, '\0');  str = buffer_getstr (b);  buffer_free (b);  peer_description_set (peer, str);  free (str);  return CMD_SUCCESS;}DEFUN (no_neighbor_description,       no_neighbor_description_cmd,       NO_NEIGHBOR_CMD2 "description",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Neighbor specific description\n"){  struct peer *peer;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  peer_description_unset (peer);  return CMD_SUCCESS;}ALIAS (no_neighbor_description,       no_neighbor_description_val_cmd,       NO_NEIGHBOR_CMD2 "description .LINE",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Neighbor specific description\n"       "Up to 80 characters describing this neighbor\n");/* Neighbor update-source. */intpeer_update_source_vty (struct vty *vty, char *peer_str, char *source_str){  struct peer *peer;  union sockunion *su;  peer = peer_and_group_lookup_vty (vty, peer_str);  if (! peer)    return CMD_WARNING;  if (source_str)    {      su = sockunion_str2su (source_str);      if (su)	{	  peer_update_source_addr_set (peer, su);	  sockunion_free (su);	}      else	peer_update_source_if_set (peer, source_str);    }  else    peer_update_source_unset (peer);  return CMD_SUCCESS;}DEFUN (neighbor_update_source,       neighbor_update_source_cmd,       NEIGHBOR_CMD2 "update-source WORD",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Source of routing updates\n"       "Interface name\n"){  return peer_update_source_vty (vty, argv[0], argv[1]);}DEFUN (no_neighbor_update_source,       no_neighbor_update_source_cmd,       NO_NEIGHBOR_CMD2 "update-source",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Source of routing updates\n"       "Interface name\n"){  return peer_update_source_vty (vty, argv[0], NULL);}intpeer_default_originate_set_vty (struct vty *vty, char *peer_str, afi_t afi,				safi_t safi, char *rmap, int set){  int ret;  struct peer *peer;  peer = peer_and_group_lookup_vty (vty, peer_str);  if (! peer)    return CMD_WARNING;  if (set)    ret = peer_default_originate_set (peer, afi, safi, rmap);  else    ret = peer_defaul

⌨️ 快捷键说明

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