summaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/wireguard/wireguard_api.c')
-rw-r--r--src/plugins/wireguard/wireguard_api.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/plugins/wireguard/wireguard_api.c b/src/plugins/wireguard/wireguard_api.c
index c5334e0ecd4..e736efcd6c0 100644
--- a/src/plugins/wireguard/wireguard_api.c
+++ b/src/plugins/wireguard/wireguard_api.c
@@ -346,7 +346,7 @@ vl_api_want_wireguard_peer_events_t_handler (
REPLY_MACRO (VL_API_WANT_WIREGUARD_PEER_EVENTS_REPLY);
}
-void
+static void
wg_api_send_peer_event (vl_api_registration_t *rp, index_t peer_index,
wg_peer_flags flags)
{
@@ -360,10 +360,16 @@ wg_api_send_peer_event (vl_api_registration_t *rp, index_t peer_index,
vl_api_send_msg (rp, (u8 *) mp);
}
-void
-wg_api_peer_event (index_t peeri, wg_peer_flags flags)
+typedef struct
{
- wg_peer_t *peer = wg_peer_get (peeri);
+ index_t peeri;
+ wg_peer_flags flags;
+} wg_api_peer_event_args_t;
+
+static void
+wg_api_peer_event_cb (wg_api_peer_event_args_t *args)
+{
+ wg_peer_t *peer = wg_peer_get (args->peeri);
vpe_client_registration_t *api_client;
vl_api_registration_t *rp;
@@ -372,11 +378,23 @@ wg_api_peer_event (index_t peeri, wg_peer_flags flags)
rp = vl_api_client_index_to_registration (api_client->client_index);
if (rp)
{
- wg_api_send_peer_event (rp, peeri, flags);
+ wg_api_send_peer_event (rp, args->peeri, args->flags);
}
};
}
+void
+wg_api_peer_event (index_t peeri, wg_peer_flags flags)
+{
+ wg_api_peer_event_args_t args = {
+ .peeri = peeri,
+ .flags = flags,
+ };
+
+ vl_api_rpc_call_main_thread (wg_api_peer_event_cb, (u8 *) &args,
+ sizeof (args));
+}
+
static void
vl_api_wg_set_async_mode_t_handler (vl_api_wg_set_async_mode_t *mp)
{