display transmitted bytes per SA

This commit is contained in:
Andreas Steffen
2009-07-30 21:33:19 +02:00
parent eab05274f4
commit 2ad51539f6
10 changed files with 203 additions and 19 deletions
+30
View File
@@ -397,6 +397,35 @@ static u_int32_t get_usetime(private_child_sa_t *this, bool inbound)
return last_use;
}
/**
* Implementation of child_sa_t.get_usebytes
*/
static u_int64_t get_usebytes(private_child_sa_t *this, bool inbound)
{
status_t status = NOT_SUPPORTED;
u_int64_t bytes;
if (inbound)
{
if (this->my_spi)
{
status = charon->kernel_interface->query_sa(charon->kernel_interface,
this->other_addr, this->my_addr,
this->my_spi, this->protocol, &bytes);
}
}
else
{
if (this->other_spi)
{
status = charon->kernel_interface->query_sa(charon->kernel_interface,
this->my_addr, this->other_addr,
this->other_spi, this->protocol, &bytes);
}
}
return (status == SUCCESS) ? bytes : 0;
}
/**
* Implementation of child_sa_t.get_lifetime
*/
@@ -776,6 +805,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other,
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_usetime = (u_int32_t(*)(child_sa_t*, bool))get_usetime;
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.get_ipcomp = (ipcomp_transform_t(*)(child_sa_t*))get_ipcomp;
this->public.set_ipcomp = (void(*)(child_sa_t*,ipcomp_transform_t))set_ipcomp;
+8
View File
@@ -244,6 +244,14 @@ struct child_sa_t {
*/
u_int32_t (*get_usetime)(child_sa_t *this, bool inbound);
/**
* Get number of bytes processed by CHILD_SA.
*
* @param inbound TRUE for inbound traffic, FALSE for outbound
* @return number of processed bytes
*/
u_int64_t (*get_usebytes)(child_sa_t *this, bool inbound);
/**
* Get the traffic selectors list added for one side.
*