📄 bgp_vty.c
字号:
"Set a password\n"){ struct peer *peer; int ret; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; ret = peer_password_unset (peer); return bgp_vty_return (vty, ret);}#endif /* HAVE_TCP_SIGNATURE */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 trasport connection-mode. */DEFUN (neighbor_transport_connection_mode, neighbor_transport_connection_mode_cmd, NEIGHBOR_CMD2 "transport connection-mode (active|passive)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Transport options\n" "Specify passive or active connection\n" "Actively establish the TCP session\n" "Passively establish the TCP session\n"){ int ret; if (strncmp (argv[1], "a", 1) == 0) { ret = peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_PASSIVE); if (ret == CMD_SUCCESS) return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_ACTIVE); else return CMD_WARNING; } else if (strncmp (argv[1], "p", 1) == 0) { ret = peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_ACTIVE); if (ret == CMD_SUCCESS) return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_PASSIVE); else return CMD_WARNING; } else return CMD_WARNING;}DEFUN (no_neighbor_transport_connection_mode, no_neighbor_transport_connection_mode_cmd, NO_NEIGHBOR_CMD2 "transport connection-mode", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Transport options\n" "Specify passive or active connection\n"){ int ret; ret = peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_PASSIVE); if (ret == CMD_SUCCESS) return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_ACTIVE); else return CMD_WARNING;}ALIAS (no_neighbor_transport_connection_mode, no_neighbor_transport_connection_mode_val_cmd, NO_NEIGHBOR_CMD2 "transport connection-mode (active|passive)", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Transport options\n" "Specify passive or active connection\n" "Actively establish the TCP session\n" "Passively establish the TCP session\n")DEFUN (neighbor_passive, neighbor_passive_cmd, NEIGHBOR_CMD2 "passive", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Don't send open messages to this neighbor\n"){ int ret; ret = peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_ACTIVE); if (ret == CMD_SUCCESS) return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CONNECT_MODE_PASSIVE); else return CMD_WARNING;}/* neighbor shutdown. */DEFUN (neighbor_shutdown, neighbor_shutdown_cmd, NEIGHBOR_CMD2 "shutdown", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n"){ return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);}DEFUN (no_neighbor_shutdown, no_neighbor_shutdown_cmd, NO_NEIGHBOR_CMD2 "shutdown", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n"){ return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);}/* neighbor capability dynamic. */DEFUN (neighbor_capability_dynamic, neighbor_capability_dynamic_cmd, NEIGHBOR_CMD2 "capability dynamic", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n"){ return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);}DEFUN (no_neighbor_capability_dynamic, no_neighbor_capability_dynamic_cmd, NO_NEIGHBOR_CMD2 "capability dynamic", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise dynamic capability to this neighbor\n"){ return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);}/* neighbor dont-capability-negotiate */DEFUN (neighbor_dont_capability_negotiate, neighbor_dont_capability_negotiate_cmd, NEIGHBOR_CMD2 "dont-capability-negotiate", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n"){ return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);}DEFUN (no_neighbor_dont_capability_negotiate, no_neighbor_dont_capability_negotiate_cmd, NO_NEIGHBOR_CMD2 "dont-capability-negotiate", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Do not perform capability negotiation\n"){ return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);}intpeer_af_flag_modify_vty (struct vty *vty, char *peer_str, afi_t afi, safi_t safi, u_int16_t flag, 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_af_flag_set (peer, afi, safi, flag); else ret = peer_af_flag_unset (peer, afi, safi, flag); return bgp_vty_return (vty, ret);}intpeer_af_flag_set_vty (struct vty *vty, char *peer_str, afi_t afi, safi_t safi, u_int16_t flag){ return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);}intpeer_af_flag_unset_vty (struct vty *vty, char *peer_str, afi_t afi, safi_t safi, u_int16_t flag){ return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);}/* neighbor capability orf prefix-list. */DEFUN (neighbor_capability_orf_prefix, neighbor_capability_orf_prefix_cmd, NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise ORF capability to the peer\n" "Advertise prefixlist ORF capability to this neighbor\n" "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n"){ u_int16_t flag = 0; if (strncmp (argv[1], "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; else if (strncmp (argv[1], "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; else if (strncmp (argv[1], "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), flag);}DEFUN (no_neighbor_capability_orf_prefix, no_neighbor_capability_orf_prefix_cmd, NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Advertise capability to the peer\n" "Advertise ORF capability to the peer\n" "Advertise prefixlist ORF capability to this neighbor\n" "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" "Capability to RECEIVE the ORF from this neighbor\n" "Capability to SEND the ORF to this neighbor\n"){ u_int16_t flag = 0; if (strncmp (argv[1], "s", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM; else if (strncmp (argv[1], "r", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_RM; else if (strncmp (argv[1], "b", 1) == 0) flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; else return CMD_WARNING; return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), flag);}/* neighbor next-hop-self. */DEFUN (neighbor_nexthop_self, neighbor_nexthop_self_cmd, NEIGHBOR_CMD2 "next-hop-self", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n"){ return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);}DEFUN (no_neighbor_nexthop_self, no_neighbor_nexthop_self_cmd, NO_NEIGHBOR_CMD2 "next-hop-self", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Disable the next hop calculation for this neighbor\n"){ return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);}/* neighbor remove-private-AS. */DEFUN (neighbor_remove_private_as, neighbor_remove_private_as_cmd, NEIGHBOR_CMD2 "remove-private-AS", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private AS number from outbound updates\n"){ return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS);}DEFUN (no_neighbor_remove_private_as, no_neighbor_remove_private_as_cmd, NO_NEIGHBOR_CMD2 "remove-private-AS", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private AS number from outbound updates\n"){ return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_REMOVE_PRIVATE_AS);}/* neighbor send-community. */DEFUN (neighbor_send_community, neighbor_send_community_cmd, NEIGHBOR_CMD2 "send-community", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n"){ return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY);}DEFUN (no_neighbor_send_community, no_neighbor_send_community_cmd, NO_NEIGHBOR_CMD2 "send-community", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n"){ return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY);}/* neighbor send-community extended. */DEFUN (neighbor_send_community_type, neighbor_send_community_type_cmd, NEIGHBOR_CMD2 "send-community (both|extended|standard)", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Send Community attribute to this neighbor\n" "Send Standard and Extended Community attributes\n" "Send Extended Community attributes\n" "Send Standard Community attributes\n"){ if (strncmp (argv[1], "s", 1) == 0) return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_COMMUNITY); if (strncmp (argv[1], "e", 1) == 0) return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), PEER_FLAG_SEND_EXT_COMMUNITY); return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_SEND_COMMUNITY| PEER_FLAG_SEND_EXT_COMMUNITY));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -