aboutsummaryrefslogtreecommitdiffstats
path: root/vlib-api
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-12-05 09:50:05 -0500
committerDave Barach <openvpp@barachs.net>2016-12-05 15:33:51 +0000
commit6d963c272cb59cbcb41a2f2c7e01834a80fad683 (patch)
tree4cd6e9245731df4621ca0b8916f16500e0d3b5a1 /vlib-api
parent6dcda02dd89e570118d5468a3226e80968d36f18 (diff)
Move interface APIs to vnet/vnet/{interface.api,interface_api.c}
Change-Id: If3f0f73ad1c1d54ac69122052c977eb83a9e16eb Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vlib-api')
-rw-r--r--vlib-api/vlibapi/api_helper_macros.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/vlib-api/vlibapi/api_helper_macros.h b/vlib-api/vlibapi/api_helper_macros.h
index 9ccdf961970..a14756565af 100644
--- a/vlib-api/vlibapi/api_helper_macros.h
+++ b/vlib-api/vlibapi/api_helper_macros.h
@@ -152,6 +152,85 @@ bad_tx_sw_if_index: \
; \
} while (0);
+#define pub_sub_handler(lca,UCA) \
+static void vl_api_want_##lca##_t_handler ( \
+ vl_api_want_##lca##_t *mp) \
+{ \
+ vpe_api_main_t *vam = &vpe_api_main; \
+ vpe_client_registration_t *rp; \
+ vl_api_want_##lca##_reply_t *rmp; \
+ uword *p; \
+ i32 rv = 0; \
+ \
+ p = hash_get (vam->lca##_registration_hash, mp->client_index); \
+ if (p) { \
+ if (mp->enable_disable) { \
+ clib_warning ("pid %d: already enabled...", mp->pid); \
+ rv = VNET_API_ERROR_INVALID_REGISTRATION; \
+ goto reply; \
+ } else { \
+ rp = pool_elt_at_index (vam->lca##_registrations, p[0]); \
+ pool_put (vam->lca##_registrations, rp); \
+ hash_unset (vam->lca##_registration_hash, \
+ mp->client_index); \
+ goto reply; \
+ } \
+ } \
+ if (mp->enable_disable == 0) { \
+ clib_warning ("pid %d: already disabled...", mp->pid); \
+ rv = VNET_API_ERROR_INVALID_REGISTRATION; \
+ goto reply; \
+ } \
+ pool_get (vam->lca##_registrations, rp); \
+ rp->client_index = mp->client_index; \
+ rp->client_pid = mp->pid; \
+ hash_set (vam->lca##_registration_hash, rp->client_index, \
+ rp - vam->lca##_registrations); \
+ \
+reply: \
+ REPLY_MACRO (VL_API_WANT_##UCA##_REPLY); \
+}
+
+#define foreach_registration_hash \
+_(interface_events) \
+_(to_netconf_server) \
+_(from_netconf_server) \
+_(to_netconf_client) \
+_(from_netconf_client) \
+_(oam_events)
+
+/* WARNING: replicated in vpp/stats.h */
+typedef struct
+{
+ u32 client_index; /* in memclnt registration pool */
+ u32 client_pid;
+} vpe_client_registration_t;
+
+struct _vl_api_ip4_arp_event;
+struct _vl_api_ip6_nd_event;
+
+typedef struct
+{
+#define _(a) uword *a##_registration_hash; \
+ vpe_client_registration_t * a##_registrations;
+ foreach_registration_hash
+#undef _
+ /* notifications happen really early in the game */
+ u8 link_state_process_up;
+
+ /* ip4 arp event registration pool */
+ struct _vl_api_ip4_arp_event *arp_events;
+
+ /* ip6 nd event registration pool */
+ struct _vl_api_ip6_nd_event *nd_events;
+
+ /* convenience */
+ vlib_main_t *vlib_main;
+ vnet_main_t *vnet_main;
+} vpe_api_main_t;
+
+extern vpe_api_main_t vpe_api_main;
+
#endif /* __api_helper_macros_h__ */
/*