BIER
[vpp.git] / src / vat / api_format.c
index eee5c74..c75857b 100644 (file)
@@ -5180,6 +5180,8 @@ _(ip_mroute_add_del_reply)                              \
 _(mpls_route_add_del_reply)                             \
 _(mpls_table_add_del_reply)                             \
 _(mpls_ip_bind_unbind_reply)                            \
+_(bier_route_add_del_reply)                             \
+_(bier_table_add_del_reply)                             \
 _(proxy_arp_add_del_reply)                              \
 _(proxy_arp_intfc_enable_disable_reply)                 \
 _(sw_interface_set_unnumbered_reply)                    \
@@ -5383,6 +5385,8 @@ _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply)                       \
 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply)                  \
 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply)                  \
 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply)                        \
+_(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply)                  \
+_(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply)                  \
 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply)                     \
 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY,                                 \
   proxy_arp_intfc_enable_disable_reply)                                 \
@@ -8547,6 +8551,154 @@ api_mpls_ip_bind_unbind (vat_main_t * vam)
   return ret;
 }
 
+static int
+api_bier_table_add_del (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_bier_table_add_del_t *mp;
+  u8 is_add = 1;
+  u32 set = 0, sub_domain = 0, hdr_len = 3;
+  mpls_label_t local_label = MPLS_LABEL_INVALID;
+  int ret;
+
+  /* Parse args required to build the message */
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "sub-domain %d", &sub_domain))
+       ;
+      else if (unformat (i, "set %d", &set))
+       ;
+      else if (unformat (i, "label %d", &local_label))
+       ;
+      else if (unformat (i, "hdr-len %d", &hdr_len))
+       ;
+      else if (unformat (i, "add"))
+       is_add = 1;
+      else if (unformat (i, "del"))
+       is_add = 0;
+      else
+       {
+         clib_warning ("parse error '%U'", format_unformat_error, i);
+         return -99;
+       }
+    }
+
+  if (MPLS_LABEL_INVALID == local_label)
+    {
+      errmsg ("missing label\n");
+      return -99;
+    }
+
+  /* Construct the API message */
+  M (BIER_TABLE_ADD_DEL, mp);
+
+  mp->bt_is_add = is_add;
+  mp->bt_label = ntohl (local_label);
+  mp->bt_tbl_id.bt_set = set;
+  mp->bt_tbl_id.bt_sub_domain = sub_domain;
+  mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
+
+  /* send it... */
+  S (mp);
+
+  /* Wait for a reply... */
+  W (ret);
+
+  return (ret);
+}
+
+static int
+api_bier_route_add_del (vat_main_t * vam)
+{
+  unformat_input_t *i = vam->input;
+  vl_api_bier_route_add_del_t *mp;
+  u8 is_add = 1;
+  u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
+  ip4_address_t v4_next_hop_address;
+  ip6_address_t v6_next_hop_address;
+  u8 next_hop_set = 0;
+  u8 next_hop_proto_is_ip4 = 1;
+  mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
+  int ret;
+
+  /* Parse args required to build the message */
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
+       {
+         next_hop_proto_is_ip4 = 1;
+         next_hop_set = 1;
+       }
+      else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
+       {
+         next_hop_proto_is_ip4 = 0;
+         next_hop_set = 1;
+       }
+      if (unformat (i, "sub-domain %d", &sub_domain))
+       ;
+      else if (unformat (i, "set %d", &set))
+       ;
+      else if (unformat (i, "hdr-len %d", &hdr_len))
+       ;
+      else if (unformat (i, "bp %d", &bp))
+       ;
+      else if (unformat (i, "add"))
+       is_add = 1;
+      else if (unformat (i, "del"))
+       is_add = 0;
+      else if (unformat (i, "out-label %d", &next_hop_out_label))
+       ;
+      else
+       {
+         clib_warning ("parse error '%U'", format_unformat_error, i);
+         return -99;
+       }
+    }
+
+  if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
+    {
+      errmsg ("next hop / label set\n");
+      return -99;
+    }
+  if (0 == bp)
+    {
+      errmsg ("bit=position not set\n");
+      return -99;
+    }
+
+  /* Construct the API message */
+  M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
+
+  mp->br_is_add = is_add;
+  mp->br_tbl_id.bt_set = set;
+  mp->br_tbl_id.bt_sub_domain = sub_domain;
+  mp->br_tbl_id.bt_hdr_len_id = hdr_len;
+  mp->br_bp = ntohs (bp);
+  mp->br_n_paths = 1;
+  mp->br_paths[0].n_labels = 1;
+  mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
+  mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
+
+  if (next_hop_proto_is_ip4)
+    {
+      clib_memcpy (mp->br_paths[0].next_hop,
+                  &v4_next_hop_address, sizeof (v4_next_hop_address));
+    }
+  else
+    {
+      clib_memcpy (mp->br_paths[0].next_hop,
+                  &v6_next_hop_address, sizeof (v6_next_hop_address));
+    }
+
+  /* send it... */
+  S (mp);
+
+  /* Wait for a reply... */
+  W (ret);
+
+  return (ret);
+}
+
 static int
 api_proxy_arp_add_del (vat_main_t * vam)
 {
@@ -22238,6 +22390,12 @@ _(mpls_ip_bind_unbind,                                                  \
 _(mpls_tunnel_add_del,                                                  \
   " via <addr> [table-id <n>]\n"                                        \
   "sw_if_index <id>] [l2]  [del]")                                      \
+_(bier_table_add_del,                                                   \
+  "<label> <sub-domain> <set> <bsl> [del]")                             \
+_(bier_route_add_del,                                                   \
+  "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
+  "[<intfc> | sw_if_index <id>]"                                        \
+  "[weight <n>] [del] [multipath]")                                     \
 _(proxy_arp_add_del,                                                    \
   "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]")                      \
 _(proxy_arp_intfc_enable_disable,                                       \