cleanup and fixes for status & statusall
This commit is contained in:
@@ -965,108 +965,12 @@ static void stroke_del_ca(private_stroke_interface_t *this,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show status of daemon
|
* log an IKE_SA to out
|
||||||
*/
|
*/
|
||||||
static void stroke_status(private_stroke_interface_t *this,
|
static void log_ike_sa(FILE *out, ike_sa_t *ike_sa, bool all)
|
||||||
stroke_msg_t *msg, FILE *out, bool all)
|
|
||||||
{
|
|
||||||
iterator_t *iterator, *children;
|
|
||||||
linked_list_t *list;
|
|
||||||
host_t *host;
|
|
||||||
peer_cfg_t *peer_cfg;
|
|
||||||
ike_cfg_t *ike_cfg;
|
|
||||||
child_cfg_t *child_cfg;
|
|
||||||
ike_sa_t *ike_sa;
|
|
||||||
char *name = NULL;
|
|
||||||
u_int32_t now = time(NULL);
|
|
||||||
|
|
||||||
if (msg->status.name)
|
|
||||||
{
|
|
||||||
pop_string(msg, &(msg->status.name));
|
|
||||||
name = msg->status.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (all)
|
|
||||||
{
|
|
||||||
leak_detective_status(out);
|
|
||||||
|
|
||||||
fprintf(out, "Performance:\n");
|
|
||||||
fprintf(out, " worker threads: %d idle of %d,",
|
|
||||||
charon->thread_pool->get_idle_threads(charon->thread_pool),
|
|
||||||
charon->thread_pool->get_pool_size(charon->thread_pool));
|
|
||||||
fprintf(out, " job queue load: %d,",
|
|
||||||
charon->job_queue->get_count(charon->job_queue));
|
|
||||||
fprintf(out, " scheduled events: %d\n",
|
|
||||||
charon->event_queue->get_count(charon->event_queue));
|
|
||||||
list = charon->kernel_interface->create_address_list(charon->kernel_interface);
|
|
||||||
|
|
||||||
fprintf(out, "Listening on %d IP addresses:\n", list->get_count(list));
|
|
||||||
while (list->remove_first(list, (void**)&host) == SUCCESS)
|
|
||||||
{
|
|
||||||
fprintf(out, " %H\n", host);
|
|
||||||
host->destroy(host);
|
|
||||||
}
|
|
||||||
list->destroy(list);
|
|
||||||
|
|
||||||
fprintf(out, "Connections:\n");
|
|
||||||
iterator = this->backend->create_peer_cfg_iterator(this->backend);
|
|
||||||
while (iterator->iterate(iterator, (void**)&peer_cfg))
|
|
||||||
{
|
|
||||||
if (peer_cfg->get_ike_version(peer_cfg) != 2 ||
|
|
||||||
(name && !streq(name, peer_cfg->get_name(peer_cfg))))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
|
|
||||||
fprintf(out, "%12s: %H[%D]...%H[%D]\n", peer_cfg->get_name(peer_cfg),
|
|
||||||
ike_cfg->get_my_host(ike_cfg), peer_cfg->get_my_id(peer_cfg),
|
|
||||||
ike_cfg->get_other_host(ike_cfg), peer_cfg->get_other_id(peer_cfg));
|
|
||||||
children = peer_cfg->create_child_cfg_iterator(peer_cfg);
|
|
||||||
while (children->iterate(children, (void**)&child_cfg))
|
|
||||||
{
|
|
||||||
linked_list_t *my_ts, *other_ts;
|
|
||||||
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
|
|
||||||
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
|
|
||||||
fprintf(out, "%12s: %#R=== %#R\n", child_cfg->get_name(child_cfg),
|
|
||||||
my_ts, other_ts);
|
|
||||||
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
|
|
||||||
other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
|
|
||||||
}
|
|
||||||
children->destroy(children);
|
|
||||||
}
|
|
||||||
iterator->destroy(iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator = charon->ike_sa_manager->create_iterator(charon->ike_sa_manager);
|
|
||||||
if (all && iterator->get_count(iterator) > 0)
|
|
||||||
{
|
|
||||||
fprintf(out, "Security Associations:\n");
|
|
||||||
}
|
|
||||||
while (iterator->iterate(iterator, (void**)&ike_sa))
|
|
||||||
{
|
|
||||||
bool ike_match = FALSE, ike_printed = FALSE;
|
|
||||||
child_sa_t *child_sa;
|
|
||||||
iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
|
|
||||||
|
|
||||||
if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
|
|
||||||
{
|
|
||||||
ike_match = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (children->iterate(children, (void**)&child_sa))
|
|
||||||
{
|
|
||||||
bool child_match = FALSE;
|
|
||||||
|
|
||||||
if (name == NULL || streq(name, child_sa->get_name(child_sa)))
|
|
||||||
{
|
|
||||||
child_match = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((child_match || ike_match) && !ike_printed)
|
|
||||||
{
|
{
|
||||||
peer_cfg_t *cfg = ike_sa->get_peer_cfg(ike_sa);
|
peer_cfg_t *cfg = ike_sa->get_peer_cfg(ike_sa);
|
||||||
u_int32_t next;
|
u_int32_t next, now = time(NULL);
|
||||||
|
|
||||||
fprintf(out, "%12s[%d]: %N, %H[%D]...%H[%D]\n",
|
fprintf(out, "%12s[%d]: %N, %H[%D]...%H[%D]\n",
|
||||||
ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
|
ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
|
||||||
@@ -1091,14 +995,14 @@ static void stroke_status(private_stroke_interface_t *this,
|
|||||||
fprintf(out, "rekeying disabled\n");
|
fprintf(out, "rekeying disabled\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ike_printed = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child_match)
|
/**
|
||||||
|
* log an CHILD_SA to out
|
||||||
|
*/
|
||||||
|
static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
|
||||||
{
|
{
|
||||||
u_int32_t rekey;
|
u_int32_t rekey, now = time(NULL);
|
||||||
u_int32_t use_in, use_out, use_fwd;
|
u_int32_t use_in, use_out, use_fwd;
|
||||||
encryption_algorithm_t encr_alg;
|
encryption_algorithm_t encr_alg;
|
||||||
integrity_algorithm_t int_alg;
|
integrity_algorithm_t int_alg;
|
||||||
@@ -1180,6 +1084,108 @@ static void stroke_status(private_stroke_interface_t *this,
|
|||||||
child_sa->get_traffic_selectors(child_sa, TRUE),
|
child_sa->get_traffic_selectors(child_sa, TRUE),
|
||||||
child_sa->get_traffic_selectors(child_sa, FALSE));
|
child_sa->get_traffic_selectors(child_sa, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show status of daemon
|
||||||
|
*/
|
||||||
|
static void stroke_status(private_stroke_interface_t *this,
|
||||||
|
stroke_msg_t *msg, FILE *out, bool all)
|
||||||
|
{
|
||||||
|
iterator_t *iterator, *children;
|
||||||
|
linked_list_t *list;
|
||||||
|
host_t *host;
|
||||||
|
peer_cfg_t *peer_cfg;
|
||||||
|
ike_cfg_t *ike_cfg;
|
||||||
|
child_cfg_t *child_cfg;
|
||||||
|
ike_sa_t *ike_sa;
|
||||||
|
char *name = NULL;
|
||||||
|
|
||||||
|
if (msg->status.name)
|
||||||
|
{
|
||||||
|
pop_string(msg, &(msg->status.name));
|
||||||
|
name = msg->status.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (all)
|
||||||
|
{
|
||||||
|
leak_detective_status(out);
|
||||||
|
|
||||||
|
fprintf(out, "Performance:\n");
|
||||||
|
fprintf(out, " worker threads: %d idle of %d,",
|
||||||
|
charon->thread_pool->get_idle_threads(charon->thread_pool),
|
||||||
|
charon->thread_pool->get_pool_size(charon->thread_pool));
|
||||||
|
fprintf(out, " job queue load: %d,",
|
||||||
|
charon->job_queue->get_count(charon->job_queue));
|
||||||
|
fprintf(out, " scheduled events: %d\n",
|
||||||
|
charon->event_queue->get_count(charon->event_queue));
|
||||||
|
list = charon->kernel_interface->create_address_list(charon->kernel_interface);
|
||||||
|
|
||||||
|
fprintf(out, "Listening on %d IP addresses:\n", list->get_count(list));
|
||||||
|
while (list->remove_first(list, (void**)&host) == SUCCESS)
|
||||||
|
{
|
||||||
|
fprintf(out, " %H\n", host);
|
||||||
|
host->destroy(host);
|
||||||
|
}
|
||||||
|
list->destroy(list);
|
||||||
|
|
||||||
|
fprintf(out, "Connections:\n");
|
||||||
|
iterator = this->backend->create_peer_cfg_iterator(this->backend);
|
||||||
|
while (iterator->iterate(iterator, (void**)&peer_cfg))
|
||||||
|
{
|
||||||
|
if (peer_cfg->get_ike_version(peer_cfg) != 2 ||
|
||||||
|
(name && !streq(name, peer_cfg->get_name(peer_cfg))))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
|
||||||
|
fprintf(out, "%12s: %H[%D]...%H[%D]\n", peer_cfg->get_name(peer_cfg),
|
||||||
|
ike_cfg->get_my_host(ike_cfg), peer_cfg->get_my_id(peer_cfg),
|
||||||
|
ike_cfg->get_other_host(ike_cfg), peer_cfg->get_other_id(peer_cfg));
|
||||||
|
children = peer_cfg->create_child_cfg_iterator(peer_cfg);
|
||||||
|
while (children->iterate(children, (void**)&child_cfg))
|
||||||
|
{
|
||||||
|
linked_list_t *my_ts, *other_ts;
|
||||||
|
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
|
||||||
|
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
|
||||||
|
fprintf(out, "%12s: %#R=== %#R\n", child_cfg->get_name(child_cfg),
|
||||||
|
my_ts, other_ts);
|
||||||
|
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
|
||||||
|
other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
|
||||||
|
}
|
||||||
|
children->destroy(children);
|
||||||
|
}
|
||||||
|
iterator->destroy(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator = charon->ike_sa_manager->create_iterator(charon->ike_sa_manager);
|
||||||
|
if (all && iterator->get_count(iterator) > 0)
|
||||||
|
{
|
||||||
|
fprintf(out, "Security Associations:\n");
|
||||||
|
}
|
||||||
|
while (iterator->iterate(iterator, (void**)&ike_sa))
|
||||||
|
{
|
||||||
|
bool ike_printed = FALSE;
|
||||||
|
child_sa_t *child_sa;
|
||||||
|
iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
|
||||||
|
|
||||||
|
if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
|
||||||
|
{
|
||||||
|
log_ike_sa(out, ike_sa, all);
|
||||||
|
ike_printed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (children->iterate(children, (void**)&child_sa))
|
||||||
|
{
|
||||||
|
if (name == NULL || streq(name, child_sa->get_name(child_sa)))
|
||||||
|
{
|
||||||
|
if (!ike_printed)
|
||||||
|
{
|
||||||
|
log_ike_sa(out, ike_sa, all);
|
||||||
|
ike_printed = TRUE;
|
||||||
|
}
|
||||||
|
log_child_sa(out, child_sa, all);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
children->destroy(children);
|
children->destroy(children);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user