* bgp_open.c, bgp_packet.c, bgp_vty.c, bgpd.[ch]: Remove "no neighbor
	  capability route-refresh" commands. Route refresh capability is sent
	  anyway now. Preserve dummy deprecated commands.

	[merge from GNU Zebra]
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 10ccdf4..67da8ff 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,5 +1,11 @@
 2005-02-01 Akihiro Mizutani <mizutani@net-chef.net>
 
+	* bgp_open.c, bgp_packet.c, bgp_vty.c, bgpd.[ch]: Remove "no neighbor
+	  capability route-refresh" commands. Route refresh capability is sent
+	  anyway now. Preserve dummy deprecated commands.
+
+2005-02-01 Akihiro Mizutani <mizutani@net-chef.net>
+
 	* bgp_attr.c, bgp_snmp.c, bgp_vty.c, bgpd.[ch]: Remove support for old
 	  draft - ie. "neighbor version 4-" commands. Preserve dummy "neighbor
 	  version" command as deprecated.
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 86f48c4..8321bcf 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -745,23 +745,6 @@
       || CHECK_FLAG (peer->flags, PEER_FLAG_DONT_CAPABILITY))
     return;
 
-  /* When the peer is IPv4 unicast only, do not send capability. */
-  if (! peer->afc[AFI_IP][SAFI_MULTICAST] 
-      && ! peer->afc[AFI_IP][SAFI_MPLS_VPN]
-      && ! peer->afc[AFI_IP6][SAFI_UNICAST] 
-      && ! peer->afc[AFI_IP6][SAFI_MULTICAST]
-      && CHECK_FLAG (peer->flags, PEER_FLAG_NO_ROUTE_REFRESH_CAP)
-      && ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
-		       PEER_FLAG_ORF_PREFIX_SM)
-      && ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
-		       PEER_FLAG_ORF_PREFIX_RM)
-      && ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_MULTICAST],
-		       PEER_FLAG_ORF_PREFIX_SM)
-      && ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_MULTICAST],
-		       PEER_FLAG_ORF_PREFIX_RM)
-      && ! CHECK_FLAG (peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
-    return;
-
   /* IPv4 unicast. */
   if (peer->afc[AFI_IP][SAFI_UNICAST])
     {
@@ -826,18 +809,15 @@
 #endif /* HAVE_IPV6 */
 
   /* Route refresh. */
-  if (! CHECK_FLAG (peer->flags, PEER_FLAG_NO_ROUTE_REFRESH_CAP))
-    {
-      SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
-      stream_putc (s, BGP_OPEN_OPT_CAP);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN + 2);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_OLD);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
-      stream_putc (s, BGP_OPEN_OPT_CAP);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN + 2);
-      stream_putc (s, CAPABILITY_CODE_REFRESH);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
-    }
+  SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
+  stream_putc (s, BGP_OPEN_OPT_CAP);
+  stream_putc (s, CAPABILITY_CODE_REFRESH_LEN + 2);
+  stream_putc (s, CAPABILITY_CODE_REFRESH_OLD);
+  stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
+  stream_putc (s, BGP_OPEN_OPT_CAP);
+  stream_putc (s, CAPABILITY_CODE_REFRESH_LEN + 2);
+  stream_putc (s, CAPABILITY_CODE_REFRESH);
+  stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
 
   /* ORF capability. */
   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 04e5bd3..854b32c 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1037,22 +1037,6 @@
 		   "Advertising" : "Removing", afi, safi);
     }
 
-  /* Encode Route Refresh capability. */
-  if (capability_code == CAPABILITY_CODE_REFRESH)
-    {
-      stream_putc (s, action);
-      stream_putc (s, CAPABILITY_CODE_REFRESH);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
-      stream_putc (s, action);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_OLD);
-      stream_putc (s, CAPABILITY_CODE_REFRESH_LEN);
-
-      if (BGP_DEBUG (normal, NORMAL))
-        zlog_debug ("%s sending CAPABILITY has %s ROUTE-REFRESH capability",
-		   peer->host, action == CAPABILITY_ACTION_SET ?
-		   "Advertising" : "Removing");
-    }
-
   /* Set packet size. */
   length = bgp_packet_set_size (s);
 
@@ -2025,42 +2009,6 @@
 		} 
 	    }
         }
