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

📄 bgp_vty.c

📁 linux 路由软件 可支持RIP OSPF BGP等
💻 C
📖 第 1 页 / 共 5 页
字号:
/* "bgp log-neighbor-changes" configuration.  */DEFUN (bgp_log_neighbor_changes,       bgp_log_neighbor_changes_cmd,       "bgp log-neighbor-changes",       "BGP specific commands\n"       "Log neighbor up/down and reset reason\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);  return CMD_SUCCESS;}DEFUN (no_bgp_log_neighbor_changes,       no_bgp_log_neighbor_changes_cmd,       "no bgp log-neighbor-changes",       NO_STR       "BGP specific commands\n"       "Log neighbor up/down and reset reason\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);  return CMD_SUCCESS;}/* "bgp bestpath med" configuration. */DEFUN (bgp_bestpath_med,       bgp_bestpath_med_cmd,       "bgp bestpath med (confed|missing-as-worst)",       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Compare MED among confederation paths\n"       "Treat missing MED as the least preferred one\n"){  struct bgp *bgp;    bgp = vty->index;  if (strncmp (argv[0], "confed", 1) == 0)    bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);  else    bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);  return CMD_SUCCESS;}DEFUN (bgp_bestpath_med2,       bgp_bestpath_med2_cmd,       "bgp bestpath med confed missing-as-worst",       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Compare MED among confederation paths\n"       "Treat missing MED as the least preferred one\n"){  struct bgp *bgp;    bgp = vty->index;  bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);  bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);  return CMD_SUCCESS;}ALIAS (bgp_bestpath_med2,       bgp_bestpath_med3_cmd,       "bgp bestpath med missing-as-worst confed",       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Treat missing MED as the least preferred one\n"       "Compare MED among confederation paths\n");DEFUN (no_bgp_bestpath_med,       no_bgp_bestpath_med_cmd,       "no bgp bestpath med (confed|missing-as-worst)",       NO_STR       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Compare MED among confederation paths\n"       "Treat missing MED as the least preferred one\n"){  struct bgp *bgp;  bgp = vty->index;    if (strncmp (argv[0], "confed", 1) == 0)    bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);  else    bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);  return CMD_SUCCESS;}DEFUN (no_bgp_bestpath_med2,       no_bgp_bestpath_med2_cmd,       "no bgp bestpath med confed missing-as-worst",       NO_STR       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Compare MED among confederation paths\n"       "Treat missing MED as the least preferred one\n"){  struct bgp *bgp;    bgp = vty->index;  bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);  bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);  return CMD_SUCCESS;}ALIAS (no_bgp_bestpath_med2,       no_bgp_bestpath_med3_cmd,       "no bgp bestpath med missing-as-worst confed",       NO_STR       "BGP specific commands\n"       "Change the default bestpath selection\n"       "MED attribute\n"       "Treat missing MED as the least preferred one\n"       "Compare MED among confederation paths\n");/* "no bgp default ipv4-unicast". */DEFUN (no_bgp_default_ipv4_unicast,       no_bgp_default_ipv4_unicast_cmd,       "no bgp default ipv4-unicast",       NO_STR       "BGP specific commands\n"       "Configure BGP defaults\n"       "Activate ipv4-unicast for a peer by default\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);  return CMD_SUCCESS;}DEFUN (bgp_default_ipv4_unicast,       bgp_default_ipv4_unicast_cmd,       "bgp default ipv4-unicast",       "BGP specific commands\n"       "Configure BGP defaults\n"       "Activate ipv4-unicast for a peer by default\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);  return CMD_SUCCESS;}/* "bgp import-check" configuration.  */DEFUN (bgp_network_import_check,       bgp_network_import_check_cmd,       "bgp network import-check",       "BGP specific commands\n"       "BGP network command\n"       "Check BGP network route exists in IGP\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);  return CMD_SUCCESS;}DEFUN (no_bgp_network_import_check,       no_bgp_network_import_check_cmd,       "no bgp network import-check",       NO_STR       "BGP specific commands\n"       "BGP network command\n"       "Check BGP network route exists in IGP\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);  return CMD_SUCCESS;}DEFUN (bgp_default_local_preference,       bgp_default_local_preference_cmd,       "bgp default local-preference <0-4294967295>",       "BGP specific commands\n"       "Configure BGP defaults\n"       "local preference (higher=more preferred)\n"       "Configure default local preference value\n"){  struct bgp *bgp;  u_int32_t local_pref;  bgp = vty->index;  VTY_GET_INTEGER ("local preference", local_pref, argv[0]);  bgp_default_local_preference_set (bgp, local_pref);  return CMD_SUCCESS;}DEFUN (no_bgp_default_local_preference,       no_bgp_default_local_preference_cmd,       "no bgp default local-preference",       NO_STR       "BGP specific commands\n"       "Configure BGP defaults\n"       "local preference (higher=more preferred)\n"){  struct bgp *bgp;  bgp = vty->index;  bgp_default_local_preference_unset (bgp);  return CMD_SUCCESS;}ALIAS (no_bgp_default_local_preference,       no_bgp_default_local_preference_val_cmd,       "no bgp default local-preference <0-4294967295>",       NO_STR       "BGP specific commands\n"       "Configure BGP defaults\n"       "local preference (higher=more preferred)\n"       "Configure default local preference value\n");static intpeer_remote_as_vty (struct vty *vty, char *peer_str, char *as_str, afi_t afi,		    safi_t safi){  int ret;  struct bgp *bgp;  as_t as;  union sockunion su;  bgp = vty->index;  /* Get AS number.  */  VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, 65535);  /* If peer is peer group, call proper function.  */  ret = str2sockunion (peer_str, &su);  if (ret < 0)    {      ret = peer_group_remote_as (bgp, peer_str, &as);      if (ret < 0)	{	  vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);	  return CMD_WARNING;	}      return CMD_SUCCESS;    }  if (peer_address_self_check (&su))    {      vty_out (vty, "%% Can not configure the local system as neighbor%s",	       VTY_NEWLINE);      return CMD_WARNING;    }  ret = peer_remote_as (bgp, &su, &as, afi, safi);  /* This peer belongs to peer group.  */  switch (ret)    {    case BGP_ERR_PEER_GROUP_MEMBER:      vty_out (vty, "%% Peer-group AS %d. Cannot configure remote-as for member%s", as, VTY_NEWLINE);      return CMD_WARNING;      break;    case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:      vty_out (vty, "%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);      return CMD_WARNING;      break;    }  return bgp_vty_return (vty, ret);}DEFUN (neighbor_remote_as,       neighbor_remote_as_cmd,       NEIGHBOR_CMD2 "remote-as <1-65535>",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a BGP neighbor\n"       AS_STR){  return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);}DEFUN (neighbor_peer_group,       neighbor_peer_group_cmd,       "neighbor WORD peer-group",       NEIGHBOR_STR       "Neighbor tag\n"       "Configure peer-group\n"){  struct bgp *bgp;  struct peer_group *group;  bgp = vty->index;  group = peer_group_get (bgp, argv[0]);  if (! group)    return CMD_WARNING;  return CMD_SUCCESS;}DEFUN (no_neighbor,       no_neighbor_cmd,       NO_NEIGHBOR_CMD2,       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2){  int ret;  union sockunion su;  struct peer_group *group;  struct peer *peer;  ret = str2sockunion (argv[0], &su);  if (ret < 0)    {      group = peer_group_lookup (vty->index, argv[0]);      if (group)	peer_group_delete (group);      else	{	  vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);	  return CMD_WARNING;	}    }  else    {      peer = peer_lookup (vty->index, &su);      if (peer)	peer_delete (peer);    }  return CMD_SUCCESS;}ALIAS (no_neighbor,       no_neighbor_remote_as_cmd,       NO_NEIGHBOR_CMD "remote-as <1-65535>",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR       "Specify a BGP neighbor\n"       AS_STR);DEFUN (no_neighbor_peer_group,       no_neighbor_peer_group_cmd,       "no neighbor WORD peer-group",       NO_STR       NEIGHBOR_STR       "Neighbor tag\n"       "Configure peer-group\n"){  struct peer_group *group;  group = peer_group_lookup (vty->index, argv[0]);  if (group)    peer_group_delete (group);  else    {      vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);      return CMD_WARNING;    }  return CMD_SUCCESS;}DEFUN (no_neighbor_peer_group_remote_as,       no_neighbor_peer_group_remote_as_cmd,       "no neighbor WORD remote-as <1-65535>",       NO_STR       NEIGHBOR_STR       "Neighbor tag\n"       "Specify a BGP neighbor\n"       AS_STR){  struct peer_group *group;  group = peer_group_lookup (vty->index, argv[0]);  if (group)    peer_group_remote_as_delete (group);  else    {      vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);      return CMD_WARNING;    }  return CMD_SUCCESS;}DEFUN (neighbor_local_as,       neighbor_local_as_cmd,       NEIGHBOR_CMD2 "local-as <1-65535>",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a local-as number\n"       "AS number used as local AS\n"){  struct peer *peer;  int ret;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  ret = peer_local_as_set (peer, atoi (argv[1]), 0);  return bgp_vty_return (vty, ret);}DEFUN (neighbor_local_as_no_prepend,       neighbor_local_as_no_prepend_cmd,       NEIGHBOR_CMD2 "local-as <1-65535> no-prepend",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a local-as number\n"       "AS number used as local AS\n"       "Do not prepend local-as to updates from ebgp peers\n"){  struct peer *peer;  int ret;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  ret = peer_local_as_set (peer, atoi (argv[1]), 1);  return bgp_vty_return (vty, ret);}DEFUN (no_neighbor_local_as,       no_neighbor_local_as_cmd,       NO_NEIGHBOR_CMD2 "local-as",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a local-as number\n"){  struct peer *peer;  int ret;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  ret = peer_local_as_unset (peer);  return bgp_vty_return (vty, ret);}ALIAS (no_neighbor_local_as,       no_neighbor_local_as_val_cmd,       NO_NEIGHBOR_CMD2 "local-as <1-65535>",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a local-as number\n"       "AS number used as local AS\n");ALIAS (no_neighbor_local_as,       no_neighbor_local_as_val2_cmd,       NO_NEIGHBOR_CMD2 "local-as <1-65535> no-prepend",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Specify a local-as number\n"       "AS number used as local AS\n"       "Do not prepend local-as to updates from ebgp peers\n");#ifdef HAVE_TCP_SIGNATUREDEFUN (neighbor_password,       neighbor_password_cmd,       NEIGHBOR_CMD2 "password LINE",       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2       "Set a password\n"       "The password\n"){  struct peer *peer;  int ret;  peer = peer_and_group_lookup_vty (vty, argv[0]);  if (! peer)    return CMD_WARNING;  ret = peer_password_set (peer, argv[1]);  return bgp_vty_return (vty, ret);}DEFUN (no_neighbor_password,       no_neighbor_password_cmd,       NO_NEIGHBOR_CMD2 "password",       NO_STR       NEIGHBOR_STR       NEIGHBOR_ADDR_STR2

⌨️ 快捷键说明

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