BD/API:add bridge_domain_set_mac_age api
[vpp.git] / src / vat / api_format.c
index 3b57ac6..06884eb 100644 (file)
@@ -1295,9 +1295,9 @@ static void
 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
 {
   u32 sw_if_index = ntohl (mp->sw_if_index);
-  errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
+  errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
          mp->mac_ip ? "mac/ip binding" : "address resolution",
-         format_ip4_address, &mp->address,
+         ntohl (mp->pid), format_ip4_address, &mp->address,
          format_ethernet_address, mp->new_mac, sw_if_index);
 }
 
@@ -1311,9 +1311,9 @@ static void
 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
 {
   u32 sw_if_index = ntohl (mp->sw_if_index);
-  errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
+  errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
          mp->mac_ip ? "mac/ip binding" : "address resolution",
-         format_ip6_address, mp->address,
+         ntohl (mp->pid), format_ip6_address, mp->address,
          format_ethernet_address, mp->new_mac, sw_if_index);
 }
 
@@ -1458,6 +1458,39 @@ static void vl_api_control_ping_reply_t_handler_json
   vam->result_ready = 1;
 }
 
+static void
+  vl_api_bridge_domain_set_mac_age_reply_t_handler
+  (vl_api_bridge_domain_set_mac_age_reply_t * mp)
+{
+  vat_main_t *vam = &vat_main;
+  i32 retval = ntohl (mp->retval);
+  if (vam->async_mode)
+    {
+      vam->async_errors += (retval < 0);
+    }
+  else
+    {
+      vam->retval = retval;
+      vam->result_ready = 1;
+    }
+}
+
+static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
+  (vl_api_bridge_domain_set_mac_age_reply_t * mp)
+{
+  vat_main_t *vam = &vat_main;
+  vat_json_node_t node;
+
+  vat_json_init_object (&node);
+  vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+
+  vat_json_print (vam->ofp, &node);
+  vat_json_free (&node);
+
+  vam->retval = ntohl (mp->retval);
+  vam->result_ready = 1;
+}
+
 static void
 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
 {
@@ -2025,7 +2058,7 @@ vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
 {
   errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
          "router_addr %U host_mac %U",
-         mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
+         ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
          format_ip4_address, &mp->host_address,
          format_ip4_address, &mp->router_address,
          format_ethernet_address, mp->host_mac);
@@ -4285,6 +4318,7 @@ _(SW_INTERFACE_SET_L2_BRIDGE_REPLY,                                     \
 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply)             \
 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details)                         \
 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details)             \
+_(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply)     \
 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply)                             \
 _(L2_FLAGS_REPLY, l2_flags_reply)                                       \
 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply)                               \
@@ -6030,6 +6064,46 @@ api_l2fib_add_del (vat_main_t * vam)
   return (vam->retval);
 }
 
+static int
+api_bridge_domain_set_mac_age (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_bridge_domain_set_mac_age_t *mp;
+  u32 bd_id = ~0;
+  u32 mac_age = 0;
+  int ret;
+
+  /* Parse args required to build the message */
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "bd_id %d", &bd_id));
+      else if (unformat (i, "mac-age %d", &mac_age));
+      else
+       break;
+    }
+
+  if (bd_id == ~0)
+    {
+      errmsg ("missing bridge domain");
+      return -99;
+    }
+
+  if (mac_age > 255)
+    {
+      errmsg ("mac age must be less than 256 ");
+      return -99;
+    }
+
+  M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
+
+  mp->bd_id = htonl (bd_id);
+  mp->mac_age = (u8) mac_age;
+
+  S (mp);
+  W (ret);
+  return ret;
+}
+
 static int
 api_l2_flags (vat_main_t * vam)
 {
@@ -8035,12 +8109,12 @@ api_dhcp_client_config (vat_main_t * vam)
   /* Construct the API message */
   M (DHCP_CLIENT_CONFIG, mp);
 
-  mp->sw_if_index = ntohl (sw_if_index);
+  mp->sw_if_index = htonl (sw_if_index);
   clib_memcpy (mp->hostname, hostname, vec_len (hostname));
   vec_free (hostname);
   mp->is_add = is_add;
   mp->want_dhcp_event = disable_event ? 0 : 1;
-  mp->pid = getpid ();
+  mp->pid = htonl (getpid ());
 
   /* send it... */
   S (mp);
@@ -11833,7 +11907,7 @@ api_want_ip4_arp_events (vat_main_t * vam)
 
   M (WANT_IP4_ARP_EVENTS, mp);
   mp->enable_disable = enable_disable;
-  mp->pid = getpid ();
+  mp->pid = htonl (getpid ());
   mp->address = address.as_u32;
 
   S (mp);
@@ -11869,7 +11943,7 @@ api_want_ip6_nd_events (vat_main_t * vam)
 
   M (WANT_IP6_ND_EVENTS, mp);
   mp->enable_disable = enable_disable;
-  mp->pid = getpid ();
+  mp->pid = htonl (getpid ());
   clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
 
   S (mp);
@@ -18419,8 +18493,9 @@ _(sw_interface_set_l2_bridge,                                           \
   "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n"               \
   "[shg <split-horizon-group>] [bvi]\n"                                 \
   "enable | disable")                                                   \
+_(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255\n")\
 _(bridge_domain_add_del,                                                \
-  "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
+  "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n")                   \
 _(l2fib_add_del,                                                        \
   "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \