aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/vici/vici_query.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2015-06-01 15:36:21 +0200
committerTobias Brunner <tobias@strongswan.org>2015-08-17 11:12:17 +0200
commit65ac0851c0a654a0d2b1011e7581889621aeab25 (patch)
tree7e5ca29069c0b1e3aae7e0d4c2d168b4aaada42f /src/libcharon/plugins/vici/vici_query.c
parent7f21363ee518e77b4e72538b668a473bd461c3a8 (diff)
downloadstrongswan-65ac0851c0a654a0d2b1011e7581889621aeab25.tar.bz2
strongswan-65ac0851c0a654a0d2b1011e7581889621aeab25.tar.xz
vici: Add ike/child-rekey events
Diffstat (limited to 'src/libcharon/plugins/vici/vici_query.c')
-rw-r--r--src/libcharon/plugins/vici/vici_query.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/libcharon/plugins/vici/vici_query.c b/src/libcharon/plugins/vici/vici_query.c
index 236d36743..e4d0d62f4 100644
--- a/src/libcharon/plugins/vici/vici_query.c
+++ b/src/libcharon/plugins/vici/vici_query.c
@@ -1031,7 +1031,9 @@ static void manage_commands(private_vici_query_t *this, bool reg)
this->dispatcher->manage_event(this->dispatcher, "list-conn", reg);
this->dispatcher->manage_event(this->dispatcher, "list-cert", reg);
this->dispatcher->manage_event(this->dispatcher, "ike-updown", reg);
+ this->dispatcher->manage_event(this->dispatcher, "ike-rekey", reg);
this->dispatcher->manage_event(this->dispatcher, "child-updown", reg);
+ this->dispatcher->manage_event(this->dispatcher, "child-rekey", reg);
manage_command(this, "list-sas", list_sas, reg);
manage_command(this, "list-policies", list_policies, reg);
manage_command(this, "list-conns", list_conns, reg);
@@ -1070,6 +1072,35 @@ METHOD(listener_t, ike_updown, bool,
return TRUE;
}
+METHOD(listener_t, ike_rekey, bool,
+ private_vici_query_t *this, ike_sa_t *old, ike_sa_t *new)
+{
+ vici_builder_t *b;
+ time_t now;
+
+ if (!this->dispatcher->has_event_listeners(this->dispatcher, "ike-rekey"))
+ {
+ return TRUE;
+ }
+
+ now = time_monotonic(NULL);
+
+ b = vici_builder_create();
+ b->begin_section(b, old->get_name(old));
+ b->begin_section(b, "old");
+ list_ike(this, b, old, now);
+ b->end_section(b);
+ b->begin_section(b, "new");
+ list_ike(this, b, new, now);
+ b->end_section(b);
+ b->end_section(b);
+
+ this->dispatcher->raise_event(this->dispatcher,
+ "ike-rekey", 0, b->finalize(b));
+
+ return TRUE;
+}
+
METHOD(listener_t, child_updown, bool,
private_vici_query_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa, bool up)
{
@@ -1106,6 +1137,45 @@ METHOD(listener_t, child_updown, bool,
return TRUE;
}
+METHOD(listener_t, child_rekey, bool,
+ private_vici_query_t *this, ike_sa_t *ike_sa, child_sa_t *old,
+ child_sa_t *new)
+{
+ vici_builder_t *b;
+ time_t now;
+
+ if (!this->dispatcher->has_event_listeners(this->dispatcher, "child-rekey"))
+ {
+ return TRUE;
+ }
+
+ now = time_monotonic(NULL);
+ b = vici_builder_create();
+
+ b->begin_section(b, ike_sa->get_name(ike_sa));
+ list_ike(this, b, ike_sa, now);
+ b->begin_section(b, "child-sas");
+
+ b->begin_section(b, old->get_name(old));
+
+ b->begin_section(b, "old");
+ list_child(this, b, old, now);
+ b->end_section(b);
+ b->begin_section(b, "new");
+ list_child(this, b, new, now);
+ b->end_section(b);
+
+ b->end_section(b);
+
+ b->end_section(b);
+ b->end_section(b);
+
+ this->dispatcher->raise_event(this->dispatcher,
+ "child-rekey", 0, b->finalize(b));
+
+ return TRUE;
+}
+
METHOD(vici_query_t, destroy, void,
private_vici_query_t *this)
{
@@ -1124,7 +1194,9 @@ vici_query_t *vici_query_create(vici_dispatcher_t *dispatcher)
.public = {
.listener = {
.ike_updown = _ike_updown,
+ .ike_rekey = _ike_rekey,
.child_updown = _child_updown,
+ .child_rekey = _child_rekey,
},
.destroy = _destroy,
},