Reverted the interface changes introduced in 3f720dc7.

This commit is contained in:
Tobias Brunner
2009-08-06 13:31:54 +02:00
parent 51c037cc71
commit b3f8ea8346
5 changed files with 15 additions and 35 deletions
+4 -6
View File
@@ -175,8 +175,6 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
if (all) if (all)
{ {
bool change;
fprintf(out, "\n%12s{%d}: ", child_sa->get_name(child_sa), fprintf(out, "\n%12s{%d}: ", child_sa->get_name(child_sa),
child_sa->get_reqid(child_sa)); child_sa->get_reqid(child_sa));
@@ -209,22 +207,22 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
} }
} }
bytes_in = child_sa->get_usebytes(child_sa, TRUE, &change); bytes_in = child_sa->get_usebytes(child_sa, TRUE);
fprintf(out, ", %lu bytes_i", bytes_in); fprintf(out, ", %lu bytes_i", bytes_in);
if (bytes_in) if (bytes_in)
{ {
use_in = child_sa->get_usetime(child_sa, TRUE, change); use_in = child_sa->get_usetime(child_sa, TRUE);
if (use_in) if (use_in)
{ {
fprintf(out, " (%ds ago)", now - use_in); fprintf(out, " (%ds ago)", now - use_in);
} }
} }
bytes_out = child_sa->get_usebytes(child_sa, FALSE, &change); bytes_out = child_sa->get_usebytes(child_sa, FALSE);
fprintf(out, ", %lu bytes_o", bytes_out); fprintf(out, ", %lu bytes_o", bytes_out);
if (bytes_out) if (bytes_out)
{ {
use_out = child_sa->get_usetime(child_sa, FALSE, change); use_out = child_sa->get_usetime(child_sa, FALSE);
if (use_out) if (use_out)
{ {
fprintf(out, " (%ds ago)", now - use_out); fprintf(out, " (%ds ago)", now - use_out);
+6 -16
View File
@@ -377,17 +377,12 @@ static enumerator_t* create_policy_enumerator(private_child_sa_t *this)
/** /**
* Implementation of child_sa_t.get_usetime * Implementation of child_sa_t.get_usetime
*/ */
static u_int32_t get_usetime(private_child_sa_t *this, bool inbound, bool update) static u_int32_t get_usetime(private_child_sa_t *this, bool inbound)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
traffic_selector_t *my_ts, *other_ts; traffic_selector_t *my_ts, *other_ts;
u_int32_t last_use = 0; u_int32_t last_use = 0;
if (!update)
{
return (inbound) ? this->my_usetime : this->other_usetime;
}
enumerator = create_policy_enumerator(this); enumerator = create_policy_enumerator(this);
while (enumerator->enumerate(enumerator, &my_ts, &other_ts)) while (enumerator->enumerate(enumerator, &my_ts, &other_ts))
{ {
@@ -433,13 +428,12 @@ static u_int32_t get_usetime(private_child_sa_t *this, bool inbound, bool update
/** /**
* Implementation of child_sa_t.get_usebytes * Implementation of child_sa_t.get_usebytes
*/ */
static u_int64_t get_usebytes(private_child_sa_t *this, bool inbound, bool *change) static u_int64_t get_usebytes(private_child_sa_t *this, bool inbound)
{ {
status_t status; status_t status;
u_int64_t bytes; u_int64_t bytes;
*change = FALSE; if (inbound)
if (inbound)
{ {
if (this->my_spi) if (this->my_spi)
{ {
@@ -448,9 +442,7 @@ static u_int64_t get_usebytes(private_child_sa_t *this, bool inbound, bool *chan
this->my_spi, this->protocol, &bytes); this->my_spi, this->protocol, &bytes);
if (status == SUCCESS && bytes > this->my_usebytes) if (status == SUCCESS && bytes > this->my_usebytes)
{ {
*change = TRUE;
this->my_usebytes = bytes; this->my_usebytes = bytes;
return bytes;
} }
} }
return this->my_usebytes; return this->my_usebytes;
@@ -464,9 +456,7 @@ static u_int64_t get_usebytes(private_child_sa_t *this, bool inbound, bool *chan
this->other_spi, this->protocol, &bytes); this->other_spi, this->protocol, &bytes);
if (status == SUCCESS && bytes > this->other_usebytes) if (status == SUCCESS && bytes > this->other_usebytes)
{ {
*change = TRUE;
this->other_usebytes = bytes; this->other_usebytes = bytes;
return bytes;
} }
} }
return this->other_usebytes; return this->other_usebytes;
@@ -851,8 +841,8 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
this->public.get_proposal = (proposal_t*(*)(child_sa_t*))get_proposal; this->public.get_proposal = (proposal_t*(*)(child_sa_t*))get_proposal;
this->public.set_proposal = (void(*)(child_sa_t*, proposal_t *proposal))set_proposal; this->public.set_proposal = (void(*)(child_sa_t*, proposal_t *proposal))set_proposal;
this->public.get_lifetime = (u_int32_t(*)(child_sa_t*, bool))get_lifetime; this->public.get_lifetime = (u_int32_t(*)(child_sa_t*, bool))get_lifetime;
this->public.get_usetime = (u_int32_t(*)(child_sa_t*, bool, bool))get_usetime; this->public.get_usetime = (u_int32_t(*)(child_sa_t*, bool))get_usetime;
this->public.get_usebytes = (u_int64_t(*)(child_sa_t*, bool, bool*))get_usebytes; this->public.get_usebytes = (u_int64_t(*)(child_sa_t*, bool))get_usebytes;
this->public.has_encap = (bool(*)(child_sa_t*))has_encap; this->public.has_encap = (bool(*)(child_sa_t*))has_encap;
this->public.get_ipcomp = (ipcomp_transform_t(*)(child_sa_t*))get_ipcomp; this->public.get_ipcomp = (ipcomp_transform_t(*)(child_sa_t*))get_ipcomp;
this->public.set_ipcomp = (void(*)(child_sa_t*,ipcomp_transform_t))set_ipcomp; this->public.set_ipcomp = (void(*)(child_sa_t*,ipcomp_transform_t))set_ipcomp;
+2 -4
View File
@@ -240,19 +240,17 @@ struct child_sa_t {
* Get last use time of the CHILD_SA. * Get last use time of the CHILD_SA.
* *
* @param inbound TRUE for inbound traffic, FALSE for outbound * @param inbound TRUE for inbound traffic, FALSE for outbound
* @param update update time of last use via kernel query
* @return time of last use in seconds * @return time of last use in seconds
*/ */
u_int32_t (*get_usetime)(child_sa_t *this, bool inbound, bool update); u_int32_t (*get_usetime)(child_sa_t *this, bool inbound);
/** /**
* Get number of bytes processed by CHILD_SA. * Get number of bytes processed by CHILD_SA.
* *
* @param inbound TRUE for inbound traffic, FALSE for outbound * @param inbound TRUE for inbound traffic, FALSE for outbound
* @param[out] change TRUE if change since last query, FALSE else
* @return number of processed bytes * @return number of processed bytes
*/ */
u_int64_t (*get_usebytes)(child_sa_t *this, bool inbound, bool *change); u_int64_t (*get_usebytes)(child_sa_t *this, bool inbound);
/** /**
* Get the traffic selectors list added for one side. * Get the traffic selectors list added for one side.
+1 -5
View File
@@ -273,11 +273,7 @@ static time_t get_use_time(private_ike_sa_t* this, bool inbound)
enumerator = this->child_sas->create_enumerator(this->child_sas); enumerator = this->child_sas->create_enumerator(this->child_sas);
while (enumerator->enumerate(enumerator, &child_sa)) while (enumerator->enumerate(enumerator, &child_sa))
{ {
u_int64_t use_bytes; use_time = max(use_time, child_sa->get_usetime(child_sa, inbound));
bool change;
use_bytes = child_sa->get_usebytes(child_sa, inbound, &change);
use_time = max(use_time, child_sa->get_usetime(child_sa, inbound, change));
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
+2 -4
View File
@@ -244,15 +244,13 @@ static void log_children(private_child_delete_t *this)
iterator = this->child_sas->create_iterator(this->child_sas, TRUE); iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
while (iterator->iterate(iterator, (void**)&child_sa)) while (iterator->iterate(iterator, (void**)&child_sa))
{ {
bool change;
DBG0(DBG_IKE, "closing CHILD_SA %s{%d} " DBG0(DBG_IKE, "closing CHILD_SA %s{%d} "
"with SPIs %.8x_i (%lu bytes) %.8x_o (%lu bytes) and TS %#R=== %#R", "with SPIs %.8x_i (%lu bytes) %.8x_o (%lu bytes) and TS %#R=== %#R",
child_sa->get_name(child_sa), child_sa->get_reqid(child_sa), child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
ntohl(child_sa->get_spi(child_sa, TRUE)), ntohl(child_sa->get_spi(child_sa, TRUE)),
child_sa->get_usebytes(child_sa, TRUE, &change), child_sa->get_usebytes(child_sa, TRUE),
ntohl(child_sa->get_spi(child_sa, FALSE)), ntohl(child_sa->get_spi(child_sa, FALSE)),
child_sa->get_usebytes(child_sa, FALSE, &change), child_sa->get_usebytes(child_sa, FALSE),
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));
} }