redesigned formatting of ipsec status|statusall
This commit is contained in:
+12
-12
@@ -769,18 +769,18 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
|
||||
now = (u_int32_t)time(NULL);
|
||||
|
||||
written += fprintf(stream, "%10s: %N, reqid: %d", this->name,
|
||||
written += fprintf(stream, "%12s: %N, reqid: %d", this->name,
|
||||
child_sa_state_names, this->state, this->reqid);
|
||||
|
||||
if (this->state == CHILD_INSTALLED)
|
||||
{
|
||||
written += fprintf(stream, ", %N, SPIs (in/out): 0x%x/0x%x",
|
||||
written += fprintf(stream, ", %N SPIs: 0x%0x_i 0x%0x_o",
|
||||
protocol_id_names, this->protocol,
|
||||
htonl(this->me.spi), htonl(this->other.spi));
|
||||
|
||||
if (info->alt)
|
||||
{
|
||||
written += fprintf(stream, "\n%10s: ", this->name);
|
||||
written += fprintf(stream, "\n%12s: ", this->name);
|
||||
|
||||
if (this->protocol == PROTO_ESP)
|
||||
{
|
||||
@@ -800,13 +800,13 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
{
|
||||
written += fprintf(stream, "-%d", this->integrity.key_size);
|
||||
}
|
||||
written += fprintf(stream, ", rekeying: ");
|
||||
written += fprintf(stream, ", rekeying ");
|
||||
|
||||
/* calculate rekey times */
|
||||
if (this->soft_lifetime)
|
||||
{
|
||||
rekeying = this->soft_lifetime - (now - this->install_time);
|
||||
written += fprintf(stream, "%ds", rekeying);
|
||||
written += fprintf(stream, "in %ds", rekeying);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -817,7 +817,7 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
iterator = this->policies->create_iterator(this->policies, TRUE);
|
||||
while (iterator->iterate(iterator, (void**)&policy))
|
||||
{
|
||||
written += fprintf(stream, "\n%10s: %R===%R, last use (in/out/fwd): ",
|
||||
written += fprintf(stream, "\n%12s: %R===%R, last use: ",
|
||||
this->name, policy->my_ts, policy->other_ts);
|
||||
|
||||
/* query policy times */
|
||||
@@ -825,31 +825,31 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
policy->other_ts, policy->my_ts, POLICY_IN, &use);
|
||||
if (status == SUCCESS && use)
|
||||
{
|
||||
written += fprintf(stream, "%ds/", now - use);
|
||||
written += fprintf(stream, "%ds_in ", now - use);
|
||||
}
|
||||
else
|
||||
{
|
||||
written += fprintf(stream, "unused/");
|
||||
written += fprintf(stream, "no_in ");
|
||||
}
|
||||
status = charon->kernel_interface->query_policy(charon->kernel_interface,
|
||||
policy->my_ts, policy->other_ts, POLICY_OUT, &use);
|
||||
if (status == SUCCESS && use)
|
||||
{
|
||||
written += fprintf(stream, "%ds/", now - use);
|
||||
written += fprintf(stream, "%ds_out ", now - use);
|
||||
}
|
||||
else
|
||||
{
|
||||
written += fprintf(stream, "unused/");
|
||||
written += fprintf(stream, "no_out ");
|
||||
}
|
||||
status = charon->kernel_interface->query_policy(charon->kernel_interface,
|
||||
policy->other_ts, policy->my_ts, POLICY_FWD, &use);
|
||||
if (status == SUCCESS && use)
|
||||
{
|
||||
written += fprintf(stream, "%ds", now - use);
|
||||
written += fprintf(stream, "%ds_fwd", now - use);
|
||||
}
|
||||
else
|
||||
{
|
||||
written += fprintf(stream, "unused");
|
||||
written += fprintf(stream, "no_fwd");
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
+11
-4
@@ -1883,6 +1883,7 @@ static void enable_natt(private_ike_sa_t *this, bool local)
|
||||
static int print(FILE *stream, const struct printf_info *info,
|
||||
const void *const *args)
|
||||
{
|
||||
int written = 0;
|
||||
private_ike_sa_t *this = *((private_ike_sa_t**)(args[0]));
|
||||
|
||||
if (this == NULL)
|
||||
@@ -1890,10 +1891,16 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
return fprintf(stream, "(null)");
|
||||
}
|
||||
|
||||
return fprintf(stream, "%10s: %N, %H[%D]...%H[%D] (%J)",
|
||||
this->name, ike_sa_state_names, this->state,
|
||||
this->my_host, this->my_id, this->other_host, this->other_id,
|
||||
this->ike_sa_id);
|
||||
written = fprintf(stream, "%12s: %N, %H[%D]...%H[%D], IKE SPIs: %J",
|
||||
this->name, ike_sa_state_names, this->state,
|
||||
this->my_host, this->my_id, this->other_host, this->other_id,
|
||||
this->ike_sa_id);
|
||||
|
||||
if (info->alt)
|
||||
{
|
||||
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,9 +164,11 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
{
|
||||
return fprintf(stream, "(null)");
|
||||
}
|
||||
return fprintf(stream, "%llx:%llx[%c]",
|
||||
this->initiator_spi, this->responder_spi,
|
||||
this->is_initiator_flag ? 'i' : 'r');
|
||||
return fprintf(stream, "0x%0llx_i%s 0x%0llx_r%s",
|
||||
this->initiator_spi,
|
||||
this->is_initiator_flag ? "*" : "",
|
||||
this->responder_spi,
|
||||
this->is_initiator_flag ? "" : "*");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -645,15 +645,17 @@ static void stroke_statusall(private_stroke_t *this, stroke_msg_t *msg)
|
||||
|
||||
leak_detective_status(this->out);
|
||||
|
||||
fprintf(this->out, "worker threads idle: %d of %d\n",
|
||||
fprintf(this->out, "Performance:\n");
|
||||
fprintf(this->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(this->out, "job queue load: %d\n",
|
||||
fprintf(this->out, " job queue load: %d,",
|
||||
charon->job_queue->get_count(charon->job_queue));
|
||||
fprintf(this->out, "scheduled events: %d\n",
|
||||
fprintf(this->out, " scheduled events: %d\n",
|
||||
charon->event_queue->get_count(charon->event_queue));
|
||||
list = charon->socket->create_local_address_list(charon->socket);
|
||||
fprintf(this->out, "listening on %d addresses:\n", list->get_count(list));
|
||||
|
||||
fprintf(this->out, "Listening on %d IP addresses:\n", list->get_count(list));
|
||||
while (list->remove_first(list, (void**)&host) == SUCCESS)
|
||||
{
|
||||
fprintf(this->out, " %H\n", host);
|
||||
@@ -666,14 +668,17 @@ static void stroke_statusall(private_stroke_t *this, stroke_msg_t *msg)
|
||||
pop_string(msg, &(msg->status.name));
|
||||
}
|
||||
|
||||
fprintf(this->out, "connections:\n");
|
||||
iterator = charon->connections->create_iterator(charon->connections);
|
||||
if (iterator->get_count(iterator) > 0)
|
||||
{
|
||||
fprintf(this->out, "Connections:\n");
|
||||
}
|
||||
while (iterator->iterate(iterator, (void**)&connection))
|
||||
{
|
||||
if (connection->is_ikev2(connection) && (msg->status.name == NULL ||
|
||||
streq(msg->status.name, connection->get_name(connection))))
|
||||
if (connection->is_ikev2(connection) && (msg->status.name == NULL
|
||||
|| streq(msg->status.name, connection->get_name(connection))))
|
||||
{
|
||||
fprintf(this->out, "%10s: %H...%H\n",
|
||||
fprintf(this->out, "%12s: %H...%H\n",
|
||||
connection->get_name(connection),
|
||||
connection->get_my_host(connection),
|
||||
connection->get_other_host(connection));
|
||||
@@ -681,14 +686,17 @@ static void stroke_statusall(private_stroke_t *this, stroke_msg_t *msg)
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
fprintf(this->out, "policies:\n");
|
||||
iterator = charon->policies->create_iterator(charon->policies);
|
||||
if (iterator->get_count(iterator) > 0)
|
||||
{
|
||||
fprintf(this->out, "Policies:\n");
|
||||
}
|
||||
while (iterator->iterate(iterator, (void**)&policy))
|
||||
{
|
||||
if (msg->status.name == NULL ||
|
||||
streq(msg->status.name, policy->get_name(policy)))
|
||||
if (msg->status.name == NULL
|
||||
|| streq(msg->status.name, policy->get_name(policy)))
|
||||
{
|
||||
fprintf(this->out, "%10s: %D...%D\n",
|
||||
fprintf(this->out, "%12s: '%D'...'%D'\n",
|
||||
policy->get_name(policy),
|
||||
policy->get_my_id(policy),
|
||||
policy->get_other_id(policy));
|
||||
@@ -696,19 +704,23 @@ static void stroke_statusall(private_stroke_t *this, stroke_msg_t *msg)
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
|
||||
fprintf(this->out, "IKE_SAs:\n");
|
||||
iterator = charon->ike_sa_manager->create_iterator(charon->ike_sa_manager);
|
||||
if (iterator->get_count(iterator) > 0)
|
||||
{
|
||||
fprintf(this->out, "Security Associations:\n");
|
||||
}
|
||||
while (iterator->iterate(iterator, (void**)&ike_sa))
|
||||
{
|
||||
bool ike_sa_printed = FALSE;
|
||||
child_sa_t *child_sa;
|
||||
iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
|
||||
|
||||
while (children->iterate(children, (void**)&child_sa))
|
||||
{
|
||||
if (!ike_sa_printed &&
|
||||
(msg->status.name == NULL ||
|
||||
streq(msg->status.name, child_sa->get_name(child_sa)) ||
|
||||
streq(msg->status.name, ike_sa->get_name(ike_sa))))
|
||||
if (!ike_sa_printed
|
||||
&& (msg->status.name == NULL
|
||||
|| streq(msg->status.name, child_sa->get_name(child_sa))
|
||||
|| streq(msg->status.name, ike_sa->get_name(ike_sa))))
|
||||
{
|
||||
fprintf(this->out, "%#K\n", ike_sa);
|
||||
ike_sa_printed = TRUE;
|
||||
@@ -742,12 +754,13 @@ static void stroke_status(private_stroke_t *this, stroke_msg_t *msg)
|
||||
bool ike_sa_printed = FALSE;
|
||||
child_sa_t *child_sa;
|
||||
iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
|
||||
|
||||
while (children->iterate(children, (void**)&child_sa))
|
||||
{
|
||||
if (!ike_sa_printed &&
|
||||
(msg->status.name == NULL ||
|
||||
streq(msg->status.name, child_sa->get_name(child_sa)) ||
|
||||
streq(msg->status.name, ike_sa->get_name(ike_sa))))
|
||||
if (!ike_sa_printed
|
||||
&& (msg->status.name == NULL
|
||||
|| streq(msg->status.name, child_sa->get_name(child_sa))
|
||||
|| streq(msg->status.name, ike_sa->get_name(ike_sa))))
|
||||
{
|
||||
fprintf(this->out, "%K\n", ike_sa);
|
||||
ike_sa_printed = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user