+typedef struct
+{
+ u32 bs_idx;
+} bfd_rpc_event_t;
+
+static void
+bfd_rpc_event_cb (const bfd_rpc_event_t * a)
+{
+ bfd_main_t *bm = &bfd_main;
+ u32 bs_idx = a->bs_idx;
+ u32 valid_bs = 0;
+ bfd_session_t session_data;
+
+ bfd_lock (bm);
+ if (!pool_is_free_index (bm->sessions, bs_idx))
+ {
+ bfd_session_t *bs = pool_elt_at_index (bm->sessions, bs_idx);
+ clib_memcpy (&session_data, bs, sizeof (bfd_session_t));
+ valid_bs = 1;
+ }
+ else
+ {
+ BFD_DBG ("Ignoring event RPC for non-existent session index %u",
+ bs_idx);
+ }
+ bfd_unlock (bm);
+
+ if (valid_bs)
+ bfd_event (bm, &session_data);
+}
+
+static void
+bfd_event_rpc (u32 bs_idx)
+{
+ const u32 data_size = sizeof (bfd_rpc_event_t);
+ u8 data[data_size];
+ bfd_rpc_event_t *event = (bfd_rpc_event_t *) data;
+
+ event->bs_idx = bs_idx;
+ vl_api_rpc_call_main_thread (bfd_rpc_event_cb, data, data_size);
+}
+
+typedef struct
+{
+ u32 bs_idx;
+} bfd_rpc_notify_listeners_t;
+
+static void
+bfd_rpc_notify_listeners_cb (const bfd_rpc_notify_listeners_t * a)
+{
+ bfd_main_t *bm = &bfd_main;
+ u32 bs_idx = a->bs_idx;
+ bfd_lock (bm);
+ if (!pool_is_free_index (bm->sessions, bs_idx))
+ {
+ bfd_session_t *bs = pool_elt_at_index (bm->sessions, bs_idx);
+ bfd_notify_listeners (bm, BFD_LISTEN_EVENT_UPDATE, bs);
+ }
+ else
+ {
+ BFD_DBG ("Ignoring notify RPC for non-existent session index %u",
+ bs_idx);
+ }
+ bfd_unlock (bm);
+}
+
+static void
+bfd_notify_listeners_rpc (u32 bs_idx)
+{
+ const u32 data_size = sizeof (bfd_rpc_notify_listeners_t);
+ u8 data[data_size];
+ bfd_rpc_notify_listeners_t *notify = (bfd_rpc_notify_listeners_t *) data;
+ notify->bs_idx = bs_idx;
+ vl_api_rpc_call_main_thread (bfd_rpc_notify_listeners_cb, data, data_size);
+}
+