aboutsummaryrefslogtreecommitdiffstats
path: root/vpp
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2016-05-06 15:14:13 +0200
committerDave Barach <openvpp@barachs.net>2016-05-10 11:10:37 +0000
commit8a95a482cfaf05e89a9383f0446584c414cd71bf (patch)
treed7d65abe93fb9ec2d52b216d452b3bbb3ecec6ab /vpp
parent686a5a5b2b22bd7fa31fae134739530a5683b228 (diff)
Add af_packet API
Change-Id: I39409ae9e75fdb59d8cbbd940fa192b24eb79b6a Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r--vpp/api/api.c44
-rw-r--r--vpp/api/vpe.api46
2 files changed, 89 insertions, 1 deletions
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 5e808795..4d7a9192 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -74,6 +74,7 @@
#include <vnet/map/map.h>
#include <vnet/cop/cop.h>
#include <vnet/ip/ip6_hop_by_hop.h>
+#include <vnet/devices/af_packet/af_packet.h>
#undef BIHASH_TYPE
#undef __included_bihash_template_h__
@@ -332,7 +333,10 @@ _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
_(LISP_GPE_ENABLE_DISABLE_STATUS_DUMP, \
lisp_gpe_enable_disable_status_dump) \
-_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)
+_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
+_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
+_(AF_PACKET_CREATE, af_packet_create) \
+_(AF_PACKET_DELETE, af_packet_delete)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
@@ -5861,6 +5865,44 @@ static void vl_api_trace_profile_del_t_handler
REPLY_MACRO(VL_API_TRACE_PROFILE_DEL_REPLY);
}
+static void
+vl_api_af_packet_create_t_handler
+(vl_api_af_packet_create_t *mp)
+{
+ vlib_main_t *vm = vlib_get_main();
+ vl_api_af_packet_create_reply_t *rmp;
+ int rv = 0;
+ u8 *host_if_name = NULL;
+
+ host_if_name = format(0, "%s", mp->host_if_name);
+ vec_add1 (host_if_name, 0);
+
+ rv = af_packet_create_if(vm, host_if_name,
+ mp->use_random_hw_addr ? 0 : mp->hw_addr);
+
+ vec_free(host_if_name);
+
+ REPLY_MACRO(VL_API_AF_PACKET_CREATE_REPLY);
+}
+
+static void
+vl_api_af_packet_delete_t_handler
+(vl_api_af_packet_delete_t *mp)
+{
+ vlib_main_t * vm = vlib_get_main();
+ vl_api_af_packet_delete_reply_t *rmp;
+ int rv = 0;
+ u8 *host_if_name = NULL;
+
+ host_if_name = format(0, "%s", mp->host_if_name);
+ vec_add1 (host_if_name, 0);
+
+ rv = af_packet_delete_if(vm, host_if_name);
+
+ vec_free(host_if_name);
+
+ REPLY_MACRO(VL_API_AF_PACKET_DELETE_REPLY);
+}
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api
index 10c62bb3..c92715f4 100644
--- a/vpp/api/vpe.api
+++ b/vpp/api/vpe.api
@@ -3355,3 +3355,49 @@ define trace_profile_del_reply {
u32 context;
i32 retval;
};
+
+/** \brief Create host-interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param host_if_name - interface name
+ @param hw_addr - interface MAC
+ @param use_random_hw_addr - use random generated MAC
+*/
+define af_packet_create {
+ u32 client_index;
+ u32 context;
+
+ u8 host_if_name[64];
+ u8 hw_addr[6];
+ u8 use_random_hw_addr;
+};
+
+/** \brief Create host-interface response
+ @param context - sender context, to match reply w/ request
+ @param retval - return value for request
+*/
+define af_packet_create_reply {
+ u32 context;
+ i32 retval;
+};
+
+/** \brief Delete host-interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param host_if_name - interface name
+*/
+define af_packet_delete {
+ u32 client_index;
+ u32 context;
+
+ u8 host_if_name[64];
+};
+
+/** \brief Delete host-interface response
+ @param context - sender context, to match reply w/ request
+ @param retval - return value for request
+*/
+define af_packet_delete_reply {
+ u32 context;
+ i32 retval;
+};