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
+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",