-      else if (cap.code == CAPABILITY_CODE_REFRESH
-	       || cap.code == CAPABILITY_CODE_REFRESH_OLD)
-        {
-          /* Check length. */
-          if (cap.length != 0)
-            {
-              zlog_info ("%s Route Refresh Capability length error %d",
-                         peer->host, cap.length);
-              bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
-              return -1;
-            }
-	  
-          if (BGP_DEBUG (normal, NORMAL))
-            zlog_debug ("%s CAPABILITY has %s ROUTE-REFRESH capability(%s) for all address-families",
-		       peer->host,
-		       action == CAPABILITY_ACTION_SET
-		       ? "Advertising" : "Removing",
-		       cap.code == CAPABILITY_CODE_REFRESH_OLD
-		       ? "old" : "new");
-	  
-          /* BGP refresh capability */
-	  if (action == CAPABILITY_ACTION_SET)
-	    {
-	      if (cap.code == CAPABILITY_CODE_REFRESH_OLD)
-		SET_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV);
-	      else
-		SET_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV);
-	    }
-	  else
-	    {
-	      if (cap.code == CAPABILITY_CODE_REFRESH_OLD)
-		UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV);
-	      else
-		UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV);
-	    }
-        }
       else
         {
           zlog_warn ("%s unrecognized capability code: %d - ignored",
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index dcca1a3..be57c12 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1594,28 +1594,28 @@
   return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
 }
 
-/* neighbor capability route-refresh. */
-DEFUN (neighbor_capability_route_refresh,
-       neighbor_capability_route_refresh_cmd,
-       NEIGHBOR_CMD2 "capability route-refresh",
-       NEIGHBOR_STR
-       NEIGHBOR_ADDR_STR2
-       "Advertise capability to the peer\n"
-       "Advertise route-refresh capability to this neighbor\n")
+/* Deprecated neighbor capability route-refresh. */
+DEFUN_DEPRECATED (neighbor_capability_route_refresh,
+		  neighbor_capability_route_refresh_cmd,
+		  NEIGHBOR_CMD2 "capability route-refresh",
+		  NEIGHBOR_STR
+		  NEIGHBOR_ADDR_STR2
+		  "Advertise capability to the peer\n"
+		  "Advertise route-refresh capability to this neighbor\n")
 {
-  return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_NO_ROUTE_REFRESH_CAP);
+  return CMD_SUCCESS;
 }
 
-DEFUN (no_neighbor_capability_route_refresh,
-       no_neighbor_capability_route_refresh_cmd,
-       NO_NEIGHBOR_CMD2 "capability route-refresh",
-       NO_STR
-       NEIGHBOR_STR
-       NEIGHBOR_ADDR_STR2
-       "Advertise capability to the peer\n"
-       "Advertise route-refresh capability to this neighbor\n")
+DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
+		  no_neighbor_capability_route_refresh_cmd,
+		  NO_NEIGHBOR_CMD2 "capability route-refresh",
+		  NO_STR
+		  NEIGHBOR_STR
+		  NEIGHBOR_ADDR_STR2
+		  "Advertise capability to the peer\n"
+		  "Advertise route-refresh capability to this neighbor\n")
 {
-  return peer_flag_set_vty (vty, argv[0], PEER_FLAG_NO_ROUTE_REFRESH_CAP);
+  return CMD_SUCCESS;
 }
 
 /* neighbor capability dynamic. */
@@ -8783,7 +8783,7 @@
   install_element (BGP_NODE, &neighbor_shutdown_cmd);
   install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
 
-  /* "neighbor capability route-refresh" commands.*/
+  /* Deprecated "neighbor capability route-refresh" commands.*/
   install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
   install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
 
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 1cce8c5..1a50476 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2067,7 +2067,6 @@
     { PEER_FLAG_DONT_CAPABILITY,          0, peer_change_none },
     { PEER_FLAG_OVERRIDE_CAPABILITY,      0, peer_change_none },
     { PEER_FLAG_STRICT_CAP_MATCH,         0, peer_change_none },
-    { PEER_FLAG_NO_ROUTE_REFRESH_CAP,     0, peer_change_reset },
     { PEER_FLAG_DYNAMIC_CAPABILITY,       0, peer_change_reset },
     { PEER_FLAG_ENFORCE_MULTIHOP,         0, peer_change_reset },
     { 0, 0, 0 }
