#include <vnet/ipsec-gre/ipsec_gre.h>
#include <vnet/flow/flow_report_classify.h>
#include <vnet/ip/punt.h>
+#include <vnet/feature/feature.h>
#undef BIHASH_TYPE
#undef __included_bihash_template_h__
_(IP_FIB_DUMP, ip_fib_dump) \
_(IP_FIB_DETAILS, ip_fib_details) \
_(IP6_FIB_DUMP, ip6_fib_dump) \
-_(IP6_FIB_DETAILS, ip6_fib_details)
+_(IP6_FIB_DETAILS, ip6_fib_details) \
+_(FEATURE_ENABLE_DISABLE, feature_enable_disable)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
else
{
u32 *tp = (u32 *) mp->ip;
- *tp = ntohl (*(u32 *) ip);
+ *tp = *(u32 *) ip;
}
mp->prefix_length = prefix_length;
mp->context = context;
clib_warning ("BUG");
}
+
+static void
+copy_fib_next_hop (fib_route_path_encode_t * api_rpath,
+ vl_api_fib_path_t * fp)
+{
+ int is_ip4;
+
+ if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
+ fp->afi = IP46_TYPE_IP4;
+ else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
+ fp->afi = IP46_TYPE_IP6;
+ else
+ {
+ is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
+ if (is_ip4)
+ fp->afi = IP46_TYPE_IP4;
+ else
+ fp->afi = IP46_TYPE_IP6;
+ }
+ if (fp->afi == IP46_TYPE_IP4)
+ memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
+ sizeof (api_rpath->rpath.frp_addr.ip4));
+ else
+ memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
+ sizeof (api_rpath->rpath.frp_addr.ip6));
+}
+
static void
send_mpls_fib_details (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
vl_api_mpls_fib_details_t *mp;
fib_route_path_encode_t *api_rpath;
vl_api_fib_path_t *fp;
- int is_ip4, path_count;
+ int path_count;
path_count = vec_len (api_rpaths);
mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
memset (fp, 0, sizeof (*fp));
fp->weight = htonl (api_rpath->rpath.frp_weight);
fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
- memcpy (fp->next_hop, &api_rpath->rpath.frp_addr, sizeof (fp->next_hop));
- if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
- fp->afi = IP46_TYPE_IP4;
- else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
- fp->afi = IP46_TYPE_IP6;
- else
- {
- is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
- if (is_ip4)
- fp->afi = IP46_TYPE_IP4;
- else
- fp->afi = IP46_TYPE_IP6;
- }
+ copy_fib_next_hop (api_rpath, fp);
fp++;
}
vl_api_ip_fib_details_t *mp;
fib_route_path_encode_t *api_rpath;
vl_api_fib_path_t *fp;
- int is_ip4, path_count;
+ int path_count;
path_count = vec_len(api_rpaths);
mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
}
fp->weight = htonl(api_rpath->rpath.frp_weight);
fp->sw_if_index = htonl(api_rpath->rpath.frp_sw_if_index);
- memcpy(fp->next_hop, &api_rpath->rpath.frp_addr, sizeof(fp->next_hop));
- if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
- fp->afi = IP46_TYPE_IP4;
- else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
- fp->afi = IP46_TYPE_IP6;
- else
- {
- is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
- if (is_ip4)
- fp->afi = IP46_TYPE_IP4;
- else
- fp->afi = IP46_TYPE_IP6;
- }
+ copy_fib_next_hop (api_rpath, fp);
fp++;
}
vl_api_ip6_fib_details_t *mp;
fib_route_path_encode_t *api_rpath;
vl_api_fib_path_t *fp;
- int is_ip4, path_count;
+ int path_count;
path_count = vec_len(api_rpaths);
mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
}
fp->weight = htonl(api_rpath->rpath.frp_weight);
fp->sw_if_index = htonl(api_rpath->rpath.frp_sw_if_index);
- memcpy(fp->next_hop, &api_rpath->rpath.frp_addr, sizeof(fp->next_hop));
- if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
- fp->afi = IP46_TYPE_IP4;
- else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
- fp->afi = IP46_TYPE_IP6;
- else
- {
- is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
- if (is_ip4)
- fp->afi = IP46_TYPE_IP4;
- else
- fp->afi = IP46_TYPE_IP6;
- }
+ copy_fib_next_hop (api_rpath, fp);
fp++;
}
u32 src_sw_if_index = 0, *dst_sw_if_index;
q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (!q)
+ return;
+
vec_foreach (dst_sw_if_index, sm->dst_by_src_sw_if_index)
{
if (*dst_sw_if_index > 0)
#endif
}
+static void
+vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
+{
+ vl_api_feature_enable_disable_reply_t *rmp;
+ int rv = 0;
+
+ u8 *arc_name = format (0, "%s%c", mp->arc_name, 0);
+ u8 *feature_name = format (0, "%s%c", mp->feature_name, 0);
+
+ vnet_feature_registration_t *reg;
+ reg =
+ vnet_get_feature_reg ((const char *) arc_name,
+ (const char *) feature_name);
+ if (reg == 0)
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ else
+ {
+ u32 sw_if_index;
+ clib_error_t *error = 0;
+
+ sw_if_index = ntohl (mp->sw_if_index);
+ if (reg->enable_disable_cb)
+ error = reg->enable_disable_cb (sw_if_index, mp->enable);
+ if (!error)
+ vnet_feature_enable_disable ((const char *) arc_name,
+ (const char *) feature_name,
+ sw_if_index, mp->enable, 0, 0);
+ else
+ {
+ clib_error_report (error);
+ rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
+ }
+ }
+
+ vec_free (feature_name);
+ vec_free (arc_name);
+
+ REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
+}
+
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
vl_msg_api_free (mp); \
}
+static void setup_message_id_table (api_main_t * am);
+
/*
* vpe_api_hookup
* Add vpe's API message handlers to the table.
* added the client registration handlers.
* See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
*/
-
static clib_error_t *
vpe_api_hookup (vlib_main_t * vm)
{
am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
+ /*
+ * Set up the (msg_name, crc, message-id) table
+ */
+ setup_message_id_table (am);
+
return 0;
}
return (void *) &unformat_vnet_sw_interface;
}
-#undef vl_api_version
-#define vl_api_version(n,v) static u32 vpe_api_version = v;
-#include <vpp-api/vpe.api.h>
-#undef vl_api_version
-
-int
-vl_msg_api_version_check (vl_api_memclnt_create_t * mp)
-{
- if (clib_host_to_net_u32 (mp->api_versions[0]) != vpe_api_version)
- {
- clib_warning ("vpe API mismatch: 0x%08x instead of 0x%08x",
- clib_host_to_net_u32 (mp->api_versions[0]),
- vpe_api_version);
- return -1;
- }
- return 0;
-}
-
static u8 *
format_arp_event (u8 * s, va_list * args)
{
};
/* *INDENT-ON* */
+#define vl_msg_name_crc_list
+#include <vpp-api/vpe_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+ foreach_vl_msg_name_crc_memclnt;
+ foreach_vl_msg_name_crc_vpe;
+#undef _
+}
+
+
/*
* fd.io coding-style-patch-verification: ON
*