📄 bgp_vty.c
字号:
/* "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");DEFUN (neighbor_activate, neighbor_activate_cmd, NEIGHBOR_CMD2 "activate", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n"){ struct peer *peer; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); return CMD_SUCCESS;}DEFUN (no_neighbor_activate, no_neighbor_activate_cmd, NO_NEIGHBOR_CMD2 "activate", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Enable the Address Family for this Neighbor\n"){ int ret; struct peer *peer; /* Lookup peer. */ peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); return bgp_vty_return (vty, ret);}DEFUN (neighbor_set_peer_group, neighbor_set_peer_group_cmd, NEIGHBOR_CMD "peer-group WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR "Member of the peer-group\n" "peer-group name\n"){ int ret; as_t as; union sockunion su; struct bgp *bgp; struct peer_group *group; bgp = vty->index; ret = str2sockunion (argv[0], &su); if (ret < 0) { vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } group = peer_group_lookup (bgp, argv[1]); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); return CMD_WARNING; } 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_group_bind (bgp, &su, group, bgp_node_afi (vty), bgp_node_safi (vty), &as); if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { vty_out (vty, "%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE); return CMD_WARNING; } return bgp_vty_return (vty, ret);}DEFUN (no_neighbor_set_peer_group, no_neighbor_set_peer_group_cmd, NO_NEIGHBOR_CMD "peer-group WORD", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR "Member of the peer-group\n" "peer-group name\n"){ int ret; struct bgp *bgp; struct peer *peer; struct peer_group *group; bgp = vty->index; peer = peer_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; group = peer_group_lookup (bgp, argv[1]); if (! group) { vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); return CMD_WARNING; } ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty), bgp_node_safi (vty)); return bgp_vty_return (vty, ret);}intpeer_flag_modify_vty (struct vty *vty, char *ip_str, u_int16_t flag, int set){ int ret; struct peer *peer; peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) return CMD_WARNING; if (set) ret = peer_flag_set (peer, flag); else ret = peer_flag_unset (peer, flag); return bgp_vty_return (vty, ret);}intpeer_flag_set_vty (struct vty *vty, char *ip_str, u_int16_t flag){ return peer_flag_modify_vty (vty, ip_str, flag, 1);}intpeer_flag_unset_vty (struct vty *vty, char *ip_str, u_int16_t flag){ return peer_flag_modify_vty (vty, ip_str, flag, 0);}/* neighbor passive. */DEFUN (neighbor_passive, neighbor_passive_cmd,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -