child_sa_t.get_usestats() can additionally return the number of processed packets

This commit is contained in:
Martin Willi
2013-03-14 14:20:54 +01:00
parent 6b35ab84da
commit d954a2081b
9 changed files with 20 additions and 16 deletions
@@ -102,8 +102,8 @@ static void update_usage(private_eap_radius_accounting_t *this,
u_int64_t sent, received;
entry_t *entry;
child_sa->get_usestats(child_sa, FALSE, NULL, &sent);
child_sa->get_usestats(child_sa, TRUE, NULL, &received);
child_sa->get_usestats(child_sa, FALSE, NULL, &sent, NULL);
child_sa->get_usestats(child_sa, TRUE, NULL, &received, NULL);
this->mutex->lock(this->mutex);
entry = this->sessions->get(this->sessions,
+2 -3
View File
@@ -273,14 +273,14 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
}
}
child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in);
child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in, NULL);
fprintf(out, ", %" PRIu64 " bytes_i", bytes_in);
if (use_in)
{
fprintf(out, " (%" PRIu64 "s ago)", (u_int64_t)(now - use_in));
}
child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out);
child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out, NULL);
fprintf(out, ", %" PRIu64 " bytes_o", bytes_out);
if (use_out)
{
@@ -1541,4 +1541,3 @@ stroke_list_t *stroke_list_create(stroke_attribute_t *attribute)
return &this->public;
}
@@ -68,7 +68,7 @@ METHOD(job_t, execute, job_requeue_t,
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
while (enumerator->enumerate(enumerator, &child_sa))
{
child_sa->get_usestats(child_sa, TRUE, &current, NULL);
child_sa->get_usestats(child_sa, TRUE, &current, NULL, NULL);
use_time = max(use_time, current);
}
enumerator->destroy(enumerator);
@@ -75,8 +75,8 @@ METHOD(job_t, execute, job_requeue_t,
{
time_t in, out, diff;
child_sa->get_usestats(child_sa, TRUE, &in, NULL);
child_sa->get_usestats(child_sa, FALSE, &out, NULL);
child_sa->get_usestats(child_sa, TRUE, &in, NULL, NULL);
child_sa->get_usestats(child_sa, FALSE, &out, NULL, NULL);
diff = time_monotonic(NULL) - max(in, out);
@@ -155,4 +155,3 @@ inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
return &this->public;
}
+6 -1
View File
@@ -524,7 +524,8 @@ static void update_usetime(private_child_sa_t *this, bool inbound)
}
METHOD(child_sa_t, get_usestats, void,
private_child_sa_t *this, bool inbound, time_t *time, u_int64_t *bytes)
private_child_sa_t *this, bool inbound,
time_t *time, u_int64_t *bytes, u_int64_t *packets)
{
if (update_usebytes(this, inbound) != FAILED)
{
@@ -541,6 +542,10 @@ METHOD(child_sa_t, get_usestats, void,
{
*bytes = inbound ? this->my_usebytes : this->other_usebytes;
}
if (packets)
{
*packets = inbound ? this->my_usepackets : this->other_usepackets;
}
}
METHOD(child_sa_t, get_mark, mark_t,
+2 -1
View File
@@ -270,9 +270,10 @@ struct child_sa_t {
* @param inbound TRUE for inbound traffic, FALSE for outbound
* @param[out] time time of last use in seconds (NULL to ignore)
* @param[out] bytes number of processed bytes (NULL to ignore)
* @param[out] packets number of processed packets (NULL to ignore)
*/
void (*get_usestats)(child_sa_t *this, bool inbound, time_t *time,
u_int64_t *bytes);
u_int64_t *bytes, u_int64_t *packets);
/**
* Get the mark used with this CHILD_SA.
+1 -1
View File
@@ -285,7 +285,7 @@ static time_t get_use_time(private_ike_sa_t* this, bool inbound)
enumerator = this->child_sas->create_enumerator(this->child_sas);
while (enumerator->enumerate(enumerator, &child_sa))
{
child_sa->get_usestats(child_sa, inbound, &current, NULL);
child_sa->get_usestats(child_sa, inbound, &current, NULL, NULL);
use_time = max(use_time, current);
}
enumerator->destroy(enumerator);
+2 -2
View File
@@ -97,8 +97,8 @@ static bool delete_child(private_quick_delete_t *this,
}
else
{
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in, NULL);
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out, NULL);
DBG0(DBG_IKE, "closing CHILD_SA %s{%d} with SPIs "
"%.8x_i (%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",
+2 -2
View File
@@ -264,8 +264,8 @@ static void log_children(private_child_delete_t *this)
}
else
{
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in);
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out);
child_sa->get_usestats(child_sa, TRUE, NULL, &bytes_in, NULL);
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out, NULL);
DBG0(DBG_IKE, "closing CHILD_SA %s{%d} with SPIs %.8x_i "
"(%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",