--- embedaddon/strongswan/src/libcharon/plugins/vici/vici_query.c 2020/06/03 09:46:45 1.1.1.1 +++ embedaddon/strongswan/src/libcharon/plugins/vici/vici_query.c 2021/03/17 00:20:09 1.1.1.2 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2017 Tobias Brunner + * Copyright (C) 2015-2020 Tobias Brunner * Copyright (C) 2015-2018 Andreas Steffen * HSR Hochschule fuer Technik Rapperswil * @@ -510,6 +510,7 @@ CALLBACK(list_sas, vici_message_t*, bool bl; char buf[BUF_LEN]; + bl = request->get_str(request, NULL, "noblock") == NULL; ike = request->get_str(request, NULL, "ike"); ike_id = request->get_int(request, 0, "ike-id"); @@ -1683,6 +1684,7 @@ static void manage_commands(private_vici_query_t *this 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, "ike-update", 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); @@ -1755,6 +1757,36 @@ METHOD(listener_t, ike_rekey, bool, return TRUE; } +METHOD(listener_t, ike_update, bool, + private_vici_query_t *this, ike_sa_t *ike_sa, host_t *local, host_t *remote) +{ + vici_builder_t *b; + time_t now; + + if (!this->dispatcher->has_event_listeners(this->dispatcher, "ike-update")) + { + return TRUE; + } + + now = time_monotonic(NULL); + + b = vici_builder_create(); + + b->add_kv(b, "local-host", "%H", local); + b->add_kv(b, "local-port", "%d", local->get_port(local)); + b->add_kv(b, "remote-host", "%H", remote); + b->add_kv(b, "remote-port", "%d", remote->get_port(remote)); + + b->begin_section(b, ike_sa->get_name(ike_sa)); + list_ike(this, b, ike_sa, now); + b->end_section(b); + + this->dispatcher->raise_event(this->dispatcher, + "ike-update", 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) { @@ -1853,6 +1885,7 @@ vici_query_t *vici_query_create(vici_dispatcher_t *dis .listener = { .ike_updown = _ike_updown, .ike_rekey = _ike_rekey, + .ike_update = _ike_update, .child_updown = _child_updown, .child_rekey = _child_rekey, },