#define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
#define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
+#define vl_api_one_l2_arp_entry_t_endian vl_noop_handler
+#define vl_api_one_l2_arp_entry_t_print vl_noop_handler
+#define vl_api_one_add_del_l2_arp_entry vl_noop_handler
+#define vl_api_one_l2_arp_bd_get vl_noop_handler
+
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
#include <vlibapi/api_helper_macros.h>
+#define REPLY_DETAILS(t, body) \
+do { \
+ unix_shared_memory_queue_t * q; \
+ rv = vl_msg_api_pd_handler (mp, rv); \
+ q = vl_api_client_index_to_input_queue (mp->client_index); \
+ if (!q) \
+ return; \
+ \
+ rmp = vl_msg_api_alloc (sizeof (*rmp)); \
+ rmp->_vl_msg_id = ntohs((t)); \
+ rmp->context = mp->context; \
+ do {body;} while (0); \
+ vl_msg_api_send_shmem (q, (u8 *)&rmp); \
+} while(0);
+
#define foreach_vpe_api_msg \
_(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
_(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
_(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
_(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
_(ONE_STATS_DUMP, one_stats_dump) \
+_(ONE_STATS_FLUSH, one_stats_flush) \
+_(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
+_(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
+_(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
static locator_t *
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
{
- rmp->status = status;
- gid_address_put (rmp->address, &addr);
- rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
+ rmp->status = status;
+ ip_address_t *ip = &gid_address_ip (&addr);
+ switch (ip_addr_version (ip))
+ {
+ case IP4:
+ clib_memcpy (rmp->address, &ip_addr_v4 (ip),
+ sizeof (ip_addr_v4 (ip)));
+ break;
+
+ case IP6:
+ clib_memcpy (rmp->address, &ip_addr_v6 (ip),
+ sizeof (ip_addr_v6 (ip)));
+ break;
+
+ default:
+ ASSERT (0);
+ }
+ rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
});
/* *INDENT-ON* */
}
u8 *mac = 0;
ip_prefix_t *ip_prefix = NULL;
+ if (mapit->pitr_set)
+ return;
+
switch (filter)
{
case 0: /* all mappings */
REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
}
+static void
+lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
+ u8 * prefix_length)
+{
+ switch (fid_addr_type (fid))
+ {
+ case FID_ADDR_IP_PREF:
+ *prefix_length = fid_addr_prefix_length (fid);
+ if (fid_addr_ip_version (fid) == IP4)
+ {
+ *api_eid_type = 0; /* ipv4 type */
+ clib_memcpy (dst, &fid_addr_ippref (fid), 4);
+ }
+ else
+ {
+ *api_eid_type = 1; /* ipv6 type */
+ clib_memcpy (dst, &fid_addr_ippref (fid), 16);
+ }
+ break;
+ case FID_ADDR_MAC:
+ *api_eid_type = 2; /* l2 mac type */
+ mac_copy (dst, fid_addr_mac (fid));
+ break;
+ default:
+ ASSERT (0);
+ }
+}
+
+static void
+vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
+{
+ vl_api_one_stats_flush_reply_t *rmp;
+ u8 rv;
+
+ rv = vnet_lisp_flush_stats ();
+ REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
+}
+
static void
vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
{
+ vl_api_one_stats_details_t *rmp;
+ lisp_api_stats_t *stats, *stat;
+ u8 rv = 0;
+
+ stats = vnet_lisp_get_stats ();
+ vec_foreach (stat, stats)
+ {
+ /* *INDENT-OFF* */
+ REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
+ ({
+ lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
+ &rmp->deid_pref_len);
+ lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
+ &rmp->seid_pref_len);
+ rmp->vni = clib_host_to_net_u32 (stat->vni);
+
+ rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0;
+ ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
+ ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
+
+ rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
+ rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
+ }));
+ /* *INDENT-ON* */
+ }
+}
+
+static void
+ vl_api_one_add_del_l2_arp_entry_t_handler
+ (vl_api_one_add_del_l2_arp_entry_t * mp)
+{
+ vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
+ int rv = 0;
+ gid_address_t _arp, *arp = &_arp;
+ memset (arp, 0, sizeof (*arp));
+
+ gid_address_type (arp) = GID_ADDR_ARP;
+ gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
+
+ /* vpp keeps ip4 addresses in network byte order */
+ clib_memcpy (&gid_address_arp_ip4 (arp), &mp->ip4, 4);
+
+ rv = vnet_lisp_add_del_l2_arp_entry (arp, mp->mac, mp->is_add);
+
+ REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
+}
+
+static void
+vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
+{
+ vl_api_one_l2_arp_bd_get_reply_t *rmp;
+ int rv = 0;
+ u32 i = 0;
+ hash_pair_t *p;
+
+ u32 *bds = vnet_lisp_l2_arp_bds_get ();
+ u32 size = hash_elts (bds) * sizeof (u32);
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
+ {
+ rmp->count = clib_host_to_net_u32 (hash_elts (bds));
+ hash_foreach_pair (p, bds,
+ ({
+ rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
+ }));
+ });
+ /* *INDENT-ON* */
+
+ hash_free (bds);
+}
+
+static void
+vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
+{
+ vl_api_one_l2_arp_entries_get_reply_t *rmp;
+ lisp_api_l2_arp_entry_t *entries = 0, *e;
+ u32 i = 0;
+ int rv = 0;
+
+ u32 bd = clib_net_to_host_u32 (mp->bd);
+
+ entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
+ u32 size = vec_len (entries) * sizeof (u32);
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
+ {
+ rmp->count = clib_host_to_net_u32 (vec_len (entries));
+ vec_foreach (e, entries)
+ {
+ mac_copy (rmp->entries[i].mac, e->mac);
+ rmp->entries[i].ip4 = e->ip4;
+ i++;
+ }
+ });
+ /* *INDENT-ON* */
+ vec_free (entries);
}
/*