@@ -2172,33 +2171,15 @@
     }
   else if (peer->status == Established)
     {
-      if (flag == PEER_FLAG_NO_ROUTE_REFRESH_CAP
-	  && CHECK_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV))
-	{
-	  if (CHECK_FLAG (peer->flags, flag))
-	    UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
-	  else
-	    SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
+      if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)
+	peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
+      else if (flag == PEER_FLAG_PASSIVE)
+	peer->last_reset = PEER_DOWN_PASSIVE_CHANGE;
+      else if (flag == PEER_FLAG_ENFORCE_MULTIHOP)
+	peer->last_reset = PEER_DOWN_MULTIHOP_CHANGE;
 
-	  bgp_capability_send (peer, AFI_IP, SAFI_UNICAST,
-			       CAPABILITY_CODE_REFRESH,
-			       CHECK_FLAG (peer->flags, flag) ?
-			       CAPABILITY_ACTION_UNSET : CAPABILITY_ACTION_SET);
-	}
-      else
-       {
-         if (flag == PEER_FLAG_NO_ROUTE_REFRESH_CAP)
-           peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
-         else if (flag == PEER_FLAG_DYNAMIC_CAPABILITY)
-           peer->last_reset = PEER_DOWN_CAPABILITY_CHANGE;
-         else if (flag == PEER_FLAG_PASSIVE)
-           peer->last_reset = PEER_DOWN_PASSIVE_CHANGE;
-         else if (flag == PEER_FLAG_ENFORCE_MULTIHOP)
-           peer->last_reset = PEER_DOWN_MULTIHOP_CHANGE;
-
-         bgp_notify_send (peer, BGP_NOTIFY_CEASE,
-                          BGP_NOTIFY_CEASE_CONFIG_CHANGE);
-       }
+      bgp_notify_send (peer, BGP_NOTIFY_CEASE,
+		       BGP_NOTIFY_CEASE_CONFIG_CHANGE);
     }
   else
     BGP_EVENT_ADD (peer, BGP_Stop);
@@ -4353,13 +4334,6 @@
 	  vty_out (vty, " neighbor %s weight %d%s", addr, peer->weight,
 		   VTY_NEWLINE);
 
-      /* Route refresh. */
-      if (CHECK_FLAG (peer->flags, PEER_FLAG_NO_ROUTE_REFRESH_CAP))
-        if (! peer_group_active (peer) ||
-	    ! CHECK_FLAG (g_peer->flags, PEER_FLAG_NO_ROUTE_REFRESH_CAP))
-	  vty_out (vty, " no neighbor %s capability route-refresh%s", addr,
-	  VTY_NEWLINE);
-
       /* Dynamic capability.  */
       if (CHECK_FLAG (peer->flags, PEER_FLAG_DYNAMIC_CAPABILITY))
         if (! peer_group_active (peer) ||
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 6fb66d3..e14a8ad 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -330,10 +330,9 @@
 #define PEER_FLAG_DONT_CAPABILITY           (1 << 2) /* dont-capability */
 #define PEER_FLAG_OVERRIDE_CAPABILITY       (1 << 3) /* override-capability */
 #define PEER_FLAG_STRICT_CAP_MATCH          (1 << 4) /* strict-match */
-#define PEER_FLAG_NO_ROUTE_REFRESH_CAP      (1 << 5) /* route-refresh */
-#define PEER_FLAG_DYNAMIC_CAPABILITY        (1 << 6) /* dynamic capability */
-#define PEER_FLAG_ENFORCE_MULTIHOP          (1 << 7) /* enforce-multihop */
-#define PEER_FLAG_LOCAL_AS_NO_PREPEND       (1 << 8) /* local-as no-prepend */
+#define PEER_FLAG_DYNAMIC_CAPABILITY        (1 << 5) /* dynamic capability */
+#define PEER_FLAG_ENFORCE_MULTIHOP          (1 << 6) /* enforce-multihop */
+#define PEER_FLAG_LOCAL_AS_NO_PREPEND       (1 << 7) /* local-as no-prepend */
 
   /* Per AF configuration flags. */
   u_int32_t af_flags[AFI_MAX][SAFI_MAX];