redesigned formatting of ipsec status|statusall

This commit is contained in:
Andreas Steffen
2006-11-01 17:28:47 +00:00
parent 1f9160614a
commit efa0ed68cf
4 changed files with 62 additions and 40 deletions
+12 -12
View File
@@ -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
View File
@@ -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;
}
/**
+5 -3
View File
@@ -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 ? "" : "*");
}
/**