bgp_vty.c
上传用户:xiaozhuqw
上传日期:2009-11-15
资源大小:1338k
文件大小:293k
- /* BGP VTY interface.
- Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
- This file is part of GNU Zebra.
- GNU Zebra is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
- GNU Zebra is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with GNU Zebra; see the file COPYING. If not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
- #include <zebra.h>
- #include "command.h"
- #include "prefix.h"
- #include "plist.h"
- #include "buffer.h"
- #include "linklist.h"
- #include "stream.h"
- #include "thread.h"
- #include "log.h"
- #include "bgpd/bgpd.h"
- #include "bgpd/bgp_attr.h"
- #include "bgpd/bgp_aspath.h"
- #include "bgpd/bgp_community.h"
- #include "bgpd/bgp_debug.h"
- #include "bgpd/bgp_fsm.h"
- #include "bgpd/bgp_mplsvpn.h"
- #include "bgpd/bgp_open.h"
- #include "bgpd/bgp_route.h"
- #include "bgpd/bgp_zebra.h"
- /* Utility function to get address family from current node. */
- afi_t
- bgp_node_afi (struct vty *vty)
- {
- if (vty->node == BGP_IPV6_NODE)
- return AFI_IP6;
- return AFI_IP;
- }
- /* Utility function to get subsequent address family from current
- node. */
- safi_t
- bgp_node_safi (struct vty *vty)
- {
- if (vty->node == BGP_VPNV4_NODE)
- return SAFI_MPLS_VPN;
- if (vty->node == BGP_IPV4M_NODE)
- return SAFI_MULTICAST;
- return SAFI_UNICAST;
- }
- int
- peer_address_self_check (union sockunion *su)
- {
- struct interface *ifp = NULL;
- if (su->sa.sa_family == AF_INET)
- ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
- #ifdef HAVE_IPV6
- else if (su->sa.sa_family == AF_INET6)
- ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
- #endif /* HAVE IPV6 */
- if (ifp)
- return 1;
- return 0;
- }
- /* Utility function for looking up peer from VTY. */
- struct peer *
- peer_lookup_vty (struct vty *vty, char *ip_str)
- {
- int ret;
- struct bgp *bgp;
- union sockunion su;
- struct peer *peer;
- bgp = vty->index;
- ret = str2sockunion (ip_str, &su);
- if (ret < 0)
- {
- vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
- return NULL;
- }
- peer = peer_lookup (bgp, &su);
- if (! peer)
- {
- vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
- return NULL;
- }
- return peer;
- }
- /* Utility function for looking up peer or peer group. */
- struct peer *
- peer_and_group_lookup_vty (struct vty *vty, char *peer_str)
- {
- int ret;
- struct bgp *bgp;
- union sockunion su;
- struct peer *peer;
- struct peer_group *group;
- bgp = vty->index;
- ret = str2sockunion (peer_str, &su);
- if (ret == 0)
- {
- peer = peer_lookup (bgp, &su);
- if (peer)
- return peer;
- }
- else
- {
- group = peer_group_lookup (bgp, peer_str);
- if (group)
- return group->conf;
- }
- vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
- VTY_NEWLINE);
- return NULL;
- }
- int
- bgp_vty_return (struct vty *vty, int ret)
- {
- char *str = NULL;
- switch (ret)
- {
- case BGP_ERR_INVALID_VALUE:
- str = "Invalid value";
- break;
- case BGP_ERR_INVALID_FLAG:
- str = "Invalid flag";
- break;
- case BGP_ERR_PEER_INACTIVE:
- str = "Activate the neighbor for the address family first";
- break;
- case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
- str = "Invalid command for a peer-group member";
- break;
- case BGP_ERR_PEER_GROUP_SHUTDOWN:
- str = "Peer-group has been shutdown. Activate the peer-group first";
- break;
- case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
- str = "This peer is a peer-group member. Please change peer-group configuration";
- break;
- case BGP_ERR_PEER_FLAG_CONFLICT:
- str = "Can't set override-capability and strict-capability-match at the same time";
- break;
- case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
- str = "No activate for peergroup can be given only if peer-group has no members";
- break;
- case BGP_ERR_PEER_BELONGS_TO_GROUP:
- str = "No activate for an individual peer-group member is invalid";
- break;
- case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
- str = "Activate the peer-group for the address family first";
- break;
- case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
- str = "Specify remote-as or peer-group remote AS first";
- break;
- case BGP_ERR_PEER_GROUP_CANT_CHANGE:
- str = "Cannot change the peer-group. Deconfigure first";
- break;
- case BGP_ERR_PEER_GROUP_MISMATCH:
- str = "Cannot have different peer-group for the neighbor";
- break;
- case BGP_ERR_PEER_FILTER_CONFLICT:
- str = "Prefix/distribute list can not co-exist";
- break;
- case BGP_ERR_NOT_INTERNAL_PEER:
- str = "Invalid command. Not an internal neighbor";
- break;
- case BGP_ERR_REMOVE_PRIVATE_AS:
- str = "Private AS cannot be removed for IBGP peers";
- break;
- case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
- str = "Local-AS allowed only for EBGP peers";
- break;
- case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
- str = "Cannot have local-as same as BGP AS number";
- break;
- }
- if (str)
- {
- vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- /* BGP global configuration. */
- DEFUN (bgp_multiple_instance_func,
- bgp_multiple_instance_cmd,
- "bgp multiple-instance",
- BGP_STR
- "Enable bgp multiple instancen")
- {
- bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_multiple_instance,
- no_bgp_multiple_instance_cmd,
- "no bgp multiple-instance",
- NO_STR
- BGP_STR
- "BGP multiple instancen")
- {
- int ret;
- ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
- if (ret < 0)
- {
- vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- return CMD_SUCCESS;
- }
- DEFUN (bgp_config_type,
- bgp_config_type_cmd,
- "bgp config-type (cisco|zebra)",
- BGP_STR
- "Configuration typen"
- "ciscon"
- "zebran")
- {
- if (strncmp (argv[0], "c", 1) == 0)
- bgp_option_set (BGP_OPT_CONFIG_CISCO);
- else
- bgp_option_unset (BGP_OPT_CONFIG_CISCO);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_config_type,
- no_bgp_config_type_cmd,
- "no bgp config-type",
- NO_STR
- BGP_STR
- "Display configuration typen")
- {
- bgp_option_unset (BGP_OPT_CONFIG_CISCO);
- return CMD_SUCCESS;
- }
- DEFUN (no_synchronization,
- no_synchronization_cmd,
- "no synchronization",
- NO_STR
- "Perform IGP synchronizationn")
- {
- return CMD_SUCCESS;
- }
- DEFUN (no_auto_summary,
- no_auto_summary_cmd,
- "no auto-summary",
- NO_STR
- "Enable automatic network number summarizationn")
- {
- return CMD_SUCCESS;
- }
- DEFUN (neighbor_version,
- neighbor_version_cmd,
- NEIGHBOR_CMD "version <4-4>",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Set the BGP version to match a neighborn"
- "Neighbor's BGP versionn")
- {
- return CMD_SUCCESS;
- }
- /* "router bgp" commands. */
- DEFUN (router_bgp,
- router_bgp_cmd,
- "router bgp <1-65535>",
- ROUTER_STR
- BGP_STR
- AS_STR)
- {
- int ret;
- as_t as;
- struct bgp *bgp;
- char *name = NULL;
- VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
- if (argc == 2)
- name = argv[1];
- ret = bgp_get (&bgp, &as, name);
- switch (ret)
- {
- case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
- vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- break;
- case BGP_ERR_AS_MISMATCH:
- vty_out (vty, "BGP is already running; AS is %d%s", as, VTY_NEWLINE);
- return CMD_WARNING;
- break;
- case BGP_ERR_INSTANCE_MISMATCH:
- vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
- vty_out (vty, "BGP instance is already running; AS is %d%s",
- as, VTY_NEWLINE);
- return CMD_WARNING;
- break;
- }
- vty->node = BGP_NODE;
- vty->index = bgp;
- return CMD_SUCCESS;
- }
- ALIAS (router_bgp,
- router_bgp_view_cmd,
- "router bgp <1-65535> view WORD",
- ROUTER_STR
- BGP_STR
- AS_STR
- "BGP viewn"
- "view namen");
- /* "no router bgp" commands. */
- DEFUN (no_router_bgp,
- no_router_bgp_cmd,
- "no router bgp <1-65535>",
- NO_STR
- ROUTER_STR
- BGP_STR
- AS_STR)
- {
- as_t as;
- struct bgp *bgp;
- char *name = NULL;
- VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, 65535);
- if (argc == 2)
- name = argv[1];
- /* Lookup bgp structure. */
- bgp = bgp_lookup (as, name);
- if (! bgp)
- {
- vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- bgp_delete (bgp);
- return CMD_SUCCESS;
- }
- ALIAS (no_router_bgp,
- no_router_bgp_view_cmd,
- "no router bgp <1-65535> view WORD",
- NO_STR
- ROUTER_STR
- BGP_STR
- AS_STR
- "BGP viewn"
- "view namen");
- /* BGP router-id. */
- DEFUN (bgp_router_id,
- bgp_router_id_cmd,
- "bgp router-id A.B.C.D",
- BGP_STR
- "Override configured router identifiern"
- "Manually configured router identifiern")
- {
- int ret;
- struct in_addr id;
- struct bgp *bgp;
- bgp = vty->index;
- ret = inet_aton (argv[0], &id);
- if (! ret)
- {
- vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- bgp_router_id_set (bgp, &id);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_router_id,
- no_bgp_router_id_cmd,
- "no bgp router-id",
- NO_STR
- BGP_STR
- "Override configured router identifiern")
- {
- int ret;
- struct in_addr id;
- struct bgp *bgp;
- bgp = vty->index;
- if (argc == 1)
- {
- ret = inet_aton (argv[0], &id);
- if (! ret)
- {
- vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (! IPV4_ADDR_SAME (&bgp->router_id, &id))
- {
- vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- bgp_router_id_unset (bgp);
- return CMD_SUCCESS;
- }
- ALIAS (no_bgp_router_id,
- no_bgp_router_id_val_cmd,
- "no bgp router-id A.B.C.D",
- NO_STR
- BGP_STR
- "Override configured router identifiern"
- "Manually configured router identifiern");
- /* BGP Cluster ID. */
- DEFUN (bgp_cluster_id,
- bgp_cluster_id_cmd,
- "bgp cluster-id A.B.C.D",
- BGP_STR
- "Configure Route-Reflector Cluster-idn"
- "Route-Reflector Cluster-id in IP address formatn")
- {
- int ret;
- struct bgp *bgp;
- struct in_addr cluster;
- bgp = vty->index;
- ret = inet_aton (argv[0], &cluster);
- if (! ret)
- {
- vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- bgp_cluster_id_set (bgp, &cluster);
- return CMD_SUCCESS;
- }
- ALIAS (bgp_cluster_id,
- bgp_cluster_id32_cmd,
- "bgp cluster-id <1-4294967295>",
- BGP_STR
- "Configure Route-Reflector Cluster-idn"
- "Route-Reflector Cluster-id as 32 bit quantityn");
- DEFUN (no_bgp_cluster_id,
- no_bgp_cluster_id_cmd,
- "no bgp cluster-id",
- NO_STR
- BGP_STR
- "Configure Route-Reflector Cluster-idn")
- {
- int ret;
- struct bgp *bgp;
- struct in_addr cluster;
- bgp = vty->index;
- if (argc == 1)
- {
- ret = inet_aton (argv[0], &cluster);
- if (! ret)
- {
- vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- bgp_cluster_id_unset (bgp);
- return CMD_SUCCESS;
- }
- ALIAS (no_bgp_cluster_id,
- no_bgp_cluster_id_arg_cmd,
- "no bgp cluster-id A.B.C.D",
- NO_STR
- BGP_STR
- "Configure Route-Reflector Cluster-idn"
- "Route-Reflector Cluster-id in IP address formatn");
- DEFUN (bgp_confederation_identifier,
- bgp_confederation_identifier_cmd,
- "bgp confederation identifier <1-65535>",
- "BGP specific commandsn"
- "AS confederation parametersn"
- "AS numbern"
- "Set routing domain confederation ASn")
- {
- struct bgp *bgp;
- as_t as;
- bgp = vty->index;
- VTY_GET_INTEGER ("AS", as, argv[0]);
- bgp_confederation_id_set (bgp, as);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_confederation_identifier,
- no_bgp_confederation_identifier_cmd,
- "no bgp confederation identifier",
- NO_STR
- "BGP specific commandsn"
- "AS confederation parametersn"
- "AS numbern")
- {
- struct bgp *bgp;
- as_t as;
- bgp = vty->index;
- if (argc == 1)
- VTY_GET_INTEGER ("AS", as, argv[0]);
- bgp_confederation_id_unset (bgp);
- return CMD_SUCCESS;
- }
- ALIAS (no_bgp_confederation_identifier,
- no_bgp_confederation_identifier_arg_cmd,
- "no bgp confederation identifier <1-65535>",
- NO_STR
- "BGP specific commandsn"
- "AS confederation parametersn"
- "AS numbern"
- "Set routing domain confederation ASn");
- DEFUN (bgp_confederation_peers,
- bgp_confederation_peers_cmd,
- "bgp confederation peers .<1-65535>",
- "BGP specific commandsn"
- "AS confederation parametersn"
- "Peer ASs in BGP confederationn"
- AS_STR)
- {
- struct bgp *bgp;
- as_t as;
- int i;
- bgp = vty->index;
- for (i = 0; i < argc; i++)
- {
- VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, 65535);
- if (bgp->as == as)
- {
- vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
- VTY_NEWLINE);
- continue;
- }
- bgp_confederation_peers_add (bgp, as);
- }
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_confederation_peers,
- no_bgp_confederation_peers_cmd,
- "no bgp confederation peers .<1-65535>",
- NO_STR
- "BGP specific commandsn"
- "AS confederation parametersn"
- "Peer ASs in BGP confederationn"
- AS_STR)
- {
- struct bgp *bgp;
- as_t as;
- int i;
- bgp = vty->index;
- for (i = 0; i < argc; i++)
- {
- VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, 65535);
-
- bgp_confederation_peers_remove (bgp, as);
- }
- return CMD_SUCCESS;
- }
- /* BGP timers. */
- DEFUN (bgp_timers,
- bgp_timers_cmd,
- "timers bgp <0-65535> <0-65535>",
- "Adjust routing timersn"
- "BGP timersn"
- "Keepalive intervaln"
- "Holdtimen")
- {
- struct bgp *bgp;
- unsigned long keepalive = 0;
- unsigned long holdtime = 0;
- bgp = vty->index;
- VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
- VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
- /* Holdtime value check. */
- if (holdtime < 3 && holdtime != 0)
- {
- vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- bgp_timers_set (bgp, keepalive, holdtime);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_timers,
- no_bgp_timers_cmd,
- "no timers bgp",
- NO_STR
- "Adjust routing timersn"
- "BGP timersn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_timers_unset (bgp);
- return CMD_SUCCESS;
- }
- ALIAS (no_bgp_timers,
- no_bgp_timers_arg_cmd,
- "no timers bgp <0-65535> <0-65535>",
- NO_STR
- "Adjust routing timersn"
- "BGP timersn"
- "Keepalive intervaln"
- "Holdtimen");
- DEFUN (bgp_client_to_client_reflection,
- bgp_client_to_client_reflection_cmd,
- "bgp client-to-client reflection",
- "BGP specific commandsn"
- "Configure client to client route reflectionn"
- "reflection of routes allowedn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_client_to_client_reflection,
- no_bgp_client_to_client_reflection_cmd,
- "no bgp client-to-client reflection",
- NO_STR
- "BGP specific commandsn"
- "Configure client to client route reflectionn"
- "reflection of routes allowedn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
- return CMD_SUCCESS;
- }
- /* "bgp always-compare-med" configuration. */
- DEFUN (bgp_always_compare_med,
- bgp_always_compare_med_cmd,
- "bgp always-compare-med",
- "BGP specific commandsn"
- "Allow comparing MED from different neighborsn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_always_compare_med,
- no_bgp_always_compare_med_cmd,
- "no bgp always-compare-med",
- NO_STR
- "BGP specific commandsn"
- "Allow comparing MED from different neighborsn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
- return CMD_SUCCESS;
- }
- /* "bgp deterministic-med" configuration. */
- DEFUN (bgp_deterministic_med,
- bgp_deterministic_med_cmd,
- "bgp deterministic-med",
- "BGP specific commandsn"
- "Pick the best-MED path among paths advertised from the neighboring ASn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_deterministic_med,
- no_bgp_deterministic_med_cmd,
- "no bgp deterministic-med",
- NO_STR
- "BGP specific commandsn"
- "Pick the best-MED path among paths advertised from the neighboring ASn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
- return CMD_SUCCESS;
- }
- /* "bgp graceful-restart" configuration. */
- DEFUN (bgp_graceful_restart,
- bgp_graceful_restart_cmd,
- "bgp graceful-restart",
- "BGP specific commandsn"
- "Graceful restart capability parametersn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_graceful_restart,
- no_bgp_graceful_restart_cmd,
- "no bgp graceful-restart",
- NO_STR
- "BGP specific commandsn"
- "Graceful restart capability parametersn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
- return CMD_SUCCESS;
- }
- DEFUN (bgp_graceful_restart_stalepath_time,
- bgp_graceful_restart_stalepath_time_cmd,
- "bgp graceful-restart stalepath-time <1-3600>",
- "BGP specific commandsn"
- "Graceful restart capability parametersn"
- "Set the max time to hold onto restarting peer's stale pathsn"
- "Delay value (seconds)n")
- {
- struct bgp *bgp;
- u_int32_t stalepath;
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
- VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
- bgp->stalepath_time = stalepath;
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_graceful_restart_stalepath_time,
- no_bgp_graceful_restart_stalepath_time_cmd,
- "no bgp graceful-restart stalepath-time",
- NO_STR
- "BGP specific commandsn"
- "Graceful restart capability parametersn"
- "Set the max time to hold onto restarting peer's stale pathsn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- if (! bgp)
- return CMD_WARNING;
- bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
- return CMD_SUCCESS;
- }
- ALIAS (no_bgp_graceful_restart_stalepath_time,
- no_bgp_graceful_restart_stalepath_time_val_cmd,
- "no bgp graceful-restart stalepath-time <1-3600>",
- NO_STR
- "BGP specific commandsn"
- "Graceful restart capability parametersn"
- "Set the max time to hold onto restarting peer's stale pathsn"
- "Delay value (seconds)n")
- /* "bgp fast-external-failover" configuration. */
- DEFUN (bgp_fast_external_failover,
- bgp_fast_external_failover_cmd,
- "bgp fast-external-failover",
- BGP_STR
- "Immediately reset session if a link to a directly connected external peer goes downn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_fast_external_failover,
- no_bgp_fast_external_failover_cmd,
- "no bgp fast-external-failover",
- NO_STR
- BGP_STR
- "Immediately reset session if a link to a directly connected external peer goes downn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
- return CMD_SUCCESS;
- }
- /* "bgp enforce-first-as" configuration. */
- DEFUN (bgp_enforce_first_as,
- bgp_enforce_first_as_cmd,
- "bgp enforce-first-as",
- BGP_STR
- "Enforce the first AS for EBGP routes(default)n")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_NO_ENFORCE_FIRST_AS);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_enforce_first_as,
- no_bgp_enforce_first_as_cmd,
- "no bgp enforce-first-as",
- NO_STR
- BGP_STR
- "Enforce the first AS for EBGP routes(default)n")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_NO_ENFORCE_FIRST_AS);
- return CMD_SUCCESS;
- }
- /* "bgp bestpath compare-routerid" configuration. */
- DEFUN (bgp_bestpath_compare_router_id,
- bgp_bestpath_compare_router_id_cmd,
- "bgp bestpath compare-routerid",
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "Compare router-id for identical EBGP pathsn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_bestpath_compare_router_id,
- no_bgp_bestpath_compare_router_id_cmd,
- "no bgp bestpath compare-routerid",
- NO_STR
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "Compare router-id for identical EBGP pathsn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
- return CMD_SUCCESS;
- }
- /* "bgp bestpath cost-community ignore" configuration. */
- DEFUN (bgp_bestpath_cost_community_ignore,
- bgp_bestpath_cost_community_ignore_cmd,
- "bgp bestpath cost-community ignore",
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "cost communityn"
- "Ignore cost communities in bestpath selectionn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_COST_COMMUNITY_IGNORE);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_bestpath_cost_community_ignore,
- no_bgp_bestpath_cost_community_ignore_cmd,
- "no bgp bestpath cost-community ignore",
- NO_STR
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "cost communityn"
- "Ignore cost communities in bestpath selectionn")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_COST_COMMUNITY_IGNORE);
- return CMD_SUCCESS;
- }
- /* "bgp bestpath as-path ignore" configuration. */
- DEFUN (bgp_bestpath_aspath_ignore,
- bgp_bestpath_aspath_ignore_cmd,
- "bgp bestpath as-path ignore",
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "AS-path attributen"
- "Ignore as-path length in selecting a routen")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
- return CMD_SUCCESS;
- }
- DEFUN (no_bgp_bestpath_aspath_ignore,
- no_bgp_bestpath_aspath_ignore_cmd,
- "no bgp bestpath as-path ignore",
- NO_STR
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "AS-path attributen"
- "Ignore as-path length in selecting a routen")
- {
- struct bgp *bgp;
- bgp = vty->index;
- bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
- return CMD_SUCCESS;
- }
- /* "bgp log-neighbor-changes" configuration. */
- DEFUN (bgp_log_neighbor_changes,
- bgp_log_neighbor_changes_cmd,
- "bgp log-neighbor-changes",
- "BGP specific commandsn"
- "Log neighbor up/down and reset reasonn")
- {
- 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 commandsn"
- "Log neighbor up/down and reset reasonn")
- {
- 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 commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Compare MED among confederation pathsn"
- "Treat missing MED as the least preferred onen")
- {
- 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 commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Compare MED among confederation pathsn"
- "Treat missing MED as the least preferred onen")
- {
- 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 commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Treat missing MED as the least preferred onen"
- "Compare MED among confederation pathsn");
- DEFUN (no_bgp_bestpath_med,
- no_bgp_bestpath_med_cmd,
- "no bgp bestpath med (confed|missing-as-worst)",
- NO_STR
- "BGP specific commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Compare MED among confederation pathsn"
- "Treat missing MED as the least preferred onen")
- {
- 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 commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Compare MED among confederation pathsn"
- "Treat missing MED as the least preferred onen")
- {
- 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 commandsn"
- "Change the default bestpath selectionn"
- "MED attributen"
- "Treat missing MED as the least preferred onen"
- "Compare MED among confederation pathsn");
- /* "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 commandsn"
- "Configure BGP defaultsn"
- "Activate ipv4-unicast for a peer by defaultn")
- {
- 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 commandsn"
- "Configure BGP defaultsn"
- "Activate ipv4-unicast for a peer by defaultn")
- {
- 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 commandsn"
- "BGP network commandn"
- "Check BGP network route exists in IGPn")
- {
- 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 commandsn"
- "BGP network commandn"
- "Check BGP network route exists in IGPn")
- {
- 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 commandsn"
- "Configure BGP defaultsn"
- "local preference (higher=more preferred)n"
- "Configure default local preference valuen")
- {
- 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 commandsn"
- "Configure BGP defaultsn"
- "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 commandsn"
- "Configure BGP defaultsn"
- "local preference (higher=more preferred)n"
- "Configure default local preference valuen");
- static int
- peer_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 neighborn"
- 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 tagn"
- "Configure peer-groupn")
- {
- 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 neighborn"
- AS_STR);
- DEFUN (no_neighbor_peer_group,
- no_neighbor_peer_group_cmd,
- "no neighbor WORD peer-group",
- NO_STR
- NEIGHBOR_STR
- "Neighbor tagn"
- "Configure peer-groupn")
- {
- 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 tagn"
- "Specify a BGP neighborn"
- 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 numbern"
- "AS number used as local ASn")
- {
- 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 numbern"
- "AS number used as local ASn"
- "Do not prepend local-as to updates from ebgp peersn")
- {
- 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 numbern")
- {
- 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 numbern"
- "AS number used as local ASn");
- 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 numbern"
- "AS number used as local ASn"
- "Do not prepend local-as to updates from ebgp peersn");
- #ifdef HAVE_TCP_SIGNATURE
- DEFUN (neighbor_password,
- neighbor_password_cmd,
- NEIGHBOR_CMD2 "password LINE",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Set a passwordn"
- "The passwordn")
- {
- 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
- "Set a passwordn")
- {
- 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 Neighborn")
- {
- 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 Neighborn")
- {
- 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-groupn"
- "peer-group namen")
- {
- 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-groupn"
- "peer-group namen")
- {
- 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);
- }
- int
- peer_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);
- }
- int
- peer_flag_set_vty (struct vty *vty, char *ip_str, u_int16_t flag)
- {
- return peer_flag_modify_vty (vty, ip_str, flag, 1);
- }
- int
- peer_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 optionsn"
- "Specify passive or active connectionn"
- "Actively establish the TCP sessionn"
- "Passively establish the TCP sessionn")
- {
- 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 optionsn"
- "Specify passive or active connectionn")
- {
- 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 optionsn"
- "Specify passive or active connectionn"
- "Actively establish the TCP sessionn"
- "Passively establish the TCP sessionn")
- DEFUN (neighbor_passive,
- neighbor_passive_cmd,
- NEIGHBOR_CMD2 "passive",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Don't send open messages to this neighborn")
- {
- 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 neighborn")
- {
- 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 neighborn")
- {
- 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 peern"
- "Advertise dynamic capability to this neighborn")
- {
- 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 peern"
- "Advertise dynamic capability to this neighborn")
- {
- 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 negotiationn")
- {
- 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 negotiationn")
- {
- return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
- }
- int
- peer_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);
- }
- int
- peer_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);
- }
- int
- peer_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 peern"
- "Advertise ORF capability to the peern"
- "Advertise prefixlist ORF capability to this neighborn"
- "Capability to SEND and RECEIVE the ORF to/from this neighborn"
- "Capability to RECEIVE the ORF from this neighborn"
- "Capability to SEND the ORF to this neighborn")
- {
- 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 peern"
- "Advertise ORF capability to the peern"
- "Advertise prefixlist ORF capability to this neighborn"
- "Capability to SEND and RECEIVE the ORF to/from this neighborn"
- "Capability to RECEIVE the ORF from this neighborn"
- "Capability to SEND the ORF to this neighborn")
- {
- 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 neighborn")
- {
- 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 neighborn")
- {
- 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 updatesn")
- {
- 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 updatesn")
- {
- 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 neighborn")
- {
- 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 neighborn")
- {
- 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 neighborn"
- "Send Standard and Extended Community attributesn"
- "Send Extended Community attributesn"
- "Send Standard Community attributesn")
- {
- 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));
- }
- DEFUN (no_neighbor_send_community_type,
- no_neighbor_send_community_type_cmd,
- NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Send Community attribute to this neighborn"
- "Send Standard and Extended Community attributesn"
- "Send Extended Community attributesn"
- "Send Standard Community attributesn")
- {
- if (strncmp (argv[1], "s", 1) == 0)
- return peer_af_flag_unset_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_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- PEER_FLAG_SEND_EXT_COMMUNITY);
- return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- (PEER_FLAG_SEND_COMMUNITY |
- PEER_FLAG_SEND_EXT_COMMUNITY));
- }
- /* neighbor soft-reconfig. */
- DEFUN (neighbor_soft_reconfiguration,
- neighbor_soft_reconfiguration_cmd,
- NEIGHBOR_CMD2 "soft-reconfiguration inbound",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Per neighbor soft reconfigurationn"
- "Allow inbound soft reconfiguration for this neighborn")
- {
- return peer_af_flag_set_vty (vty, argv[0],
- bgp_node_afi (vty), bgp_node_safi (vty),
- PEER_FLAG_SOFT_RECONFIG);
- }
- DEFUN (no_neighbor_soft_reconfiguration,
- no_neighbor_soft_reconfiguration_cmd,
- NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Per neighbor soft reconfigurationn"
- "Allow inbound soft reconfiguration for this neighborn")
- {
- return peer_af_flag_unset_vty (vty, argv[0],
- bgp_node_afi (vty), bgp_node_safi (vty),
- PEER_FLAG_SOFT_RECONFIG);
- }
- DEFUN (neighbor_route_reflector_client,
- neighbor_route_reflector_client_cmd,
- NEIGHBOR_CMD2 "route-reflector-client",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Configure a neighbor as Route Reflector clientn")
- {
- struct peer *peer;
- peer = peer_and_group_lookup_vty (vty, argv[0]);
- if (! peer)
- return CMD_WARNING;
- return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- PEER_FLAG_REFLECTOR_CLIENT);
- }
- DEFUN (no_neighbor_route_reflector_client,
- no_neighbor_route_reflector_client_cmd,
- NO_NEIGHBOR_CMD2 "route-reflector-client",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Configure a neighbor as Route Reflector clientn")
- {
- return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- PEER_FLAG_REFLECTOR_CLIENT);
- }
- /* neighbor route-server-client. */
- DEFUN (neighbor_route_server_client,
- neighbor_route_server_client_cmd,
- NEIGHBOR_CMD2 "route-server-client",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Configure a neighbor as Route Server clientn")
- {
- return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- PEER_FLAG_RSERVER_CLIENT);
- }
- DEFUN (no_neighbor_route_server_client,
- no_neighbor_route_server_client_cmd,
- NO_NEIGHBOR_CMD2 "route-server-client",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Configure a neighbor as Route Server clientn")
- {
- return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty),
- PEER_FLAG_RSERVER_CLIENT);
- }
- DEFUN (neighbor_attr_unchanged,
- neighbor_attr_unchanged_cmd,
- NEIGHBOR_CMD2 "attribute-unchanged",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP attribute is propagated unchanged to this neighborn")
- {
- return peer_af_flag_set_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 (neighbor_attr_unchanged1,
- neighbor_attr_unchanged1_cmd,
- NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP attribute is propagated unchanged to this neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen")
- {
- 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_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), flags);
- }
- DEFUN (neighbor_attr_unchanged2,
- neighbor_attr_unchanged2_cmd,
- NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP attribute is propagated unchanged to this neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen")
- {
- 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_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), flags);
- }
- DEFUN (neighbor_attr_unchanged3,
- neighbor_attr_unchanged3_cmd,
- NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP attribute is propagated unchanged to this neighborn"
- "Nexthop attributen"
- "As-path attributen"
- "Med attributen")
- {
- 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_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), flags);
- }
- DEFUN (neighbor_attr_unchanged4,
- neighbor_attr_unchanged4_cmd,
- NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP attribute is propagated unchanged to this neighborn"
- "Med attributen"
- "As-path attributen"
- "Nexthop attributen")
- {
- 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 neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen");
- 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 neighborn"
- "As-path attributen"
- "Med attributen"
- "Nexthop attributen");
- 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 neighborn"
- "Nexthop attributen"
- "Med attributen"
- "As-path attributen");
- 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 neighborn"
- "Nexthop attributen"
- "As-path attributen"
- "Med attributen");
- 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 neighborn"
- "Med attributen"
- "Nexthop attributen"
- "As-path attributen");
- 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 neighborn"
- "Med attributen"
- "As-path attributen"
- "Nexthop attributen");
- 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 neighborn")
- {
- 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 neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen")
- {
- 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 neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen")
- {
- 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 neighborn"
- "Nexthop attributen"
- "As-path attributen"
- "Med attributen")
- {
- 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 neighborn"
- "Med attributen"
- "As-path attributen"
- "Nexthop attributen")
- {
- 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 neighborn"
- "As-path attributen"
- "Nexthop attributen"
- "Med attributen");
- 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 neighborn"
- "As-path attributen"
- "Med attributen"
- "Nexthop attributen");
- 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 neighborn"
- "Nexthop attributen"
- "Med attributen"
- "As-path attributen");
- 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 neighborn"
- "Nexthop attributen"
- "As-path attributen"
- "Med attributen");
- 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 neighborn"
- "Med attributen"
- "Nexthop attributen"
- "As-path attributen");
- 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 neighborn"
- "Med attributen"
- "As-path attributen"
- "Nexthop attributen");
- /* EBGP multihop configuration. */
- int
- peer_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;
- }
- int
- peer_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 networksn")
- {
- 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 networksn"
- "maximum hop countn")
- {
- 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 networksn")
- {
- 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 networksn"
- "maximum hop countn");
- /* disable-connected-check */
- DEFUN (neighbor_disable_connected_check,
- neighbor_disable_connected_check_cmd,
- NEIGHBOR_CMD2 "disable-connected-check",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "one-hop away EBGP peer using loopback addressn")
- {
- return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
- }
- DEFUN (no_neighbor_disable_connected_check,
- no_neighbor_disable_connected_check_cmd,
- NO_NEIGHBOR_CMD2 "disable-connected-check",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "one-hop away EBGP peer using loopback addressn")
- {
- return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
- }
- /* Enforce multihop. */
- ALIAS (neighbor_disable_connected_check,
- neighbor_enforce_multihop_cmd,
- NEIGHBOR_CMD2 "enforce-multihop",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Enforce EBGP neighbors perform multihopn");
- DEFUN (neighbor_description,
- neighbor_description_cmd,
- NEIGHBOR_CMD2 "description .LINE",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Neighbor specific descriptionn"
- "Up to 80 characters describing this neighborn")
- {
- 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, ' ');
- 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 descriptionn")
- {
- 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 descriptionn"
- "Up to 80 characters describing this neighborn");
- /* Neighbor update-source. */
- int
- peer_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 updatesn"
- "Interface namen")
- {
- 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 updatesn"
- "Interface namen")
- {
- return peer_update_source_vty (vty, argv[0], NULL);
- }
- int
- peer_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_default_originate_unset (peer, afi, safi);
- return bgp_vty_return (vty, ret);
- }
- /* neighbor default-originate. */
- DEFUN (neighbor_default_originate,
- neighbor_default_originate_cmd,
- NEIGHBOR_CMD2 "default-originate",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Originate default route to this neighborn")
- {
- return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), NULL, 1);
- }
- DEFUN (neighbor_default_originate_rmap,
- neighbor_default_originate_rmap_cmd,
- NEIGHBOR_CMD2 "default-originate route-map WORD",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Originate default route to this neighborn"
- "Route-map to specify criteria to originate defaultn"
- "route-map namen")
- {
- return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), argv[1], 1);
- }
- DEFUN (no_neighbor_default_originate,
- no_neighbor_default_originate_cmd,
- NO_NEIGHBOR_CMD2 "default-originate",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Originate default route to this neighborn")
- {
- return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), NULL, 0);
- }
- ALIAS (no_neighbor_default_originate,
- no_neighbor_default_originate_rmap_cmd,
- NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Originate default route to this neighborn"
- "Route-map to specify criteria to originate defaultn"
- "route-map namen");
- /* Set neighbor's BGP port. */
- int
- peer_port_vty (struct vty *vty, char *ip_str, int afi, char *port_str)
- {
- struct peer *peer;
- u_int16_t port;
- struct servent *sp;
- peer = peer_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- if (! port_str)
- {
- sp = getservbyname ("bgp", "tcp");
- port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
- }
- else
- {
- VTY_GET_INTEGER("port", port, port_str);
- }
- peer_port_set (peer, port);
- return CMD_SUCCESS;
- }
- /* Set specified peer's BGP port. */
- DEFUN (neighbor_port,
- neighbor_port_cmd,
- NEIGHBOR_CMD "port <0-65535>",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Neighbor's BGP portn"
- "TCP port numbern")
- {
- return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
- }
- DEFUN (no_neighbor_port,
- no_neighbor_port_cmd,
- NO_NEIGHBOR_CMD "port",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Neighbor's BGP portn")
- {
- return peer_port_vty (vty, argv[0], AFI_IP, NULL);
- }
- ALIAS (no_neighbor_port,
- no_neighbor_port_val_cmd,
- NO_NEIGHBOR_CMD "port <0-65535>",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Neighbor's BGP portn"
- "TCP port numbern");
- /* neighbor weight. */
- int
- peer_weight_set_vty (struct vty *vty, char *ip_str, char *weight_str,
- afi_t afi, safi_t safi)
- {
- int ret;
- struct peer *peer;
- u_int16_t weight;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
- ret = peer_weight_set (peer, weight, afi, safi);
- return CMD_SUCCESS;
- }
- int
- peer_weight_unset_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi)
- {
- struct peer *peer;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- peer_weight_unset (peer, afi, safi);
- return CMD_SUCCESS;
- }
- DEFUN (neighbor_weight,
- neighbor_weight_cmd,
- NEIGHBOR_CMD2 "weight <0-65535>",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Set default weight for routes from this neighborn"
- "default weightn")
- {
- return peer_weight_set_vty (vty, argv[0], argv[1], bgp_node_afi (vty),
- bgp_node_safi (vty));
- }
- DEFUN (no_neighbor_weight,
- no_neighbor_weight_cmd,
- NO_NEIGHBOR_CMD2 "weight",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Set default weight for routes from this neighborn")
- {
- return peer_weight_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty));
- }
- ALIAS (no_neighbor_weight,
- no_neighbor_weight_val_cmd,
- NO_NEIGHBOR_CMD2 "weight <0-65535>",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Set default weight for routes from this neighborn"
- "default weightn");
- /* Override capability negotiation. */
- DEFUN (neighbor_override_capability,
- neighbor_override_capability_cmd,
- NEIGHBOR_CMD2 "override-capability",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Override capability negotiation resultn")
- {
- return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
- }
- DEFUN (no_neighbor_override_capability,
- no_neighbor_override_capability_cmd,
- NO_NEIGHBOR_CMD2 "override-capability",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Override capability negotiation resultn")
- {
- return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
- }
- DEFUN (neighbor_strict_capability,
- neighbor_strict_capability_cmd,
- NEIGHBOR_CMD "strict-capability-match",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Strict capability negotiation matchn")
- {
- return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
- }
- DEFUN (no_neighbor_strict_capability,
- no_neighbor_strict_capability_cmd,
- NO_NEIGHBOR_CMD "strict-capability-match",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Strict capability negotiation matchn")
- {
- return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
- }
- int
- peer_timers_set_vty (struct vty *vty, char *ip_str, char *keep_str,
- char *hold_str)
- {
- int ret;
- struct peer *peer;
- u_int32_t keepalive;
- u_int32_t holdtime;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
- VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
- ret = peer_timers_set (peer, keepalive, holdtime);
- return bgp_vty_return (vty, ret);
- }
- int
- peer_timers_unset_vty (struct vty *vty, char *ip_str)
- {
- int ret;
- struct peer *peer;
- peer = peer_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- ret = peer_timers_unset (peer);
- return bgp_vty_return (vty, ret);
- }
- DEFUN (neighbor_timers,
- neighbor_timers_cmd,
- NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP per neighbor timersn"
- "Keepalive intervaln"
- "Holdtimen")
- {
- return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
- }
- DEFUN (no_neighbor_timers,
- no_neighbor_timers_cmd,
- NO_NEIGHBOR_CMD2 "timers",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "BGP per neighbor timersn")
- {
- return peer_timers_unset_vty (vty, argv[0]);
- }
- int
- peer_advertise_interval_vty (struct vty *vty, char *ip_str, char *time_str,
- int set)
- {
- int ret;
- struct peer *peer;
- u_int32_t routeadv = 0;
- peer = peer_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- if (time_str)
- VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
- if (set)
- ret = peer_advertise_interval_set (peer, routeadv);
- else
- ret = peer_advertise_interval_unset (peer);
- return CMD_SUCCESS;
- }
- DEFUN (neighbor_advertise_interval,
- neighbor_advertise_interval_cmd,
- NEIGHBOR_CMD "advertisement-interval <0-600>",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Minimum interval between sending BGP routing updatesn"
- "time in secondsn")
- {
- return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
- }
- DEFUN (no_neighbor_advertise_interval,
- no_neighbor_advertise_interval_cmd,
- NO_NEIGHBOR_CMD "advertisement-interval",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Minimum interval between sending BGP routing updatesn")
- {
- return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
- }
- ALIAS (no_neighbor_advertise_interval,
- no_neighbor_advertise_interval_val_cmd,
- NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Minimum interval between sending BGP routing updatesn"
- "time in secondsn");
- /* neighbor interface */
- int
- peer_interface_vty (struct vty *vty, char *ip_str, char *str)
- {
- int ret;
- struct peer *peer;
- peer = peer_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- if (str)
- ret = peer_interface_set (peer, str);
- else
- ret = peer_interface_unset (peer);
- return CMD_SUCCESS;
- }
- DEFUN (neighbor_interface,
- neighbor_interface_cmd,
- NEIGHBOR_CMD "interface WORD",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Interfacen"
- "Interface namen")
- {
- return peer_interface_vty (vty, argv[0], argv[1]);
- }
- DEFUN (no_neighbor_interface,
- no_neighbor_interface_cmd,
- NO_NEIGHBOR_CMD "interface WORD",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR
- "Interfacen"
- "Interface namen")
- {
- return peer_interface_vty (vty, argv[0], NULL);
- }
- /* Set distribute list to the peer. */
- int
- peer_distribute_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
- char *name_str, char *direct_str)
- {
- int ret;
- struct peer *peer;
- int direct = FILTER_IN;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- /* Check filter direction. */
- if (strncmp (direct_str, "i", 1) == 0)
- direct = FILTER_IN;
- else if (strncmp (direct_str, "o", 1) == 0)
- direct = FILTER_OUT;
- ret = peer_distribute_set (peer, afi, safi, direct, name_str);
- return bgp_vty_return (vty, ret);
- }
- int
- peer_distribute_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
- safi_t safi, char *direct_str)
- {
- int ret;
- struct peer *peer;
- int direct = FILTER_IN;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- /* Check filter direction. */
- if (strncmp (direct_str, "i", 1) == 0)
- direct = FILTER_IN;
- else if (strncmp (direct_str, "o", 1) == 0)
- direct = FILTER_OUT;
- ret = peer_distribute_unset (peer, afi, safi, direct);
- return bgp_vty_return (vty, ret);
- }
- DEFUN (neighbor_distribute_list,
- neighbor_distribute_list_cmd,
- NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Filter updates to/from this neighborn"
- "IP access-list numbern"
- "IP access-list number (expanded range)n"
- "IP Access-list namen"
- "Filter incoming updatesn"
- "Filter outgoing updatesn")
- {
- return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), argv[1], argv[2]);
- }
- DEFUN (no_neighbor_distribute_list,
- no_neighbor_distribute_list_cmd,
- NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Filter updates to/from this neighborn"
- "IP access-list numbern"
- "IP access-list number (expanded range)n"
- "IP Access-list namen"
- "Filter incoming updatesn"
- "Filter outgoing updatesn")
- {
- return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), argv[2]);
- }
- /* Set prefix list to the peer. */
- int
- peer_prefix_list_set_vty (struct vty *vty, char *ip_str, afi_t afi,
- safi_t safi, char *name_str, char *direct_str)
- {
- int ret;
- struct peer *peer;
- int direct = FILTER_IN;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- /* Check filter direction. */
- if (strncmp (direct_str, "i", 1) == 0)
- direct = FILTER_IN;
- else if (strncmp (direct_str, "o", 1) == 0)
- direct = FILTER_OUT;
- ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
- return bgp_vty_return (vty, ret);
- }
- int
- peer_prefix_list_unset_vty (struct vty *vty, char *ip_str, afi_t afi,
- safi_t safi, char *direct_str)
- {
- int ret;
- struct peer *peer;
- int direct = FILTER_IN;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
-
- /* Check filter direction. */
- if (strncmp (direct_str, "i", 1) == 0)
- direct = FILTER_IN;
- else if (strncmp (direct_str, "o", 1) == 0)
- direct = FILTER_OUT;
- ret = peer_prefix_list_unset (peer, afi, safi, direct);
- return bgp_vty_return (vty, ret);
- }
- DEFUN (neighbor_prefix_list,
- neighbor_prefix_list_cmd,
- NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Filter updates to/from this neighborn"
- "Name of a prefix listn"
- "Filter incoming updatesn"
- "Filter outgoing updatesn")
- {
- return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), argv[1], argv[2]);
- }
- DEFUN (no_neighbor_prefix_list,
- no_neighbor_prefix_list_cmd,
- NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
- NO_STR
- NEIGHBOR_STR
- NEIGHBOR_ADDR_STR2
- "Filter updates to/from this neighborn"
- "Name of a prefix listn"
- "Filter incoming updatesn"
- "Filter outgoing updatesn")
- {
- return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
- bgp_node_safi (vty), argv[2]);
- }
- int
- peer_aslist_set_vty (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
- char *name_str, char *direct_str)
- {
- int ret;
- struct peer *peer;
- int direct = FILTER_IN;
- peer = peer_and_group_lookup_vty (vty, ip_str);
- if (! peer)
- return CMD_WARNING;
- /* Check filter direction. */
- if (strncmp (direct_str, "i", 1) == 0)
- direct = FILTER_IN;