Add custom mac address option to vhost interfaces.
[vpp.git] / vpp / api / api.c
index 55de994..e30240c 100644 (file)
@@ -69,6 +69,7 @@
 #include <vnet/nsh-vxlan-gpe/nsh_vxlan_gpe.h>
 #include <vnet/lisp-gpe/lisp_gpe.h>
 #include <vnet/map/map.h>
+#include <vnet/cop/cop.h>
 
 #undef BIHASH_TYPE
 #undef __included_bihash_template_h__
@@ -307,7 +308,10 @@ _(MAP_DEL_DOMAIN, map_del_domain)                                       \
 _(MAP_ADD_DEL_RULE, map_add_del_rule)                                   \
 _(MAP_DOMAIN_DUMP, map_domain_dump)                                     \
 _(MAP_RULE_DUMP, map_rule_dump)                                                \
-_(MAP_SUMMARY_STATS, map_summary_stats)
+_(MAP_SUMMARY_STATS, map_summary_stats)                                        \
+_(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable)          \
+_(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)          \
+_(GET_NODE_GRAPH, get_node_graph)
 
 #define QUOTE_(x) #x
 #define QUOTE(x) QUOTE_(x)
@@ -1795,6 +1799,7 @@ vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp)
     kp = clib_mem_alloc (sizeof (*kp));
     *kp = sup_and_sub_key;
     
+    memset (&template, 0, sizeof (template));
     template.type = VNET_SW_INTERFACE_TYPE_SUB;
     template.sup_sw_if_index = hi->sw_if_index;
     template.sub.id = id;
@@ -3546,7 +3551,8 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t *mp)
 
     rv = dpdk_vhost_user_create_if(vnm, vm, (char *)mp->sock_filename,
                               mp->is_server, &sw_if_index, (u64)~0,
-                              mp->renumber, ntohl(mp->custom_dev_instance));
+                              mp->renumber, ntohl(mp->custom_dev_instance),
+                              (mp->use_custom_mac)?mp->mac_address:NULL);
 
     REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
     ({
@@ -4859,6 +4865,78 @@ static void vl_api_ipsec_sa_set_key_t_handler
     REPLY_MACRO(VL_API_IPSEC_SA_SET_KEY_REPLY);
 }
 
+static void vl_api_cop_interface_enable_disable_t_handler
+(vl_api_cop_interface_enable_disable_t * mp)
+{
+    vl_api_cop_interface_enable_disable_reply_t * rmp;
+    int rv;
+    u32 sw_if_index = ntohl(mp->sw_if_index);
+    int enable_disable;
+
+    VALIDATE_SW_IF_INDEX(mp);
+
+    enable_disable = (int) mp->enable_disable;
+
+    rv = cop_interface_enable_disable (sw_if_index, enable_disable);
+
+    BAD_SW_IF_INDEX_LABEL;
+
+    REPLY_MACRO(VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
+}
+
+static void vl_api_cop_whitelist_enable_disable_t_handler
+(vl_api_cop_whitelist_enable_disable_t * mp)
+{
+    vl_api_cop_whitelist_enable_disable_reply_t * rmp;
+    cop_whitelist_enable_disable_args_t _a, *a=&_a;
+    u32 sw_if_index = ntohl(mp->sw_if_index);
+    int rv;
+
+    VALIDATE_SW_IF_INDEX(mp);
+
+    a->sw_if_index = sw_if_index;
+    a->ip4 = mp->ip4;
+    a->ip6 = mp->ip6;
+    a->default_cop = mp->default_cop;
+    a->fib_id = ntohl(mp->fib_id);
+
+    rv = cop_whitelist_enable_disable (a);
+
+    BAD_SW_IF_INDEX_LABEL;
+
+    REPLY_MACRO(VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
+}
+
+static void vl_api_get_node_graph_t_handler
+(vl_api_get_node_graph_t * mp)
+{
+    int rv = 0;
+    u8 * vector = 0;
+    api_main_t * am = &api_main;
+    vlib_main_t * vm = vlib_get_main();
+    void * oldheap;
+    vl_api_get_node_graph_reply_t * rmp;
+    
+    pthread_mutex_lock (&am->vlib_rp->mutex);
+    oldheap = svm_push_data_heap (am->vlib_rp);
+    
+    /* 
+     * Keep the number of memcpy ops to a minimum (e.g. 1).
+     * The current size of the serialized vector is
+     * slightly under 4K.
+     */
+    vec_validate (vector, 4095);
+    vec_reset_length (vector);
+
+    vector = vlib_node_serialize (&vm->node_main, vector);
+    
+    svm_pop_heap (oldheap);
+    pthread_mutex_unlock (&am->vlib_rp->mutex);
+
+    REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
+                 rmp->reply_in_shmem = (uword) vector);
+}
+
 #define BOUNCE_HANDLER(nn)                                              \
 static void vl_api_##nn##_t_handler (                                   \
     vl_api_##nn##_t *mp)                                                \