aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-02-10 17:09:01 +0100
committerMartin Willi <martin@revosec.ch>2014-05-07 14:13:35 +0200
commitb40a12a96fecf688f81a81ecb292ff435e65bcd2 (patch)
tree09e4f038d964d406f1457f3703b455b3be67dd66 /src/libcharon/plugins
parent293431269b59377af84c519c29ba0fabdbd3885b (diff)
downloadstrongswan-b40a12a96fecf688f81a81ecb292ff435e65bcd2.tar.bz2
strongswan-b40a12a96fecf688f81a81ecb292ff435e65bcd2.tar.xz
vici: Raise events with an optional identifier for specific connections
Diffstat (limited to 'src/libcharon/plugins')
-rw-r--r--src/libcharon/plugins/vici/suites/test_event.c4
-rw-r--r--src/libcharon/plugins/vici/suites/test_request.c2
-rw-r--r--src/libcharon/plugins/vici/vici_dispatcher.c12
-rw-r--r--src/libcharon/plugins/vici/vici_dispatcher.h5
4 files changed, 14 insertions, 9 deletions
diff --git a/src/libcharon/plugins/vici/suites/test_event.c b/src/libcharon/plugins/vici/suites/test_event.c
index 771f12701..4dd9c7309 100644
--- a/src/libcharon/plugins/vici/suites/test_event.c
+++ b/src/libcharon/plugins/vici/suites/test_event.c
@@ -55,7 +55,7 @@ START_TEST(test_event)
ck_assert(vici_register(conn, "test", event_cb, &count) == 0);
ck_assert(vici_register(conn, "nonexistent", event_cb, &count) != 0);
- dispatcher->raise_event(dispatcher, "test", vici_message_create_from_args(
+ dispatcher->raise_event(dispatcher, "test", 0, vici_message_create_from_args(
VICI_KEY_VALUE, "key1", chunk_from_str("value1"),
VICI_END));
@@ -100,7 +100,7 @@ START_TEST(test_stress)
/* do some event re/deregistration in between */
ck_assert(vici_register(conn, "dummy", event_cb, NULL) == 0);
- dispatcher->raise_event(dispatcher, "test",
+ dispatcher->raise_event(dispatcher, "test", 0,
vici_message_create_from_args(
VICI_KEY_VALUE, "key1", chunk_from_str("value1"),
VICI_END));
diff --git a/src/libcharon/plugins/vici/suites/test_request.c b/src/libcharon/plugins/vici/suites/test_request.c
index 1f124d3dc..8cb11a7ea 100644
--- a/src/libcharon/plugins/vici/suites/test_request.c
+++ b/src/libcharon/plugins/vici/suites/test_request.c
@@ -188,7 +188,7 @@ START_TEST(test_stress)
{
/* do some event management in between */
ck_assert(vici_register(conn, "dummy", event_cb, &events) == 0);
- dispatcher->raise_event(dispatcher, "dummy",
+ dispatcher->raise_event(dispatcher, "dummy", 0,
vici_message_create_from_args(
VICI_KEY_VALUE, "key1", chunk_from_str("value1"),
VICI_END));
diff --git a/src/libcharon/plugins/vici/vici_dispatcher.c b/src/libcharon/plugins/vici/vici_dispatcher.c
index 797e51f61..982206af1 100644
--- a/src/libcharon/plugins/vici/vici_dispatcher.c
+++ b/src/libcharon/plugins/vici/vici_dispatcher.c
@@ -382,11 +382,12 @@ METHOD(vici_dispatcher_t, manage_event, void,
}
METHOD(vici_dispatcher_t, raise_event, void,
- private_vici_dispatcher_t *this, char *name, vici_message_t *message)
+ private_vici_dispatcher_t *this, char *name, u_int id,
+ vici_message_t *message)
{
enumerator_t *enumerator;
event_t *event;
- u_int *id;
+ u_int *current;
this->mutex->lock(this->mutex);
event = this->events->get(this->events, name);
@@ -397,9 +398,12 @@ METHOD(vici_dispatcher_t, raise_event, void,
this->mutex->unlock(this->mutex);
enumerator = array_create_enumerator(event->clients);
- while (enumerator->enumerate(enumerator, &id))
+ while (enumerator->enumerate(enumerator, &current))
{
- send_op(this, *id, VICI_EVENT, name, message);
+ if (id == 0 || id == *current)
+ {
+ send_op(this, *current, VICI_EVENT, name, message);
+ }
}
enumerator->destroy(enumerator);
diff --git a/src/libcharon/plugins/vici/vici_dispatcher.h b/src/libcharon/plugins/vici/vici_dispatcher.h
index 518550491..effe5a670 100644
--- a/src/libcharon/plugins/vici/vici_dispatcher.h
+++ b/src/libcharon/plugins/vici/vici_dispatcher.h
@@ -92,12 +92,13 @@ struct vici_dispatcher_t {
void (*manage_event)(vici_dispatcher_t *this, char *name, bool reg);
/**
- * Raise an event to all clients registered to that event.
+ * Raise an event to a specific or all clients registered to that event.
*
* @param name event name to raise
+ * @param id client connection ID, 0 for all
* @param message event message to send, gets destroyed
*/
- void (*raise_event)(vici_dispatcher_t *this, char *name,
+ void (*raise_event)(vici_dispatcher_t *this, char *name, u_int id,
vici_message_t *message);
/**